org.knime.core.node.util
Class ColumnSelectionPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.knime.core.node.util.ColumnSelectionPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ColumnSelectionPanel
extends JPanel

Class implements a panel to choose a column of a certain type retrieved from the DataTableSpec.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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.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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ColumnSelectionPanel(Border border, Class<? extends DataValue>... filterValueClasses)
          Creates new Panel that will filter columns for particular value classes.
ColumnSelectionPanel(Border border, ColumnFilter columnFilter)
          Creates new Panel that will filter columns using the given ColumnFilter.
ColumnSelectionPanel(Border border, ColumnFilter columnFilter, boolean addNoneCol)
          Creates new Panel that will filter columns using the given ColumnFilter.
ColumnSelectionPanel(Border border, ColumnFilter columnFilter, boolean addNoneCol, boolean addRowID)
          Creates new Panel that will filter columns using the given ColumnFilter.
ColumnSelectionPanel(Class<? extends DataValue>... filterValueClasses)
          Creates new Panel that will filter columns for particular value classes.
ColumnSelectionPanel(JLabel label, Class<? extends DataValue>... filterValueClasses)
          Creates a column selection panel with a label instead of a border which preserves the minimum size to either the label width or the combo box width.
ColumnSelectionPanel(JLabel label, ColumnFilter columnFilter)
          Creates a column selection panel with a label instead of a border which preserves the minimum size to either the label width or the combo box width.
ColumnSelectionPanel(String borderTitle)
          Creates a new column selection panel with the given border title; all column are included in the combox box.
ColumnSelectionPanel(String borderTitle, Class<? extends DataValue>... filterValueClasses)
          Creates new Panel that will filter columns for particular value classes.
 
Method Summary
 void addActionListener(ActionListener l)
          Delegate method to the underlying combo box.
 void addItemListener(ItemListener aListener)
          Adds an item listener to the underlying combo box.
 void fixSelectablesTo(String... colName)
          Attempts to set the argument as selected column and disables the combo box if there is only one available.
 int getNrItemsInList()
           
 String getSelectedColumn()
          Gets the selected column.
 DataColumnSpec getSelectedColumnAsSpec()
          Gets the selected column as DataColumnSpec.
 int getSelectedIndex()
           
 boolean isRequired()
          Indicates whether in the current configuration at least one compatible type is required or not.
 void removeActionListener(ActionListener l)
          Delegate method to the underlying combo box.
 void removeItemListener(ItemListener aListener)
          Removes an item listener to the underlying combo box.
 boolean rowIDSelected()
           
 void setEnabled(boolean enabled)
           
 void setRequired(boolean isRequired)
          True, if a compatible type is required, false otherwise.
 void setRowIDSelected()
          Selects the RowID item in the item list if a RowID entry exists.
 void setSelectedColumn(String columnName)
           
 void setSelectedIndex(int index)
          Selects the given index in the combo box.
 void update(DataTableSpec spec, String selColName)
          Updates this filter panel by removing all current items and adding the columns according to the content of the argument spec.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, isValidateRoot, 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, 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, setLayout, 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, setComponentOrientation, 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

ColumnSelectionPanel

public ColumnSelectionPanel(Class<? extends DataValue>... filterValueClasses)
Creates new Panel that will filter columns for particular value classes. The panel will have a titled border with name "Column Selection".

Parameters:
filterValueClasses - classes derived from DataValue. The combo box will allow to select only columns compatible with one of these classes. All other columns will be ignored.
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(String borderTitle)
Creates a new column selection panel with the given border title; all column are included in the combox box.

Parameters:
borderTitle - The border title.

ColumnSelectionPanel

public ColumnSelectionPanel(String borderTitle,
                            Class<? extends DataValue>... filterValueClasses)
Creates new Panel that will filter columns for particular value classes. The panel will have a title border with a given title.

Parameters:
filterValueClasses - a class derived from DataValue. The combo box will allow to select only columns compatible with one of these classes. All other columns will be ignored.
borderTitle - The title of the border
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(Border border,
                            ColumnFilter columnFilter)
Creates new Panel that will filter columns using the given ColumnFilter. The panel will have a border as given. If null, no border is set.

Parameters:
columnFilter - ColumnFilter. The combo box will allow to select only columns compatible with the column filter. All other columns will be ignored.
border - Border for the panel or null to have no border.
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(Border border,
                            ColumnFilter columnFilter,
                            boolean addNoneCol)
Creates new Panel that will filter columns using the given ColumnFilter. The panel will have a border as given. If null, no border is set.

Parameters:
columnFilter - ColumnFilter. The combo box will allow to select only columns compatible with the column filter. All other columns will be ignored.
border - Border for the panel or null to have no border.
addNoneCol - true, if a none option should be added to the column list
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(Border border,
                            ColumnFilter columnFilter,
                            boolean addNoneCol,
                            boolean addRowID)
Creates new Panel that will filter columns using the given ColumnFilter. The panel will have a border as given. If null, no border is set.

Parameters:
columnFilter - ColumnFilter. The combo box will allow to select only columns compatible with the column filter. All other columns will be ignored.
border - Border for the panel or null to have no border.
addNoneCol - true, if a none option should be added to the column list
addRowID - true, if a RowID option should be added to the column list
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(Border border,
                            Class<? extends DataValue>... filterValueClasses)
Creates new Panel that will filter columns for particular value classes. The panel will have a border as given. If null, no border is set.

Parameters:
filterValueClasses - classes derived from DataValue. The combo box will allow to select only columns compatible with one of theses classes. All other columns will be ignored.
border - Border for the panel or null to have no border.
See Also:
update(DataTableSpec,String)

ColumnSelectionPanel

public ColumnSelectionPanel(JLabel label,
                            ColumnFilter columnFilter)
Creates a column selection panel with a label instead of a border which preserves the minimum size to either the label width or the combo box width.

Parameters:
label - label of the combo box.
columnFilter - ColumnFilter. The combo box will allow to select only columns compatible with the column filter. All other columns will be ignored.

ColumnSelectionPanel

public ColumnSelectionPanel(JLabel label,
                            Class<? extends DataValue>... filterValueClasses)
Creates a column selection panel with a label instead of a border which preserves the minimum size to either the label width or the combo box width.

Parameters:
label - label of the combo box.
filterValueClasses - allowed classes.
Method Detail

setRequired

public final void setRequired(boolean isRequired)
True, if a compatible type is required, false otherwise. If required an exception is thrown in the update method + if no compatible type was found in the input spec. If it is not required this exception is suppressed.

Parameters:
isRequired - True, if at least one compatible type is required, false otherwise.

isRequired

public final boolean isRequired()
Indicates whether in the current configuration at least one compatible type is required or not.

Returns:
True, if at least one compatible type is required, false otherwise.

update

public final void update(DataTableSpec spec,
                         String selColName)
                  throws NotConfigurableException
Updates this filter panel by removing all current items and adding the columns according to the content of the argument spec. If a column name is provided and it is not filtered out the corresponding item in the combo box will be selected.

Parameters:
spec - To get the column names, types and the current index from.
selColName - The column name to be set as chosen.
Throws:
NotConfigurableException - If the spec does not contain at least one compatible type.

rowIDSelected

public boolean rowIDSelected()
Returns:
true if the user has selected the RowID

getSelectedColumnAsSpec

public final DataColumnSpec getSelectedColumnAsSpec()
Gets the selected column as DataColumnSpec. If the addNoneCol flag is true the method returns null if the user has selected the no column item from the combo box.

Returns:
The spec of the column that is currently selected or null if the addNoneCol flag is set to true and the no column item is selected or the addRowID flag is set to true and the RowID column item is selected. Check the useRowID column if the RowID option was selected.

getSelectedColumn

public final String getSelectedColumn()
Gets the selected column. If the addNoneCol flag is true the method returns null if the user has selected the no column item from the combo box.

Returns:
The cell that is currently being selected or null if the addNoneCol flag is set to true and the no column item is selected or the addRowID flag is set to true and the RowID column item is selected. Check the useRowID column if the RowID option was selected.

fixSelectablesTo

public void fixSelectablesTo(String... colName)
Attempts to set the argument as selected column and disables the combo box if there is only one available.

Parameters:
colName - Name of the fixed x columns.

getSelectedIndex

public final int getSelectedIndex()
Returns:
the selected index.

getNrItemsInList

public int getNrItemsInList()
Returns:
the number of selectable elements in the list.

setSelectedIndex

public final void setSelectedIndex(int index)
Selects the given index in the combo box.

Parameters:
index - Select this item.

setSelectedColumn

public final void setSelectedColumn(String columnName)
Parameters:
columnName - - the name of the column to select.

setRowIDSelected

public final void setRowIDSelected()
Selects the RowID item in the item list if a RowID entry exists.


setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class JComponent
Parameters:
enabled - true if enabled otherwise false.
See Also:
Component.setEnabled(boolean)

addItemListener

public void addItemListener(ItemListener aListener)
Adds an item listener to the underlying combo box.

Parameters:
aListener - The listener to be registered
See Also:
JComboBox.addItemListener(ItemListener)

removeItemListener

public void removeItemListener(ItemListener aListener)
Removes an item listener to the underlying combo box.

Parameters:
aListener - The listener to be unregistered
See Also:
JComboBox.removeItemListener(ItemListener)

addActionListener

public void addActionListener(ActionListener l)
Delegate method to the underlying combo box.

Parameters:
l - The action listener being added from the combo box.
See Also:
JComboBox.addActionListener(ActionListener)

removeActionListener

public void removeActionListener(ActionListener l)
Delegate method to the underlying combo box.

Parameters:
l - The action listener being removed from the combo box.
See Also:
JComboBox.removeActionListener(ActionListener)


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.