com.levigo.util.swing.action
Class DelegateAction

java.lang.Object
  extended by com.levigo.util.swing.action.DelegateAction
All Implemented Interfaces:
ActionListener, EventListener, Action

public class DelegateAction
extends Object
implements Action

An Action which delegates the actual action to a delegate Action, but allows other properties of the action to be overridden. This class maintains a private set of properites. If a property has been set on this class, it will be used instead of the delegate's property. Otherwise it will fall back to the asking the delegate. This class currently supports static actions only: no property changes from the delegate action or this class are propagated. Consequently, calling addPropertyChangeListener(PropertyChangeListener) or removePropertyChangeListener(PropertyChangeListener) has no effect.


Field Summary
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
DelegateAction(Action delegate)
          Create a new delegate action delegating to the given delegate action.
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 Object getValue(String key)
          Get the value for the given property key.
 boolean isEnabled()
           
 void putValue(String key, Object value)
          Override the value for the given property key.
 void removeOverriddenProperty(String key)
          Remove the overridden property for the given key.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void reset()
          Reset all properties and the enabled state to the values of the delegate action.
 void setEnabled(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegateAction

public DelegateAction(Action delegate)
Create a new delegate action delegating to the given delegate action.

Parameters:
delegate - the delegate
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

getValue

public Object getValue(String key)
Get the value for the given property key. If the property has been overridden, the local value is returned. Otherwise we fall back to the delegate's property value.

Specified by:
getValue in interface Action
See Also:
Action.getValue(java.lang.String)

putValue

public void putValue(String key,
                     Object value)
Override the value for the given property key. The delegate action remains unchanged.

Specified by:
putValue in interface Action
See Also:
Action.putValue(java.lang.String, java.lang.Object)

setEnabled

public void setEnabled(boolean b)
Specified by:
setEnabled in interface Action

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Action

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface Action

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface Action

removeOverriddenProperty

public void removeOverriddenProperty(String key)
Remove the overridden property for the given key.

Parameters:
key -

reset

public void reset()
Reset all properties and the enabled state to the values of the delegate action.



Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.