This is my execute:
public boolean execute(PlugInContext context) throws Exception{
/************ GUI ***************/
dialog = new MultiInputDialog(context.getWorkbenchFrame(), getName(),
true);
setDialogValues(dialog, context);
GUIUtil.centreOnWindow(dialog);
dialog.setVisible(true);
if (! dialog.wasOKPressed()) {cbLayer.removeActionListener
((ActionListener)aLayer);
bNext.removeActionListener((ActionListener)aNext);
bPrev.removeActionListener((ActionListener)aPrev);
return false; }
cbLayer.removeActionListener((ActionListener)aLayer);
bNext.removeActionListener((ActionListener)aNext);
bPrev.removeActionListener((ActionListener)aPrev);
return true;
}
The function updateUIForAction(ActionEvent e) is called when an user presses
the button "bNext". You can see that in:
private class MethodActionListener
implements ActionListener {
public void actionPerformed(ActionEvent e)
{
updateUIForAction(e);
}
}
private void setDialogValues(MultiInputDialog dialog, PlugInContext
context)
{
dialog.setSideBarDescription("Compute the features classification");
cbLayer = dialog.addLayerComboBox(LAYER, null, context.getLayerManager
());
lLayer = dialog.addLabel(" ");
lLayer.setVisible(true);
cbLayer.setActionCommand("load");
cbLayer.addItemListener(new MethodItemListener());
cbLayer.addActionListener(aLayer);
dialog.addSeparator();
cbClass = dialog.addComboBox("Class", (String)cl.get(0), cl, "Class
selection");
cbCriteria = dialog.addComboBox("Criteria", (String)criteria.get(0),
criteria, "Criteria selection");
cbClass.addItemListener(new MethodItemListener());
cbClass.setEnabled(false);
cbCriteria.setEnabled(false);
lR = dialog.addLabel("Feature's reliability: "); //
dialog.addRow("prev", bPrev, bNext, null, "next");
bNext.addActionListener(aNext);
bPrev.addActionListener(aPrev);
bNext.setActionCommand("next");
bPrev.setActionCommand("prev");
bPrev.setEnabled(prev);
bNext.setEnabled(false);
updateUIForFunction();
}
regards,
Diego
On Feb 4, 2008 3:40 PM, Larry Becker <[EMAIL PROTECTED]> wrote:
> Well the initialize method looks OK. I see you've commented out the
> selectionManager = context.getLayerViewPanel().getSelectionManager();
> which will not be valid at initialization time.
>
> I'm not sure what updateUIForAction(ActionEvent e) is supporting.
> What about your execute() method?
>
> regards,
>
> Larry
>
> On Feb 4, 2008 8:30 AM, Diego Tosato <[EMAIL PROTECTED]> wrote:
> > Hi Larry, this is the code in my plug in:
> > public void initialize(PlugInContext context) throws Exception {
> > c = context;
> > workbenchContext = context.getWorkbenchContext();
> > context.getFeatureInstaller().addMainMenuItem(this, new String[]
> > {"Tools", "FeatureMatching" }, getName(), false, null,
> > this.createEnableCheck(workbenchContext));
> > //selectionManager =
> > context.getLayerViewPanel().getSelectionManager();
> >
> > }
> >
> >
> > ...
> >
> >
> > private void updateUIForAction(ActionEvent e) {
> >
> > if("next".equals(e.getActionCommand()) && load ){
> > if(prev){
> > prev = false;
> > reliability = String.valueOf(f.getAttribute("RELIABILITY"));
> > classSelection(f);
> > fcNew.add(f);
> >
> > }
> > else{
> > fprev = f;
> > f = (Feature)it.next();
> > reliability = String.valueOf(f.getAttribute("RELIABILITY"));
> > classSelection(f);
> > fcNew.add(f);
> > }
> > selectionManager.clear();
> >
> > c.getLayerViewPanel
> ().getSelectionManager().getFeaturesWithSelectedItems();
> >
> > System.out.println(selectionManager.getFeaturesWithSelectedItems
> (layer).toString());
> >
> > c.getLayerViewPanel
> ().getSelectionManager().getFeatureSelection().selectItems(layer,
> > f);
> > try {
> > myZoom.execute(c); // myZoom is an object of type: ZoomToSelectedItems
> > } catch (Exception e1){}
> >
> > bPrev.setEnabled(!prev);
> > }
> > if("prev".equals(e.getActionCommand()) && load){
> > prev = true;
> > reliability = String.valueOf(fprev.getAttribute("RELIABILITY"));
> > fcNew.remove(f);
> >
> > System.out.println(c.getLayerViewPanel
> ().getSelectionManager().getFeatureSelection().toString());
> >
> > c.getLayerViewPanel
> ().getSelectionManager().getFeatureSelection().selectItems(layer,
> > fprev);
> > try {
> > myZoom.execute(c);
> > } catch (Exception e1) {}
> > bPrev.setEnabled(!prev);
> > }
> >
> > and here the exception:
> >
> >
> > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
> > at
> > featureMatching.ClassificationPlugIn.updateUIForAction(
> ClassificationPlugIn.java:206)
> > at
> > featureMatching.ClassificationPlugIn.access$1(ClassificationPlugIn.java
> :182)
> > at
> >
> featureMatching.ClassificationPlugIn$MethodActionListener.actionPerformed(
> ClassificationPlugIn.java:244)
> > at
> > javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
> > at
> > javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java
> :2202)
> > at
> > javax.swing.DefaultButtonModel.fireActionPerformed(
> DefaultButtonModel.java:420)
> > at
> > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> > at
> > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(
> BasicButtonListener.java:236)
> > at
> > java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
> > at java.awt.Component.processMouseEvent(Component.java:5583)
> > at javax.swing.JComponent.processMouseEvent(JComponent.java
> :3135)
> > at java.awt.Component.processEvent(Component.java:5348)
> > at java.awt.Container.processEvent(Container.java:2010)
> > at java.awt.Component.dispatchEventImpl(Component.java:4050)
> > at java.awt.Container.dispatchEventImpl(Container.java:2068)
> > at java.awt.Component.dispatchEvent(Component.java:3885)
> > at
> > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
> > at
> > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
> > at java.awt.LightweightDispatcher.dispatchEvent(Container.java
> :3866)
> > at java.awt.Container.dispatchEventImpl(Container.java:2054)
> > at java.awt.Window.dispatchEventImpl(Window.java:1791)
> > at java.awt.Component.dispatchEvent(Component.java:3885)
> > at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> > at
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(
> EventDispatchThread.java:269)
> > at
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(
> EventDispatchThread.java:190)
> > at
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(
> EventDispatchThread.java:180)
> > at java.awt.Dialog$1.run(Dialog.java:535)
> > at java.awt.Dialog$2.run(Dialog.java:563)
> > at java.security.AccessController.doPrivileged(Native Method)
> > at java.awt.Dialog.show(Dialog.java:561)
> > at java.awt.Component.show(Component.java:1302)
> > at java.awt.Component.setVisible(Component.java:1255)
> > at
> > com.vividsolutions.jump.workbench.ui.MultiInputDialog.setVisible(
> MultiInputDialog.java:178)
> > at
> > featureMatching.ClassificationPlugIn.execute(ClassificationPlugIn.java
> :98)
> > at
> >
> com.vividsolutions.jump.workbench.plugin.AbstractPlugIn$1.actionPerformed(
> AbstractPlugIn.java:130)
> > at
> > javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
> > at
> > javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java
> :2202)
> > at
> > javax.swing.DefaultButtonModel.fireActionPerformed(
> DefaultButtonModel.java:420)
> > at
> > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> > at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
> > at apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java
> :104)
> > at java.awt.MenuItem.processActionEvent(MenuItem.java:597)
> > at java.awt.MenuItem.processEvent(MenuItem.java:556)
> > at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java
> :298)
> > at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:286)
> > at java.awt.EventQueue.dispatchEvent(EventQueue.java:466)
> > at
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(
> EventDispatchThread.java:269)
> > at
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(
> EventDispatchThread.java:190)
> > at
> > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
> > at
> > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
> > at java.awt.EventDispatchThread.run(EventDispatchThread.java
> :110)
> >
> >
> > regards,
> >
> > Diego
> >
> > On Feb 4, 2008 3:16 PM, Larry Becker <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Diego,
> > >
> > > Sounds like something is corrupt or you haven't initialized your
> > > plugin properly. We can give more specific hints if you post more
> > > code and include the entire exception trace.
> > >
> > > regards,
> > >
> > > Larry Becker
> > >
> > >
> > >
> > >
> > > On Feb 4, 2008 7:28 AM, Diego Tosato <[EMAIL PROTECTED]> wrote:
> > > > Ok, I've already looked into these ones but the solution is hard to
> find
> > > > out. I've isolated the problem on the object: SelectionManager. It
> is
> > always
> > > > "null". In particular the command
> > > >
> > > > context.getLayerViewPanel().getSelectionManager()
> > > >
> > > > returns null every time (exception).
> > > > I'm working on a solution but I don't know how to use a
> > SelectionManager.
> > > >
> > > > Diego
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Feb 1, 2008 3:01 PM, Stefan Steiniger <[EMAIL PROTECTED]> wrote:
> > > > > mhm.. don't know what to do (i have no idea about graphic stuff
> and
> > > > > threading).
> > > > > but what you could do is to look into the code of one of these
> plugins
> > > > > (especially the last one):
> > > > >
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomBarPlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomNextPlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomPreviousPlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomToClickPlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomToCoordinatePlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomToFencePlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomToFullExtentPlugIn
> > > > > com.vividsolutions.jump.workbench.ui.zoom.ZoomToLayerPlugIn
> > > > >
> > > > > stefan
> > > > >
> > > > > Diego Tosato schrieb:
> > > > >
> > > > > > Thanks Stefan, i have followed your suggestion but the problem
> is
> > not
> > > > > > solved. Because I have the following exception:
> > > > > >
> > > > > > Exception in thread "AWT-EventQueue-0"
> > > > java.lang.NullPointerException
> > > > > >
> > > > > >
> > > > > > This is my function in the plug in:
> > > > > >
> > > > > > private void updateUIForAction(ActionEvent e) {
> > > > > >
> > > > > > ...
> > > > > >
> > > > > >
> > > >
> > c.getLayerViewPanel
> ().getSelectionManager().getFeatureSelection().selectItems(layer,f,(Collection)layer.getFeatureCollectionWrapper());
> > > > > > try {
> > > > > > myZoom.execute(c);
> > > > > > } catch (Exception e) {}
> > > > > >
> > > > > > where c is a reference to context (c = context;) and f is a
> Feature.
> > > > > >
> > > > > > bye
> > > > > > Diego
> > > > > >
> > > > > > On Jan 31, 2008 7:24 PM, Stefan Steiniger <[EMAIL PROTECTED]
> > > > >
> > > > >
> > > > >
> > > > > > <mailto:[EMAIL PROTECTED]>> wrote:
> > > > > >
> > > > > > Hei,
> > > > > >
> > > > > > you can use:
> > > > > >
> > > > > > private ZoomToSelectedItemsPlugIn myZoom = new
> > > > > > ZoomToSelectedItemsPlugIn();
> > > > > > myZoom.execute(context);
> > > > > >
> > > > > > (where context is the PluginContext given in the Plugin
> > execute()
> > > > > > method)
> > > > > >
> > > > > > but you need first to clean the current selection and add
> your
> > > > object
> > > > > > that you want to zoom to.
> > > > > > such as:
> > > > > >
> > > >
> > context.getLayerViewPanel
> ().getSelectionManager().getFeatureSelection().selectItems(actualLayer,
> > > > > >
> > > > > > features);
> > > > > >
> > > > > > with Collection features and Layer actualLayer
> > > > > >
> > > > > > hope that helps
> > > > > > stefan
> > > > > >
> > > > > > Diego Tosato schrieb:
> > > > > > > Hi, I'm working on a new plug in for openJUMP v1.2 D on
> > Eclipse
> > > > > > 3.3.1.1 <http://3.3.1.1>
> > > > > > > <http://3.3.1.1>. I' ve a problem: I want to zooming on a
> > > > specific
> > > > > > > feature. I've tried to use this function:
> > > > > > >
> > > > > > > zoomToSelectedItemsPlugIn.zoom(
> > > > > > > FeatureUtil.toGeometries(features),
> > > > > > > taskFrame.getLayerViewPanel());
> > > > > > >
> > > > > > >
> > > > > > > in a block try-catch but it doesn't work. In particular
> I've
> > no
> > > > > > > understood what is the object "taskFrame".
> > > > > > > Maybe is it too simple draw a feature in a separated
> > interface?
> > > > > > > Can anyone give me an alternative solution?
> > > > > > >
> > > > > > > Diego
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > ******************************************************************
> > > > > > > Diego Tosato
> > > > > > > Sito Personale: http://p0ll0.altervista.org/
> > > > > > >
> > > > ******************************************************************
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > >
> ------------------------------------------------------------------------
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > jump-users mailing list
> > > > > > > [email protected]
> > > > > > <mailto:[email protected]>
> > > > >
> > > > > > > http://lists.refractions.net/mailman/listinfo/jump-users
> > > > > >
> > > > > > _______________________________________________
> > > > > > jump-users mailing list
> > > > > > [email protected]
> > > > > > <mailto:[email protected]>
> > > > >
> > > > >
> > > > >
> > > > > > http://lists.refractions.net/mailman/listinfo/jump-users
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> ******************************************************************
> > > > > > Diego Tosato
> > > > > > Sito Personale: http://p0ll0.altervista.org/
> > > > > >
> ******************************************************************
> > > > > >
> > > > > >
> > > > > >
> > ------------------------------------------------------------------------
> > > > > >
> > > > > > _______________________________________________
> > > > > > jump-users mailing list
> > > > > > [email protected]
> > > > > > http://lists.refractions.net/mailman/listinfo/jump-users
> > > > > _______________________________________________
> > > > > jump-users mailing list
> > > > > [email protected]
> > > > > http://lists.refractions.net/mailman/listinfo/jump-users
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > ******************************************************************
> > > > Diego Tosato
> > > > Sito Personale: http://p0ll0.altervista.org/
> > > > ******************************************************************
> > > > _______________________________________________
> > > > jump-users mailing list
> > > > [email protected]
> > > > http://lists.refractions.net/mailman/listinfo/jump-users
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > http://amusingprogrammer.blogspot.com/
> > >
> > >
> > >
> > > _______________________________________________
> > > jump-users mailing list
> > > [email protected]
> > > http://lists.refractions.net/mailman/listinfo/jump-users
> > >
> >
> >
> >
> > --
> > ******************************************************************
> > Diego Tosato
> > Sito Personale: http://p0ll0.altervista.org/
> > ******************************************************************
> > _______________________________________________
> > jump-users mailing list
> > [email protected]
> > http://lists.refractions.net/mailman/listinfo/jump-users
> >
> >
>
>
>
> --
> http://amusingprogrammer.blogspot.com/
> _______________________________________________
> jump-users mailing list
> [email protected]
> http://lists.refractions.net/mailman/listinfo/jump-users
>
--
******************************************************************
Diego Tosato
Sito Personale: http://p0ll0.altervista.org/
******************************************************************
_______________________________________________
jump-users mailing list
[email protected]
http://lists.refractions.net/mailman/listinfo/jump-users