<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Eventlistener in Java Addin Tool in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/eventlistener-in-java-addin-tool/m-p/140931#M3669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Forum&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am porting a Tool for ArcMap to a Java Addin, and I want to listen to Document events.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Tools init() function, I do the following, which I found &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_an_application_extension/000100000336000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;here:&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;((MxDocument)mxDoc).addIDocumentEventsListener(new IDocumentEventsAdapter(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override public void openDocument(IDocumentEventsOpenDocumentEvent e){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOptionPane.showMessageDialog(null, "Hey: Document opened!");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, with this code in its init() function, ArcMap hangs and never opens any Document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcMap did not hang when I tried&amp;nbsp; the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;newDocument &lt;/SPAN&gt;&lt;SPAN&gt;event instead, however a Document that is closed and re-opened will not fire the the newDocument Event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if someone could answer any of my questions here, that would be nice:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Are we supposed to fire a &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;super.openDocument(e);&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; after having done our own logic? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried that, but it did not seem to change anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Could it be, that I should rather listen to Events in an Extension than in this Tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It might be, that Extensions are loaded first..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Any other suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the hope of an answer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marianne Wiese&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:46:15 GMT</pubDate>
    <dc:creator>Marianne_BilstedWiese</dc:creator>
    <dc:date>2021-12-11T07:46:15Z</dc:date>
    <item>
      <title>Eventlistener in Java Addin Tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/eventlistener-in-java-addin-tool/m-p/140931#M3669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Forum&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am porting a Tool for ArcMap to a Java Addin, and I want to listen to Document events.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Tools init() function, I do the following, which I found &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/sdk/10.0/java_ao_adf/conceptualhelp/engine/index.html#/How_to_create_an_application_extension/000100000336000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;here:&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;((MxDocument)mxDoc).addIDocumentEventsListener(new IDocumentEventsAdapter(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override public void openDocument(IDocumentEventsOpenDocumentEvent e){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; JOptionPane.showMessageDialog(null, "Hey: Document opened!");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, with this code in its init() function, ArcMap hangs and never opens any Document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcMap did not hang when I tried&amp;nbsp; the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;newDocument &lt;/SPAN&gt;&lt;SPAN&gt;event instead, however a Document that is closed and re-opened will not fire the the newDocument Event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if someone could answer any of my questions here, that would be nice:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Are we supposed to fire a &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;super.openDocument(e);&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; after having done our own logic? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried that, but it did not seem to change anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Could it be, that I should rather listen to Events in an Extension than in this Tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It might be, that Extensions are loaded first..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Any other suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the hope of an answer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marianne Wiese&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:46:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/eventlistener-in-java-addin-tool/m-p/140931#M3669</guid>
      <dc:creator>Marianne_BilstedWiese</dc:creator>
      <dc:date>2021-12-11T07:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Eventlistener in Java Addin Tool</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/eventlistener-in-java-addin-tool/m-p/140932#M3670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello there&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I can answer my own question now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works for me, if I put this code in the &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;init()&lt;/SPAN&gt;&lt;SPAN&gt; method of an Apllication Extension that loads automatically at startup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I get messages both on newDocument and on openDocument Events.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It does not seem necessary to forward the &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;super.specificEvent()&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/Marianne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2012 08:30:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/eventlistener-in-java-addin-tool/m-p/140932#M3670</guid>
      <dc:creator>Marianne_BilstedWiese</dc:creator>
      <dc:date>2012-02-06T08:30:18Z</dc:date>
    </item>
  </channel>
</rss>

