ContextAwareAction menu display issue
"winder" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <[email protected]> |
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