現在のノード/ノードの状態に応じて (アプリケーションのトップ メニュー、およびノードの右クリックのポップアップ メニューで) 有効または無効になるアクションを実装しようとしています。
@ActionID(
        category = "Application",
        id = "it.cre.app.tree.actions.ShowEventsAction")
@ActionRegistration(
        iconBase = "it/cre/app/tree/actions/show.png",
        displayName = "#CTL_ShowAction")
@ActionReferences({
    @ActionReference(path = "Menu/Edit", position = 100),
    @ActionReference(path = "Toolbars/File", position = 300),
    @ActionReference(path = "Application/edit", position = 0)})
@NbBundle.Messages("CTL_ShowAction=Show Events")
public class ShowEventsAction implements ActionListener {
    private ShowAuditEventsCapability showAuditEventsCapability;
    public ShowEventsAction(ShowAuditEventsCapability context) {
        showAuditEventsCapability = context;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        if (showAuditEventsCapability != null) {
            doSomething();
        }
    }
}
例: このアクションは、デフォルトでは、1 つのノードが選択されている場合にのみ有効になります。同じ動作が必要ですが、選択したノードの状態にも基づいています。
私のすべてのノードは私のインターフェースを実装しています:
public interface INode {
    //obviously the state of the node could change at runtime
    public boolean someState(); 
}
したがって、次のような方法でアクションでノードの状態を取得できます。
boolean state = Utilities.actionsGlobalContext().lookup(INode.class).someState();
複数のノードが選択されたときにこのアクションが無効になるのと同じように、ノードを選択したときにアクションを有効/無効にするために、前のコードの断片を使用するにはどうすればよいですか?
助言がありますか?