org.knime.core.node.util
Class FileSelectionPanel

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.FileSelectionPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FileSelectionPanel
extends JPanel

Author:
Kilian Thiel, 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
protected static Color DEFAULT_BG
          default background color for editable components.
protected static Color DEFAULT_FG
          default foreground color for editable components.
 
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
FileSelectionPanel(String configKey, String historyID, int dialogType, boolean directoryOnly)
          Constructor that creates a file/directory chooser of the given type without a file filter.
FileSelectionPanel(String configKey, String historyID, int dialogType, boolean directoryOnly, String... validExtensions)
          Constructor that creates a file or directory chooser of the given type that filters the files according to the given extensions.
FileSelectionPanel(String configKey, String historyID, int dialogType, String... validExtensions)
          Constructor that creates a file chooser of the given type that filters the files according to the given extensions.
FileSelectionPanel(String configKey, String historyID, String... validExtensions)
          Constructor that creates a file chooser with an JFileChooser.OPEN_DIALOG that filters files according to the given extensions.
 
Method Summary
 void loadSettingsFrom(NodeSettingsRO settings, DataTableSpec[] specs)
          Method loadSettingsFrom.
 void saveSettingsTo(NodeSettingsWO settings)
          Saves all settings to settings object.
 void setBorderTitle(String newTitle)
          Replaces the title displayed in the border that surrounds the editfield and browse button with the specified new title.
protected  void setEnabledComponents(boolean enabled)
          Enables components if enabled is true, otherwise components will be disabled.
(package private)  void updateComponent(String newFile)
          Updates the components if the components filename is out of syn with the given filename.
 
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, 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, 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
 

Field Detail

DEFAULT_FG

protected static final Color DEFAULT_FG
default foreground color for editable components.


DEFAULT_BG

protected static final Color DEFAULT_BG
default background color for editable components.

Constructor Detail

FileSelectionPanel

public FileSelectionPanel(String configKey,
                          String historyID,
                          String... validExtensions)
Constructor that creates a file chooser with an JFileChooser.OPEN_DIALOG that filters files according to the given extensions. Also non-existing paths are accepted.

Parameters:
configKey - the model holding the value
historyID - to identify the file history
validExtensions - only show files with those extensions

FileSelectionPanel

public FileSelectionPanel(String configKey,
                          String historyID,
                          int dialogType,
                          boolean directoryOnly)
Constructor that creates a file/directory chooser of the given type without a file filter. Also non-existing paths are accepted.

Parameters:
configKey - the model holding the value
dialogType - JFileChooser.OPEN_DIALOG, JFileChooser.SAVE_DIALOG or JFileChooser.CUSTOM_DIALOG
historyID - to identify the file history
directoryOnly - true if only directories should be selectable, otherwise only files can be selected

FileSelectionPanel

public FileSelectionPanel(String configKey,
                          String historyID,
                          int dialogType,
                          String... validExtensions)
Constructor that creates a file chooser of the given type that filters the files according to the given extensions. Also non-existing paths are accepted.

Parameters:
configKey - the config key
dialogType - JFileChooser.OPEN_DIALOG, JFileChooser.SAVE_DIALOG or JFileChooser.CUSTOM_DIALOG
validExtensions - only show files with those extensions
historyID - id for the file history

FileSelectionPanel

public FileSelectionPanel(String configKey,
                          String historyID,
                          int dialogType,
                          boolean directoryOnly,
                          String... validExtensions)
Constructor that creates a file or directory chooser of the given type that filters the files according to the given extensions. Also non-existing paths are accepted.

Parameters:
configKey - the config key.
dialogType - JFileChooser.OPEN_DIALOG, JFileChooser.SAVE_DIALOG or JFileChooser.CUSTOM_DIALOG
directoryOnly - true if only directories should be selectable, otherwise only files can be selected
validExtensions - only show files with those extensions
historyID - to identify the file histroy
Method Detail

updateComponent

void updateComponent(String newFile)
Updates the components if the components filename is out of syn with the given filename.

Parameters:
newFile - The new filename to set if the components filename is not equal with the given one.

setEnabledComponents

protected void setEnabledComponents(boolean enabled)
Enables components if enabled is true, otherwise components will be disabled.

Parameters:
enabled - If true components will be enabled, if false disabled.

setBorderTitle

public void setBorderTitle(String newTitle)
Replaces the title displayed in the border that surrounds the editfield and browse button with the specified new title. The default title of the component is "Selected File:" or "Selected Directory:".

Parameters:
newTitle - the new title to display in the border.
Throws:
NullPointerException - if the new title is null.

saveSettingsTo

public void saveSettingsTo(NodeSettingsWO settings)
Saves all settings to settings object.

Parameters:
settings - Object to store settings in.

loadSettingsFrom

public void loadSettingsFrom(NodeSettingsRO settings,
                             DataTableSpec[] specs)
                      throws InvalidSettingsException
Method loadSettingsFrom.

Parameters:
settings - The NodeSettings object of the containing NodeDialogPane.
specs - The DataTableSpec[] of the containing NodeDialogPane.
Throws:
InvalidSettingsException - If settings could not be loaded.


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.