Setting the wait cursor in case of pupup menu custom action

Post here questions and problems related to oXygen frameworks/document types.
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Setting the wait cursor in case of pupup menu custom action

Post by Vince »

How can I set a wait cursor in case of custom action inserted to the popup menu ?
What I've tried so far:

Code: Select all

public void customizeAuthorPopUpMenu(JPopupMenu popUp, AuthorAccess authorAccess) {
            AbstractAction custom = new AbstractAction("TEST") {
            
            @Override
            public void actionPerformed(ActionEvent e) {
              javax.swing.JFrame parentFrame = (JFrame) PluginWorkspaceProvider.getPluginWorkspace().getParentFrame();
              parentFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 
              try {
                Thread.sleep(10000);
              } catch (InterruptedException e1) {
                e1.printStackTrace();
              }
              parentFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
          };
          popUp.insert(custom, 0);
        }        
}
Thanks
Radu
Posts: 9084
Joined: Fri Jul 09, 2004 5:18 pm

Re: Setting the wait cursor in case of pupup menu custom action

Post by Radu »

Hi,

The code looks good to me, so when the action is invoked at first it sets the cursor on the main frame to wait_cursor, then the action performs its specific code and then at the end you switch the cursor on the main frame back to the normal cursor.
So doesn't the code work? What's the current behavior you obtain?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Setting the wait cursor in case of pupup menu custom action

Post by Vince »

Hi,

The code does not work.
Cursor does not change at all.

I'm using Oxygen 23

Regards,
Vincent
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Setting the wait cursor in case of pupup menu custom action

Post by Vince »

I do some additionnal tests.

When I click on the menu item, if my mouse pointer hovers over the tab, the wait cursor appears
If my mouse pointer is just under the tab, cusrosr does not change.

It's seems that the editing area cursor takes priority over the one I set.

Hope this helps.

Regards,
Vincent
Radu
Posts: 9084
Joined: Fri Jul 09, 2004 5:18 pm

Re: Setting the wait cursor in case of pupup menu custom action

Post by Radu »

Hi Vincent,

Indeed the Author panel has its own text I-beam cursor set. And setting a cursor on the parent frame does not impose the same cursor on descendant Swing components.
Maybe you can try to cast this "authorAccess.getEditorAccess().getAuthorComponent()" to a JPanel and set the busy cursor also on it.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Vince
Posts: 64
Joined: Wed Dec 03, 2014 11:25 am

Re: Setting the wait cursor in case of pupup menu custom action

Post by Vince »

Great, it works !

Thanks
Post Reply