private ToolStrip buildToolstrip ( MapWidget mapWidget ) { toolStrip = new ToolStrip ( ) ; toolStrip . setWidth100 ( ) ; toolStrip . setPadding ( 3 ) ; ClientLayerTreeInfo layerTreeInfo = mapModel . getMapInfo ( ) . getLayerTree ( ) ; if ( layerTreeInfo != null ) { for ( ClientToolInfo tool : layerTreeInfo . getTools ( ) ) { String id = tool . getToolId ( ) ; Canvas button = null ; ToolbarBaseAction action = LayerTreeRegistry . getToolbarAction ( id , mapWidget ) ; if ( action instanceof ToolbarWidget ) { toolStrip . addMember ( ( ( ToolbarWidget ) action ) . getWidget ( ) ) ; } else if ( action instanceof ToolbarCanvas ) { button = ( ( ToolbarCanvas ) action ) . getCanvas ( ) ; } else if ( action instanceof LayerTreeAction ) { button = new LayerTreeButton ( this , ( LayerTreeAction ) action ) ; } else if ( action instanceof LayerTreeModalAction ) { button = new LayerTreeModalButton ( this , ( LayerTreeModalAction ) action ) ; } else { String msg = "LayerTree tool with id " + id + " unknown." ; Log . logError ( msg ) ; // console log SC . warn ( msg ) ; // in your face } if ( button != null ) { toolStrip . addMember ( button ) ; LayoutSpacer spacer = new LayoutSpacer ( ) ; spacer . setWidth ( WidgetLayout . layerTreePadding ) ; toolStrip . addMember ( spacer ) ; } } } final Canvas [ ] toolStripMembers = toolStrip . getMembers ( ) ; // delaying this fixes an image 'undefined' error Timer t = new Timer ( ) { public void run ( ) { updateButtonIconsAndStates ( toolStripMembers ) ; } } ; t . schedule ( 10 ) ; return toolStrip ; }
Builds the toolbar