Reputation: 2199
What is the proper preferedID for the Netbeans Projects TopComponent? I created a small module to help with a project however I need a button in the module to trigger when a certain subnode is highlighted in the Projects Pane. Using Utilities.actionsGlobalContext() will not help since the button is in another module and simply redeclaring a value to keep the most recent subNode that was selected is not ideal. Does anyone have any suggestions?
Upvotes: 0
Views: 88
Reputation: 7752
If I understand you correctly, you want to be able to perform an Action (of a button) that exists in another module?
One way to do this would be to register your (button's) action in your module's layer file:
...
<folder name="SomeFolder">
<folder name="MyActions">
<file name="com-my-Action.instance">
<attr name="delegate" newvalue="com.my.Action"/>
<attr name="displayName" bundlevalue="com.my.Bundle#MYACTION_DIPLAYNAME"/>
...
</file>
</folder>
</folder>
And then using Utilities.actionsForPath(string)
look this action up:
List<? extends Action> actions = Utilities.actionsForPath("SomeFolder/MyActions");
Action myAction = null;
for (Action action : a) {
if (action.getValue(Action.NAME).equals("My Action Display Name")) {
myAction = action;
break;
}
}
// use the action
myAction.actionPerformed(null);
See Also
javadoc for Utilities.actionsForPath(string)
Upvotes: 2