Problem with plugin HiperLink on kosmo 2.0 version

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with plugin HiperLink on kosmo 2.0 version

Giovanni Virdis

Hi Sergio thanks for your fast reply,

In order

 

1) The initialize() method is really called

2) The GestioneLink() class define a getIcon() method but I don’t know if returns a non null icon

 

This is my class

 

package it.riteco.sassari.gestioneLink;

 

import javax.swing.Icon;

import javax.swing.ImageIcon;

 

import org.saig.jump.plugin.utils.hiperlink.HiperLinkCursorTool;

 

import com.vividsolutions.jump.workbench.JUMPWorkbench;

import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;

import com.vividsolutions.jump.workbench.plugin.EnableCheck;

import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;

import com.vividsolutions.jump.workbench.plugin.PlugInContext;

import com.vividsolutions.jump.workbench.ui.images.IconLoader;

 

/**

 * Questa classe permette di aprire la scheda collegata alla geometria

 * <p>

 * </p>

 *

 * @author Giovanni Virdis

 * @since 1.0.0

 */

public class GestioneLinkPlugIn  extends AbstractPlugIn {

 

 

      /** Nome Plugin  */

    public final static String NAME = "Gestione Link Scheda";

 

    /** Icona */

    public static final ImageIcon ICON = IconLoader.icon("rayo.gif"); //$NON-NLS-1$

   

   

      @Override

      public String getName() {

            return NAME;

      }

     

      @Override

      public Icon getIcon() {

            return ICON;

      }

 

      @Override

      public void initialize(PlugInContext context) throws Exception {

      /** Aggiunge il plugin alla toolbar */

     HiperLinkCursorTool hiperLinkCursorTool = new GestioneLink();

     context.getWorkbenchFrame().getToolBar().addCursorTool(hiperLinkCursorTool.getName(),

     hiperLinkCursorTool,GestioneLink.createEnableCheck(context.getWorkbenchContext()));

      }

     

     

      @Override

      public boolean execute(PlugInContext context) throws Exception {

            return false;

      }

 

      @Override

      public void finish(PlugInContext context) {

      /**Rimuove il plugin dalla toolbar */

       context.getWorkbenchFrame().getToolBar().removePlugIn(this);

      }

 

      @Override

      public EnableCheck getCheck()

      {

         EnableCheckFactory factory = new EnableCheckFactory(JUMPWorkbench.getFrameInstance()

                  .getContext());  

         return factory.createTaskWindowMustBeActiveCheck();

      }

 

}

 

Regards  Giovanni

 

 


_______________________________________________
Kosmo_int mailing list
[hidden email]
http://lists.saig.es/mailman/listinfo/kosmo_int
Reply | Threaded
Open this post in threaded view
|

Re: Problem with plugin HiperLink on kosmo 2.0 version

Sergio Baños Calvo
Good morning Giovanni.

I have imported the GestioneLinkPlugIn into a sample project (changing
GestioneLink class to HiperLinkCursorTool) and everything works fine.
Try the next:

1) Change the call to

context.getWorkbenchFrame().getToolBar().addCursorTool(hiperLinkCursorTool.getName(),


hiperLinkCursorTool,GestioneLink./createEnableCheck/(context.getWorkbenchContext()));


to


context.getWorkbenchFrame().getToolBar().addCursorTool(hiperLinkCursorTool.getName(),


hiperLinkCursorTool, HiperLinkCursorTool.ICON,
GestioneLink./createEnableCheck/(context.getWorkbenchContext()));


in order to avoid any problems with GestioneLink getIcon()

2) In the finish method, the cursor tool button is never removed, as you
remove the plugin, but you have added the cursor tool instead to the
main toolbar

@Override

*public* *void* finish(PlugInContext context) {

/**Rimuove il plugin dalla toolbar */

context.getWorkbenchFrame().getToolBar().removePlugIn(*this*);

}

to

@Override

*public* *void* finish(PlugInContext context) {

/**Rimuove il plugin dalla toolbar */

context.getWorkbenchFrame().getToolBar().removeCursorTool(hiperLinkCursorTool);

}

and add the hiperLinkCursorTool as a class field.

Hope this helps. If the problem persists, could you send me the
GestioneLink class to my personal mail to check it?

Regards,

Giovanni Virdis escribió:

>
> Hi Sergio thanks for your fast reply,
>
> In order
>
> 1) The initialize() method is really called
>
> 2) The GestioneLink() class define a getIcon() method but I don’t know
> if returns a non null icon
>
> This is my class
>
> *package* it.riteco.sassari.gestioneLink;
>
> *import* javax.swing.Icon;
>
> *import* javax.swing.ImageIcon;
>
> *import* org.saig.jump.plugin.utils.hiperlink.HiperLinkCursorTool;
>
> *import* com.vividsolutions.jump.workbench.JUMPWorkbench;
>
> *import* com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
>
> *import* com.vividsolutions.jump.workbench.plugin.EnableCheck;
>
> *import* com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
>
> *import* com.vividsolutions.jump.workbench.plugin.PlugInContext;
>
> *import* com.vividsolutions.jump.workbench.ui.images.IconLoader;
>
> /**
>
> * Questa classe permette di aprire la scheda collegata alla geometria
>
> * <p>
>
> * </p>
>
> *
>
> * *@author* Giovanni Virdis
>
> * *@since* 1.0.0
>
> */
>
> *public* *class* GestioneLinkPlugIn *extends* AbstractPlugIn {
>
> /** Nome Plugin */
>
> *public* *final* *static* String /NAME/ = "Gestione Link Scheda";
>
> /** Icona */
>
> *public* *static* *final* ImageIcon /ICON/ =
> IconLoader./icon/("rayo.gif"); //$NON-NLS-1$
>
> @Override
>
> *public* String getName() {
>
> *return* /NAME/;
>
> }
>
> @Override
>
> *public* Icon getIcon() {
>
> *return* /ICON/;
>
> }
>
> @Override
>
> *public* *void* initialize(PlugInContext context) *throws* Exception {
>
> /** Aggiunge il plugin alla toolbar */
>
> HiperLinkCursorTool hiperLinkCursorTool = *new* GestioneLink();
>
> context.getWorkbenchFrame().getToolBar().addCursorTool(hiperLinkCursorTool.getName(),
>
> hiperLinkCursorTool,GestioneLink./createEnableCheck/(context.getWorkbenchContext()));
>
> }
>
> @Override
>
> *public* *boolean* execute(PlugInContext context) *throws* Exception {
>
> *return* *false*;
>
> }
>
> @Override
>
> *public* *void* finish(PlugInContext context) {
>
> /**Rimuove il plugin dalla toolbar */
>
> context.getWorkbenchFrame().getToolBar().removePlugIn(*this*);
>
> }
>
> @Override
>
> *public* EnableCheck getCheck()
>
> {
>
> EnableCheckFactory factory = *new*
> EnableCheckFactory(JUMPWorkbench./getFrameInstance/()
>
> .getContext());
>
> *return* factory.createTaskWindowMustBeActiveCheck();
>
> }
>
> }
>
> Regards Giovanni
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kosmo_int mailing list
> [hidden email]
> http://lists.saig.es/mailman/listinfo/kosmo_int
>  

--

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: [hidden email]

_______________________________________________
Kosmo_int mailing list
[hidden email]
http://lists.saig.es/mailman/listinfo/kosmo_int