Hi Scott:
I am trying to hunt down example(s).
There is what I have sorted ...
1) ToolManager owns the concept of the default tool ...
ToolManager.defaultModalToolProxy
2) this method has package visibility; and is accessed directly (there is no
getter!)
Here is an example of MenuToolCategory checking if its new menu item is the
default (and thus should start out life selected)
menuItem = new MenuItem(parent, SWT.RADIO, index);
menuItem.setText(tool.getName());
menuItem.setImage(tool.getImage());
if (items.contains( ((ToolManager)manager).defaultModalToolProxy))
menuItem.setSelection(true);
3) there is also a static final ToolProxy.DEFAULT_ID which is how it figures
out which thing to use as the defaultModalTool
/**
* The ID of the default tool: Zoom
*/
private static final String DEFAULT_ID = "net.refractions.udig.tools.Zoom";
//$NON-NLS-1$
4) The ToolPalette has the concept of a default entry; so our
MapToolPaletteFactory could perform a similar check to above
So perhaps something like the following will work?
for( ModalItem modalItem : category ) {
String label = fixLabel(modalItem.getName());
ToolEntry tool = new MapToolEntry(label, modalItem, category.getId());
if( ToolProxy.DEFAULT_ID.equals( tool.getId() ) ){
root.setDefaultEntry( tool ); // will this work??
}
drawer.add(tool);
}
--
Jody Garnett
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel