Good morning Giovanni.

I think there is a concept that should be clarified:

PlugIns -> Menu items and toolbar buttons that executes an action
Tools -> Activates a cursor with an associated funcionality

In the example that you sent the two concepts are mixed in one. The functionality that you're trying to develop uses a cursor to draw the polygon, so a tool should be used. You should change your code and redefine only the methods getName() and getIcon() (to use the ones that you have indicated) and the gestureFinished() and create() methods:

public static CursorTool create( LayerNamePanelProxy layerNamePanelProxy ) { FeatureDrawingUtil featureDrawingUtil = new FeatureDrawingUtil(layerNamePanelProxy);

return featureDrawingUtil.prepare(new MyCursorTool(featureDrawingUtil), true);
   }

   protected void gestureFinished() throws Exception {
       reportNothingToUndoYet();
String message = createEnableCheck(getWorkbench().getContext(),this).check(null); if(message != null)
       {
           getWorkbench().getFrame().warnUser(message);
           return;
       }

       if (!checkPolygon()) {
           return;
       }

// Here an add edit transaction is created, you can get the drawed polygon with the method getPolygon() featureDrawingUtil.drawRing(getPolygon(), isRollingBackInvalidEdits(), this, getPanel());

// If you want to open a custom dialog or something else, change the previous line and open your dialog // After that, if the dialog has finished correctly, add your feature to the editable layer.
   }

Your class must only extend the DrawPolygonTool class and must no implement PlugIn.

In order to add the tool to the main toolbar, use this:

DelegatingTool delPolygonTool = (DelegatingTool) MyCursorTool.create(toolbox.getContext());
drawPolygonTool = (MyCursorTool) delPolygonTool.getDelegate();
context.getWorkbenchFrame().getToolBar().addCursorTool(drawPolygonTool.getName(), delPolygonTool, MyCursorTool.createEnableCheck(context.getWorkbenchContext(),drawPolygonTool));

Hope this helps.

Regards,

Giovanni Virdis escribió:
Hi Paco,

I had already tried the solution that you have proposed to me, but the error is 
the same one. what I can make?

Regards, Giovanni


Message: 2
Date: Thu, 24 Apr 2008 13:21:16 +0200
From: Paco Abato <[EMAIL PROTECTED]>
Subject: Re: [Kosmo] R: Resumen de Kosmo, Vol 24, Envío 30
To: Lista de Kosmo <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Hi Giovanni,

try this code:

    public void install( PlugInContext context ) throws Exception {
        if(disegnapoligonoPlugIn == null)
        {
FeatureDrawingUtil featureDrawingUtil = new FeatureDrawingUtil(context.getWorkbenchContext()); disegnapoligonoPlugIn = new DisegnaPoligonoPlugIn(featureDrawingUtil);
        }
        disegnapoligonoPlugIn.initialize(context);
    }


I can't test the code now. Anyway, I hope it helps you.

Regards.


Giovanni Virdis escribió:
Hi Paco,

First of all thanks for your help.
I do not know if you see the class java that I send, but I have a problem.
I have two class DisegnaPoligonoExtension and DisegnaPoligonoPlugIn
DisegnaPoligonoPlugIn extends DrawPolygonTool and implements PlugIn, in the method install of the class DisegnaPoligonoExtension I must initialize DisegnaPoligonoPlugIn
private DisegnaPoligonoPlugIn disegnapoligonoPlugIn;

public void install( PlugInContext context ) throws Exception {
  if(disegnapoligonoPlugIn == null)
   {
        disegnapoligonoPlugIn =  new DisegnaPoligonoPlugIn(null);
.....
}
I initialize to null is correct? If no which value I can use

When I execute the extension I have the following problem

14/02/2007 12:29:55 ERROR root:197 - Exception in thread "main" 14/02/2007 12:29:55 ERROR root:197 - java.lang.InstantiationException: org.saig.jump.plugin.DisegnaPoligono.DisegnaPoligonoPlugIn
14/02/2007 12:29:55 ERROR root:197 -    at java.lang.Class.newInstance0(Unknown 
Source)
14/02/2007 12:29:55 ERROR root:197 -    at java.lang.Class.newInstance(Unknown 
Source)
14/02/2007 12:29:55 ERROR root:197 -    at 
com.vividsolutions.jump.workbench.plugin.PlugInManager.loadPlugInClasses(PlugInManager.java:205)
14/02/2007 12:29:55 ERROR root:197 -    at 
com.vividsolutions.jump.workbench.plugin.PlugInManager.load(PlugInManager.java:125)
14/02/2007 12:29:55 ERROR root:197 -    at 
com.vividsolutions.jump.workbench.JUMPConfiguration.initializeExternalPlugIns(JUMPConfiguration.java:1560)
14/02/2007 12:29:55 ERROR root:197 -    at 
com.vividsolutions.jump.workbench.JUMPConfiguration.configure(JUMPConfiguration.java:677)
14/02/2007 12:29:55 ERROR root:197 -    at 
com.vividsolutions.jump.workbench.JUMPWorkbench.main(JUMPWorkbench.java:369)


_______________________________________________
Kosmo mailing list
[email protected]
http://lists.saig.es/mailman/listinfo/kosmo


--

Sergio Baños Calvo

Jefe de desarrollos
Sistemas Abiertos de Información Geográfica, S.L. (SAIG S.L.)
Tlfno. móvil: 685005960
Tlfno. fijo: (+34) 954788876

E-mail: [EMAIL PROTECTED]

_______________________________________________
Kosmo mailing list
[email protected]
http://lists.saig.es/mailman/listinfo/kosmo

Responder a