dsto.dfc.swing.commands
Class BasicFileOpenCommand

java.lang.Object
  extended by dsto.dfc.swing.commands.AbstractCommand
      extended by dsto.dfc.swing.commands.BasicFileOpenCommand
All Implemented Interfaces:
Command, Iconic, Copyable, ActionListener, Cloneable, EventListener

public class BasicFileOpenCommand
extends AbstractCommand

Base class for File Open commands.

Version:
$Revision$

Field Summary
protected  Component owner
           
 
Fields inherited from class dsto.dfc.swing.commands.AbstractCommand
displayName, icon
 
Fields inherited from interface dsto.dfc.swing.icons.Iconic
NULL_ICON
 
Constructor Summary
BasicFileOpenCommand()
           
BasicFileOpenCommand(Component owner)
           
 
Method Summary
protected  void dialogCancelled(JFileChooser chooser)
          Superclasses may override this to handle the case where the user cancels the dialog.
 void execute()
          Provides a basic implementation: pops up a file chooser and calls either openFile () or dialogCancelled ().
 KeyStroke getAccelerator()
          Get a keyboard accelerator for the command.
 String getDescription()
          A short description of the command, suitable for a tooltip or use in a status panel.
 String getGroupInView(String viewName)
          Get the preferred group that this command should appear in for a given view.
 char getMnemonic()
          Get a character shortcut for the command (eg for use on a menu).
 String getName()
          The formal identifying name for this command (eg edit.Copy, file.Open).
protected  void handleError()
           
protected  void handleError(Throwable exception)
           
protected  void initFileChooser(JFileChooser chooser)
          Superclasses may override this to setup the file chooser before display.
 boolean isInteractive()
          True if this command will interact with the user when execute() is called.
protected  void openFile(JFileChooser chooser)
          Superclasses may override this to open a file selected via the chooser.
 
Methods inherited from class dsto.dfc.swing.commands.AbstractCommand
actionPerformed, canReplace, clone, getDefaultDisplayName, getDisplayName, getIcon, getLargeIcon, getLogString, isEnabled, setDisplayName, setIcon
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owner

protected Component owner
Constructor Detail

BasicFileOpenCommand

public BasicFileOpenCommand()

BasicFileOpenCommand

public BasicFileOpenCommand(Component owner)
Method Detail

execute

public void execute()
Provides a basic implementation: pops up a file chooser and calls either openFile () or dialogCancelled ().

Specified by:
execute in interface Command
Specified by:
execute in class AbstractCommand
See Also:
initFileChooser(javax.swing.JFileChooser), openFile(javax.swing.JFileChooser), dialogCancelled(javax.swing.JFileChooser)

initFileChooser

protected void initFileChooser(JFileChooser chooser)
Superclasses may override this to setup the file chooser before display.


openFile

protected void openFile(JFileChooser chooser)
Superclasses may override this to open a file selected via the chooser.


dialogCancelled

protected void dialogCancelled(JFileChooser chooser)
Superclasses may override this to handle the case where the user cancels the dialog.


handleError

protected void handleError()

handleError

protected void handleError(Throwable exception)

getName

public String getName()
Description copied from interface: Command
The formal identifying name for this command (eg edit.Copy, file.Open). This must not change during the lifetime of a command instance.

Specified by:
getName in interface Command
Specified by:
getName in interface Iconic
Specified by:
getName in class AbstractCommand

getDescription

public String getDescription()
Description copied from interface: Command
A short description of the command, suitable for a tooltip or use in a status panel.

Specified by:
getDescription in interface Command
Specified by:
getDescription in class AbstractCommand

isInteractive

public boolean isInteractive()
Description copied from interface: Command
True if this command will interact with the user when execute() is called.

Specified by:
isInteractive in interface Command
Specified by:
isInteractive in class AbstractCommand

getGroupInView

public String getGroupInView(String viewName)
Description copied from interface: Command
Get the preferred group that this command should appear in for a given view. This may be overridden by a setting in the CommandRegistry.

If the command changes its group in any view it should generate a groupInView property change event with the old value set to the old group and the new value set to the new group.

Specified by:
getGroupInView in interface Command
Specified by:
getGroupInView in class AbstractCommand
Parameters:
viewName - The name of the view.
Returns:
The group in the view, or null if this command does not appear in the given view.

getMnemonic

public char getMnemonic()
Description copied from interface: Command
Get a character shortcut for the command (eg for use on a menu). May return 0 for no mnemonic.

Specified by:
getMnemonic in interface Command
Specified by:
getMnemonic in class AbstractCommand

getAccelerator

public KeyStroke getAccelerator()
Description copied from interface: Command
Get a keyboard accelerator for the command. May return null for no accelerator.

Specified by:
getAccelerator in interface Command
Overrides:
getAccelerator in class AbstractCommand


Copyright © 2008 Commonwealth of Australia