csheets
Class CleanSheets

java.lang.Object
  extended by csheets.CleanSheets

public class CleanSheets
extends Object

CleanSheets - the main class of the application. The class manages workbooks, performs I/O operations and provides support for notifying listeners when workbooks are created, loaded or saved.

Author:
Einar Pehrson

Nested Class Summary
static class CleanSheets.EventDispatcher
          A utility for dispatching events on the AWT event dispatching thread.
 
Constructor Summary
CleanSheets()
          Creates the CleanSheets application.
 
Method Summary
 void addSpreadsheetAppListener(SpreadsheetAppListener listener)
          Registers the given listener on the spreadsheet application.
 void create()
          Creates a new workbook.
 void exit()
          Exits the application.
 File getFile(Workbook workbook)
          Returns the file in which the given workbook is stored.
 Properties getUserProperties()
          Returns the current user properties.
 Workbook getWorkbook(File file)
          Returns the workbook that is stored in the given file, if it is already open.
 Workbook[] getWorkbooks()
          Returns the workbooks that are open.
 boolean isFileOpen(File file)
          Returns whether the given file is open, and a workbook thereby loaded from it or saved to it.
 boolean isWorkbookStored(Workbook workbook)
          Returns whether a file has been specified for the given workbook, either when it was loaded or when it was last saved.
 void load(File file)
          Loads a workbook from the given file.
static void main(String[] args)
          Starts CleanSheets from the command-line.
 void removeSpreadsheetAppListener(SpreadsheetAppListener listener)
          Removes the given listener from the spreadsheet application.
 void save(Workbook workbook)
          Saves the given workbook to the file from which it was loaded, or to which it was most recently saved.
 void saveAs(Workbook workbook, File file)
          Saves the given workbook to the given file.
 void unload(Workbook workbook)
          Unloads the given workbook.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CleanSheets

public CleanSheets()
Creates the CleanSheets application.

Method Detail

main

public static void main(String[] args)
Starts CleanSheets from the command-line.

Parameters:
args - the command-line arguments (not used)

getUserProperties

public Properties getUserProperties()
Returns the current user properties.

Returns:
the current user properties

exit

public void exit()
Exits the application.


create

public void create()
Creates a new workbook.


load

public void load(File file)
          throws IOException,
                 ClassNotFoundException
Loads a workbook from the given file.

Parameters:
file - the file in which the workbook is stored
Throws:
IOException - if the file could not be loaded correctly
ClassNotFoundException

unload

public void unload(Workbook workbook)
Unloads the given workbook.

Parameters:
workbook - the workbook to unload

save

public void save(Workbook workbook)
          throws IOException
Saves the given workbook to the file from which it was loaded, or to which it was most recently saved.

Parameters:
workbook - the workbook to save
Throws:
IOException - if the file could not be saved correctly

saveAs

public void saveAs(Workbook workbook,
                   File file)
            throws IOException
Saves the given workbook to the given file.

Parameters:
workbook - the workbook to save
file - the file to which the workbook should be saved
Throws:
IOException - if the file could not be saved correctly

getWorkbooks

public Workbook[] getWorkbooks()
Returns the workbooks that are open.

Returns:
the workbooks that are open

getFile

public File getFile(Workbook workbook)
Returns the file in which the given workbook is stored.

Returns:
the file in which the given workbook is stored, or null if it isn't

isWorkbookStored

public boolean isWorkbookStored(Workbook workbook)
Returns whether a file has been specified for the given workbook, either when it was loaded or when it was last saved.

Returns:
whether the given workbook belongs to a file

getWorkbook

public Workbook getWorkbook(File file)
Returns the workbook that is stored in the given file, if it is already open.

Parameters:
file - the file to look for
Returns:
the workbook that is stored in the given file, or null if the file isn't open

isFileOpen

public boolean isFileOpen(File file)
Returns whether the given file is open, and a workbook thereby loaded from it or saved to it.

Parameters:
file - the file to look for
Returns:
whether the given file is open

addSpreadsheetAppListener

public void addSpreadsheetAppListener(SpreadsheetAppListener listener)
Registers the given listener on the spreadsheet application.

Parameters:
listener - the listener to be added

removeSpreadsheetAppListener

public void removeSpreadsheetAppListener(SpreadsheetAppListener listener)
Removes the given listener from the spreadsheet application.

Parameters:
listener - the listener to be removed