com.dlsc.flexgantt.swing.layer.system

## Class SpreadsheetLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer
  - - com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
    - - com.dlsc.flexgantt.swing.layer.system.SpreadsheetLayer

- All Implemented Interfaces:
    IDatelineModelListener, IGanttChartModelListener, IEditable, FocusListener, MouseListener, MouseMotionListener, PropertyChangeListener, EventListener, CellEditorListener, MouseInputListener, TreeWillExpandListener

      public class SpreadsheetLayer
      extends AbstractSystemLayer
      implements IGanttChartModelListener, FocusListener, MouseInputListener, CellEditorListener, IDatelineModelListener, PropertyChangeListener, TreeWillExpandListener, IEditable

  The spreadsheet layer gets used when the Gantt chart wants to display the spreadsheet data provided by the `IGanttChartModel`.
  Since:
    2.1
  Author:
    Dirk Lemmermann
  See Also:
    `IGanttChartModel.getSpreadsheetValue(com.dlsc.flexgantt.model.gantt.ISpreadsheet, Object, ITimeSpan)`, `ISpreadsheetCellRenderer`, `ISpreadsheetCellEditor`

- - ### Field Summary

    - ### Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpreadsheetLayer(LayerContainer lc)` Constructs a new spreadsheet layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `datelineModelChanged(DatelineModelEvent e)` The listener's callback method that gets invoked when the model's time span or time zone changes.
    `void` | `datelineModelWillChange(DatelineModelEvent evt)` The listener's callback method that gets invoked when the model's time span or time zone will change.
    `boolean` | `editCellAt(int row, ITimeSpan span)` Programmatically starts editing the cell at `row` and `span`, if those indices are in the valid range, and the cell at those indices is editable.
    `boolean` | `editCellAt(int row, ITimeSpan span, InputEvent e)` Programmatically starts editing the cell at `row` and `span`, if those indices are in the valid range, and the cell at those indices is editable.
    `boolean` | `editCellFocused(InputEvent evt)` Starts the editing of the currently focused spreadsheet cell.
    `void` | `editingCanceled(ChangeEvent e)`
    `void` | `editingStopped(ChangeEvent e)`
    `void` | `focusGained(FocusEvent e)`
    `void` | `focusLost(FocusEvent e)`
    `void` | `focusOnCellAbove()` Moves the focus to the cell that is above the currently focused cell.
    `void` | `focusOnCellBelow()` Moves the focus to the cell that is below the currently focused cell.
    `void` | `focusOnCellNext()` Moves the focus to the next cell to the right.
    `void` | `focusOnCellPrevious()` Moves the focus to the next cell to the left.
    `void` | `focusOnFirstCell()` Moves the focus to the cell that is in the upper left hand corner of the spreadsheet.
    `void` | `focusOnLastCell()` Moves the focus to the cell that is in the lower right corner of the spreadsheet.
    `void` | `focusOnPageDown()` Moves the focus to a cell that is exactly one page below the current page.
    `void` | `focusOnPageUp()` Moves the focus to a cell that is exactly one page above the current page.
    `void` | `ganttChartChanged(GanttChartModelEvent evt)` Callback method that gets invoked whenever change occures in the Gantt chart model that is being observed by the listener.
    `ISpreadsheetCellEditor` | `getCellEditor()` Returns the currently used cell editor.
    `ISpreadsheetCellEditor` | `getCellEditor(Class cl)` Returns a cell editor for the given object type.
    `ISpreadsheetCellEditor` | `getCellEditor(int row, ITimeSpan span)` Returns the cell editor for the spreadsheet cell specified by the given row and time span.
    `Color` | `getCellFocusColor()` Returns the color used for displaying the focused state.
    `Rectangle` | `getCellRect(int row, ITimeSpan span)` Returns the cell rectangle for the cell at the given row and time span.
    `ISpreadsheetCellRenderer` | `getCellRenderer(Class cl)` Returns a spreadsheet cell renderer for the given object type.
    `int` | `getEditingRow()` Returns the row in which editing currently takes place.
    `ITimeSpan` | `getEditingTimeSpan()` Returns the time span at which editing currently takes place.
    `Component` | `getEditorComponent()` Returns the user interface component that is currently being used to edit a cell value.
    `boolean` | `hasFocus()` Determines if the spreadsheet layer currently has the focus and can be edited.
    `boolean` | `isEditing()` Returns TRUE if a cell is currently being edited.
    `void` | `mouseClicked(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `protected void` | `paintLayer(Graphics g)`
    `void` | `propertyChange(PropertyChangeEvent evt)`
    `void` | `removeEditor()` Discards the editor object and frees the real estate it used for cell rendering.
    `void` | `setCellEditor(Class cl, ISpreadsheetCellEditor editor)` Specifies a cell editor for the given object type.
    `void` | `setCellFocusColor(Color cellFocusColor)` Sets the color used for displaying the focused state.
    `void` | `setCellRenderer(Class cl, ISpreadsheetCellRenderer renderer)` Specifies a spreadsheet cell renderer for the given object type.
    `void` | `setEditingRow(int row)` Sets the row in which editing currently takes place.
    `void` | `setEditingTimeSpan(ITimeSpan span)` Sets the time span at which editing currently takes place.
    `void` | `setHasFocus(boolean hasFocus)` Specifies if the spreadsheet layer currently has the focus and can be edited.
    `void` | `setVisible(boolean visible)` Specifies whether the layer is visible or not.
    `void` | `treeWillCollapse(TreeExpansionEvent event)` Removes the focus from the spreadsheet when the tree table gets collapsed.
    `void` | `treeWillExpand(TreeExpansionEvent event)` Removes the focus from the spreadsheet when the tree table gets expanded.

    - ### Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getHeight, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, getWidth, isVisible, removePropertyChangeListener, repaint, repaint, repaint, setAlpha, tearDown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SpreadsheetLayer

          public SpreadsheetLayer(LayerContainer lc)

      Constructs a new spreadsheet layer.
      Parameters:
        `lc` - the layer container to which the layer belongs
      Since:
        2.1

  - ### Method Detail

    - #### hasFocus

          public boolean hasFocus()

      Determines if the spreadsheet layer currently has the focus and can be edited.
      Returns:
        TRUE if the layer has the focus
      Since:
        2.1

    - #### setHasFocus

          public void setHasFocus(boolean hasFocus)

      Specifies if the spreadsheet layer currently has the focus and can be edited.
      Parameters:
        `hasFocus` - TRUE if the layer has to have the focus
      Since:
        2.1

    - #### setCellFocusColor

          public void setCellFocusColor(Color cellFocusColor)

      Sets the color used for displaying the focused state.
      Parameters:
        `cellFocusColor` - the color used for the focused state of a cell
      Since:
        2.1

    - #### getCellFocusColor

          public Color getCellFocusColor()

      Returns the color used for displaying the focused state.
      Returns:
        the color used for the focused state of a cell
      Since:
        2.1

    - #### setVisible

          public void setVisible(boolean visible)

      Description copied from class: `AbstractLayer`
      Specifies whether the layer is visible or not.
      Overrides:
        `setVisible` in class `AbstractLayer`
      Parameters:
        `visible` - if TRUE the layer will be visible
      See Also:
        `AbstractLayer.isVisible()`

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### focusGained

          public void focusGained(FocusEvent e)

      Specified by:
        `focusGained` in interface `FocusListener`

    - #### focusLost

          public void focusLost(FocusEvent e)

      Specified by:
        `focusLost` in interface `FocusListener`

    - #### mouseDragged

          public void mouseDragged(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### ganttChartChanged

          public void ganttChartChanged(GanttChartModelEvent evt)

      Description copied from interface: `IGanttChartModelListener`
      Callback method that gets invoked whenever change occures in the Gantt chart model that is being observed by the listener.
      Specified by:
        `ganttChartChanged` in interface `IGanttChartModelListener`
      Parameters:
        `evt` - the event object describing the change that took place in the Gantt chart model

    - #### mouseClicked

          public void mouseClicked(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `MouseListener`

    - #### removeEditor

          public void removeEditor()

      Discards the editor object and frees the real estate it used for cell rendering.
      Since:
        2.1
      See Also:
        `getCellEditor()`

    - #### getEditorComponent

          public Component getEditorComponent()

      Returns the user interface component that is currently being used to edit a cell value.
      Specified by:
        `getEditorComponent` in interface `IEditable`
      Returns:
        the user interface component
      Since:
        2.1

    - #### isEditing

          public boolean isEditing()

      Returns TRUE if a cell is currently being edited.
      Specified by:
        `isEditing` in interface `IEditable`
      Returns:
        TRUE if the user is currently editing a cell
      Since:
        2.1

    - #### getCellEditor

          public ISpreadsheetCellEditor getCellEditor()

      Returns the currently used cell editor. This is the editor that the layer seemed most appropriate to use for editing the user selected spreadsheet cell. The editor was chosen based on the object type of the current cell value or the class returned by `IGanttChartModel.getSpreadsheetValueType(ISpreadsheet, Object, ITimeSpan)` .
      Returns:
        the cell editor that is currently being used
      Since:
        2.1
      See Also:
        `setCellEditor(Class, ISpreadsheetCellEditor)`

    - #### editCellFocused

          public boolean editCellFocused(InputEvent evt)

      Starts the editing of the currently focused spreadsheet cell.
      Specified by:
        `editCellFocused` in interface `IEditable`
      Parameters:
        `evt` - the input event, which triggered the editing operation
      Returns:
        TRUE if the cell can be edited
      Since:
        2.1
      See Also:
        `editCellAt(int, ITimeSpan)`

    - #### editCellAt

          public boolean editCellAt(int row,
                                    ITimeSpan span)

      Programmatically starts editing the cell at `row` and `span`, if those indices are in the valid range, and the cell at those indices is editable.
      Parameters:
        `row` - the row to be edited
        `span` - the time span to be edited
      Returns:
        FALSE if for any reason the cell cannot be edited, or if the indices are invalid
      Since:
        2.1

    - #### editCellAt

          public boolean editCellAt(int row,
                                    ITimeSpan span,
                                    InputEvent e)

      Programmatically starts editing the cell at `row` and `span`, if those indices are in the valid range, and the cell at those indices is editable.
      Parameters:
        `row` - the row to be edited
        `span` - the time span to be edited
        `e` - the event that triggered the edit operation
      Returns:
        FALSE if for any reason the cell cannot be edited, or if the indices are invalid
      Since:
        2.1

    - #### getEditingRow

          public int getEditingRow()

      Returns the row in which editing currently takes place.
      Returns:
        the editing row
      Since:
        2.1
      See Also:
        `getEditingTimeSpan()`, `getEditorComponent()`, `setEditingRow(int)`

    - #### setEditingRow

          public void setEditingRow(int row)

      Sets the row in which editing currently takes place.
      Parameters:
        `row` - the editing row
      Since:
        2.1
      See Also:
        `setEditingTimeSpan(ITimeSpan)`, `getEditingRow()`

    - #### getEditingTimeSpan

          public ITimeSpan getEditingTimeSpan()

      Returns the time span at which editing currently takes place.
      Returns:
        the edited time span
      Since:
        2.1

    - #### setEditingTimeSpan

          public void setEditingTimeSpan(ITimeSpan span)

      Sets the time span at which editing currently takes place.
      Parameters:
        `span` - the edited time span
      Since:
        2.1

    - #### getCellEditor

          public ISpreadsheetCellEditor getCellEditor(int row,
                                                      ITimeSpan span)

      Returns the cell editor for the spreadsheet cell specified by the given row and time span.
      Parameters:
        `row` - the row where the cell is located
        `span` - the time span where the cell is located
      Returns:
        the spreadsheet cell editor appropriate for editing the value of the given cell
      Since:
        2.1

    - #### getCellRect

          public Rectangle getCellRect(int row,
                                       ITimeSpan span)

      Returns the cell rectangle for the cell at the given row and time span.
      Parameters:
        `row` - the row of the cell
        `span` - the time span of the cell
      Returns:
        the bounding box of the cell
      Since:
        2.1

    - #### editingStopped

          public void editingStopped(ChangeEvent e)

      Specified by:
        `editingStopped` in interface `CellEditorListener`

    - #### editingCanceled

          public void editingCanceled(ChangeEvent e)

      Specified by:
        `editingCanceled` in interface `CellEditorListener`

    - #### datelineModelWillChange

          public void datelineModelWillChange(DatelineModelEvent evt)
                                       throws DatelineModelVetoException

      Description copied from interface: `IDatelineModelListener`
      The listener's callback method that gets invoked when the model's time span or time zone will change.
      Specified by:
        `datelineModelWillChange` in interface `IDatelineModelListener`
      Parameters:
        `evt` - the event that occured on the dateline
      Throws:
        `DatelineModelVetoException` - if the listener does not want the change to happen

    - #### datelineModelChanged

          public void datelineModelChanged(DatelineModelEvent e)

      Description copied from interface: `IDatelineModelListener`
      The listener's callback method that gets invoked when the model's time span or time zone changes.
      Specified by:
        `datelineModelChanged` in interface `IDatelineModelListener`
      Parameters:
        `e` - the event that occured on the dateline

    - #### setCellRenderer

          public void setCellRenderer(Class cl,
                                      ISpreadsheetCellRenderer renderer)

      Specifies a spreadsheet cell renderer for the given object type. Cell renderers are used during the rendering of the spreadsheet layer. Different cell renderers can be used for different spreadsheet cells, depending on the type of object shown in that cell.
      Parameters:
        `cl` - the object type
        `renderer` - the renderer used to visualize objects of the given type
      Since:
        2.1
      See Also:
        `getCellRenderer(Class)`

    - #### setCellEditor

          public void setCellEditor(Class cl,
                                    ISpreadsheetCellEditor editor)

      Specifies a cell editor for the given object type. Cell editors are used for editing the values of spreadsheet cells. Different cell editors can be used for different spreadsheet cells, depending on the type of object shown in that cell.
      Parameters:
        `cl` - the object type
        `editor` - the editor used to edit objects of the given type
      Since:
        2.1
      See Also:
        `getCellEditor(Class)`

    - #### getCellRenderer

          public ISpreadsheetCellRenderer getCellRenderer(Class cl)

      Returns a spreadsheet cell renderer for the given object type. Cell renderers are used during the rendering of the spreadsheet layer. Different cell renderers can be used for different spreadsheet cells, depending on the type of object shown in that cell.
      Parameters:
        `cl` - the object type for which to return a matching cell renderer
      Returns:
        a cell renderer for the given object type
      Since:
        2.1
      See Also:
        `setCellRenderer(Class, ISpreadsheetCellRenderer)`

    - #### getCellEditor

          public ISpreadsheetCellEditor getCellEditor(Class cl)

      Returns a cell editor for the given object type. Cell editors are used for editing the values in spreadsheet cells. Different cell editors can be used for different spreadsheet cells, depending on the type of object shown in that cell.
      Parameters:
        `cl` - the object type for which to return a matching cell editor
      Returns:
        a cell editor for the given object type
      Since:
        2.1
      See Also:
        `setCellEditor(Class, ISpreadsheetCellEditor)`

    - #### propertyChange

          public void propertyChange(PropertyChangeEvent evt)

      Specified by:
        `propertyChange` in interface `PropertyChangeListener`

    - #### treeWillExpand

          public void treeWillExpand(TreeExpansionEvent event)
                              throws ExpandVetoException

      Removes the focus from the spreadsheet when the tree table gets expanded.
      Specified by:
        `treeWillExpand` in interface `TreeWillExpandListener`
      Parameters:
        `event` - the tree expansion event
      Throws:
        `ExpandVetoException` - if the spreadsheet does not allow the tree table to be expanded
      Since:
        2.1

    - #### treeWillCollapse

          public void treeWillCollapse(TreeExpansionEvent event)
                                throws ExpandVetoException

      Removes the focus from the spreadsheet when the tree table gets collapsed.
      Specified by:
        `treeWillCollapse` in interface `TreeWillExpandListener`
      Parameters:
        `event` - the tree expansion event
      Throws:
        `ExpandVetoException` - if the spreadsheet does not allow the tree table to be collapsed
      Since:
        2.1

    - #### focusOnCellBelow

          public void focusOnCellBelow()

      Moves the focus to the cell that is below the currently focused cell.
      Since:
        2.1

    - #### focusOnCellAbove

          public void focusOnCellAbove()

      Moves the focus to the cell that is above the currently focused cell.
      Since:
        2.1

    - #### focusOnCellPrevious

          public void focusOnCellPrevious()

      Moves the focus to the next cell to the left.
      Since:
        2.1

    - #### focusOnCellNext

          public void focusOnCellNext()

      Moves the focus to the next cell to the right.
      Since:
        2.1

    - #### focusOnFirstCell

          public void focusOnFirstCell()

      Moves the focus to the cell that is in the upper left hand corner of the spreadsheet.
      Since:
        2.1

    - #### focusOnLastCell

          public void focusOnLastCell()

      Moves the focus to the cell that is in the lower right corner of the spreadsheet.
      Since:
        2.1

    - #### focusOnPageUp

          public void focusOnPageUp()

      Moves the focus to a cell that is exactly one page above the current page.
      Since:
        2.1

    - #### focusOnPageDown

          public void focusOnPageDown()

      Moves the focus to a cell that is exactly one page below the current page.
      Since:
        2.1

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.