1 19 package org.openide.util.actions; 20 21 22 30 public abstract class BooleanStateAction extends SystemAction implements Presenter.Menu, Presenter.Popup, 31 Presenter.Toolbar { 32 33 static final long serialVersionUID = 6394800019181426199L; 34 35 36 public static final String PROP_BOOLEAN_STATE = "booleanState"; 38 42 public javax.swing.JMenuItem getMenuPresenter() { 43 return org.netbeans.modules.openide.util.AWTBridge.getDefault().createMenuPresenter(this); 44 } 45 46 51 public javax.swing.JMenuItem getPopupPresenter() { 52 return org.netbeans.modules.openide.util.AWTBridge.getDefault().createPopupPresenter(this); 53 } 54 55 59 public java.awt.Component getToolbarPresenter() { 60 return org.netbeans.modules.openide.util.AWTBridge.getDefault().createToolbarPresenter(this); 61 } 62 63 66 public boolean getBooleanState() { 67 return getProperty(PROP_BOOLEAN_STATE).equals(Boolean.TRUE); 68 } 69 70 75 public void setBooleanState(boolean value) { 76 Boolean newValue = value ? Boolean.TRUE : Boolean.FALSE; 77 Boolean oldValue = (Boolean ) putProperty(PROP_BOOLEAN_STATE, newValue); 78 79 firePropertyChange(PROP_BOOLEAN_STATE, oldValue, newValue); 80 } 81 82 85 protected void initialize() { 86 putProperty(PROP_BOOLEAN_STATE, Boolean.TRUE); 87 super.initialize(); 88 } 89 90 95 public void actionPerformed(java.awt.event.ActionEvent ev) { 96 setBooleanState(!getBooleanState()); 97 } 98 } 99 | Popular Tags |