void (@Nullable DesignerEditorPanel designer) { if (myDesigner == null && designer == null) { return; } if (myDesigner != null && designer != null && myGroups.equals(designer.getPaletteGroups())) { myDesigner = designer; restoreSelection(); return; } for (PaletteItemsComponent itemsComponent : myItemsComponents) { itemsComponent.removeListSelectionListener(mySelectionListener); } myDesigner = designer; myPaletteContainer.removeAll(); if (designer == null) { myGroups = Collections.emptyList(); myGroupComponents = Collections.emptyList(); myItemsComponents = Collections.emptyList(); } else { myGroups = designer.getPaletteGroups(); myGroupComponents = new ArrayList<>(); myItemsComponents = new ArrayList<>(); } for (PaletteGroup group : myGroups) { PaletteGroupComponent groupComponent = new PaletteGroupComponent(group); PaletteItemsComponent itemsComponent = new PaletteItemsComponent(group, designer); groupComponent.setItemsComponent(itemsComponent); groupComponent.addFocusListener(myFocusListener); myGroupComponents.add(groupComponent); itemsComponent.addListSelectionListener(mySelectionListener); myItemsComponents.add(itemsComponent); myPaletteContainer.add(groupComponent); myPaletteContainer.add(itemsComponent); } myPaletteContainer.revalidate(); if (myDesigner != null) { restoreSelection(); } }