com.sas.swing.visuals.util
Class ChangeCursorCommand

com.sas.swing.visuals.util.ChangeCursorCommand
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 ChangeCursorCommand
implements com.sas.util.Command, com.sas.util.ApplyInterface

A command for changing a component's cursor. 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 cursor for a set of components. For example,

 // create command to set busy cursor
 ChangeCursorCommand cmd = new ChangeCursorCommand (
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 // 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 cursors
 cmd.undoAll ();
 

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

Field Summary
 
Fields inherited from interface com.sas.util.ApplyInterface
ABORT, CONTINUE
 
Constructor Summary
ChangeCursorCommand(java.awt.Cursor cursor)
          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 cursor for a given component.
 java.awt.Cursor getCursor()
          Returns the cursor 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 cursor change, if any.
 void undoAll()
          Undoes all cursor changes, if any.
 

Constructor Detail

ChangeCursorCommand

public ChangeCursorCommand(java.awt.Cursor cursor)
Constructor.

Parameters:
cursor - the cursor to change to when executed
See Also:
getCursor(), 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

getCursor

public java.awt.Cursor getCursor()
Returns the cursor that this command uses.

Returns:
the cursor 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 cursor 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 cursor 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 cursor 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.