viewer.setPaletteRoot(root);
viewer.addPaletteListener(new PaletteListener(){
public void activeToolChanged(PaletteViewer palette, ToolEntry tool){
ToolEntryEditPart part = (ToolEntryEditPart)palette.getEditPartRegistry().get(tool);
if(part!=null){
// get the active editor
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editorPart = page.getActiveEditor();
// execute processing of the palette item
if(editorPart!=null){
if(editorPart instanceof HTMLSourceEditor){
IPaletteItem item = (IPaletteItem)tools.get(tool);
item.execute((HTMLSourceEditor)editorPart);
}
else if(editorPart instanceof IPaletteTarget){
IPaletteItem item = (IPaletteItem)tools.get(tool);
item.execute(((IPaletteTarget)editorPart).getPaletteTarget());
}
}
// unset palette selection
part.setToolSelected(false);
}
}
});
viewer.getControl().addMouseListener(new MouseAdapter(){
public void mouseUp(MouseEvent e) {