It should be possible; we have an example of adding a Tool to a view toolbar
which you should be able to adapt.
- The Info view has the Info Tool on its view toolbar
- The Table view has the selection tool on its view toolbar
I suspect that the entry needs to be added as a normal Action; with the action
calling the current Map's setTool method.
From InfoView2:
protected void fillActionBars() {
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolBar = actionBars.getToolBarManager();
IAction infoTool =
ApplicationGIS.getToolManager().getToolAction(InfoTool.ID,
InfoTool.CATEGORY_ID);
assert( infoTool != null );
if( toolBar != null ){
toolBar.add( infoTool );
}
super.fillActionBars();
}
Internally that ToolManager.getToolAction method does the following.
public IAction getToolAction( String toolID, String categoryID ) {
final IAction tool = getToolInteral(toolID, categoryID);
if( tool == null )
return null;
return new IAction(){
IAction wrapped=tool;
public void addPropertyChangeListener( IPropertyChangeListener
listener ) {
wrapped.addPropertyChangeListener(listener);
}
…
};
}
I expect for your CoolBar you are filling in an extension point and need to
supply an Action via an ID.
1) You could use a contribution - to perform the above code to look up an
Action to contribute to your menu. I recommend this as something you can do
today :-)
2) You could make a bridging class "MyToolAction" which looks up the correct
tool and delegates as required
3) Make an IExecutableExtension ToolAction so you only have one class rather
than many "MyToolAction" classes.
Something like:
public class ToolAction extends IAction implements IExectuableExtension {
final Tool tool;
public ToolAction( String toolID ){
tool = ApplicationGIS.getToolManager().findToolProxy(String toolID)l
}
public void addPropertyChangeListener( IPropertyChangeListener listener ) {
tool.addPropertyChangeListener(listener);
}
}
Where I would need to make a method for findToolProxy( String ) as one does not
appear to be provided yet (they all use toolID and categroyID).
--
Jody Garnett
On Tuesday, 17 January 2012 at 9:43 PM, Susana Fernández García wrote:
>
> Hello,
>
>
>
>
>
> I have a problem with the toolbar.
>
>
>
>
>
> I added a MapView editor to my RCP application. My application has a main
> toolbar (coolbar), and I want to declaratively add tools of Udig (like zoom
> in, pan… not all) that work on the map.
>
>
> I created a new toolbar with the URI my coolbar and in “commandID” added
> “net.refractions.udig.tool.default.zoom.in
> (http://net.refractions.udig.tool.default.zoom.in)” but it don’t work on the
> map (with modal tools also doesn’t work)
>
>
> I read the tutorials but don’t find how.
>
>
>
>
>
> It is possible? How?
>
>
>
>
>
> Thanks!
>
>
>
>
>
> Susana
>
>
>
> This message including any attachments may contain confidential information,
> according to our Information Security Management System, and intended solely
> for a specific individual to whom they are addressed. Any unauthorised copy,
> disclosure or distribution of this message is strictly forbidden. If you have
> received this transmission in error, please notify the sender immediately and
> delete it. Este mensaje, y en su caso, cualquier fichero anexo al mismo,
> puede contener información clasificada por su emisor como confidencial en el
> marco de su Sistema de Gestión de Seguridad de la Información siendo para uso
> exclusivo del destinatario, quedando prohibida su divulgación copia o
> distribución a terceros sin la autorización expresa del remitente. Si Vd. ha
> recibido este mensaje erróneamente, se ruega lo notifique al remitente y
> proceda a su borrado. Gracias por su colaboración. Esta mensagem, incluindo
> qualquer ficheiro anexo, pode conter informação confidencial, de acordo com
> nosso Sistema de Gestão de Segurança da Informação, sendo para uso exclusivo
> do destinatário e estando proibida a sua divulgação, cópia ou distribuição a
> terceiros sem autorização expressa do remetente da mesma. Se recebeu esta
> mensagem por engano, por favor avise de imediato o remetente e apague-a.
> Obrigado pela sua colaboração.
>
>
> _______________________________________________
> 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