FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

NodeAction JMenuItem enablement error

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
andvicoso



Joined: 20 Nov 2008
Posts: 15

PostPosted: Thu Oct 15, 2009 2:13 pm    Post subject: NodeAction JMenuItem enablement error Reply with quote

Hello,

I'm trying to show a node popup menu on other screen position. So, I'm doing something like this:

Code:

public JPopupMenu getNodePopup(){
    final Node node = new MyNode(myLookup);
    return Utilities.actionsToPopup(node.getActions(false), Lookups.fixed(node, node.getLookup()));
}


But I've seen that inside CookieAction (which is one of the possible actions from the node), a NodeAction->resultChanged (from the created DelegateAction) like the above:

Code:

 public void resultChanged(LookupEvent ev) {
     boolean old = enabled;
     enabled = delegate.enable(nodes());
     support.firePropertyChange(PROP_ENABLED, old, enabled);
}


is called, and it correctly sets the local enabled field. But, after the execution returns to the Utilities.actionsToPopup, the created JMenuItem is never set enabled/disabled based on that trully corresponding NodeAction.enabled field. Even if I try set the enablement of the action inside the overriden getPopupPresenter method from my action, like this:

Code:

@Override
public JMenuItem getPopupPresenter() {
    final JMenuItem menu = new JMenuItem(this);//super.getPopupPresenter();
    menu.setEnabled(isEnabled());//Try to force the enablement
    return menu;
}


The problem here is that the isEnabled method from MyAction calls isEnabled from NodeAction, which returns (Boolean) getProperty(PROP_ENABLED), which is different from the correct enablement.

Am I doing something wrong?
Back to top
View user's profile Send private message
andvicoso



Joined: 20 Nov 2008
Posts: 15

PostPosted: Tue Nov 03, 2009 6:30 pm    Post subject: Reply with quote

Nobody???
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB