com.sas.swing.visuals.util
Class ChangeEnabledStateCommand

com.sas.swing.visuals.util.ChangeEnabledStateCommand
All Implemented Interfaces:
com.sas.lang.StringDataInterface, com.sas.PublicClonable, com.sas.util.ApplyInterface, com.sas.util.Command, com.sas.util.SimpleCommand, java.lang.Cloneable

public class ChangeEnabledStateCommand
implements com.sas.util.Command, com.sas.util.ApplyInterface

A command for changing a component's enabled state. The command may be executed any number of times with different components and supports undo, and thus provides an easy way to temporarily change the enabled state for a set of components. For example,

 // create command to disable components
 ChangeEnabledStateCommand cmd = new ChangeEnabledStateCommand (false);
 // apply the command to our container and all its children
 com.sas.swing.visuals.util.Util.apply (container, cmd);
 // do some work
 [...]
 // restore the container and its children back to their original enabled state
 cmd.undoAll ();
 

See Also:
CompositeCommand, ChangeCursorCommand, DisableCommand, Util.apply(java.awt.Component, com.sas.util.ApplyInterface)

Field Summary
 
Fields inherited from interface com.sas.util.ApplyInterface
ABORT, CONTINUE
 
Constructor Summary
ChangeEnabledStateCommand(boolean state)
          Constructor.
 
Method Summary
 int apply(java.lang.Object obj)
          Alias for execute(obj).
 java.lang.Object clone()
          Clones this command.
 void execute(java.lang.Object obj)
          Changes the enabled state for a given component.
 boolean getEnabledState()
          Returns the enabled state that this command uses.
 java.lang.String getText()
          Placeholder to satisy interface requirements.
 boolean isExecutable()
          Returns true since this command is executable.
 boolean isUndoable()
          Returns true since this command is undoable.
 void setText(java.lang.String text)
          Placeholder to satisy interface requirements; does nothing.
 void undo()
          Undoes the most recent enabled state change, if any.
 void undoAll()
          Undoes all state changes, if any.
 

Constructor Detail

ChangeEnabledStateCommand

public ChangeEnabledStateCommand(boolean state)
Constructor.

Parameters:
state - the enabled state to change to when executed
See Also:
getEnabledState(), execute(java.lang.Object)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this command.

Specified by:
clone in interface com.sas.PublicClonable
Specified by:
clone in interface com.sas.util.Command
Overrides:
clone in class java.lang.Object
Returns:
a new command equivalent to this one
Throws:
java.lang.CloneNotSupportedException - this class supports cloning, but a subclass may not

getEnabledState

public boolean getEnabledState()
Returns the enabled state that this command uses.

Returns:
the enabled state set at construction

isExecutable

public boolean isExecutable()
Returns true since this command is executable.

Specified by:
isExecutable in interface com.sas.util.Command
Returns:
true
See Also:
execute(java.lang.Object)

execute

public void execute(java.lang.Object obj)
Changes the enabled state for a given component.

Specified by:
execute in interface com.sas.util.SimpleCommand
Parameters:
obj - must be an instance of java.awt.Component
See Also:
undo()

apply

public int apply(java.lang.Object obj)
Alias for execute(obj).

Specified by:
apply in interface com.sas.util.ApplyInterface
Parameters:
obj - must be an instance of java.awt.Component
Returns:
ApplyInterface.CONTINUE
See Also:
execute(java.lang.Object)

isUndoable

public boolean isUndoable()
Returns true since this command is undoable.

Specified by:
isUndoable in interface com.sas.util.Command
Returns:
true
See Also:
undo()

undo

public void undo()
Undoes the most recent enabled state change, if any.

Specified by:
undo in interface com.sas.util.Command
See Also:
execute(java.lang.Object), undoAll()

undoAll

public void undoAll()
Undoes all state changes, if any.

See Also:
undo()

getText

public java.lang.String getText()
Placeholder to satisy interface requirements.

Specified by:
getText in interface com.sas.lang.StringDataInterface
Returns:
the empty string ("")
See Also:
setText(java.lang.String)

setText

public void setText(java.lang.String text)
Placeholder to satisy interface requirements; does nothing.

Specified by:
setText in interface com.sas.lang.StringDataInterface
See Also:
getText()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.