6 Replies Latest reply on Mar 21, 2012 11:34 AM by 916491

    Listener issue

      Greetings. After using the ISDK to integrate AutoVue (Webserver) and our CMS, we have made the applet to open automatically a file and any number of selected markups using the system described in the "AutoVue API Programmer's Guide":

      Property masterMarkup = m_vueBean.getMarkupProperty();
      Property[] listMarkups =
      Property aMarkup = listMarkup[0];
      InputStream is = m_vueBean.readMarkup(aMarkup);

      The case is, by doing these operations automatically upon opening, we encountered a few problems that luckily we were able to solve - all but one, not grave, but which is still escaping us. When the applet loads, the markup dropdown menu to select them remains blank, as if no markup was open - though they are open all over the file, and the lower markup menu shows up properly.

      Then, as soon as any action is performed - such as right click on a markup to hide or make it active -, an exception happens and the drop-down menu finally gets the markups to choose from. The exception says:

      JVue: Error while notifying listener com.cimmetry.vueframe.markup.f@1627c16
      java.lang.ClassCastException: [B cannot be cast to com.cimmetry.vueframe.markup.h
           at com.cimmetry.vueframe.markup.f.a(Unknown Source)
           at com.cimmetry.vueframe.markup.f.onMarkupEvent(Unknown Source)
           at com.cimmetry.markupbean.event.a.run(Unknown Source)
           at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
           at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
           at java.awt.EventQueue.access$000(EventQueue.java:84)
           at java.awt.EventQueue$1.run(EventQueue.java:602)
           at java.awt.EventQueue$1.run(EventQueue.java:600)
           at java.security.AccessController.doPrivileged(Native Method)
           at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
           at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
           at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
           at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
           at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

      Our guess is that, when any markup action is performed, like adding or deleting a markup file, it is added automatically to this listener... As long as it is done using the GUI of the applet. But when done through the API, this listener is never invoked, and thus the first time an action tries to get it, it generates the exception and then makes a thorough regeneration to get up to date.

      We would like a way to provoke from the place we have the API code such a regeneration. We tried to use a setActiveMarkup function - which works - to mimic the manual action from the GUI, but to no use: all actions we cast from the code simply seem to avoid the listener.

      Any suggestion?

      Edited by: Jordi Bosch on Mar 15, 2012 12:21 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
        • 1. Re: Listener issue
          The markup drop-down listens to events and updates itself depending which event is sent.
          In this case it does not receive events it expects.

          Try calling m_markupBean.notifyMarkupChanged() at the end to force an update.
          • 2. Re: Listener issue
            No luck, the drop down menu didn't update. I believe I got a null result from the (active) markup update method. This is the console output i got (server details are ***'ed):

            JVue: >> Exec(clbGetRemoteEvents)
            JVue: >> URL connection: sun.net.www.protocol.http.HttpURLConnection:***********************
            JVue: << Exec: result = null
            JVue: exec time: 5, Total : 1816

            My guess is, since before the method the markup was not in the drop down menu, it couldn't update anything, and thus the null result at the attempt. So, I still need to somehow generate a way to make the applet aware of its active markups.
            • 3. Re: Listener issue
              Hi Jordy,

              Not sure if you didn't get the markup at all in the list or you got it, but it was showing 'null' name.

              To finish initialization of the markup in your code you will need something like this (init the markup name and properties):
              try {
              InputStream is = vueBean.readMarkup(aMarkup);
              Markup activeMarkup = markupBean.readMarkup(is, true);
              String name = aMarkup.getSinglePropertyValue(Property.PROP_DOC_NAME);
              } catch (IOException ex) {
              // TODO: handle exception

              In this case the combo should be updated properly and you should see your markup name in it.
              If it still doesn't work then it means there is something wrong with the way you run it on applet startup.
              You'll need to describe how you do it...

              Did you consider using com.cimmetry.jvue.JVue.openMarkup() API instead?
              If it suites your needs then it will do everyting for you with just a couple of lines of code...

              • 4. Re: Listener issue
                Hi Artash, and thanks for your time.

                The only difference with my code is that mine had not the active set and notify lines, but after adding them, the system behaved in the same way.

                As for the dropdown list, it is completely blank (room for one single text line, but blank). As soon as I manually activate, hide, create a new markup, etc. It is properly filled with the markup names. I had nulls some time ago, but I fixed the issue by properly passing the properties that were required.

                As for that interface, I needed this one to control several steps in the opening process, since I have a heavy customization, and it seemed more possible in this way. For the applet initialization, I do the following:

                1.- Feed the applet with a custom string that includes a file information id, and may contain any number of markup information ids. These id's refer to the way my repository manages files.
                2.- With a listener, I catch the moment the file opens - VueEvent.ONSHOWINGFILE -, then check if my entry string contains any markup to open.
                3.- Get the active bean, and load the properties associated to all existing markups for the current file.
                4.- I open the markups from the entry string that exist in the property list - requested markups that are not on the list are treated as errors -. The method is pretty much the one in your post. I only activate a layer in the end, to activate markup 1.
                5.- The markup opening process requires me to enter markup mode first, which creates a default markup. Once all markups are open, I delete it: myMarkupBean.deleteMarkup(); Removing this deletion code does not affect the issue at hand.
                6.- Activation of markup 1.

                That's pretty much it.
                • 5. Re: Listener issue
                  The way you are describing it should work fine.
                  When you activate, hide or create new markup it sends an event which triggers combo update.
                  That's what you need to achieve with notifyMarkupChanged() call at end of markup loading.

                  You can try one more thing to initialize properly when you enter markup mode...
                  After entering markup mode post markup reading to be executed later on event dispatch thread, this will make sure that you read your markups only after markup mode entering event was fully processed.

                  So it will look something like this:

                  javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {

                  Let me know how it goes...
                  • 6. Re: Listener issue
                    That worked!

                    So, the conclusion is that any markup file opening has to happen after the event ONENTERMARKUPMODE, or cause this strange issue with the listener.

                    Thank you very much for your help, Artash.