Java 类org.openide.util.actions.BooleanStateAction 实例源码

项目:incubator-netbeans    文件:Actions.java   
/** Popup menu */
public CheckMenuBridge(JCheckBoxMenuItem item, BooleanStateAction action, boolean popup) {
    super(item, action);
    this.popup = popup;

    if (popup) {
        prepareMargins(item, action);
    }

    Object base = action.getValue("iconBase"); //NOI18N
    Object i = null;

    if (action instanceof SystemAction) {
        i = action.getValue(SystemAction.PROP_ICON);
    } else {
        i = action.getValue(Action.SMALL_ICON);
    }

    hasOwnIcon = (base != null) || (i != null);
}
项目:incubator-netbeans    文件:DefaultAWTBridge.java   
public JMenuItem createMenuPresenter (Action action) {
    if (action instanceof BooleanStateAction) {
        BooleanStateAction b = (BooleanStateAction)action;
        return new Actions.CheckboxMenuItem (b, true);
    }
    if (action instanceof SystemAction) {
        SystemAction s = (SystemAction)action;
        return new Actions.MenuItem (s, true);
    }

    return new Actions.MenuItem (action, true);
}
项目:incubator-netbeans    文件:DefaultAWTBridge.java   
public @Override JMenuItem createPopupPresenter(Action action) {
    JMenuItem item;
    if (action instanceof BooleanStateAction) {
        BooleanStateAction b = (BooleanStateAction)action;
        item = new Actions.CheckboxMenuItem (b, false);
    } else if (action instanceof SystemAction) {
        SystemAction s = (SystemAction)action;
        item = new Actions.MenuItem (s, false);
    } else {
        item = new Actions.MenuItem (action, false);
    }
    return item;
}
项目:incubator-netbeans    文件:Actions.java   
/** @param changedProperty the name of property that has changed
* or null if it is not known
*/
@Override
public void updateState(String changedProperty) {
    super.updateState(changedProperty);

    if ((changedProperty == null) || changedProperty.equals(BooleanStateAction.PROP_BOOLEAN_STATE)) {
        button.setSelected(((BooleanStateAction) action).getBooleanState());
    }
}
项目:incubator-netbeans    文件:Actions.java   
/** Connects buttons to action.
* @param button the button
* @param action the action
*/
public static void connect(AbstractButton button, BooleanStateAction action) {
    Bridge b = new BooleanButtonBridge(button, action);
    b.prepare();
}
项目:incubator-netbeans    文件:Actions.java   
public BooleanButtonBridge(AbstractButton button, BooleanStateAction action) {
    super(button, action);
}
项目:incubator-netbeans    文件:Actions.java   
/** Constructs a new ActToolbarToggleButton for specified action */
public ToolbarToggleButton(BooleanStateAction aAction) {
    super(null, false);
    Actions.connect(this, aAction);
}
项目:incubator-netbeans    文件:Actions.java   
/** Attaches checkbox menu item to boolean state action.
* @param item menu item
* @param action action
* @param popup create popup or menu item
*/
public static void connect(JCheckBoxMenuItem item, BooleanStateAction action, boolean popup) {
    Bridge b = new CheckMenuBridge(item, action, popup);
    b.prepare();
}
项目:incubator-netbeans    文件:Actions.java   
/** Constructs a new ActCheckboxMenuItem with the specified label
*  and connects it to the given BooleanStateAction.
* @param aAction the action to which this menu item should be connected
* @param useMnemonic if true, the menu try to find mnemonic in action label
*/
public CheckboxMenuItem(BooleanStateAction aAction, boolean useMnemonic) {
    Actions.connect(this, aAction, !useMnemonic);
}