Re: ContextAwareAction menu display issue
markiewb <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
Set the lazy-flag of @ActionRegistration to false! Best regards, markiewb ----- Ursprungligt meddelande ----- Från: "winder" <[email protected]> Skickat: 07.03.2016 17:36 Till: "[email protected]" <[email protected]> Ämne: [platform-dev] ContextAwareAction menu display issue I'm trying to implement a custom ContextAwareAction that is enabled/disabled using logic outside the Node system. I've implemented this using the "roll your own" code here: http://wiki.netbeans.org/DevFaqActionContextSensitive This works perfectly for some toolbar actions - they are grayed out when disabled. I'm not trying to do something similar with a menu action. Functionally it works as well, it is not selectable when disabled. But the text is always white on white (or not set maybe??). Here is my action: Code: @ActionID( category = "File", id = "com.willwinder.ugs.nbp.editor.EditGcodeFile" ) @ActionRegistration( displayName = "#CTL_EditGcodeFile" ) @ActionReference(path = "Menu/File", position = 1301) @Messages("CTL_EditGcodeFile=Edit Gcode File...") //public final class EditGcodeFile implements ActionListener { public final class EditGcodeFile extends AbstractAction implements ContextAwareAction { BackendAPI backend; public EditGcodeFile() { this (Utilities.actionsGlobalContext()); } public EditGcodeFile(Lookup lookup) { backend = CentralLookup.getDefault().lookup(BackendAPI.class); } @Override public Action createContextAwareInstance(Lookup actionContext) { return new EditGcodeFile(actionContext); } @Override public boolean isEnabled() { return backend.getGcodeFile() != null; } @Override public void actionPerformed(ActionEvent e) { // My action... } Attachments: http://forums.netbeans.org//files/screen_shot_2016_03_07_at_90629_am_135.png