List<PaletteEntry> allEntries = new ArrayList<PaletteEntry>(getChildren()); // MUST
// make
// a
// copy
for (Iterator<PaletteEntry> iter = allEntries.iterator(); iter.hasNext();) {
PaletteEntry entry = iter.next();
remove(entry);
}
// create new entries
add(createModelIndependentTools());
IToolBehaviorProvider currentToolBehaviorProvider = cfgProvider.getDiagramTypeProvider().getCurrentToolBehaviorProvider();
IPaletteCompartmentEntry[] paletteCompartments = currentToolBehaviorProvider.getPalette();
for (IPaletteCompartmentEntry compartmentEntry : paletteCompartments) {
PaletteDrawer drawer = new PaletteDrawer(compartmentEntry.getLabel(), getImageDescriptor(compartmentEntry));
if (!compartmentEntry.isInitiallyOpen()) {
drawer.setInitialState(PaletteDrawer.INITIAL_STATE_CLOSED);
}
add(drawer);
List<IToolEntry> toolEntries = compartmentEntry.getToolEntries();
for (IToolEntry toolEntry : toolEntries) {
if (toolEntry instanceof ICreationToolEntry) {
ICreationToolEntry creationToolEntry = (ICreationToolEntry) toolEntry;
PaletteEntry createTool = createTool(creationToolEntry);
if (createTool != null) {
drawer.add(createTool);
}
} else if (toolEntry instanceof IStackToolEntry) {
IStackToolEntry stackToolEntry = (IStackToolEntry) toolEntry;
PaletteStack stack = new PaletteStack(stackToolEntry.getLabel(), stackToolEntry.getDescription(), GraphitiUi
.getImageService().getImageDescriptorForId(cfgProvider.getDiagramTypeProvider().getProviderId(), stackToolEntry.getIconId()));
drawer.add(stack);
List<ICreationToolEntry> creationToolEntries = stackToolEntry.getCreationToolEntries();
for (ICreationToolEntry creationToolEntry : creationToolEntries) {
PaletteEntry createTool = createTool(creationToolEntry);
if (createTool != null) {
stack.add(createTool);
}
}
} else if (toolEntry instanceof IPaletteSeparatorEntry) {