Dear Jesse,
First, sorry for this late reply, I add to work on another project.
I have a problem while applying your solution, I get a null reference
when I invoke the getTool() with categoryID and toolID. I had a look in
the ToolManager code and I think that the addToModalCategory() and
addToMenuCategory() methods simply does not add the new ToolProxy when
the attribute "onToolbar" is false. Thus, It is impossible to retrieve
the action.
I have another problem with your proposed solution. As far as I
understand, I will be able to "activate" a tool that is declared in a
plugin through its plugin.xml descriptor. What I would like is to be
able a tool that is unknown at start-up. In order you better understand
what I would like to do, I will precise here what I expect to do:
1) a thread is running, looking for files.
2) A first file is found. It is parsed to get the path of a external
executable. A new Tool button appears on the GUI. When the user clicks
the button, the executable is started.
3) A second file is found. It is parsed to get the path of a external
executable. A second new Tool button appears on the GUI. When the user
clicks the button, this second executable is started.
4) etc.
So I can't create the tools at start-up because I don't how many tools
there will be.
Thanks for your help
Vincent
Jesse Eichar wrote:
This is on the list of features for 1.1 but for 1.0.x you will have to
do some hacking.
(This is pseudocode so it will take some tweaking)
1. Define your tool as not on Toolbar. This will allow you tool get
the ToolProxy from the ToolManager but it won't be on the toolbar.
2. When you want to add the tool you have to get the ToolManager:
ProjectUIPlugin.getDefault().getToolManager.getTool(). This returns
an action you can add to the Toolbar.
3. Add the tool to the toolbar by getting the MapEditor's
EditorSite.getActionBars().getCoolbar().add(tool).
4. The MapEditor editor site can be obtained by:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite()
(Assuming the editor is the active editor).
Hope this helps. Jesse
Vincent Nouguier wrote:
Hello all,
I would like to add new tool buttons in the toolbar at runtime. The
addition of the button is started by an external event. This event
contains information for the GUI (an icon and a label) and
information about what has to be done when the button is pressed. I
don't know at startup how many buttons (and when) have to be integrated.
Is there a way to integrate tools during execution ?
Thanks in advance,
Vincent
_______________________________________________
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
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel