Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arc: Events Dr Andy Evans. Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components.

Similar presentations


Presentation on theme: "Arc: Events Dr Andy Evans. Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components."— Presentation transcript:

1 Arc: Events Dr Andy Evans

2 Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components and many non-GUI components (for example, for data changes).

3 Useful MxDocument: addIDocumentEventsDispListener Map : addIActiveViewEventsListener Map : addIMapEventsListener FeatureLayer : addIFeatureLayerSelectionEventsListener TIN/Raster/Feature/NetworkLayer : addILayerEventsListener

4 Adapters We saw that java.awt supplies Adapter classes. These are classes that match an interface, but with nothing in the methods. You can extend the class, and then override the methods you want to, without having to do all of them. However, we saw them in anonymous inner classes.

5 Shutting a Window myFrame.addWindowListener( new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } ); Arc has a number of Adapters you can use like this for key jobs. Check what classes implement the Listeners in the docs.

6 New document ((MxDocument)mxDoc).addIDocumentEventsListener( new IDocumentEventsAdapter(){ @Override public void newDocument (IDocumentEventsNewDocumentEvent e){ // Do something when new document. } ); NB: This needs some additional try-catch blocks.

7 Closing document ((MxDocument)mxDoc).addIDocumentEventsListener( new IDocumentEventsAdapter(){ @Override public boolean beforeCloseDocument (IDocumentEventsBeforeCloseDocumentEvent e){ // Do something when closing document. } );

8 Dirty, dirty, document If you close a document but have made programmatic changes to it, this can be lost unless the user saves the map. To ask the user if they want to, set the document as “dirty”, e.g. at the end of the beforeCloseDocument method. IDocumentDirty doc = (IDocumentDirty)app.getDocument(); doc.setDirty(); They will then be asked before final closing.

9 DIY Of course, you can make your own listeners. Just add a new class to your project/package.


Download ppt "Arc: Events Dr Andy Evans. Event communication Arc is, plainly, set up for Event Based Programming. You can register listeners with most GUI components."

Similar presentations


Ads by Google