org.knime.core.node.tableview
Class TableView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by org.knime.core.node.tableview.TableView
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class TableView
extends JScrollPane

Panel containing a table view on a generic DataTable. The table is located in a scroll pane and row and column headers are visible and fixed.
For the caching strategy used in the table refer to TableContentModel.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
Serialized Form

Nested Class Summary
static class TableView.TableAction
          Action associate with the table.
 
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableView()
          Creates new empty TableView.
TableView(DataTable table)
          Creates new instance of a TableView based on a DataTable.
TableView(DataTable table, HiLiteHandler propHdl)
          Creates new instance of a TableView based on a DataTable.
TableView(TableContentModel model)
          Constructs new View by calling this(new TableContentView(model)).
TableView(TableContentView contentView)
          Creates new instance of a TableView given a content view.
 
Method Summary
 void cancelRowCountingInBackground()
          Delegate method to cancel row counting.
 void countRowsInBackground()
          Delegate method to start row counting.
 JMenu createHiLiteMenu()
          Get a new menu to control hiliting for this view.
(package private)  Collection<JMenuItem> createHiLiteMenuItems()
          Helper function to create new JMenuItems that are in the hilite menu.
 JMenu createNavigationMenu()
          Create the navigation menu for this table view.
 JMenu createViewMenu()
          Get a new menu with view controllers (row height, etc.) for this view.
protected  void find(String search, boolean idOnly)
          Find cells (or row IDs) that match the search string.
 JViewport getColumnHeader()
          Delegates to super implementation but sets an appropriate preferred size before returning.
 int getColumnHeaderViewHeight()
          Get the height of the column header view or -1 if none has been set (no data available).
 int getColumnWidth()
          Returns the width of the first column or -1 if there are no columns.
 TableContentModel getContentModel()
          Get reference to underlying TableContentModel.
 TableContentView getContentTable()
          Get reference to table view that is in the scroll pane's view port.
 TableRowHeaderView getHeaderTable()
          Get reference to row header table, that is the column displaying the row keys from the underlying table.
 int getRowHeight()
          Get row height from table.
 void gotoCell(int row, int col)
          Scrolls to the given coordinate cell.
 boolean hasData()
          This table "has data" when there is valid input, i.e.
 boolean hasHiLiteHandler()
          Checks if a property handler is registered.
 void hiliteSelected()
          Sends a request to the content table to hilite all currently selected rows.
 boolean isColumnHeaderResizingAllowed()
          Whether or not the resizing of the column header height is allowed.
 boolean isShowColorInfo()
          Is color icon shown?
 boolean isShowIconInColumnHeader()
          Get the status if the icon in the column header is shown.
 TableView.TableAction registerFindAction()
          Creates and registers the "Find ..." action on this component.
 TableView.TableAction registerFindNextAction()
          Creates and registers the "Find Next" action on this component.
 TableView.TableAction registerGotoRowAction()
          Creates and registers the "Go to Row" action on this component.
 void registerNavigationActions()
          Registers all actions for navigation on the table, namely "Find...", "Find Next" and "Go to Row...".
 void resetHilite()
          Sends a request to the content table to reset (unhilite) all rows.
 void setColumnHeaderResizingAllowed(boolean isColumnHeaderResizingAllowed)
          Enable or disable the resizing of the column header height.
 void setColumnHeaderViewHeight(int newHeight)
          Set the height of the column header view.
 void setColumnWidth(int width)
          Sets an equal width in all columns.
 void setCorner(String key, Component corner)
          Overwritten to add (north-south) resize listener to upper left corner.
 void setDataTable(DataTable data)
          Sets a new DataTable as content.
 void setHiLiteHandler(HiLiteHandler hiLiteHdl)
          Sets a new HiLiteHandler this view talks to.
 void setRowHeight(int newHeight)
          Set a new row height in the table.
 void setShowColorInfo(boolean showIt)
          Shall row header encode the color information in an icon?
 void setShowIconInColumnHeader(boolean show)
          Set whether or not the icon in the column header is to be displayed.
 void showHiLitedOnly(boolean showOnlyHilite)
          Deprecated. Implementors should refer to getContentModel().setTableContentFilter(TableContentFilter)
protected  void showPopup(Point p)
          Opens the popup menu on the row header.
 boolean showsHiLitedOnly()
          Deprecated. Implementors should refer to getContentModel().getTableContentFilter()
 void unHiliteSelected()
          Sends a request to the content table to unhilite all currently selected rows.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, isVisible, 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, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableView

public TableView()
Creates new empty TableView. Content and handlers are set using the appropriate methods, that is, setDataTable(DataTable) and setHiLiteHandler(HiLiteHandler). The model for this view, however, is not null. That is, it's completely legal to do getContentModel() right after calling this constructor.


TableView

public TableView(TableContentView contentView)
Creates new instance of a TableView given a content view. A row header is created and displayed. There is no property handler connected to this view at this time.

Parameters:
contentView - view to display.
Throws:
NullPointerException - if contentView is null

TableView

public TableView(TableContentModel model)
Constructs new View by calling this(new TableContentView(model)).

Parameters:
model - model to be displayed.
Throws:
NullPointerException - if model is null.
See Also:
TableView(TableContentView)

TableView

public TableView(DataTable table)
Creates new instance of a TableView based on a DataTable. A row header is created and displayed.

Parameters:
table - table to be displayed
Throws:
NullPointerException - if table is null.

TableView

public TableView(DataTable table,
                 HiLiteHandler propHdl)
Creates new instance of a TableView based on a DataTable. A row header is created and displayed.

Parameters:
table - table to be displayed
propHdl - used to connect other views, may be null
Throws:
NullPointerException - if table is null
Method Detail

getContentTable

public TableContentView getContentTable()
Get reference to table view that is in the scroll pane's view port.

Returns:
reference to content table

getContentModel

public TableContentModel getContentModel()
Get reference to underlying TableContentModel. This call is identical to calling (TableContentModel)(getContentTable().getModel()).

Returns:
the model displayed.

getHeaderTable

public TableRowHeaderView getHeaderTable()
Get reference to row header table, that is the column displaying the row keys from the underlying table.

Returns:
reference to row header.

getColumnHeader

public JViewport getColumnHeader()
Delegates to super implementation but sets an appropriate preferred size before returning. If the table has no columns (but more than 0 rows), the corner was not shown (because of 0,0 preferred dimension).

Overrides:
getColumnHeader in class JScrollPane

setCorner

public void setCorner(String key,
                      Component corner)
Overwritten to add (north-south) resize listener to upper left corner.

Overrides:
setCorner in class JScrollPane

hasHiLiteHandler

public final boolean hasHiLiteHandler()
Checks if a property handler is registered.

Returns:
true if global hiliting is possible (property handler is available).
See Also:
TableContentModel.hasHiLiteHandler()

hasData

public boolean hasData()
This table "has data" when there is valid input, i.e. the DataTable to display is not null. The status may changed during runtime by calling the model's setDataTable(DataTable) method.

Returns:
true when there is data to display, false otherwise
See Also:
TableContentModel.hasData()

hiliteSelected

public void hiliteSelected()
Sends a request to the content table to hilite all currently selected rows.

See Also:
TableContentView.hiliteSelected()

unHiliteSelected

public void unHiliteSelected()
Sends a request to the content table to unhilite all currently selected rows.

See Also:
TableContentView.unHiliteSelected()

resetHilite

public void resetHilite()
Sends a request to the content table to reset (unhilite) all rows.

See Also:
TableContentView.resetHilite()

setDataTable

public void setDataTable(DataTable data)
Sets a new DataTable as content.

Parameters:
data - new data to be shown; may be null to have an empty table.
See Also:
TableContentModel.setDataTable(DataTable)

setHiLiteHandler

public void setHiLiteHandler(HiLiteHandler hiLiteHdl)
Sets a new HiLiteHandler this view talks to. The argument may be null to disconnect from the current HiLiteHandler.

Parameters:
hiLiteHdl - the new HiLiteHandler.

showHiLitedOnly

@Deprecated
public final void showHiLitedOnly(boolean showOnlyHilite)
Deprecated. Implementors should refer to getContentModel().setTableContentFilter(TableContentFilter)

Control behavior to show only hilited rows.

Parameters:
showOnlyHilite - true Filter and display only rows whose hilite status is set.
See Also:
TableContentModel.getTableContentFilter()

showsHiLitedOnly

@Deprecated
public boolean showsHiLitedOnly()
Deprecated. Implementors should refer to getContentModel().getTableContentFilter()

Get status of filtering for hilited rows.

Returns:
true: only hilited rows are shown, false: all rows are shown.
See Also:
TableContentModel.getTableContentFilter()

cancelRowCountingInBackground

public void cancelRowCountingInBackground()
Delegate method to cancel row counting.

See Also:
TableContentModel.cancelRowCountingInBackground()

countRowsInBackground

public void countRowsInBackground()
Delegate method to start row counting.

See Also:
TableContentModel.countRowsInBackground()

getRowHeight

public int getRowHeight()
Get row height from table.

Returns:
current row height
See Also:
JTable.getRowHeight()

getColumnWidth

public int getColumnWidth()
Returns the width of the first column or -1 if there are no columns.

Returns:
the width of the first column.

setColumnWidth

public void setColumnWidth(int width)
Sets an equal width in all columns.

Parameters:
width - the new width.
See Also:
TableColumn.setPreferredWidth(int)

getColumnHeaderViewHeight

public int getColumnHeaderViewHeight()
Get the height of the column header view or -1 if none has been set (no data available).

Returns:
The height of the column header view.

setColumnHeaderViewHeight

public void setColumnHeaderViewHeight(int newHeight)
Set the height of the column header view. If none has been set (i.e. no data is available), this method does nothing.

Parameters:
newHeight - The new height.

setRowHeight

public void setRowHeight(int newHeight)
Set a new row height in the table.

Parameters:
newHeight - the new height
See Also:
JTable.setRowHeight(int)

setShowColorInfo

public void setShowColorInfo(boolean showIt)
Shall row header encode the color information in an icon?

Parameters:
showIt - true for show icon (and thus the color), false ignore colors
See Also:
TableRowHeaderView.setShowColorInfo(boolean)

isShowColorInfo

public boolean isShowColorInfo()
Is color icon shown?

Returns:
true if it is, false otherwise
See Also:
TableRowHeaderView.isShowColorInfo()

setShowIconInColumnHeader

public void setShowIconInColumnHeader(boolean show)
Set whether or not the icon in the column header is to be displayed. Delegate method to setShowColorInfo(boolean).

Parameters:
show - Whether or not this icon should be shown.

isShowIconInColumnHeader

public boolean isShowIconInColumnHeader()
Get the status if the icon in the column header is shown. Delegate method to isShowColorInfo().

Returns:
true when the icon is shown, false otherwise.

isColumnHeaderResizingAllowed

public boolean isColumnHeaderResizingAllowed()
Whether or not the resizing of the column header height is allowed. The default is false.

Returns:
the isColumnHeaderResizingAllowed.
See Also:
setColumnHeaderResizingAllowed(boolean)

setColumnHeaderResizingAllowed

public void setColumnHeaderResizingAllowed(boolean isColumnHeaderResizingAllowed)
Enable or disable the resizing of the column header height.

Parameters:
isColumnHeaderResizingAllowed - If true resizing is allowed.

find

protected void find(String search,
                    boolean idOnly)
Find cells (or row IDs) that match the search string. If a matching element is found, the view is scrolled to that position. Successive calls of this method with the same arguments will continue the search.

Parameters:
search - The search string.
idOnly - If only the ID column should be searched.
Throws:
NullPointerException - If search argument is null.

gotoCell

public void gotoCell(int row,
                     int col)
Scrolls to the given coordinate cell. This method is invoked from the navigation menu. If there is no such coordinate it will display an error message.

Parameters:
row - the row to scroll to
col - the col to scroll to (negative for row key)

showPopup

protected void showPopup(Point p)
Opens the popup menu on the row header. It allows to trigger hilite events.

Parameters:
p - location where to open the popup

createNavigationMenu

public JMenu createNavigationMenu()
Create the navigation menu for this table view.

Returns:
a new JMenu with navigation controllers.

createHiLiteMenu

public JMenu createHiLiteMenu()
Get a new menu to control hiliting for this view.

Returns:
a new JMenu with hiliting buttons

createHiLiteMenuItems

Collection<JMenuItem> createHiLiteMenuItems()
Helper function to create new JMenuItems that are in the hilite menu.

Returns:
all those items in an array

createViewMenu

public JMenu createViewMenu()
Get a new menu with view controllers (row height, etc.) for this view.

Returns:
a new JMenu with control buttons.

registerNavigationActions

public void registerNavigationActions()
Registers all actions for navigation on the table, namely "Find...", "Find Next" and "Go to Row...".


registerFindAction

public TableView.TableAction registerFindAction()
Creates and registers the "Find ..." action on this component. Multiple invocation of this method have no effect (lazy initialization).

Returns:
The non-null action representing the find task.
See Also:
registerNavigationActions()

registerFindNextAction

public TableView.TableAction registerFindNextAction()
Creates and registers the "Find Next" action on this component. Multiple invocation of this method have no effect (lazy initialization).

Returns:
The non-null action representing the find next task.
See Also:
registerNavigationActions()

registerGotoRowAction

public TableView.TableAction registerGotoRowAction()
Creates and registers the "Go to Row" action on this component. Multiple invocation of this method have no effect (lazy initialization).

Returns:
The non-null action representing the go to row task.
See Also:
registerNavigationActions()


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.