Thanks for that Jody,
Unfortunately root.setDefaultEntry(tool); set’s Zoom as highlighted in the
palette, but the tool is still not active so dragging the mouse does not zoom
in.
I have also tried using a ToolProxy as such:
ToolProxy toolProxy = (ToolProxy) modalItem;
toolProxy.setActive(true);
But that was no help either.
At this moment I am still stuck so moving onto another issue and hopefully
someone has an idea as to how to get the Zoom tool active as default.
Thanks, Scott.
From: Jody Garnett [mailto:[email protected]]
Sent: Thursday, August 18, 2011 11:52 AM
To: User-friendly Internet GIS
Cc: Scott Henderson
Subject: default tool example
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
________________________________
The contents of this email are confidential and may be subject to legal or
professional privilege and copyright. No representation is made that this email
is free of viruses or other defects. If you have received this communication in
error, you may not copy or distribute any part of it or otherwise disclose its
contents to anyone. Please advise the sender of your incorrect receipt of this
correspondence.
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel