net.sf.jga.swing.spreadsheet
Class Controller

java.lang.Object
  extended by net.sf.jga.swing.spreadsheet.Controller

public class Controller
extends java.lang.Object

Provides for generally common operations on a spreadsheet when it is in an application.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall

Field Summary
static int CANCEL_OPTION
           
static int NO_OPTION
           
static int YES_OPTION
           
 
Constructor Summary
Controller(Spreadsheet sheet)
          Builds a Controller to control the given sheet widget.
 
Method Summary
 int confirm(java.lang.String msg, java.lang.String title)
          Asks the user a Yes/No/Cancel question.
 javax.swing.Action getCellEditorCmd()
          Returns an Action that changes the type of the current cell.
 javax.swing.Action getCellFormatCmd()
          Returns an Action that reformats the current cell.
 javax.swing.Action getCellRenameCmd()
          Returns an Action that renames the current cell.
 javax.swing.Action getCellRendererCmd()
          Returns an Action that changes the type of the current cell.
 javax.swing.Action getCellTypeCmd()
          Returns an Action that changes the type of the current cell.
 javax.swing.Action getCellValidatorCmd()
          Returns an Action that changes the type of the current cell.
 javax.swing.Action getDefaultEditableCmd()
          Returns an Action that changes the default cell format.
 javax.swing.Action getDefaultEditorCmd()
          Returns an Action that changes the default cell editor.
 javax.swing.Action getDefaultFormatCmd()
          Returns an Action that changes the default cell format.
 javax.swing.Action getDefaultRendererCmd()
          Returns an Action that changes the default cell renderer.
 javax.swing.Action getDefaultTypeCmd()
          Returns an Action that changes the default cell type.
 javax.swing.Action getDefaultValueCmd()
          Returns an Action that changes the default cell type.
 javax.swing.Action getFileNewCmd()
          Returns an Action that resets the spreadsheet to default state.
 javax.swing.Action getFileOpenCmd()
          Returns an Action that sets the spreadsheet to the contents of a file.
 javax.swing.Action getFileSaveAsCmd()
          Returns an Action that saves the spreadsheet to a file.
 javax.swing.Action getFileSaveCmd()
          Returns an Action that saves the spreadsheet to the file from whence it came.
 javax.swing.Action getImportClassCmd()
          Returns an Action that allows the user to import a class.
 javax.swing.Action getSheetColumnsCmd()
          Returns an Action that resizes the worksheet.
 javax.swing.Action getSheetRowsCmd()
          Returns an Action that resizes the worksheet.
 java.net.URL getSheetSource()
           
 boolean isSheetDirty()
           
 int loadSheet(Spreadsheet sheet)
          Loads a spreadsheet
 void newWorksheet()
          Creates a new, empty spreadsheet with default settings.
 void notify(java.lang.String msg, java.lang.String title)
          Displays an error message to the user
 int openFile()
          Prompts the user for a file to open, and sets the spreadsheet to the file's contents.
 java.lang.String prompt(java.lang.String msg, java.lang.String val)
          Prompts the user for a string value.
 int promptAndSave()
          Prompts the user using a supplied functor, and returns one of YES, NO, or CANCEL
 int saveFile()
           
 int saveFileAs()
           
 int saveSheet(Spreadsheet sheet, boolean prompt)
          Saves a spreadsheet
 void setCellName(int row, int col)
          Prompts the user for the name of the designated cell.
 void setColumnCount()
          Prompts the user for the number of columns
 void setConfirmFunctor(BinaryFunctor<java.lang.String,java.lang.String,java.lang.Integer> fn)
          Sets the functor used to ask the user a yes/no/cancel question
 void setDefaultType()
          Prompts the user for the cell type.
 void setDefaultValue()
          Prompts the user for the default cell value.
 void setErrorFunctor(BinaryFunctor<java.lang.String,java.lang.String,?> fn)
          Sets the functor used to display an error message.
 void setLoadFunctor(UnaryFunctor<Spreadsheet,java.lang.Integer> fn)
          Sets the functor used to get an output stream
 void setPromptFunctor(BinaryFunctor<java.lang.String,java.lang.String,java.lang.String> fn)
          Sets the functor used to prompt the user for simple information.
 void setRowCount()
          Prompts the user for the number of rows
 void setSaveFunctor(BinaryFunctor<Spreadsheet,java.lang.Boolean,java.lang.Integer> fn)
          Sets the functor used to get an output stream
 void setSheetDirty(boolean flag)
           
 void setSheetSource(java.net.URL url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YES_OPTION

public static final int YES_OPTION
See Also:
Constant Field Values

NO_OPTION

public static final int NO_OPTION
See Also:
Constant Field Values

CANCEL_OPTION

public static final int CANCEL_OPTION
See Also:
Constant Field Values
Constructor Detail

Controller

public Controller(Spreadsheet sheet)
Builds a Controller to control the given sheet widget.

Method Detail

prompt

public java.lang.String prompt(java.lang.String msg,
                               java.lang.String val)
Prompts the user for a string value.

Parameters:
msg - the description of the string to be shown to the user
val - the default or existing value of the string

setPromptFunctor

public void setPromptFunctor(BinaryFunctor<java.lang.String,java.lang.String,java.lang.String> fn)
Sets the functor used to prompt the user for simple information.


confirm

public int confirm(java.lang.String msg,
                   java.lang.String title)
Asks the user a Yes/No/Cancel question.

Returns:
a value taken fro

setConfirmFunctor

public void setConfirmFunctor(BinaryFunctor<java.lang.String,java.lang.String,java.lang.Integer> fn)
Sets the functor used to ask the user a yes/no/cancel question


notify

public void notify(java.lang.String msg,
                   java.lang.String title)
Displays an error message to the user


setErrorFunctor

public void setErrorFunctor(BinaryFunctor<java.lang.String,java.lang.String,?> fn)
Sets the functor used to display an error message.


loadSheet

public int loadSheet(Spreadsheet sheet)
Loads a spreadsheet


setLoadFunctor

public void setLoadFunctor(UnaryFunctor<Spreadsheet,java.lang.Integer> fn)
Sets the functor used to get an output stream


saveSheet

public int saveSheet(Spreadsheet sheet,
                     boolean prompt)
Saves a spreadsheet


setSaveFunctor

public void setSaveFunctor(BinaryFunctor<Spreadsheet,java.lang.Boolean,java.lang.Integer> fn)
Sets the functor used to get an output stream


getFileNewCmd

public javax.swing.Action getFileNewCmd()
Returns an Action that resets the spreadsheet to default state.


getFileOpenCmd

public javax.swing.Action getFileOpenCmd()
Returns an Action that sets the spreadsheet to the contents of a file.


getFileSaveCmd

public javax.swing.Action getFileSaveCmd()
Returns an Action that saves the spreadsheet to the file from whence it came.


getFileSaveAsCmd

public javax.swing.Action getFileSaveAsCmd()
Returns an Action that saves the spreadsheet to a file.


getDefaultEditableCmd

public javax.swing.Action getDefaultEditableCmd()
Returns an Action that changes the default cell format.


getDefaultTypeCmd

public javax.swing.Action getDefaultTypeCmd()
Returns an Action that changes the default cell type.


getDefaultValueCmd

public javax.swing.Action getDefaultValueCmd()
Returns an Action that changes the default cell type.


getDefaultFormatCmd

public javax.swing.Action getDefaultFormatCmd()
Returns an Action that changes the default cell format.


getDefaultRendererCmd

public javax.swing.Action getDefaultRendererCmd()
Returns an Action that changes the default cell renderer.


getDefaultEditorCmd

public javax.swing.Action getDefaultEditorCmd()
Returns an Action that changes the default cell editor.


getSheetColumnsCmd

public javax.swing.Action getSheetColumnsCmd()
Returns an Action that resizes the worksheet.


getSheetRowsCmd

public javax.swing.Action getSheetRowsCmd()
Returns an Action that resizes the worksheet.


getImportClassCmd

public javax.swing.Action getImportClassCmd()
Returns an Action that allows the user to import a class.


getCellRenameCmd

public javax.swing.Action getCellRenameCmd()
Returns an Action that renames the current cell.


getCellFormatCmd

public javax.swing.Action getCellFormatCmd()
Returns an Action that reformats the current cell.


getCellTypeCmd

public javax.swing.Action getCellTypeCmd()
Returns an Action that changes the type of the current cell.


getCellRendererCmd

public javax.swing.Action getCellRendererCmd()
Returns an Action that changes the type of the current cell.


getCellEditorCmd

public javax.swing.Action getCellEditorCmd()
Returns an Action that changes the type of the current cell.


getCellValidatorCmd

public javax.swing.Action getCellValidatorCmd()
Returns an Action that changes the type of the current cell.


setDefaultType

public void setDefaultType()
Prompts the user for the cell type.


setColumnCount

public void setColumnCount()
Prompts the user for the number of columns


setRowCount

public void setRowCount()
Prompts the user for the number of rows


setDefaultValue

public void setDefaultValue()
Prompts the user for the default cell value.


setCellName

public void setCellName(int row,
                        int col)
Prompts the user for the name of the designated cell.


newWorksheet

public void newWorksheet()
Creates a new, empty spreadsheet with default settings.


openFile

public int openFile()
Prompts the user for a file to open, and sets the spreadsheet to the file's contents.


saveFile

public int saveFile()

saveFileAs

public int saveFileAs()

promptAndSave

public int promptAndSave()
Prompts the user using a supplied functor, and returns one of YES, NO, or CANCEL


isSheetDirty

public boolean isSheetDirty()

setSheetDirty

public void setSheetDirty(boolean flag)

getSheetSource

public java.net.URL getSheetSource()

setSheetSource

public void setSheetSource(java.net.URL url)


Copyright © 2002-2006 David A. Hall. All Rights Reserved.