com.pietschy.command
Class CloseWindowCommand<T extends java.awt.Window>

java.lang.Object
  extended by com.pietschy.command.Command
      extended by com.pietschy.command.ActionCommand
          extended by com.pietschy.command.CloseWindowCommand<T>
All Implemented Interfaces:
ActionCommandExecutor, Bindable, Identifiable

public class CloseWindowCommand<T extends java.awt.Window>
extends ActionCommand

Provides common funcitonality used for closing windows. This command performs the following,

The default close operation simply calls Component.setVisible(boolean) and optionally calls Window.dispose() if isDisposeOnClose() returns true. Subclasses can alter the behaviour of the command by overriding the #handleClose(T) method.

The following is an example using a JDialog.

   #configuration
   close-dialog@face.text=_Close@ESCAPE

   CloseWindowCommand<JDialog> command = new CloseWindowCommand<JDialog&rt;("close-dialog");
   command.setWindow(myDialog);
 


Field Summary
 
Fields inherited from class com.pietschy.command.ActionCommand
PARAMETER_ACTION_EVENT, PARAMETER_INVOKER, PARAMETER_INVOKER_WINDOW, PARAMETER_MODIFIERS
 
Fields inherited from class com.pietschy.command.Command
internalLog, PROPERTY_ENABLED, PROPERTY_VISIBLE
 
Constructor Summary
CloseWindowCommand()
          Creates a new anonymous instance.
CloseWindowCommand(java.lang.String id)
          Creates a new instance with the specified id.
CloseWindowCommand(java.lang.String id, T window)
          Creates a new instance with the specified id and that closes the specified window.
CloseWindowCommand(T window)
          Creates a new anonymous instance that closes the specified window.
 
Method Summary
 T getTargetWindow()
          Gets the window associated with this command.
protected  void handleClose(T window)
          Called to close the specified window.
protected  void handleExecute()
          Invokes #handleClose(T).
 boolean isDisposeOnClose()
          Checks if the window should be disposed on close.
 void setDisposeOnClose(boolean disposeOnClose)
          Configures this command to dispose the window on close.
 void setTargetWindow(T newWindow)
          Sets the window that this command will close.
 
Methods inherited from class com.pietschy.command.ActionCommand
addActionCommandListener, addInterceptor, bindToContainer, createButton, createButton, createButton, createButton, createMenuItem, createMenuItem, createMenuItem, createMenuItem, doButtonAttachments, doButtonDetachments, execute, execute, getActionAdapter, getActionAdapter, getActionEvent, getInvoker, getInvokerWindow, getModifiers, getParameter, getParameter, getParameters, installShortCut, installShortCut, postExecute, preExecute, putParameter, putParameters, removeActionCommandListener, removeInterceptor, requestDefaultIn, unbindFromContainer, uninstallShortCut, uninstallShortCut
 
Methods inherited from class com.pietschy.command.Command
addContainerPropertyListener, addFace, addHoverListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, attach, bind, bind, bind, buttonIterator, configureAppearance, configureAppearances, configureButtonAppearances, configureButtonStates, configureButtonStates, createButton, createButton, createButton, createButton, createComponent, createMenuItem, createMenuItem, createMenuItem, createMenuItem, detach, faceExists, findBestFace, fireHoverEnded, fireHoverStarted, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlternativeFaceContexts, getButtonFactory, getButtonIn, getCommandContainer, getContainerProperty, getContainerPropertySupport, getDefaultFace, getDefaultFace, getFace, getFace, getId, getMenuFactory, getProperty, getProperty, getPropertyNames, getToolbarFactory, isAnonymous, isAttachedTo, isBound, isEnabled, isVisible, loadConfiguration, notifyCommandContainerHierarchyChanged, putProperties, putProperty, rebind, removeContainerPropertyListener, removeHoverListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, requestFocusIn, setButtonFactory, setEnabled, setMenuFactory, setToolbarFactory, setVisible, toString, unbind, validateId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.pietschy.command.ActionCommandExecutor
addPropertyChangeListener, addPropertyChangeListener, isEnabled, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.pietschy.command.Identifiable
getId
 

Constructor Detail

CloseWindowCommand

public CloseWindowCommand()
Creates a new anonymous instance.

See Also:
#setWindow(T)

CloseWindowCommand

public CloseWindowCommand(java.lang.String id)
Creates a new instance with the specified id.

Parameters:
id - the command id.
See Also:
#setWindow(T)

CloseWindowCommand

public CloseWindowCommand(java.lang.String id,
                          T window)
Creates a new instance with the specified id and that closes the specified window.

Parameters:
id - the command id.
window - the window to close.

CloseWindowCommand

public CloseWindowCommand(T window)
Creates a new anonymous instance that closes the specified window.

Parameters:
window - the window to close.
Method Detail

setTargetWindow

public void setTargetWindow(T newWindow)
Sets the window that this command will close.

Parameters:
newWindow - the new window to close.

handleExecute

protected void handleExecute()
Invokes #handleClose(T).

Specified by:
handleExecute in class ActionCommand

handleClose

protected void handleClose(T window)
Called to close the specified window. The default implementation sets the window visibility to false and invokes Window.dispose() if isDisposeOnClose() returns true.

Subclasses can override to perform application specific close operations.

Parameters:
window - the window to close.

getTargetWindow

public T getTargetWindow()
Gets the window associated with this command.

Returns:
the window associated with this command.

isDisposeOnClose

public boolean isDisposeOnClose()
Checks if the window should be disposed on close.

Returns:
true to dispose the window on close, false otherwise.

setDisposeOnClose

public void setDisposeOnClose(boolean disposeOnClose)
Configures this command to dispose the window on close.

Parameters:
disposeOnClose - true to invoke Window.dispose() during #handleClose(T), false otherwise.


Copyright © 2006 - 2007 Andrew Pietsch