This is a strange little area,  The recommended way right now is to do:

IToolManager manager=ApplicationGIS.getToolManager();
IAction action = manager.getTool( neededToolID );
action.run();

A couple of notes about this:

1. getTool() will be deprecated because it is misnamed. I am renaming it to getToolAction() 2. The run method will disable the active tool and will enable the new tool.

Jesse


On Apr 4, 2007, at 6:29 AM, Sergiy Doroshenko wrote:

Hi all!

The question is how to activate some tool from the code. For example,
click on some button will activate DistanceTool - its icon will be
shown on toolbar, its cursor will be shown.
I tried to do like this:
                                ((AbstractModalTool) 
ApplicationGIS.getToolManager()
                                                
.getActiveTool()).setActive(false);
                                SimpleTool select = (SimpleTool) ApplicationGIS
                                                .getToolManager().findTool(
                                                                nededToolID);
                                select.setActive(true);

But this code doesn't update toolbar and cursor; and when we select
another tool from toolbar, the tool that was activated in that code
remains active. So, this is wrong.

Can you describe me rigth way to activate tool?
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to