Arc Events Dr Andy Evans Event communication Arc

  • Slides: 9
Download presentation
Arc: Events Dr Andy Evans

Arc: Events Dr Andy Evans

Event communication Arc is, plainly, set up for Event Based Programming. You can register

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).

Useful Mx. Document: add. IDocument. Events. Disp. Listener Map : add. IActive. View. Events.

Useful Mx. Document: add. IDocument. Events. Disp. Listener Map : add. IActive. View. Events. Listener Map : add. IMap. Events. Listener Feature. Layer : add. IFeature. Layer. Selection. Events. Listener TIN/Raster/Feature/Network. Layer : add. ILayer. Events. Listener

Adapters We saw that java. awt supplies Adapter classes. These are classes that match

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.

Shutting a Window my. Frame. add. Window. Listener( new Window. Adapter(){ public void window.

Shutting a Window my. Frame. add. Window. Listener( new Window. Adapter(){ public void window. Closing(Window. Event 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.

New document ((Mx. Document)mx. Doc). add. IDocument. Events. Listener( new IDocument. Events. Adapter(){ @Override

New document ((Mx. Document)mx. Doc). add. IDocument. Events. Listener( new IDocument. Events. Adapter(){ @Override public void new. Document (IDocument. Events. New. Document. Event e){ // Do something when new document. } } ); NB: This needs some additional try-catch blocks.

Closing document ((Mx. Document)mx. Doc). add. IDocument. Events. Listener( new IDocument. Events. Adapter(){ @Override

Closing document ((Mx. Document)mx. Doc). add. IDocument. Events. Listener( new IDocument. Events. Adapter(){ @Override public boolean before. Close. Document (IDocument. Events. Before. Close. Document. Event e){ // Do something when closing document. } } );

Dirty, document If you close a document but have made programmatic changes to it,

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 before. Close. Document method. IDocument. Dirty doc = (IDocument. Dirty)app. get. Document(); doc. set. Dirty(); They will then be asked before final closing.

DIY Of course, you can make your own listeners. Just add a new class

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