ProjectViewPopupMenu actions....

Hi,

I have an action, registered to appear in the ProjectViewPopupMenu. I want to make this action sensitive to the currently selected node in the project view.

I want to be able to implement the following:
a)if the user clicks on a module 'node', my menu action is visible.
b)if they click on any other node, it is not.

Can someone tell me how I can find out information about the currently selected node?

Thanks in advance,

Daniel

2 comments

For future reference, here is what I ended up using.

0

Oh, I think your question now is not relevant for you:), but exactly this functionality I was need in my plugin.
I found a solution and here I post it, maybe it will be helpful for others

    @Override     public void update(AnActionEvent e) {         DataContext dataContext = e.getDataContext();         Presentation presentation = e.getPresentation();         Module maybeSelectedModule = DataKeys.MODULE_CONTEXT.getData(dataContext);         if(maybeSelectedModule == null) {             hide(presentation);             return;         }         show(presentation);     }     private static void show(Presentation presentation) {         presentation.setEnabled(true);         presentation.setVisible(true);     }     private static void hide(Presentation presentation) {         presentation.setEnabled(false);         presentation.setVisible(false);     }


If you need to know all selected modules(selected with Ctrl pressed) you need to use DataKeys.MODULE_CONTEXT_ARRAY.

0

Please sign in to leave a comment.