I am making great use of this utility to retrieve a list of actions that should be presented to users as menu choices on right-click of a node; such as shown in a BeanTreeView. I even have submenus working.
My only outstanding desire is to order the menu items in the way I prefer. I have used the "position" attribute in the Action Reference, but it seems to be ignored. I have to assume that I am doing something wrong. Wondering if someone could offer some advice. Below is the code I use to collect these actions followed by one of the actions that are added to the menu. @ActionID( category = "QuickPoleSpan", id = "com.sonideft.actions.span.CopyPopUpAction" ) @ActionRegistration( displayName = "#CTL_SpanCopyPopUpAction", lazy = false ) @ActionReferences({ @ActionReference(path = "Span/Actions") }) @Messages("CTL_SpanCopyPopUpAction=Copy...") public final class SpanCopyPopUpAction extends AbstractAction implements ActionListener, Presenter.Popup { @Override public void actionPerformed(ActionEvent e) { //NOP } protected String iconResource() { return "org/openide/resources/actions/copy.gif"; // NOI18N } @NbBundle.Messages({ "# {0} - count ", "SPAN_COPY_ITEMS_ON_CLIPBOARD={0} Item(s) on ClipBoard", }) @Override public JMenuItem getPopupPresenter() { JMenu menu = new JMenu(Bundle.CTL_SpanCopyPopUpAction()); List<? extends Action> actionsForPath = Utilities.actionsForPath("Actions/QuickPoleSpan_Copy_SubActions"); for (Action action : actionsForPath) { if (action instanceof Presenter.Popup pop) menu.add(pop.getPopupPresenter()); else menu.add(action); } return menu; } } //One of many actions with different values for position: @ActionID( category = "QuickPoleSpan_Copy_SubActions",//NOI18N id = "com.sonideft.core.SpanCopyGuySpansAction"//NOI18N ) @ActionRegistration( displayName = "#CTL_CopyGuySpanAction",lazy=false//NOI18N ) @ActionReference(path = "Span/Actions", position = 100)//NOI18N @NbBundle.Messages("CTL_CopyGuySpanAction=Span Guys") public class SpanCopyGuySpanAction extends AbstractSpanSelectAction { private static final long serialVersionUID = 1L; public SpanCopyGuySpanAction () { putValue(NAME, Bundle.CTL_CopyGuySpanAction()); customEnable(); } @Override public void actionPerformed (ActionEvent e) { copyToClipboard(spannode, AttachmentDemographics.TYPE_GUY,AttachmentDemographics.SUBTYPE_ANY); } @Override public final void customEnable() { if (spannode==null) setEnabled(false); else { AttachmentDemographics demos1 = AttachmentDemographics.getDemographics(spannode.getLocalProxylist()); this.setEnabled(demos1.guy); } } } Regards, Stephen Cumminger