public class ExecutionTableView extends View
ExecutionTableView(String, boolean, LanguageFile, String)
to specify a language file from which
labels, tooltips and messages are read by the given language id. The following language labels are available:
Resources.LANGUAGE_FILE
.
ExecutionTableColumn
s and ExecutionTableItem
s. You can modify the content and style of
table cells in the specific item.add(ExecutionTableColumn)
/add(ExecutionTableItem)
/...) to add columns and items to the table view.
Number
and Boolean
. All other cell object types
use the DefaultTableCellRenderer
.addDefaultCellRenderer(Class, TableCellRenderer)
.
ExecutionTableItem
and the related ExecutionTableColumn
are editable (by default they are not editable).
The input the user has entered is a String
. Use ExecutionTableItem.InputParser
s to convert the input in the correct object type. You can specify a default parser
for all cells using ExecutionTableItem.setDefaultInputParser(InputParser)
or parsers for each cell using ExecutionTableItem.setCellInputParser(int, InputParser)
.// add columns and items to the table ... // the first and the last column are editable table.getColumn(0).setEditable(true); table.getColumn(table.getColumnCount() - 1).setEditable(true); // the cells of the item contain numeric data so set the suitable input parser // because each cell contains numbers we can set a default parser without adding one to each cell item.setDefaultInputParser(new ExecutionTableItem.NumericInputParser()); // enable edit mode item.setEditable(true); // now the user can edit the first and the last cellGrid lines:
setGridBorder(ExecutionTableBorder)
to specify a custom grid style or to disable the grid lines of the table.
ExecutionTableGroup
s to display objects (columns or items) that are distinct from other objects and add the groups by
using either addColumnGroup(ExecutionTableGroup)
or addItemGroup(ExecutionTableGroup)
.// create a non-repeatable group with a solid black border of 2 pixels // for the first column (start index 0 and 1 column as the amount) final ExecutionTableGroup colGroup = new ExecutionTableGroup(new ExecutionTableBorder(2, Color.black), 0, 1, false); // create a repeatable group with a solid black border of 2 pixels // that starts at the 3 row (start index 2) and includes 2 rows final ExecutionTableGroup itemGroup = new ExecutionTableGroup(new ExecutionTableBorder(2, Color.black), 2, 2, true); // add the groups to the table tableView.addColumnGroup(colGroup); tableView.addItemGroup(itemGroup);Sorting:
sortItems(int, SortOrder)
to sort the items of the table by a specific column.
Math.PI
) should be masked with the pi symbol. Therefore you create a new mask and add it to the column like:
// create the mask final Mask piMask = new Mask("pi", Symbol.getPredefinedSymbol(PredefinedSymbol.PI)); // add it to the column column.addMask(piMask);Save and load the configuration:
View.saveConfiguration(Configuration)
and View.loadConfiguration(Configuration)
.
It is saved or restored the visibility of the view. This makes it possible that you can store the state of the view persistent.javax.swing.JComponent.AccessibleJComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ExecutionTableView(java.lang.String title)
Creates a new execution table view.
|
ExecutionTableView(java.lang.String title,
boolean closable)
Creates a new execution table view.
|
ExecutionTableView(java.lang.String title,
boolean closable,
LanguageFile langFile,
java.lang.String langID)
Creates a new execution table view.
|
ExecutionTableView(java.lang.String title,
boolean closable,
java.lang.String langID)
Creates a new execution table view.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ExecutionTableColumn column)
Adds a new column to the table.
|
void |
add(ExecutionTableColumn[] columns)
Adds new columns to the table.
|
void |
add(ExecutionTableItem item)
Adds a new item to the table.
|
void |
add(ExecutionTableItem[] items)
Adds new items to the table.
|
void |
addColumnGroup(ExecutionTableGroup group)
Adds a new column group to the table.
|
void |
addDefaultCellRenderer(java.lang.Class<?> c,
javax.swing.table.TableCellRenderer renderer)
Adds a new default renderer for the specified class.
|
void |
addItemGroup(ExecutionTableGroup group)
Adds a new item (row) group to the table.
|
void |
clearSelection()
Clears the selection of the table.
|
int |
convertItemIndexToVisible(int index)
Converts the given item index (of a visible item) in an index of the visible rows list.
|
boolean |
getAutoRepaint()
Indicates whether auto repaint is enabled in the view.
|
boolean |
getAutoResizeColumns()
Indicates whether the columns are auto resizable.
|
ExecutionTableColumn |
getColumn(int index)
Gets the column at the given index.
|
ExecutionTableColumn |
getColumnByID(int id)
Gets the column by the specified id.
|
int |
getColumnCount()
Gets the number of columns of the table.
|
ExecutionTableGroup |
getColumnGroup(int index)
Gets the column group at the given index.
|
int |
getColumnGroupCount()
Gets the number of column groups in the table.
|
java.awt.Color |
getDefaultGridColor()
Gets the system dependent default grid line color.
|
ExecutionTableColumn |
getFirstColumn()
Gets the first column of the table.
|
ExecutionTableItem |
getFirstItem()
Gets the first item of the table.
|
ExecutionTableBorder |
getGridBorder()
Gets the grid border.
|
ExecutionTableItem |
getItem(int index)
Gets the item at the specified index.
|
ExecutionTableItem |
getItemByID(int id)
Gets the item by the specified id.
|
int |
getItemCount()
Gets the number of items (rows) of the table.
|
ExecutionTableGroup |
getItemGroup(int index)
Gets the item group at the given index.
|
int |
getItemGroupCount()
Gets the number of item groups in the table.
|
int |
getItemHeight()
Gets the height of the items in the table.
|
ExecutionTableColumn |
getLastColumn()
Gets the last column of the table.
|
ExecutionTableItem |
getLastItem()
Gets the last item of the table.
|
ExecutionTableColumn |
getSelectedColumn()
Gets the selected column in the table.
|
ExecutionTableItem |
getSelectedItem()
Gets the selected item in the table.
|
ExecutionTableItem |
getSelectedItem(int index)
Gets the selected item at the specified index.
|
int |
getSelectedItemCount()
Gets the number of selected items in the table.
|
SelectionType |
getSelectionType()
Gets the selection type of the table.
|
ExecutionTableItem |
getVisibleRow(int index)
Gets the visible row at the specified index.
|
ExecutionTableItem |
getVisibleRowByID(int id)
Gets the visible item by the specified id.
|
int |
getVisibleRowCount()
Gets the number of visible rows in the table.
|
boolean |
isAutoScrollEnabled()
Indicates whether auto scroll is enabled meaning that the execution table is automatically scrolled to the
last item that was added.
|
boolean |
isSortable()
Indicates whether the table is sortable meaning that a user can sort the items using buttons at each item
to change the position up/down.
|
void |
remove(ExecutionTableColumn column)
Removes the column from the table.
|
void |
remove(ExecutionTableItem item)
Removes the item from the table.
|
void |
removeAllColumnGroups()
Removes all column groups from the table.
|
void |
removeAllColumns()
Removes all columns from the table.
|
void |
removeAllItemGroups()
Removes all item groups from the table.
|
void |
removeAllItems()
Removes all items from the table.
|
void |
removeColumnGroup(ExecutionTableGroup group)
Removes a column group from the table.
|
void |
removeItemGroup(ExecutionTableGroup group)
Removes an item (row) group from the table.
|
protected void |
repaintComponent()
Repaints the component.
|
void |
reset()
Resets the table view meaning that all columns, items and groups are removed from the table.
|
void |
setAutoRepaint(boolean autoRepaint)
Sets whether the view is allowed to be auto repainted.
|
void |
setAutoResizeColumns(boolean enabled)
Sets whether the columns are auto resizable.
|
void |
setAutoScrollEnabled(boolean autoScroll)
Sets whether auto scroll should be enabled meaning that the execution table is automatically scrolled to the
last item that was added.
|
void |
setColumnHeaderHeight(int height)
Sets the height of the column header.
|
void |
setGridBorder(ExecutionTableBorder border)
Sets the grid border.
|
void |
setItemHeight(int height)
Sets the given value as the height for all items of the table.
|
void |
setRepaintDisabled(boolean disabled)
Sets whether the repaint of the component is disabled meaning the component cannot be repainted until the disable state is revoked.
|
void |
setSelectionType(SelectionType type)
Sets the selection type of the table.
|
void |
setSortable(boolean sortable)
Sets whether the table is sortable meaning that a user can sort the items using buttons at each item
to change the position up/down.
|
void |
sortItems(int colIndex,
javax.swing.SortOrder order)
Sorts the items by a specified column index and sort order.
|
addHeaderBarComponent, addHeaderBarSeparator, addImpl, autoRepaint, beforeRemove, close, extendTitle, getContentPanel, getTitle, highlight, highlight, isClosable, isVisible, loadConfiguration, loadConfiguration, readConfigurationData, removeAll, removeHeaderBarComponent, saveConfiguration, saveConfiguration, setBorder, setCloseButtonToolTip, setLayout, setVisible, toString, writeConfigurationData
isRepaintDisabled, repaint
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
public ExecutionTableView(java.lang.String title) throws java.lang.IllegalArgumentException
title
- the title of the view which is displayed in the header barjava.lang.IllegalArgumentException
- public ExecutionTableView(java.lang.String title, boolean closable) throws java.lang.IllegalArgumentException
title
- the title of the view which is displayed in the header barclosable
- true
if the table view can be closed by the user using the "X" in the header bar otherwise false
(if a table view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)java.lang.IllegalArgumentException
- public ExecutionTableView(java.lang.String title, boolean closable, java.lang.String langID) throws java.lang.IllegalArgumentException
title
- the title of the view which is displayed in the header barclosable
- true
if the table view can be closed by the user using the "X" in the header bar otherwise false
(if a table view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)langID
- the language idjava.lang.IllegalArgumentException
- public ExecutionTableView(java.lang.String title, boolean closable, LanguageFile langFile, java.lang.String langID) throws java.lang.IllegalArgumentException
LanguageFile
and a language id to display language dependent
messages and tooltips in the table view. The following language labels are available:
title
- the title of the view which is displayed in the header barclosable
- true
if the table view can be closed by the user using the "X" in the header bar otherwise false
(if a table view is not closable he must be set invisible manually using View.setVisible(boolean)
if required)langFile
- the language file or null
if the table view should not use language dependent labels, tooltips or messages (in this case the predefined labels, tooltips and messages are shown)langID
- the language idjava.lang.IllegalArgumentException
- public boolean getAutoRepaint()
getAutoRepaint
in class View
true
if auto repainting is allowed otherwise false
public void setAutoRepaint(boolean autoRepaint)
BaseComponent.repaint()
on your own to visualize the changes you made to a component or view.
BaseComponent.repaint()
method of the view is automatically
invoked to make the changes visible. But ensure that this does not overload the EDT (event dispatch thread).n
objects in a loop and you activate the auto repaint option.n
calls to BaseComponent.repaint()
instead of one call at the end of the loop.GuiRequest
) and in consequence of that
the algorithm must wait until the pending event is processed in the EDT.setAutoRepaint
in class View
autoRepaint
- true
if auto repainting should be enabled otherwise false
public void addDefaultCellRenderer(java.lang.Class<?> c, javax.swing.table.TableCellRenderer renderer) throws java.lang.IllegalArgumentException
c
- the classrenderer
- the rendererjava.lang.IllegalArgumentException
- public ExecutionTableBorder getGridBorder()
null
if the table does not have grid linespublic void setGridBorder(ExecutionTableBorder border)
setAutoRepaint(boolean)
)!border
- the border or null
if the table should not have grid linesgetDefaultGridColor()
public java.awt.Color getDefaultGridColor()
public int getItemHeight()
public void setItemHeight(int height)
height
- the heightpublic void setColumnHeaderHeight(int height) throws java.lang.IllegalArgumentException
height
- the height of the column headerjava.lang.IllegalArgumentException
- < 0
public boolean getAutoResizeColumns()
true
if the columns are auto resizable (default) otherwise false
public void setAutoResizeColumns(boolean enabled)
ExecutionTableColumn.setWidth(int)
.
enabled
- true
if auto resize of the columns is enabled otherwise false
public boolean isSortable()
true
if the table is sortable otherwise false
public void setSortable(boolean sortable)
sortItems(int, SortOrder)
.
i1
and i5
with
i1 - visible
i2 - invisible
i3 - invisible
i4 - invisible
i5 - visible
i1
is
i5 - visible
i2 - invisible
i3 - invisible
i4 - invisible
i1 - visible
sortable
- if the table should be sortable otherwise false
public boolean isAutoScrollEnabled()
true
if auto scroll is enabled otherwise false
public void setAutoScrollEnabled(boolean autoScroll)
autoScroll
- true
if auto scroll should be enabled otherwise false
public SelectionType getSelectionType()
public void setSelectionType(SelectionType type) throws java.lang.IllegalArgumentException
type
- the selection typejava.lang.IllegalArgumentException
- public ExecutionTableColumn getSelectedColumn()
null
if no cell is selectedclearSelection()
public ExecutionTableItem getSelectedItem()
null
if no cell is selectedclearSelection()
public int getSelectedItemCount()
public ExecutionTableItem getSelectedItem(int index) throws java.lang.IndexOutOfBoundsException
SelectionType
is set to SelectionType.ROWS
.
java.lang.IndexOutOfBoundsException
- index < 0 || index >= getSelectedItemCount()
)clearSelection()
public void clearSelection()
public void add(ExecutionTableColumn column) throws java.lang.IllegalArgumentException
column
- the columnjava.lang.IllegalArgumentException
- public void add(ExecutionTableColumn[] columns) throws java.lang.IllegalArgumentException
columns
- the list of column to be addedjava.lang.IllegalArgumentException
- public void add(ExecutionTableItem item) throws java.lang.IllegalArgumentException
item
- the itemjava.lang.IllegalArgumentException
- public void add(ExecutionTableItem[] items) throws java.lang.IllegalArgumentException
items
- the list of items to be addedjava.lang.IllegalArgumentException
- public void remove(ExecutionTableColumn column)
column
- the columnpublic void remove(ExecutionTableItem item)
item
- the itempublic void removeAllColumns()
public void removeAllItems()
public int getColumnCount()
public ExecutionTableColumn getColumn(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getColumnCount()
)public ExecutionTableColumn getColumnByID(int id)
id
- the idnull
if there is no column with the given idpublic ExecutionTableColumn getFirstColumn()
null
if the table does not have a columnpublic ExecutionTableColumn getLastColumn()
null
if the table does not have a columnpublic int getItemCount()
ExecutionTableItem
can be made invisible.
Use getVisibleRowCount()
and getVisibleRow(int)
to iterate over the visible items of the table.
public ExecutionTableItem getItem(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getItemCount()
)public ExecutionTableItem getItemByID(int id)
id
- the idnull
if there is no item with the given idpublic ExecutionTableItem getFirstItem()
null
if the table does not have an itempublic ExecutionTableItem getLastItem()
null
if the table does not have an itempublic int getVisibleRowCount()
getVisibleRowCount()
is unequal getItemCount()
if an ExecutionTableItem
is set to invisible using
ExecutionTableItem.setVisible(boolean)
.
public ExecutionTableItem getVisibleRow(int index) throws java.lang.IndexOutOfBoundsException
ExecutionTableItem.setVisible(boolean)
the index of the item that can be requested using
ExecutionTableItem.getIndex()
is not the index of the item in the list of visible items/rows.convertItemIndexToVisible(int)
to convert an item index in an index of the visible rows list.
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getVisibleRowCount()
)public ExecutionTableItem getVisibleRowByID(int id)
id
- the idnull
if there is no visible item with the given idpublic int convertItemIndexToVisible(int index)
index
- the item indexpublic void sortItems(int colIndex, javax.swing.SortOrder order) throws java.lang.IndexOutOfBoundsException
SortOrder.UNSORTED
. The column index
does not matter.
colIndex
- the index of the column the items should be ordered byorder
- the sort orderjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getColumnCount()
)public void addColumnGroup(ExecutionTableGroup group)
group
- the group to be added as a column grouppublic void removeColumnGroup(ExecutionTableGroup group)
group
- the group to be removedpublic int getColumnGroupCount()
public ExecutionTableGroup getColumnGroup(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getColumnGroupCount()
)public void removeAllColumnGroups()
public void addItemGroup(ExecutionTableGroup group)
group
- the group to be added as an item grouppublic void removeItemGroup(ExecutionTableGroup group)
group
- the group to be removedpublic int getItemGroupCount()
public ExecutionTableGroup getItemGroup(int index) throws java.lang.IndexOutOfBoundsException
index
- the indexjava.lang.IndexOutOfBoundsException
- index < 0 || index >= getItemGroupCount()
)public void removeAllItemGroups()
public void reset()
public void setRepaintDisabled(boolean disabled)
BaseComponent.repaint()
is invoked automatically.
setRepaintDisabled
in class BaseComponent
disabled
- true
if the repaint mechanism should be disabled otherwise false
protected void repaintComponent()
BaseComponent.repaint()
. You can override this method to repaint sub-components but ensure that
the super type method is invoked too meaning:
protected void repaintComponent() { // repaint the parent super.repaintComponent(); // repaint sub-components ... }
repaintComponent
in class BaseComponent