de.cbse.jeasy
Class JETable

java.lang.Object
  extended by de.cbse.jeasy.JEObject
      extended by de.cbse.jeasy.JEComponent
          extended by de.cbse.jeasy.JEParentComponent
              extended by de.cbse.jeasy.JETable
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.event.FocusListener, java.awt.event.InputMethodListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.awt.event.WindowFocusListener, java.awt.event.WindowListener, java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.event.CaretListener, javax.swing.event.ChangeListener, javax.swing.event.DocumentListener, javax.swing.event.ListSelectionListener, javax.swing.event.MenuKeyListener, javax.swing.event.PopupMenuListener, javax.swing.event.TableModelListener, javax.swing.event.TreeExpansionListener, javax.swing.event.TreeModelListener, javax.swing.event.TreeSelectionListener

public class JETable
extends JEParentComponent

Implements a JTable and enhances it functionality.
Columns of JETables are sortable and filterable by click left or right mouse at the header.
The sort algorithm depends on the entries of the column and is choosen automaticly.

See a demonstration in the program JEasyExample tab "Table sum and sort".

Properties :

Properties :

Author:
Harry Pfohl

Field Summary
 
Fields inherited from class de.cbse.jeasy.JEComponent
animated, backup, buttonBehind, caretPosition, component, endMarkPosition, enterPressed, isPressed, jeButtonBehind, label, labelBehind, labelText, parentId, scrollPane, tree, treeNode, window
 
Fields inherited from class de.cbse.jeasy.JEObject
aaa, ACTIVITYBAR, ANIMATION, BORDER, BUSINESSOBJECT_NAME, BUTTON, BUTTONGROUP, CHECKBOX, CHECKBOXMENUITEM, COLOR, COMBOBOX, ComboBoxButtonWidth, COMBOLIST, CONSTRAINTS, CONTEXT_HELP_FOCUS_GAINED, CONTEXT_HELP_FOCUS_LOST, CONTEXT_HELP_MOUSE_ENTERED, CONTEXT_HELP_MOUSE_EXITED, DATAFIELD, DATATYPE, DESKTOPPANE, DIALOG, EDITORPANE, FONT, FORMAT, FRAME, GANTTGRID, GLOBAL, GRADIENTPAINT, HELP, ICON, ID_JESTART, INPUT_ERROR_DATE, INPUT_ERROR_LENGTH, INPUT_ERROR_MANDATORY, INPUT_ERROR_PARSE, INPUT_ERROR_RANGE, INPUT_ERROR_REGULAREXPRESSION, INPUT_ERROR_TIME, INPUT_ERRORS, INSETS, INTERNALFRAME, intType, LABEL, LIST, LOCALE, MENU, MENUBAR, MENUITEM, MESSAGE, METHODINVOCATION, NO_CONSTANT, NO_INPUT_ERROR, OPTIONPANE, PANEL, POPUP, PROGRESSBAR, PROPERTIE_NAME, propertyHashMap, RADIOBUTTON, RADIOBUTTONMENUITEM, refresh, SPINNER, SPLITPANE, START, STORE, STRING, TABBEDPANE, TABLE, TASKPANE, TEXTUREPAINT, THEME, TIPS, TOOLBAR, TREE, TREENODE, type, WINDOW
 
Constructor Summary
JETable(JELocaleProperties hm)
          Reads the properties from a HashMap
JETable(JENode jen)
          Constructor based on a XML file parsed to a TreeNode.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Action from popup filter
 JEColumnIdentifier addColumn(JEComponent jeo)
          Inserts a TableColumn with properties out of the JEasy object.
 JEColumnIdentifier addColumn(java.lang.String s)
          Inserts a TableColumn with the string as columnname.
 void addColumns(java.util.Vector v)
          Inserts TableColumns with the vector containig strings.
 void addMessage(JENode jen)
          Adds the entrys of an XML String as a row of the table.
 void addMessage(JENode jen, int row)
          Adds the entrys of an XML String as a row of the table.
 void addMessage(java.lang.String message)
          Adds the entrys of an XML String as a row of the table.
 void addMessage(java.lang.String message, int row)
          Adds the entrys of an XML String as a row of the table.
 void addSumColumn(int column)
          Adds a sum in the sum row for the given column.
 void addSumColumn(int column, int columnIndicator, java.lang.Object value)
          Adds a sum in the sum row for the given column if the value of the columnIndicator is equals the given value.
 void addSumRow()
          Adds a sum row to show sums of columns.
 void clear()
          Clears all rows, sorts and filters of the table
 void createTable(java.lang.String xml)
          Builds a table with columns and rows out of an XML-String.
 void executeQuery(java.lang.String driverName, java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String query)
          Execute a JDBC query and builds a table from the ResultSet
 JETableCellRenderer getCellRenderer(int col)
          Gets the CellRenderer of a column.
 javax.swing.table.TableColumn getColumn(int col)
          Gets the TableColumn of the column
 int getColumnByIdentifier(JEColumnIdentifier columnIdentifier)
          Gets the columnnumber of the DataModel for a given column identifierr
 javax.swing.table.TableColumn getColumnByJEasyId(java.lang.String jeasyId)
          Gets the TableColumn of the TableColumnModel for a given JEasy id.
 int getColumnByName(java.lang.String colname)
          Gets the columnnumber of the DataModel for a given column name
 int getColumnCount()
          Gets the number of columns of the table column model.
 JEColumnIdentifier getColumnIdentifier(int col)
          Gets the columnnumber of the DataModel for a given column identifier
 javax.swing.table.TableColumnModel getColumnModel()
           
 java.lang.String getColumnName(int col)
          Gets the title of a column.
 int getColumnNumByJEasyId(java.lang.String jeasyId)
          Gets the columnnumber of the DataModel for a given JEasy id.
 java.lang.String getColumnTagName(int col)
          Gets the tag for this columns used by getMessage.
 int getColumnWidth(int col)
          Gets the width of a column.
 java.lang.String getCSVData()
          Returns a StringBuffer in CSV format.
 java.lang.String getCSVData(java.lang.String separator)
          Returns a String in CSV format.
 javax.swing.JTable getJTable()
          Gets the swing JTable
 java.lang.String getMessage(int row)
          Returns the values of a row in XML format.
 int getRowCount()
          Gets the number of rows in the table.
 int getSelectedRow()
          Gets the selected row of the table.
 JETableModel getTableModel()
           
 java.lang.Object getValueAt(int row, int col)
          Gets the value of a cell.
 boolean hasMarkingCol()
          Checks wether the table has a marking column
 boolean hasProcessingCol()
          Checks wether the table has a processing column
 void init()
          Creates jfc-Objects with the given properties.
 boolean isMarked(int row)
           
 void mark(int row)
          If the table has a marker col, the checkbox of this row and column will be selected.
 void markAll()
          Marks all rows.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
          Performs mouse event action like rollover text and color
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void moveRow(int row, int i)
          Moves the given row up or down and selects the row.
 void moveRows(int startRow, int endRow, int i)
          Moves the given rows up or down and select them.
 void removeColumns()
          Clears the table and removes all columns from the table
 void removeRow(int row)
          Removes a row from the table.
 void removeSumRow()
          Removes the sum row.
 void repaint()
          Sets the entry of the component to the backuped value
 void setColumnWidth(int col, int width)
          Sets the width of a column.
 void setDataVector(java.util.Vector rows)
          Sets the data vector of the table model.
 void setFixWidth(int col, int width)
          Sets the fix width of a column by setting the min, max and preferred size of a column
 void setHorizontalAlignment(int col, int alignment)
          Sets the horizontal alignments of a column.
 void setSelectedRow(int row)
          Sets the selected row of the table.
 void setupComponent()
          Set the property values to the component
 void setValueAt(java.lang.Object o, int row, int col)
          Sets the value of a cell.
 void unmark(int row)
          If the table has a marker col, the checkbox of this row and column will be selected.
 void unmarkAll()
          Unmarks all rows.
 
Methods inherited from class de.cbse.jeasy.JEParentComponent
addElement, backupEntry, cloneAll, getChilds, getLayoutManager, invokeAll, invokeAll, invokeAll, invokeAll, invokeAll, removeAll, removeId, restoreEntry, setEnabledAll, setEnabledAll, setVisibleAll, setVisibleAll, wasEntryChanged
 
Methods inherited from class de.cbse.jeasy.JEComponent
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, addListeners, caretPositionChanged, caretUpdate, changedUpdate, componentHidden, componentMoved, componentResized, componentShown, examine, examine, focusGained, focusLost, getAddableComponent, getAnimation, getBackupEntry, getButtonBehind, getClosedIcon, getColumns, getComponent, getDataType, getIcon, getJEButtonBehind, getJLabel, getJScrollpane, getLabel, getLabelBehind, getLabelText, getLeafIcon, getMandatory, getName, getOpenIcon, getParentId, getToolTipText, getTreeNode, getValue, getValueBeforeFocus, getValueNotNull, getValues, getWindow, inputMethodTextChanged, insertUpdate, isAnimated, isEditable, isExiting, isListening, isShowing, isVerified, isVisible, itemStateChanged, jCallBackInputVerifier, keyPressed, keyReleased, keyTyped, menuKeyPressed, menuKeyReleased, menuKeyTyped, mouseDragged, mouseMoved, mouseWheelMoved, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, propertyChange, refresh, remove, removeActionListeners, removeUpdate, restoreValueBeforeFocus, setAnimated, setBackground, setBackground, setEnabled, setEnabled, setExiting, setFocus, setForeground, setForeground, setIcon, setListening, setMandatory, setParentId, setProperties, setText, setToolTipText, setTreeNode, setValue, setValueBeforeFocus, setValues, setVerified, setVisible, setVisible, stateChanged, tableChanged, textUpdate, timerTask, transferFocus, transferFocusBackward, treeCollapsed, treeExpanded, treeNodesChanged, treeNodesInserted, treeNodesRemoved, treeStructureChanged, valueChanged, valueChanged, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened
 
Methods inherited from class de.cbse.jeasy.JEObject
clearPreview, clone, getApplLocale, getBorderConstantProperty, getBorderProperty, getCharGProperty, getCharProperty, getColorProperty, getConstraintsProperty, getFontProperty, getGProperty, getGradientPaintProperty, getId, getImageConstantProperty, getImageIconProperty, getInsetsProperty, getJEGlobal, getJETexturePaintProperty, getLayoutProperty, getLocaleProperties, getObjectsHashMap, getObjectsNonPreviewHashMap, getPreviewHashMap, getPreviewObject, getProjectDirectory, getPropertieHashMap, getProperty, getProperty, getPropertyAsArray, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsInteger, getPropertyAsObject, getPropertyAsObject, getPropertyAsVector, getPropertyAsVector, getReferenceButtonBehind, getReferenceId, getRegisterText, getResourceUrl, getRootPane, getRootPaneId, getSwingConstantProperty, getTabbedPaneConstantProperty, getTexturePaintProperty, getType, getUniqueNumber, hasSuperclass, invoke, invoke, invoke, invoke, isApplet, isEnterprise, isGlobalAnimation, isGlobalListening, isInited, isPreview, isPreviewMember, isProfessional, isRefresh, isSetuped, isStandard, registerJEObject, removeProperties, removeProperty, removeProperty, setApplet, setApplLocale, setGlobalAnimation, setGlobalListening, setInited, setJeGlobal, setLocaleProperties, setPreview, setPreviewHashMap, setPreviewMember, setPreviewObject, setProjectDirectory, setPropertieHashMap, setProperties, setProperties, setProperty, setProperty, setRefresh, setRootPane, setRootPaneId, setSetuped, setType, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JETable

public JETable(JELocaleProperties hm)
Reads the properties from a HashMap

Parameters:
hm - HashMap

JETable

public JETable(JENode jen)
Constructor based on a XML file parsed to a TreeNode.

Parameters:
jen -
See Also:
JESaxParser
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Action from popup filter

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Overrides:
actionPerformed in class JEComponent

createTable

public void createTable(java.lang.String xml)
Builds a table with columns and rows out of an XML-String. In metadata is a tag column with a tag name inside. The name is the columnName. To hide columns set the width to zero. Alignments are LEFT or RIGHT or CENTER. The class is a String as default, use Boolean to see a checkbox. In data are rows where the tagnames are the columnNames. The entries of these tags are cells of the table. Format :

Parameters:
XML - -String

executeQuery

public void executeQuery(java.lang.String driverName,
                         java.lang.String url,
                         java.lang.String user,
                         java.lang.String password,
                         java.lang.String query)
                  throws java.lang.Exception
Execute a JDBC query and builds a table from the ResultSet

Parameters:
message -
Throws:
java.lang.Exception

addColumn

public JEColumnIdentifier addColumn(JEComponent jeo)
Inserts a TableColumn with properties out of the JEasy object. If no column was added jet, the processing column and the marking column are insert first if these table properties are set.

Parameters:
jeo - jeasy component e.g. JEDataField
Returns:

addColumn

public JEColumnIdentifier addColumn(java.lang.String s)
Inserts a TableColumn with the string as columnname.

Parameters:
s -
Returns:

addColumns

public void addColumns(java.util.Vector v)
Inserts TableColumns with the vector containig strings.

Parameters:
v -

addMessage

public void addMessage(JENode jen,
                       int row)
Adds the entrys of an XML String as a row of the table. The tagnames should correspond to the JEasy id of the column or the XMLTag

Parameters:
message -

addMessage

public void addMessage(java.lang.String message,
                       int row)
Adds the entrys of an XML String as a row of the table. The tagnames should correspond to the JEasy id of the column or the XMLTag

Parameters:
message -

addMessage

public void addMessage(JENode jen)
Adds the entrys of an XML String as a row of the table. The tagnames should correspond to the JEasy id of the column or the XMLTag

Parameters:
message -

addMessage

public void addMessage(java.lang.String message)
Adds the entrys of an XML String as a row of the table. The tagnames should correspond to the JEasy id of the column or the XMLTag

Parameters:
message -

getMessage

public java.lang.String getMessage(int row)
Returns the values of a row in XML format. The tag is column name or the XMLTag of the corresponding jeasyid.

Parameters:
row - data in XML format

addSumColumn

public void addSumColumn(int column)
Adds a sum in the sum row for the given column.

Parameters:
column -
columnIndicator -
value -

addSumRow

public void addSumRow()
Adds a sum row to show sums of columns.


removeSumRow

public void removeSumRow()
Removes the sum row.


getCSVData

public java.lang.String getCSVData()
Returns a StringBuffer in CSV format. Every line ends with '\n'. Alle entries are separated by ';' The first line contains the column header followed by the rows where each row is a line

Returns:

getCSVData

public java.lang.String getCSVData(java.lang.String separator)
Returns a String in CSV format. Every line ends with '\n'. Alle entries are separated by the separator. The first line contains the column header followed by the rows where each row is a line

Returns:

addSumColumn

public void addSumColumn(int column,
                         int columnIndicator,
                         java.lang.Object value)
Adds a sum in the sum row for the given column if the value of the columnIndicator is equals the given value. This method is used to sum only marked rows.

Parameters:
column - column to build a sum
columnIndicator - the column to check for the value
value - value to be checked

clear

public void clear()
Clears all rows, sorts and filters of the table

Overrides:
clear in class JEParentComponent

getCellRenderer

public JETableCellRenderer getCellRenderer(int col)
Gets the CellRenderer of a column.


getColumnByIdentifier

public int getColumnByIdentifier(JEColumnIdentifier columnIdentifier)
Gets the columnnumber of the DataModel for a given column identifierr

Parameters:
columnIdentifier -
Returns:
the number of the column or -1 of non column was found

getColumnByJEasyId

public javax.swing.table.TableColumn getColumnByJEasyId(java.lang.String jeasyId)
Gets the TableColumn of the TableColumnModel for a given JEasy id. Usefull when the table columns are built out of jeasy datafields

Parameters:
jeasyId -
Returns:
the TableColumn or null if non column was found

getColumnByName

public int getColumnByName(java.lang.String colname)
Gets the columnnumber of the DataModel for a given column name

Parameters:
column - name name of the column
Returns:
the colnumber of the column or -1 of no column was found

getColumnCount

public int getColumnCount()
Gets the number of columns of the table column model.

Returns:

getSelectedRow

public int getSelectedRow()
Gets the selected row of the table.

Returns:

setSelectedRow

public void setSelectedRow(int row)
Sets the selected row of the table.


getColumnIdentifier

public JEColumnIdentifier getColumnIdentifier(int col)
Gets the columnnumber of the DataModel for a given column identifier

Parameters:
columnIdentifier -
Returns:
the number of the column or -1 of non column was found

getColumn

public javax.swing.table.TableColumn getColumn(int col)
Gets the TableColumn of the column

Parameters:
col -
Returns:

getColumnModel

public javax.swing.table.TableColumnModel getColumnModel()
Returns:

getColumnName

public java.lang.String getColumnName(int col)
Gets the title of a column.

Returns:

getColumnNumByJEasyId

public int getColumnNumByJEasyId(java.lang.String jeasyId)
Gets the columnnumber of the DataModel for a given JEasy id. Usefull whne the table columns are built out of jeasy datafields

Parameters:
jeasyId -
Returns:
the number of the column or -1 of non column was found

getColumnTagName

public java.lang.String getColumnTagName(int col)
Gets the tag for this columns used by getMessage. It is the XMLTag of the jeasy id of the column or the jeasyid of the column or the header value of the column.

Parameters:
jeasyId -
Returns:
the number of the column or -1 of non column was found

getColumnWidth

public int getColumnWidth(int col)
Gets the width of a column.


setColumnWidth

public void setColumnWidth(int col,
                           int width)
Sets the width of a column.


getJTable

public javax.swing.JTable getJTable()
Gets the swing JTable

Returns:

getRowCount

public int getRowCount()
Gets the number of rows in the table. If a sum row is added it is unaccounted.

Returns:

getTableModel

public JETableModel getTableModel()
Returns:

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Gets the value of a cell.

Parameters:
row -
col -
Returns:

hasMarkingCol

public boolean hasMarkingCol()
Checks wether the table has a marking column

Returns:

hasProcessingCol

public boolean hasProcessingCol()
Checks wether the table has a processing column

Returns:

init

public void init()
Creates jfc-Objects with the given properties. The font of the text is set to global.labelFont.

Overrides:
init in class JEParentComponent

isMarked

public boolean isMarked(int row)
Parameters:
row -
Returns:

mark

public void mark(int row)
If the table has a marker col, the checkbox of this row and column will be selected.

Parameters:
row -

markAll

public void markAll()
Marks all rows.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class JEComponent

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Description copied from class: JEComponent
Performs mouse event action like rollover text and color

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class JEComponent

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class JEComponent

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class JEComponent

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class JEComponent

removeColumns

public void removeColumns()
Clears the table and removes all columns from the table


repaint

public void repaint()
Description copied from class: JEComponent
Sets the entry of the component to the backuped value

Overrides:
repaint in class JEComponent

setDataVector

public void setDataVector(java.util.Vector rows)
Sets the data vector of the table model. Each vector element is a row vector with one element for each column.

Parameters:
rows -

setHorizontalAlignment

public void setHorizontalAlignment(int col,
                                   int alignment)
Sets the horizontal alignments of a column. Use the SwingConstants LEFT CENTER RIGHT for alignments


setupComponent

public void setupComponent()
Description copied from class: JEParentComponent
Set the property values to the component

Overrides:
setupComponent in class JEParentComponent

setFixWidth

public void setFixWidth(int col,
                        int width)
Sets the fix width of a column by setting the min, max and preferred size of a column

Parameters:
col - column number
width - width in pixel

setValueAt

public void setValueAt(java.lang.Object o,
                       int row,
                       int col)
Sets the value of a cell.

Parameters:
o -
row -
col -

unmark

public void unmark(int row)
If the table has a marker col, the checkbox of this row and column will be selected.

Parameters:
row -

unmarkAll

public void unmarkAll()
Unmarks all rows.


moveRow

public void moveRow(int row,
                    int i)
Moves the given row up or down and selects the row.

Parameters:
row -
i -

moveRows

public void moveRows(int startRow,
                     int endRow,
                     int i)
Moves the given rows up or down and select them.

Parameters:
row -
i -

removeRow

public void removeRow(int row)
Removes a row from the table.

Parameters:
row -