-
Notifications
You must be signed in to change notification settings - Fork 1
DevFaqToggleActionAddToEditorToolbar
-
extend from org.openide.util.actions.BooleanStateAction
-
in the constructor add a property-change listener to the action itself and let the action implement `PropertyChangeListener `
-
within
PropertyChangeListener#propertyChange
check for the propertyNamePROP_BOOLEAN_STATE
to distinguish the toggle event from other events
Example
package de.markiewb.netbeans.plugins.debuggerutils;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import org.netbeans.api.annotations.common.StaticResource;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.*;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.BooleanStateAction;
@ActionID(
category = "Debug",
id = "de.markiewb.netbeans.plugins.debuggerutils.SkipAllBreakpoints"
)
@ActionRegistration(
lazy = false,
displayName = "#CTL_SkipAllBreakpoints"
)
@ActionReferences({
@ActionReference(path = "Toolbars/Debug", position = 1050),
@ActionReference(path = "Menu/RunProject", position = 2350)
}
)
@Messages("CTL_SkipAllBreakpoints=Skip all breakpoin&ts")
public final class SkipAllBreakpoints extends BooleanStateAction implements PropertyChangeListener {
@StaticResource
private static final String iconpath = "de/markiewb/netbeans/plugins/debuggerutils/Breakpoint_stroke.png";
public SkipAllBreakpoints() {
addPropertyChangeListener(this);
setBooleanState(false); //initially unchecked
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(PROP_BOOLEAN_STATE)) {
/* your action here, get the state by getBooleanState()*/
}
}
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
public String getName() {
return Bundle.CTL_SkipAllBreakpoints();
}
@Override
protected String iconResource() {
return iconpath;
}
}
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqToggleActionAddToEditorToolbar , that was last modified by NetBeans user Markiewb on 2016-06-02T21:50:34Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-01-26, and needs to be reviewed.
Apache NetBeans is an effort undergoing incubation at The Apache Software Foundation (ASF).
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
This wiki is an experiment pending Apache NetBeans Community approval.