arcgissamples\editing\EditEventsListener.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package arcgissamples.editing; import java.io.IOException; import java.util.HashMap; import javax.swing.SwingUtilities; import com.esri.arcgis.controls.IEngineEditEvents; import com.esri.arcgis.controls.IEngineEditEventsOnAbortEvent; import com.esri.arcgis.controls.IEngineEditEventsOnAfterDrawSketchEvent; import com.esri.arcgis.controls.IEngineEditEventsOnBeforeStopEditingEvent; import com.esri.arcgis.controls.IEngineEditEventsOnBeforeStopOperationEvent; import com.esri.arcgis.controls.IEngineEditEventsOnChangeFeatureEvent; import com.esri.arcgis.controls.IEngineEditEventsOnConflictsDetectedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnCreateFeatureEvent; import com.esri.arcgis.controls.IEngineEditEventsOnCurrentTaskChangedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnCurrentZChangedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnDeleteFeatureEvent; import com.esri.arcgis.controls.IEngineEditEventsOnSaveEditsEvent; import com.esri.arcgis.controls.IEngineEditEventsOnSelectionChangedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnSketchFinishedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnSketchModifiedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnStartEditingEvent; import com.esri.arcgis.controls.IEngineEditEventsOnStartOperationEvent; import com.esri.arcgis.controls.IEngineEditEventsOnStopEditingEvent; import com.esri.arcgis.controls.IEngineEditEventsOnStopOperationEvent; import com.esri.arcgis.controls.IEngineEditEventsOnTargetLayerChangedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnVertexAddedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnVertexDeletedEvent; import com.esri.arcgis.controls.IEngineEditEventsOnVertexMovedEvent; import com.esri.arcgis.interop.AutomationException; public class EditEventsListener implements IEngineEditEvents { private static final long serialVersionUID = 1L; private EventsPane pane; //A list of which events the user is interested in private HashMap<String, Boolean> shouldListen = new HashMap<String, Boolean>(); public EditEventsListener(EventsPane pane) { //EventsPane will be used to print the events this.pane = pane; } public void update(String eventName, boolean isInterested) { shouldListen.put(eventName, isInterested); } private void print(final String event) { //if user is interested in the event if (shouldListen.get(event)!=null&&shouldListen.get(event)==true){ //print it on the EventsPane through Swing's EDT (event dispatching thread) SwingUtilities.invokeLater(new Runnable(){ public void run() { pane.getTextOutput().setText( pane.getTextOutput().getText()+ "- "+ event + "()\n"); } }); } } public void onAbort(IEngineEditEventsOnAbortEvent arg0) throws IOException, AutomationException { print("onAbort"); } public void onAfterDrawSketch(IEngineEditEventsOnAfterDrawSketchEvent arg0) throws IOException, AutomationException { print("onAbort"); } public void onBeforeStopEditing( IEngineEditEventsOnBeforeStopEditingEvent arg0) throws IOException, AutomationException { print("onBeforeStopEditing"); } public void onBeforeStopOperation( IEngineEditEventsOnBeforeStopOperationEvent arg0) throws IOException, AutomationException { print("onBeforeStopOperation"); } public void onChangeFeature(IEngineEditEventsOnChangeFeatureEvent arg0) throws IOException, AutomationException { print("onChangeFeature"); } public void onConflictsDetected( IEngineEditEventsOnConflictsDetectedEvent arg0) throws IOException, AutomationException { print("onConflictsDetected"); } public void onCreateFeature(IEngineEditEventsOnCreateFeatureEvent arg0) throws IOException, AutomationException { print("onCreateFeature"); } public void onCurrentTaskChanged( IEngineEditEventsOnCurrentTaskChangedEvent arg0) throws IOException, AutomationException { print("onCurrentTaskChanged"); } public void onCurrentZChanged(IEngineEditEventsOnCurrentZChangedEvent arg0) throws IOException, AutomationException { print("onCurrentZChanged"); } public void onDeleteFeature(IEngineEditEventsOnDeleteFeatureEvent arg0) throws IOException, AutomationException { print("onDeleteFeature"); } public void onSaveEdits(IEngineEditEventsOnSaveEditsEvent arg0) throws IOException, AutomationException { print("onSaveEdits"); } public void onSelectionChanged(IEngineEditEventsOnSelectionChangedEvent arg0) throws IOException, AutomationException { print("onSelectionChanged"); } public void onSketchFinished(IEngineEditEventsOnSketchFinishedEvent arg0) throws IOException, AutomationException { print("onSketchFinished"); } public void onSketchModified(IEngineEditEventsOnSketchModifiedEvent arg0) throws IOException, AutomationException { print("onSketchModified"); } public void onStartEditing(IEngineEditEventsOnStartEditingEvent arg0) throws IOException, AutomationException { print("onStartEditing"); } public void onStartOperation(IEngineEditEventsOnStartOperationEvent arg0) throws IOException, AutomationException { print("onStartOperation"); } public void onStopEditing(IEngineEditEventsOnStopEditingEvent arg0) throws IOException, AutomationException { print("onStopEditing"); } public void onStopOperation(IEngineEditEventsOnStopOperationEvent arg0) throws IOException, AutomationException { print("onStopOperation"); } public void onTargetLayerChanged( IEngineEditEventsOnTargetLayerChangedEvent arg0) throws IOException, AutomationException { print("onTargetLayerChanged"); } public void onVertexAdded(IEngineEditEventsOnVertexAddedEvent arg0) throws IOException, AutomationException { print("onVertexAdded"); } public void onVertexDeleted(IEngineEditEventsOnVertexDeletedEvent arg0) throws IOException, AutomationException { print("onVertexDeleted"); } public void onVertexMoved(IEngineEditEventsOnVertexMovedEvent arg0) throws IOException, AutomationException { print("onVertexMoved"); } }