edu.kzoo.grid.gui
Class FileMenuActionHandler

java.lang.Object
  |
  +--edu.kzoo.grid.gui.FileMenuActionHandler

public class FileMenuActionHandler
extends java.lang.Object

Grid GUI Support Package:
The FileMenuActionHandler class implements the methods used by the File menu defined in GridAppFrame.

Version:
15 December 2003
Author:
Alyce Brady (based on code by Julie Zelenski)
See Also:
GridAppFrame

Constructor Summary
FileMenuActionHandler(GridAppFrame frame, GridDataFileHandler fileHandler)
          Creates a new file menu action handler tied to the specified frame.
 
Method Summary
protected  GridFileChooser createFileChooser()
          Creates the file chooser.
protected  GridCreationDialog createGridCreationDialog()
          Creates a grid creation dialog.
 void createNewGrid()
          Creates a new empty grid and invokes the grid editor.
 void editGrid()
          Enables editing of the existing grid from the parent frame.
protected  GridFileChooser getFileChooser()
          Gets the file chooser dialog used previously (if any) or creates a new one using the createFileChooser method.
protected  GridDataFileHandler getFileHandler()
          Gets the object that handles file i/o.
protected  GridCreationDialog getGridCreationDialog()
          Gets the dialog used previously (if any) for grid creation.
protected  GridAppFrame getParentFrame()
          Gets the frame containing the file menu associated with this handler.
protected  void invokeEditor()
          Invokes the appropriate grid editor to edit the grid from the parent frame.
 void openFile()
          Reads a new grid from a saved data file.
 void saveFile()
          Saves the grid from the parent frame to a data file.
 boolean supportsFileIO()
          Indicates whether this action handler supports file i/o.
 boolean supportsGridEditing()
          Indicates whether this action handler supports grid editing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileMenuActionHandler

public FileMenuActionHandler(GridAppFrame frame,
                             GridDataFileHandler fileHandler)
Creates a new file menu action handler tied to the specified frame. (Precondition: frame is not null. )

Parameters:
frame - the frame that uses this action handler
fileHandler - object that can read and write a grid; null if this handler should not support file i/o
Method Detail

getParentFrame

protected GridAppFrame getParentFrame()
Gets the frame containing the file menu associated with this handler.

Returns:
the frame with this file menu

getGridCreationDialog

protected GridCreationDialog getGridCreationDialog()
Gets the dialog used previously (if any) for grid creation.

Returns:
the dialog that prompts for grid creation parameters

createGridCreationDialog

protected GridCreationDialog createGridCreationDialog()
Creates a grid creation dialog.

Returns:
a grid creation dialog

getFileChooser

protected GridFileChooser getFileChooser()
Gets the file chooser dialog used previously (if any) or creates a new one using the createFileChooser method.

Returns:
the file chooser for finding files to read to or write from

createFileChooser

protected GridFileChooser createFileChooser()
Creates the file chooser.

Returns:
the file to open

getFileHandler

protected GridDataFileHandler getFileHandler()
Gets the object that handles file i/o.

Returns:
file i/o handler

supportsFileIO

public boolean supportsFileIO()
Indicates whether this action handler supports file i/o.

Returns:
true if this action handler was constructed with a non-null grid data file handler

supportsGridEditing

public boolean supportsGridEditing()
Indicates whether this action handler supports grid editing. Should only be redefined in subclasses that also redefine the invokeEditor method.


createNewGrid

public void createNewGrid()
Creates a new empty grid and invokes the grid editor. (Precondition: supportsGridEditing() == true


invokeEditor

protected void invokeEditor()
Invokes the appropriate grid editor to edit the grid from the parent frame. Should be redefined in subclasses that support a grid editor, to construct and run the editor.


editGrid

public void editGrid()
Enables editing of the existing grid from the parent frame. Subclasses that support grid editing should ensure that the application is not actively running and modifying the grid while the grid is being edited. For example, if the parent frame is a SteppedGridAppFrame, the subclass should call the frame's stop method.


openFile

public void openFile()
Reads a new grid from a saved data file. Gets file via file chooser dialog, reads contents using the specified file handler. On error, brings up dialog and continues using previous grid.


saveFile

public void saveFile()
Saves the grid from the parent frame to a data file.