csheets.ui.ctrl
Class UIController

java.lang.Object
  extended by csheets.ui.ctrl.UIController
All Implemented Interfaces:
SpreadsheetAppListener, EventListener

public class UIController
extends Object
implements SpreadsheetAppListener

A controller for managing the current selection, i.e. the active workbook, spreadsheet and cell, as well as for keeping track of modifications to workbooks and of user interface extensions.

Author:
Einar Pehrson

Nested Class Summary
static class UIController.EventDispatcher
          A utility for dispatching events on the AWT event dispatching thread.
 
Constructor Summary
UIController(CleanSheets app)
          Creates a new user interface controller.
 
Method Summary
 void addEditListener(EditListener listener)
          Registers the given listener on the user interface controller.
 void addSelectionListener(SelectionListener listener)
          Registers the given listener on the user interface controller.
 Cell getActiveCell()
          Returns the active cell of the active workbook's active spreadsheet.
 Spreadsheet getActiveSpreadsheet()
          Returns the active spreadsheet.
 Workbook getActiveWorkbook()
          Returns the active workbook.
 TransferHandler getCellTransferHandler()
          Returns the transfer haandler used to transfer ranges of cells.
 UIExtension[] getExtensions()
          Returns the user interface extensions that have been loaded.
 Properties getUserProperties()
          Returns the current user properties.
 boolean isActiveWorkbookModified()
          Returns whether the active workbook has been modified.
 boolean isWorkbookModified(Workbook workbook)
          Returns whether the given workbook has been modified.
 void removeEditListener(EditListener listener)
          Removes the given listener from the user interface controller.
 void removeSelectionListener(SelectionListener listener)
          Removes the given listener from the user interface controller.
 void setActiveCell(Cell cell)
          Sets the active cell of the application, and thereby also the active spreadsheet and workbook.
 void setActiveSpreadsheet(Spreadsheet spreadsheet)
          Sets the active spreadsheet of the application, and thereby also the active workbook.
 void setActiveWorkbook(Workbook workbook)
          Sets the given workbook of the application.
 void setWorkbookModified(Workbook workbook)
          Specifies whether the given workbook has been modified.
 void workbookCreated(SpreadsheetAppEvent event)
          Invoked by the spreadsheet application to indicate that a new workbook has been created.
 void workbookLoaded(SpreadsheetAppEvent event)
          Invoked by the spreadsheet application to indicate that a workbook has been loaded from the given file.
 void workbookSaved(SpreadsheetAppEvent event)
          Invoked by the spreadsheet application to indicate that a workbook was saved to the given file.
 void workbookUnloaded(SpreadsheetAppEvent event)
          Invoked by the spreadsheet application to indicate that a workbook has been unloaded (closed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIController

public UIController(CleanSheets app)
Creates a new user interface controller.

Parameters:
app - the CleanSheets application
Method Detail

getActiveWorkbook

public Workbook getActiveWorkbook()
Returns the active workbook.

Returns:
the active workbook

setActiveWorkbook

public void setActiveWorkbook(Workbook workbook)
Sets the given workbook of the application.

Parameters:
workbook - the workbook to use

getActiveSpreadsheet

public Spreadsheet getActiveSpreadsheet()
Returns the active spreadsheet.

Returns:
the active spreadsheet

setActiveSpreadsheet

public void setActiveSpreadsheet(Spreadsheet spreadsheet)
Sets the active spreadsheet of the application, and thereby also the active workbook.

Parameters:
spreadsheet - the spreadsheet to use

getActiveCell

public Cell getActiveCell()
Returns the active cell of the active workbook's active spreadsheet.

Returns:
the active cell

setActiveCell

public void setActiveCell(Cell cell)
Sets the active cell of the application, and thereby also the active spreadsheet and workbook.

Parameters:
cell - the cell to use

isActiveWorkbookModified

public boolean isActiveWorkbookModified()
Returns whether the active workbook has been modified.

Returns:
whether the active workbook has been modified

isWorkbookModified

public boolean isWorkbookModified(Workbook workbook)
Returns whether the given workbook has been modified.

Returns:
whether the given workbook has been modified

setWorkbookModified

public void setWorkbookModified(Workbook workbook)
Specifies whether the given workbook has been modified.

Parameters:
workbook - the relevant workbook

getCellTransferHandler

public TransferHandler getCellTransferHandler()
Returns the transfer haandler used to transfer ranges of cells.

Returns:
the transfer haandler used to transfer ranges of cells

getUserProperties

public Properties getUserProperties()
Returns the current user properties.

Returns:
the current user properties

getExtensions

public UIExtension[] getExtensions()
Returns the user interface extensions that have been loaded.

Returns:
the user interface extensions that have been loaded

workbookCreated

public void workbookCreated(SpreadsheetAppEvent event)
Description copied from interface: SpreadsheetAppListener
Invoked by the spreadsheet application to indicate that a new workbook has been created.

Specified by:
workbookCreated in interface SpreadsheetAppListener
Parameters:
event - the spreadsheet application event that occured

workbookLoaded

public void workbookLoaded(SpreadsheetAppEvent event)
Description copied from interface: SpreadsheetAppListener
Invoked by the spreadsheet application to indicate that a workbook has been loaded from the given file.

Specified by:
workbookLoaded in interface SpreadsheetAppListener
Parameters:
event - the spreadsheet application event that occured

workbookUnloaded

public void workbookUnloaded(SpreadsheetAppEvent event)
Description copied from interface: SpreadsheetAppListener
Invoked by the spreadsheet application to indicate that a workbook has been unloaded (closed).

Specified by:
workbookUnloaded in interface SpreadsheetAppListener
Parameters:
event - the spreadsheet application event that occured

workbookSaved

public void workbookSaved(SpreadsheetAppEvent event)
Description copied from interface: SpreadsheetAppListener
Invoked by the spreadsheet application to indicate that a workbook was saved to the given file.

Specified by:
workbookSaved in interface SpreadsheetAppListener
Parameters:
event - the spreadsheet application event that occured

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Registers the given listener on the user interface controller.

Parameters:
listener - the listener to be added

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Removes the given listener from the user interface controller.

Parameters:
listener - the listener to be removed

addEditListener

public void addEditListener(EditListener listener)
Registers the given listener on the user interface controller.

Parameters:
listener - the listener to be added

removeEditListener

public void removeEditListener(EditListener listener)
Removes the given listener from the user interface controller.

Parameters:
listener - the listener to be removed