public final boolean isEnabled() { return action.isEnabled(); }
public boolean isEnabled() { Action a = findAction(); if (a == null) { a = delegate; } // 40915 - hold last action weakly Action last = lastRef == null ? null : lastRef.get(); if (a != last) { if (last != null) { last.removePropertyChangeListener(weakL); } lastRef = new WeakReference<Action>(a); a.addPropertyChangeListener(weakL); } return a.isEnabled(); }
/** Perform the action. Tries the performer and then scans the ActionMap * of selected topcomponent. */ public void actionPerformed(final ActionEvent ev) { // First try global context action. final Action action = GlobalManager.getDefault().findGlobalAction(getActionMapKey(), getSurviveFocusChange()); if (action != null) { if (action.isEnabled()) { action.actionPerformed(ev); } else { Toolkit.getDefaultToolkit().beep(); } return; } final Object ap = getActionPerformer(); if (ap != null) { org.openide.util.actions.ActionInvoker.invokeAction( this, ev, asynchronous(), new Runnable() { public void run() { if (ap == getActionPerformer()) { getActionPerformer().performAction(CallbackSystemAction.this); } } } ); return; } Toolkit.getDefaultToolkit().beep(); }
@Override public boolean isEnabled() { // assert EventQueue.isDispatchThread(); if (delegate instanceof Action) { return ((Action)delegate).isEnabled(); } return true; }
public final boolean isEnabled() { return action.isEnabled(); }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled() { Action action = GlobalManager.getDefault().findGlobalAction( getActionMapKey(), getSurviveFocusChange() ); if (action != null) { setEnabled(action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if ((l == null) || (l.get() != this)) { l = new ActionDelegateListener(this, action); putProperty(LISTENER, l); } else { l.attach(action); } } } else { if (getActionPerformer() != null) { // we have performer setEnabled(true); } else { setEnabled(false); } clearListener(); } }
public boolean isEnabled() { assert EventQueue.isDispatchThread(); javax.swing.Action a = findAction(); return a == null ? false : a.isEnabled(); }
void updateState(ActionMap prev, ActionMap now, boolean fire) { if (key == null) { return; } boolean prevEnabled = false; if (prev != null) { Action prevAction = prev.get(key); if (prevAction != null) { prevEnabled = fire && prevAction.isEnabled(); prevAction.removePropertyChangeListener(weakL); } } if (now != null) { Action nowAction = now.get(key); boolean nowEnabled; if (nowAction != null) { nowAction.addPropertyChangeListener(weakL); nowEnabled = nowAction.isEnabled(); } else { nowEnabled = fallback != null && fallback.isEnabled(); } PropertyChangeSupport sup = fire ? support : null; if (sup != null && nowEnabled != prevEnabled) { sup.firePropertyChange("enabled", prevEnabled, !prevEnabled); // NOI18N } } }
public boolean isEnabled() { Action a = findAction(); if (a == null) { a = delegate; } // 40915 - hold last action weakly Action last = lastRef == null ? null : lastRef.get(); if (a != last) { if (last != null) { last.removePropertyChangeListener(weakL); } lastRef = new WeakReference<Action>(a); a.addPropertyChangeListener(weakL); } return a.isEnabled(); }
public void actionPerformed(final ActionEvent e) { assert EventQueue.isDispatchThread(); if (getDelegate() instanceof Action) { if (!((Action)getDelegate()).isEnabled()) { Toolkit.getDefaultToolkit().beep(); // Do not fire newValue == null (see #165838) firePropertyChange("enabled", null, isEnabled()); // NOI18N return; } } boolean async = Boolean.TRUE.equals(map.get("asynchronous")); // NOI18N Runnable ar = new Runnable() { public void run() { getDelegate().actionPerformed(e); } }; ActionInvoker.invokeAction(this, e, async, ar); }
button.setEnabled(action.isEnabled());
button.setEnabled(action.isEnabled());
updateState(null); currentOnes.add(single); single.setEnabled(action.isEnabled());
/** Perform the action. Tries the performer and then scans the ActionMap * of selected topcomponent. */ public void actionPerformed(final ActionEvent ev) { // First try global context action. final Action action = GlobalManager.getDefault().findGlobalAction(getActionMapKey(), getSurviveFocusChange()); if (action != null) { if (action.isEnabled()) { action.actionPerformed(ev); } else { Utilities.disabledActionBeep(); } return; } final Object ap = getActionPerformer(); if (ap != null) { org.openide.util.actions.ActionInvoker.invokeAction( this, ev, asynchronous(), new Runnable() { public void run() { if (ap == getActionPerformer()) { getActionPerformer().performAction(CallbackSystemAction.this); } } } ); return; } Utilities.disabledActionBeep(); }
@Override public boolean isEnabled() { return incrementSupport.isIncrementEnabled() || originalAction.isEnabled(); } }
/** Updates the enabled state by checking performer and ActionMap */ private void updateEnabled() { Action action = GlobalManager.getDefault().findGlobalAction( getActionMapKey(), getSurviveFocusChange() ); if (action != null) { setEnabled(action.isEnabled()); synchronized (LISTENER) { ActionDelegateListener l = (ActionDelegateListener) getProperty(LISTENER); if ((l == null) || (l.get() != this)) { l = new ActionDelegateListener(this, action); putProperty(LISTENER, l); } else { l.attach(action); } } } else { if (getActionPerformer() != null) { // we have performer setEnabled(true); } else { setEnabled(false); } clearListener(); } }
private void setAcceleratorAction(final JButton button, final KeyStroke ks) { final Action setAcceleratorAction = new SetFKeyAcceleratorOnNextClickAction(ks); button.setAction(setAcceleratorAction); button.setEnabled(setAcceleratorAction.isEnabled()); final String text = TextUtils.getText("f_button_unassigned"); button.setText(text); }
@Override public void actionPerformed(ActionEvent e) { if (!openCustomEditor(e)) { Action a = getActionMap().get(delegateActionBind); if (a != null && a.isEnabled()) { a.actionPerformed(e); } } }
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed try { getExplorerManager().setSelectedNodes(new Node[] { rootNode }); } catch (PropertyVetoException pve) { // this should be always possible --> if not, notify problem PropertyDialogManager.notify(pve); } if ((newAction != null) && (newAction.isEnabled())) { newAction.actionPerformed(evt); } } //GEN-LAST:event_newButtonActionPerformed