Eventlistener in Java Addin Tool

Discussion created by mbw@geus.dk on Feb 5, 2012
Latest reply on Feb 6, 2012 by mbw@geus.dk
Hi Forum

I am porting a Tool for ArcMap to a Java Addin, and I want to listen to Document events.

In the Tools init() function, I do the following, which I found here:

((MxDocument)mxDoc).addIDocumentEventsListener(new IDocumentEventsAdapter(){
       @Override public void openDocument(IDocumentEventsOpenDocumentEvent e){
         JOptionPane.showMessageDialog(null, "Hey: Document opened!");

However, with this code in its init() function, ArcMap hangs and never opens any Document.
ArcMap did not hang when I tried  the newDocument event instead, however a Document that is closed and re-opened will not fire the the newDocument Event.

So, if someone could answer any of my questions here, that would be nice:
1) Are we supposed to fire a super.openDocument(e);  after having done our own logic?
I tried that, but it did not seem to change anything.
2) Could it be, that I should rather listen to Events in an Extension than in this Tool?
It might be, that Extensions are loaded first..
3) Any other suggestions?

In the hope of an answer
Marianne Wiese