Select to view content in your preferred language

Exception when trying to edit features and attribute values at the same time

1213
3
11-06-2012 12:21 AM
JFr
by
Emerging Contributor
Hello,

I am developing an application which should allow users to edit the form and position of features as well as their attribute values. One of these operations for itself works fine and without any trouble. But when I try to use both operations at the same time an exception is thrown and the application doesn't work anymore. I noticed this in one case: The 'Edit Vertices' tool in the JEditToolsPicker toolbar must be activated, next I choose a feature in the map which should be edited (the features are contained by editable feature layer). I use a HitTestOverlay to edit attribute values of features (adopted from Esri sample code). When a feature in the map is clicked, a dialog to modify the attribute values opens. After a value is edited and confirmed (so the dialog closes), the mentioned exception is thrown:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
 at com.esri.client.toolkit.overlays.FeatureEditOverlay.handleFakeVertex(FeatureEditOverlay.java:844)
 at com.esri.client.toolkit.overlays.FeatureEditOverlay.onMouseMoved(FeatureEditOverlay.java:539)
 at com.esri.map.MapOverlay$b.mouseMoved(Unknown Source)
 at java.awt.Component.processMouseMotionEvent(Unknown Source)
 at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
 at java.awt.Component.processEvent(Unknown Source)
 at java.awt.Container.processEvent(Unknown Source)
 at java.awt.Component.dispatchEventImpl(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 at java.awt.Component.dispatchEvent(Unknown Source)
 at com.esri.map.MapOverlay.a(Unknown Source)
 at com.esri.map.MapOverlay.onMouseMoved(Unknown Source)
 at com.esri.map.MapOverlay$b.mouseMoved(Unknown Source)
 at java.awt.Component.processMouseMotionEvent(Unknown Source)
 at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
 at java.awt.Component.processEvent(Unknown Source)
 at java.awt.Container.processEvent(Unknown Source)
 at java.awt.Component.dispatchEventImpl(Unknown Source)
 at java.awt.Container.dispatchEventImpl(Unknown Source)
 at java.awt.Component.dispatchEvent(Unknown Source)

This is the code which provides the HitTestOverlay:
 
private void addHitTestOverlay(JMap jMap, final ArcGISFeatureLayer featureLayer) 
{
        final HitTestOverlay hitTestOverlay = new HitTestOverlay(featureLayer);
        hitTestOverlay.addHitTestListener(new HitTestListener() 
        {
            @Override
            public void graphicHit(HitTestEvent arg0) {
                // show the attributes of the selected graphic in an editable form.
                List<Graphic> hitGraphics = hitTestOverlay.getHitGraphics();
                FeatureDataForm featureDataForm =
                    new FeatureDataForm(featureLayer, hitGraphics.get(0));
                // show the form on the bottom-right of the application.
                featureDataForm.getDialog().setLocation(
                    (int) window.getContentPane().getLocationOnScreen().getX() +
                        window.getContentPane().getWidth() - featureDataForm.getDialog().getWidth() - 10,
                    (int) window.getContentPane().getLocationOnScreen().getY() +
                        window.getContentPane().getHeight() - featureDataForm.getDialog().getHeight() - 10);
                featureDataForm.show();
            }
        });
        jMap.addMapOverlay(hitTestOverlay);
}


This is were the map overlay is added to the map:
    LocalFeatureService service = new LocalFeatureService(dir+"\\data\\myPackage.mpk");
    //details of all feature layer in the feature service
    final List<LayerDetails> details = service.getFeatureLayers();
    service.addLocalServiceStartCompleteListener(new LocalServiceStartCompleteListener() 
    {
        @Override
         public void localServiceStartComplete(LocalServiceStartCompleteEvent arg0) 
         {
             for(int i = 0; i<details.size();i++)
             {              
                  //create new feature layer
               featureLayer = new ArcGISFeatureLayer(details.get(i).getUrl());
                  //add feature to the map
               map.getLayers().add(featureLayer);
                  //add HitTestOverlay
           addHitTestDialog(map,featureLayer);   
             } 
        }
    });
    service.startAsync();


This exception only occurs in the described case. When another tool is chosen, the editing of attribute values works without trouble. I also haven't done any modifications in the provided classes.
Any idea why this happens in exactly this case ? I hope that this could be understood.
Any help would be appreciated.

Thanks
J.
0 Kudos
3 Replies
EricBader
Honored Contributor
This is a good catch. I, too, can reproduce this scenario.
There "might" be a workaround, but we are looking into it.
Sorry for the inconvenience, but just wanted to let folks know that we are looking.
0 Kudos
EricBader
Honored Contributor
Actually, in the 10.1.1 version coming in December (the next release), this behavior seems to improve. However, there are still some exceptions being thrown when you want to use a HitTestOverlay concurrently with the JEditToolsPicker's edit vertices tool activated. Looking into this.
0 Kudos
EricBader
Honored Contributor
Ok. Here is an update.

Yes, using the JEditToolsPicker as-is with your own HitTestOverlay can cause conflicts. Since the source code for this toolkit component is provided, you could edit and recompile it for your own purposes to make this work.

The out-of-the-box components are really intended for simple editing workflows.

I hope this is useful information.
0 Kudos