public ActionDelegateListener(CallbackSystemAction c, Action delegate) { super(c); this.delegate = new WeakReference<Action>(delegate); delegate.addPropertyChangeListener(this); }
public void attach(Action action) { Reference<Action> d = delegate; if ((d == null) || (d.get() == action)) { return; } Action prev = d.get(); // reattaches to different action if (prev != null) { prev.removePropertyChangeListener(this); } this.delegate = new WeakReference<Action>(action); action.addPropertyChangeListener(this); }
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 ActionDelegateListener(CallbackSystemAction c, Action delegate) { super(c); this.delegate = new WeakReference<Action>(delegate); delegate.addPropertyChangeListener(this); }
/** Attaches listener to given action */ final void addNotify() { action.addPropertyChangeListener(actionL); updateState(null); }
public void attach(Action action) { Reference<Action> d = delegate; if ((d == null) || (d.get() == action)) { return; } Action prev = d.get(); // reattaches to different action if (prev != null) { prev.removePropertyChangeListener(this); } this.delegate = new WeakReference<Action>(action); action.addPropertyChangeListener(this); }
/** Constructs new action that is bound to given context and * listens for changes of <code>ActionMap</code> in order to delegate * to right action. */ protected BaseDelAction(Map map, Object key, Lookup actionContext, Action fallback, boolean surviveFocusChange, boolean async) { this.map = map; this.key = key; this.fallback = fallback; this.global = GlobalManager.findManager(actionContext, surviveFocusChange); this.weakL = WeakListeners.propertyChange(this, fallback); this.async = async; if (fallback != null) { fallback.addPropertyChangeListener(weakL); } }
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(); }
protected ActionListener getDelegate() { if (delegate == null) { ActionListener al; if (parent == null) { Object listener = map.get("delegate"); // NOI18N if (!(listener instanceof ActionListener)) { throw new NullPointerException("No 'delegate' in " + map); } al = (ActionListener) listener; } else { al = parent.getDelegate(); } delegate = bindToContext(al, context); if (delegate instanceof Action) { Action actionDelegate = (Action) delegate; if (weakL == null) { weakL = WeakListeners.propertyChange(this, actionDelegate); } actionDelegate.addPropertyChangeListener(weakL); // Ensure display names and other properties are in sync or propagate them syncActionDelegateProperty(Action.NAME, actionDelegate); } } return delegate; }
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 } } }
/** * {@inheritDoc} */ @Override public void addPropertyChangeListener(PropertyChangeListener listener) { delegate.addPropertyChangeListener(listener); }
@Override public void addPropertyChangeListener (final @Nonnull PropertyChangeListener listener) { delegate.addPropertyChangeListener(listener); }
public ActionDelegateListener(CallbackSystemAction c, Action delegate) { super(c); this.delegate = new WeakReference<Action>(delegate); delegate.addPropertyChangeListener(this); }
private void setAction(Action newAction) { if(action!=null) { action.removePropertyChangeListener(visibleListener); } if(newAction!=null) { newAction.addPropertyChangeListener(visibleListener); } action = newAction; } @Override
/** * Constructor * * @param a toggle action to perform when the button is pressed */ public ToggleButton(Action a) { super(a); if (a.getValue(Action.SMALL_ICON) != null) { setText(null); } a.addPropertyChangeListener(this); }
public ToggleActionPropertyChangeListener(Action action, AbstractButton button) { if (shouldAddListener(action, button)) { this.buttonRef = new WeakReference<AbstractButton>(button); action.addPropertyChangeListener(this); } }
public void attach (javax.swing.Action action) { if (delegate == action) { return; } // reattaches to different action if (this.delegate != null) { this.delegate.removePropertyChangeListener(this); } this.delegate = action; action.addPropertyChangeListener(this); }
public CButtonExt(Action action) { this.action = action; // Read properties from the action onActionPropertyChange(new PropertyChangeEvent(action,null,null,null)); // Listen to action property changes action.addPropertyChangeListener( EventHandler.create(PropertyChangeListener.class, this, "onActionPropertyChange", "")); }
/** * Installs listeners on the view object. */ @Override protected void installViewListeners(View p) { super.installViewListeners(p); Action undoActionInView = p.getActionMap().get(ID); if (undoActionInView != null && undoActionInView != this) { undoActionInView.addPropertyChangeListener(redoActionPropertyListener); } }
/** * Description of the Method * * @param b Description of Parameter * @param a Description of Parameter */ private void registerButtonForAction(AbstractButton b, Action a) { PropertyChangeListener actionPropertyChangeListener = createActionChangeListener(b); a.addPropertyChangeListener(actionPropertyChangeListener); b.setEnabled(a.isEnabled()); }