public void createPartControl ( Composite parent ) { viewer = new PaletteViewer ( ) ; viewer . createControl ( parent ) ; PaletteRoot root = new PaletteRoot ( ) ; String [ ] category = getCategories ( ) ; for ( int i = 0 ; i < category . length ; i ++ ) { PaletteDrawer group = new PaletteDrawer ( category [ i ] ) ; IPaletteItem [ ] items = getPaletteItems ( category [ i ] ) ; for ( int j = 0 ; j < items . length ; j ++ ) { HTMLPaletteEntry entry = new HTMLPaletteEntry ( items [ j ] . getLabel ( ) , null , items [ j ] . getImageDescriptor ( ) ) ; tools . put ( entry , items [ j ] ) ; group . add ( entry ) ; } root . add ( group ) ; } viewer . setPaletteRoot ( root ) ; viewer . getControl ( ) . addMouseListener ( new MouseAdapter ( ) { @ Override public void mouseDoubleClick ( MouseEvent e ) { // IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); // IEditorPart editorPart = page.getActiveEditor(); // if(editorPart!=null){ // editorPart.setFocus(); // } if ( e . button == 1 ) { EditPart part = PaletteView . this . viewer . findObjectAt ( new Point ( e . x , e . y ) ) ; IPaletteItem item = null ; if ( part != null ) { if ( part . getModel ( ) instanceof HTMLPaletteEntry ) item = tools . get ( part . getModel ( ) ) ; } if ( item != null ) insert ( item ) ; } } } ) ; }
create controls and apply configurations .