LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.win.swing
Class LySwingTable

java.lang.Object
  extended by leon.view.graphic.LyGraphicalObject
      extended by leon.view.win.swing.LySwingObject
          extended by leon.view.win.swing.LySwingFieldItem
              extended by leon.view.win.swing.LySwingPanel
                  extended by leon.view.win.swing.LySwingTable
All Implemented Interfaces:
LyActionListener, LyEventTransmitter, LySelectionListener, LyGetLabelInterface, LyGetLockInterface, LyGetValueInterface, LyIsIdleInterface, LyPdfInterface, LyPrintInterface, LyGraphicalComponent, LyGraphicalFieldItem, LyGraphicalPanel, LyGraphicalTable, LyViewComponent, LyFreeInterface, LySetEnabledInterface, LySetIdleInterface, LySetPopupMenuInterface, LySetTableInterface, LySetWaitingInterface, LySwingComponent

public class LySwingTable
extends LySwingPanel
implements LySwingComponent, LyIsIdleInterface, LySetIdleInterface, LySetTableInterface, LySetWaitingInterface, LyGetLabelInterface, LyGetValueInterface, LyPrintInterface, LyPdfInterface, LyGraphicalTable, LyActionListener, LySelectionListener, LyGetLockInterface

This class implements the Table object (as described in the dtd) for swing viewer.

A table allows to display a set of rows and columns containing a set of cells. It can contain a header providing information about the content of the cells of the list. It is possible to define its selection modes (simple, extended, multiple or none) and finally to indicate if horizontal and/or vertical separation lines should be drawn.

See Also:
LyTable

Nested Class Summary
 class LySwingTable._TablePrinter
          This class manages the print processus of the table.
 
Field Summary
static java.lang.String __VERSION
           
static int ARRAY_MIN_WIDTH
          Min. width for arrays.
static int MAX_COMPUTED_WIDTH_COUNT
          Maximum limit of the width computation.
static int MIN_ROW_HEIGHT
          Minimum row height of the table, in pixels.
 java.lang.String STATUS_COLUMN_NAME
          The name used for the status column.
 
Constructor Summary
LySwingTable(LyTable table)
          Class constructor of a Table object for the Swing target.
 
Method Summary
 void actionPerformed(LyActionEvent actionEvent)
          (non-Javadoc).
 void addRow(LyRow row)
          (non-Javadoc).
 void addRow(LyRow row, int idx)
          Adds the specified row at the given index in this table.
 void addRowCursor(int row, int offset)
          Sets the row of given index to have a pointing cursor.
 boolean areAllHeadersHidden()
          Return the visibility of headers.
 void checkEditionStatus(LyComponent removedComponent)
           
 int computeColumnPreferredWidth(LyJTableComponent tableComp, int indexColumn, java.awt.Font font, int currentRow, boolean useColWidth)
          Computes the minimum width of a column used to display entirely its data.
 int computeRowHeight(LyRow row)
          Compute the height of a given row.
 void configureColumnModel(LyJTableComponent tableComp)
          Configures the TableColumnModel of the table.
 java.awt.Component createLyJTableComponent()
          Creates the graphical table using models and renderers.
 void ensureColumnsWidth(int idx)
          Checks if the columns are wide enough for the row specified by its index.
 void ensureColumnsWidth(int rowIndex, int colIndex)
          Checks if a column is wide enough for the row and column specified by their index.
 void free()
          (non-Javadoc).
 void freezeColumn(int idx)
          Don't do anything.
 void generatePdf(java.lang.String fileName)
          Nothing is done in this method.
 java.awt.Component getComponent()
          (non-Javadoc).
 java.lang.String getController()
          (non-Javadoc).
 int getDataRowCount()
          Gets the number of rows.
 LySwingFooter getFooter(int i)
          Returns the footer of the column at the specified position.
 java.util.Vector<LySwingFooter> getFooters()
          Gets the list of footers for this table.
 LySwingHeader getHeader(int i)
          Returns the header of the column at the specified position.
 java.util.Vector<LySwingHeader> getHeaders()
          Gets the list of headers for this table.
 int getIndex(LyRow row)
          Gets the index of the specified row.
 java.lang.String getLabel()
          (non-Javadoc).
 java.lang.Object getLock()
          Get a lock on the table to prevent concurrent access on rows.
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of this table depending on its columns and rows as well as its status column and footer row, if any.
 LySwingRow getRow(int i)
          Gets the row at the specified position.
 java.util.Hashtable<java.lang.Integer,java.lang.Integer> getRowCursors()
          Returns the list of row indexes that have a cursor.
 LyTable.SelectionMode getSelectionMode()
          Gets this table selection mode.
 LySelectionTransmitter getSelectionTransmitter()
          (non-Javadoc).
 java.awt.Image getSortImage(boolean ascending)
          Returns the header image for the ascending or descending properties.
 LyJTableStatusColumn getStatusColumn()
          Gets the swing component for the status column.
 LyJTableStatusHeader getStatusHeader()
          Gets the swing component for the status column header.
 LyJTableComponent getTableComponent()
          Gets the swing table component.
 java.awt.Dimension getTableComponentOffset()
          Returns the offset of the headers component relative to this table component.
 LyJTableFooter getTableFooter()
          Gets the swing table footer.
 LyJTableModel getTableModel()
          Gets the table model.
 java.lang.String getValue()
          (non-Javadoc).
 boolean hasFooters()
          Indicates if this table has footers.
 boolean hasHeaders()
          Indicates if this table has headers.
 boolean hasStatusColumn()
          Checks if this table has a status column.
 void hideRow(int idx, boolean hide)
          (non-Javadoc).
 void initialize()
          Creates the table component by initializing the table model and its cell renderers, then registers the event listeners.
 void initRenderers()
          Initialize the cell and header renderers.
 boolean isHierarchical()
          Indicates if the table is hierarchical.
 boolean isHLines()
          Indicates if the horizontal lines are drawn or not.
 boolean isIdle()
          (non-Javadoc).
 boolean isStatusColumn(int columnIndex)
          Checks if the column at the specified index is the table status column.
 boolean isVLines()
          Indicates if the vertical lines are drawn or not.
 void print(LyPrintListenerInterface listener)
          Invokes a print dialog.
 void removeRow(int idx)
          Removes the row specified by its index in the table.
 void removeRow(LyRow row)
          Removes the specified row in the table.
 void resetRowCursors()
          Resets the list of row containing cursors.
 void selectAll(boolean select, boolean updateView)
          Selects or deselects all rows, columns and cells in this table without triggering selection events.
 void selectionPerformed(LySelectionEvent selectionEvent)
          Triggers events when table cells are selected.
 void selectRow(int idx, boolean select)
          Selects or deselects the row specified by its index.
 void selectRow(LyRow row, boolean select)
          Selects or deselects the specified row in the table.
 void setContent()
          Sets the content of the table.
 void setEnabled(boolean status)
          Updates attribute enabled to the given value.
 void setFooters(LyFooters footers)
          Sets sub-component footers.
 void setHeaders(LyHeaders headers)
          Sets sub-component headers.
 void setIdle(boolean status)
          (non-Javadoc).
 void setNeedResizeColumns(boolean needResizeColumns)
           
 void setNRows(int nRows)
          Updates attribute nRows to the given value.
 void setWaiting(boolean status)
          Nothing is done in this method.
 void showRow(int idx)
          (non-Javadoc).
 void swapRows(int idx1, int idx2)
          Swaps the rows at the specified indexes.
 void updateColumnWidth()
          Computes the column width based on the first elements in columns.
 void updateRow(LyRow row)
          Updates the specified row.
 void updateSelection(int index1, int index2)
          Updates the selection state of the rows from index1 to index2.
 
Methods inherited from class leon.view.win.swing.LySwingPanel
setPopupMenu
 
Methods inherited from class leon.view.win.swing.LySwingFieldItem
getActionTransmitter
 
Methods inherited from class leon.view.win.swing.LySwingObject
getBounds, getChildrenBounds, getDefaultFrame
 
Methods inherited from class leon.view.graphic.LyGraphicalObject
expand, getEnv, getEnvironment, getIdCode, getIntResource, getMessage, getMessage, getResource, getString, getString, getString, getViewComponent, getViewManager, isFreed, isFreeing, isImageAnimated, processDemand, processDemand, testResource, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface leon.view.graphic.LyGraphicalComponent
getViewComponent
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

MIN_ROW_HEIGHT

public static int MIN_ROW_HEIGHT
Minimum row height of the table, in pixels.


MAX_COMPUTED_WIDTH_COUNT

public static int MAX_COMPUTED_WIDTH_COUNT
Maximum limit of the width computation.


ARRAY_MIN_WIDTH

public static int ARRAY_MIN_WIDTH
Min. width for arrays.


STATUS_COLUMN_NAME

public java.lang.String STATUS_COLUMN_NAME
The name used for the status column.

Constructor Detail

LySwingTable

public LySwingTable(LyTable table)
Class constructor of a Table object for the Swing target.

Parameters:
table - a TABLE component defined for every type of view targets. This table is initialized for the swing view and filled with the default table values.
Method Detail

initialize

public void initialize()
Creates the table component by initializing the table model and its cell renderers, then registers the event listeners.


setContent

public void setContent()
Sets the content of the table.


setNeedResizeColumns

public void setNeedResizeColumns(boolean needResizeColumns)

initRenderers

public void initRenderers()
Initialize the cell and header renderers. Sets also their colors and fonts.


isHierarchical

public boolean isHierarchical()
Indicates if the table is hierarchical.

Returns:
true if this table's rows can contain sub-rows, false otherwise

getTableComponent

public LyJTableComponent getTableComponent()
Gets the swing table component.

Returns:
the table component

getTableModel

public LyJTableModel getTableModel()
Gets the table model.

Returns:
the source model of this table

getTableFooter

public LyJTableFooter getTableFooter()
Gets the swing table footer.

Returns:
the table's footer component

getStatusColumn

public LyJTableStatusColumn getStatusColumn()
Gets the swing component for the status column.

Returns:
the component that display the status column

getStatusHeader

public LyJTableStatusHeader getStatusHeader()
Gets the swing component for the status column header.

Returns:
the component that display the status column header

getTableComponentOffset

public java.awt.Dimension getTableComponentOffset()
Returns the offset of the headers component relative to this table component.

Returns:
the offset of the headers.

areAllHeadersHidden

public boolean areAllHeadersHidden()
Return the visibility of headers.

Returns:
true if all the headers are hidden

createLyJTableComponent

public java.awt.Component createLyJTableComponent()
Creates the graphical table using models and renderers. Defines and registers the listeners for the table to behave like it should.

Returns:
a fully initialized graphical table

resetRowCursors

public void resetRowCursors()
Resets the list of row containing cursors.


addRowCursor

public void addRowCursor(int row,
                         int offset)
Sets the row of given index to have a pointing cursor.

Parameters:
row - the index of the row
offset - the offset for current row

getRowCursors

public java.util.Hashtable<java.lang.Integer,java.lang.Integer> getRowCursors()
Returns the list of row indexes that have a cursor.

Returns:
the list of row indexes that have a cursor

computeRowHeight

public int computeRowHeight(LyRow row)
Compute the height of a given row.

Parameters:
row - the row whose height must be computed.
Returns:
the height of the row (in pixels).

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of this table depending on its columns and rows as well as its status column and footer row, if any.

Returns:
the preferred size of this component

isStatusColumn

public boolean isStatusColumn(int columnIndex)
Checks if the column at the specified index is the table status column.

Parameters:
columnIndex - index of the column to test
Returns:
true if column at columnIndex is the status column

hasStatusColumn

public boolean hasStatusColumn()
Checks if this table has a status column.

Returns:
true if this table has a status column

configureColumnModel

public void configureColumnModel(LyJTableComponent tableComp)
Configures the TableColumnModel of the table. Sets the header and footer values and the header renderer for each column, then configures these column to their preferred width, with a final unresizable column to fill the unused space of the table.

Parameters:
tableComp - the table component to configure

computeColumnPreferredWidth

public int computeColumnPreferredWidth(LyJTableComponent tableComp,
                                       int indexColumn,
                                       java.awt.Font font,
                                       int currentRow,
                                       boolean useColWidth)
Computes the minimum width of a column used to display entirely its data.

Parameters:
tableComp - the table component
indexColumn - index of the column
font - the font used in the given column
currentRow - current column
useColWidth - indicates whether columnWidth must be taken into account
Returns:
the minimum width for a column where each data of it is displayed

getRow

public LySwingRow getRow(int i)
Gets the row at the specified position.

Parameters:
i - the row position
Returns:
the LySwingRow at position i

getDataRowCount

public int getDataRowCount()
Gets the number of rows.

Returns:
the number of available rows (data)

getHeader

public LySwingHeader getHeader(int i)
Returns the header of the column at the specified position.

Parameters:
i - the position of the column
Returns:
the LySwingHeader at position i

getHeaders

public java.util.Vector<LySwingHeader> getHeaders()
Gets the list of headers for this table.

Returns:
a Vector that contains all the header objects

getFooter

public LySwingFooter getFooter(int i)
Returns the footer of the column at the specified position.

Parameters:
i - the position of the column
Returns:
the LySwingFooter at position i

getFooters

public java.util.Vector<LySwingFooter> getFooters()
Gets the list of footers for this table.

Returns:
a Vector that contains all the LySwingFooter objects

hasHeaders

public boolean hasHeaders()
Indicates if this table has headers.

Returns:
true if this table has some header

hasFooters

public boolean hasFooters()
Indicates if this table has footers.

Returns:
true if this table has some header

getSortImage

public java.awt.Image getSortImage(boolean ascending)
Returns the header image for the ascending or descending properties.

Parameters:
ascending - the ascending property if true, else the descending property
Returns:
the sort image

getSelectionMode

public LyTable.SelectionMode getSelectionMode()
Gets this table selection mode. It may be one of the following:

Returns:
the selection mode

getLabel

public java.lang.String getLabel()
(non-Javadoc).

Specified by:
getLabel in interface LyGetLabelInterface
See Also:
LyGetLabelInterface.getLabel()

getValue

public java.lang.String getValue()
(non-Javadoc).

Specified by:
getValue in interface LyGetValueInterface
See Also:
LyGetValueInterface.getValue()

isHLines

public boolean isHLines()
Indicates if the horizontal lines are drawn or not.

Returns:
the horizontal lines property
See Also:
LyTable.isHLines()

isVLines

public boolean isVLines()
Indicates if the vertical lines are drawn or not.

Returns:
the vertical lines property
See Also:
LyTable.isVLines()

getController

public java.lang.String getController()
(non-Javadoc).

Overrides:
getController in class LyGraphicalObject
Returns:
The controller id of this component, may be null.
See Also:
LyGraphicalObject.getController()

getComponent

public java.awt.Component getComponent()
(non-Javadoc).

Specified by:
getComponent in interface LySwingComponent
Overrides:
getComponent in class LySwingObject
Returns:
this Swing view component
See Also:
LySwingComponent.getComponent()

getIndex

public int getIndex(LyRow row)
Gets the index of the specified row.

Parameters:
row - the row
Returns:
the index of the specified row

isIdle

public final boolean isIdle()
(non-Javadoc).

Specified by:
isIdle in interface LyIsIdleInterface
Returns:
true if the component is idle (it is not refreshed when modifications are applied).
See Also:
LyIsIdleInterface.isIdle()

setIdle

public void setIdle(boolean status)
(non-Javadoc).

Specified by:
setIdle in interface LySetIdleInterface
Parameters:
status - new idle status (LySetIdleInterface interface)
See Also:
LySetIdleInterface.setIdle(boolean)

checkEditionStatus

public void checkEditionStatus(LyComponent removedComponent)

setEnabled

public void setEnabled(boolean status)
Description copied from interface: LyGraphicalTable
Updates attribute enabled to the given value.

Specified by:
setEnabled in interface LyGraphicalTable
Specified by:
setEnabled in interface LySetEnabledInterface
Parameters:
status - Boolean indicating if attribute enabled is set or unset.
See Also:
LySetEnabledInterface.setEnabled(boolean)

setNRows

public void setNRows(int nRows)
Description copied from interface: LyGraphicalTable
Updates attribute nRows to the given value.

Specified by:
setNRows in interface LyGraphicalTable
Parameters:
nRows - New value of nRows.
See Also:
LyGraphicalTable.setNRows(int)

setHeaders

public void setHeaders(LyHeaders headers)
Description copied from interface: LyGraphicalTable
Sets sub-component headers.

Specified by:
setHeaders in interface LyGraphicalTable
Parameters:
headers - New value of headers
See Also:
leon.view.setinterface.LySetTableInterface#setHeaders(LyHeaders)

setFooters

public void setFooters(LyFooters footers)
Description copied from interface: LyGraphicalTable
Sets sub-component footers.

Specified by:
setFooters in interface LyGraphicalTable
Parameters:
footers - New value of footers
See Also:
leon.view.setinterface.LySetTableInterface#LyFooters(LyFooters)

addRow

public void addRow(LyRow row)
(non-Javadoc).

Specified by:
addRow in interface LySetTableInterface
Parameters:
row - the row to add
See Also:
LySetTableInterface.addRow(leon.view.LyRow)

addRow

public void addRow(LyRow row,
                   int idx)
Adds the specified row at the given index in this table.

Specified by:
addRow in interface LySetTableInterface
Parameters:
row - the row to add
idx - the position where the row must be inserted. If this position is -1, the row is added at the end of the rows in the table.
See Also:
LySetTableInterface.addRow(leon.view.LyRow, int)

updateColumnWidth

public void updateColumnWidth()
Computes the column width based on the first elements in columns.


ensureColumnsWidth

public void ensureColumnsWidth(int idx)
Checks if the columns are wide enough for the row specified by its index.

Parameters:
idx - of the row we check

ensureColumnsWidth

public void ensureColumnsWidth(int rowIndex,
                               int colIndex)
Checks if a column is wide enough for the row and column specified by their index.

Parameters:
rowIndex - index of the row we check
colIndex - index of the column we check

freezeColumn

public void freezeColumn(int idx)
Don't do anything.

Specified by:
freezeColumn in interface LySetTableInterface
Parameters:
idx - this attribute is not used in this implementation
See Also:
LySetTableInterface.freezeColumn(int)

updateRow

public void updateRow(LyRow row)
Updates the specified row. This method is not implemented yet.

Specified by:
updateRow in interface LySetTableInterface
Parameters:
row - the row to update
See Also:
LySetTableInterface.updateRow(leon.view.LyRow)

removeRow

public void removeRow(int idx)
Removes the row specified by its index in the table. If the idle mode is set, the row is not removed.

Specified by:
removeRow in interface LySetTableInterface
Parameters:
idx - the position of the row in this table
See Also:
LySetTableInterface.removeRow(int)

removeRow

public void removeRow(LyRow row)
Removes the specified row in the table. If the idle mode is set, the row is not removed.

Specified by:
removeRow in interface LySetTableInterface
Parameters:
row - the row to remove
See Also:
removeRow(int), LySetTableInterface.removeRow(leon.view.LyRow)

selectionPerformed

public void selectionPerformed(LySelectionEvent selectionEvent)
Triggers events when table cells are selected. Nothing is done if _skipSelectionDemand is set.

Specified by:
selectionPerformed in interface LySelectionListener
Parameters:
selectionEvent - description of the selection which has occured
See Also:
LySelectionListener.selectionPerformed(leon.view.event.LySelectionEvent)

actionPerformed

public void actionPerformed(LyActionEvent actionEvent)
(non-Javadoc).

Specified by:
actionPerformed in interface LyActionListener
See Also:
LyActionListener.actionPerformed(leon.view.event.LyActionEvent)

getSelectionTransmitter

public LySelectionTransmitter getSelectionTransmitter()
(non-Javadoc).

Specified by:
getSelectionTransmitter in interface LyEventTransmitter
Overrides:
getSelectionTransmitter in class LySwingFieldItem
Returns:
null
See Also:
LyEventTransmitter.getSelectionTransmitter()

selectAll

public void selectAll(boolean select,
                      boolean updateView)
Selects or deselects all rows, columns and cells in this table without triggering selection events.

Specified by:
selectAll in interface LySetTableInterface
Parameters:
select - new selection status
updateView - indicates if the view must be updated. This attribute is not used in this implementation.
See Also:
JTable.selectAll(), JTable.clearSelection()

selectRow

public void selectRow(int idx,
                      boolean select)
Selects or deselects the row specified by its index.

Specified by:
selectRow in interface LySetTableInterface
Parameters:
idx - the position of the row in this table
select - the selection status
See Also:
LySetTableInterface.selectRow(int, boolean)

selectRow

public void selectRow(LyRow row,
                      boolean select)
Selects or deselects the specified row in the table. If the idle mode is set, the row is not (de)selected.

Specified by:
selectRow in interface LySetTableInterface
Parameters:
row - the row in this table
select - the selection status
See Also:
selectRow(int, boolean), LySetTableInterface.selectRow(LyRow, boolean)

showRow

public void showRow(int idx)
(non-Javadoc).

Specified by:
showRow in interface LySetTableInterface
Parameters:
idx - the index of the row to show
See Also:
LySetTableInterface.showRow(int)

hideRow

public void hideRow(int idx,
                    boolean hide)
(non-Javadoc).

Specified by:
hideRow in interface LySetTableInterface
Parameters:
idx - the index of the row to show or hide
hide - indicates if the row has to be shown or hided
See Also:
LySetTableInterface.hideRow(int, boolean)

swapRows

public void swapRows(int idx1,
                     int idx2)
Swaps the rows at the specified indexes. Do nothing if the idle mode is set.

Specified by:
swapRows in interface LySetTableInterface
Parameters:
idx1 - the position of the first row to swap
idx2 - the position of the second row to swap
See Also:
LySetTableInterface.swapRows(int, int)

updateSelection

public void updateSelection(int index1,
                            int index2)
Updates the selection state of the rows from index1 to index2.

Parameters:
index1 - the beginning of the selection
index2 - the end of the selection

setWaiting

public void setWaiting(boolean status)
Nothing is done in this method.

Specified by:
setWaiting in interface LySetWaitingInterface
Parameters:
status - is not used in this implementation
See Also:
LySetWaitingInterface.setWaiting(boolean)

free

public void free()
(non-Javadoc).

Specified by:
free in interface LyGraphicalComponent
Specified by:
free in interface LyFreeInterface
Overrides:
free in class LyGraphicalObject
See Also:
LyFreeInterface.free()

generatePdf

public void generatePdf(java.lang.String fileName)
                 throws java.io.IOException
Nothing is done in this method.

Specified by:
generatePdf in interface LyPdfInterface
Throws:
java.io.IOException
See Also:
LyPdfInterface.generatePdf(java.lang.String)

print

public void print(LyPrintListenerInterface listener)
Invokes a print dialog.

Specified by:
print in interface LyPrintInterface
Parameters:
listener - this attribut is not used in this implementation
See Also:
LySwingTable._TablePrinter, LyPrintInterface.print(leon.view.getinterface.LyPrintListenerInterface)

getLock

public java.lang.Object getLock()
Get a lock on the table to prevent concurrent access on rows.

Specified by:
getLock in interface LyGetLockInterface
Returns:
a valid lock for synchronized()

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com