com.jbbres.lib.actions.tools.swing
Class JNewFileSelection

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 com.jbbres.lib.actions.tools.swing.JNewFileSelection
All Implemented Interfaces:
com.jbbres.lib.PropertiesOwner, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.DocumentListener

public class JNewFileSelection
extends javax.swing.JPanel
implements com.jbbres.lib.PropertiesOwner, java.awt.event.ActionListener, javax.swing.event.DocumentListener

An swing object that can be used to allow the user to select a file.

The object is composed of a JTextField where the user can enter the name of the file and a JComboBox where he can select the directory. the text field accepts the Variable objects by drag and drop, and the combo box display the list of the variables containing a file, and allows the user to choose its own directory if he wishes so.


Release Notes:

v1.1.0:

  • Use JXFileChooser instead of JXFileChooser
  • Since:
    1.0.0
    Version:
    1.1.0
    Author:
    Jean-Baptiste Bres
    See Also:
    Serialized Form

    Nested Class Summary
     
    Nested classes/interfaces inherited from class javax.swing.JComponent
    javax.swing.JComponent.AccessibleJComponent
     
    Nested classes/interfaces inherited from class java.awt.Component
    java.awt.Component.BaselineResizeBehavior
     
    Field Summary
    static java.lang.String PROPERTY_FILE_NAME
              The Constant PROPERTY_FILE_NAME.
    static java.lang.String PROPERTY_FOLDER
              The Constant PROPERTY_FOLDER.
     
    Fields inherited from class javax.swing.JComponent
    TOOL_TIP_TEXT_KEY, 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
    JNewFileSelection()
              Create the JFileCreation.
    JNewFileSelection(java.io.File defaultFile)
              Create the JFileCreation.
    JNewFileSelection(java.lang.String defaultPath)
              Create the JFileCreation.
    JNewFileSelection(Workflow workflow)
              Create the JFileCreation.
    JNewFileSelection(Workflow workflow, java.io.File defaultFile)
              Create the JFileCreation.
    JNewFileSelection(Workflow workflow, java.io.File defaultFile, boolean diplayPath)
              Create the JFileCreation.
    JNewFileSelection(Workflow workflow, java.lang.String defaultPath)
              Create the JFileCreation.
     
    Method Summary
     void actionPerformed(java.awt.event.ActionEvent e)
               
     void addActionListener(java.awt.event.ActionListener l)
              Add a file selection listener.
     void addStaticFolder(java.io.File folder)
              Add a static folder to the "in folder" list.
     void changedUpdate(javax.swing.event.DocumentEvent e)
               
     void displayPath(boolean d)
              If TRUE the whole path of the file will be display.
     void fireActionPerformed()
              Reports a file selection.
     java.io.File getCurrentDirectory()
              Returns the current directory.
     java.lang.String getFileName()
              Gets the file name.
     java.lang.String getFileNamelabelText()
              Returns the text displayed in front of the field where the user can input the file name.
     java.lang.String getFolderLabelText()
              Returns the text displayed in front of the field where the user can select the destination folder.
     java.util.Properties getProperties()
               
     java.io.File getSelectedDirectory()
              Returns the selected directory.
     java.io.File getSelectedFile()
              Returns the selected file.
     java.lang.String getSelectedFilePath()
              Return the selected path.
     Workflow getWorkflow()
              Gets the workflow.
     void insertUpdate(javax.swing.event.DocumentEvent e)
               
     boolean isEditable()
              Returns the boolean indicating whether this Component is editable or not.
     boolean isPathDisplayed()
              Return TRUE if the whole path of the file will be display.
     void removeActionListener(java.awt.event.ActionListener l)
              Remove a file selection listener.
     void removeStaticFolder(java.io.File folder)
              Remove a static folder.
     void removeUpdate(javax.swing.event.DocumentEvent e)
               
     void setCurrentDirectory(java.io.File dir)
              Sets the current directory.
     void setEditable(boolean editable)
              Sets the specified boolean to indicate whether or not this Component should be editable.
     void setEnabled(boolean enabled)
               
     void setFileName(java.lang.String fileName)
              Sets the file name.
     void setFileNameLabelText(java.lang.String text)
              Set the text displayed in front of the field where the user can input the file name.
     void setFolderLabelText(java.lang.String text)
              Set the text displayed in front of the field where the user can input select the destination folder.
     void setProperties(java.util.Properties properties)
               
     void setSelectedDirectory(java.io.File directory)
              Sets the selected directory.
     void setSelectedFile(java.io.File file)
              Sets the selected file.
     void setSelectedFilePath(java.lang.String path)
              Set the current path and the current selected file.
     void setWorkflow(Workflow workflow)
              Sets the workflow.
     
    Methods inherited from class javax.swing.JPanel
    getAccessibleContext, getUI, getUIClassID, setUI, updateUI
     
    Methods inherited from class javax.swing.JComponent
    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
     
    Methods inherited from class java.awt.Container
    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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
     
    Methods inherited from class java.awt.Component
    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    PROPERTY_FILE_NAME

    public static final java.lang.String PROPERTY_FILE_NAME
    The Constant PROPERTY_FILE_NAME.

    See Also:
    Constant Field Values

    PROPERTY_FOLDER

    public static final java.lang.String PROPERTY_FOLDER
    The Constant PROPERTY_FOLDER.

    See Also:
    Constant Field Values
    Constructor Detail

    JNewFileSelection

    public JNewFileSelection(Workflow workflow)
    Create the JFileCreation.

    Parameters:
    workflow - - Associated workflow.

    JNewFileSelection

    public JNewFileSelection(Workflow workflow,
                             java.io.File defaultFile)
    Create the JFileCreation.

    Parameters:
    workflow - - Associated workflow.
    defaultFile - - default file

    JNewFileSelection

    public JNewFileSelection(Workflow workflow,
                             java.lang.String defaultPath)
    Create the JFileCreation.

    Parameters:
    workflow - - Associated workflow.
    defaultPath - - String

    JNewFileSelection

    public JNewFileSelection()
    Create the JFileCreation.
    In order to access to the variables, you have to set the workflow by calling the setWorkflow method.


    JNewFileSelection

    public JNewFileSelection(java.lang.String defaultPath)
    Create the JFileCreation.
    In order to access to the variables, you have to set the workflow by calling the setWorkflow method.

    Parameters:
    defaultPath - - String

    JNewFileSelection

    public JNewFileSelection(java.io.File defaultFile)
    Create the JFileCreation.
    In order to access to the variables, you have to set the workflow by calling the setWorkflow method.

    Parameters:
    defaultFile - - File

    JNewFileSelection

    public JNewFileSelection(Workflow workflow,
                             java.io.File defaultFile,
                             boolean diplayPath)
    Create the JFileCreation.

    Parameters:
    workflow - - Associated workflow.
    defaultFile - - File
    diplayPath - - if TRUE the whole path of the file is displayed. Otherwise only the file name.
    Method Detail

    setFileNameLabelText

    public void setFileNameLabelText(java.lang.String text)
    Set the text displayed in front of the field where the user can input the file name.

    Parameters:
    text - - text to be displayed in front of the field where the user can input the file name

    getFileNamelabelText

    public java.lang.String getFileNamelabelText()
    Returns the text displayed in front of the field where the user can input the file name.

    Returns:
    the text displayed in front of the field where the user can input the file name

    getFolderLabelText

    public java.lang.String getFolderLabelText()
    Returns the text displayed in front of the field where the user can select the destination folder.

    Returns:
    the text displayed in front of the field where the user can select the destination folder

    setFolderLabelText

    public void setFolderLabelText(java.lang.String text)
    Set the text displayed in front of the field where the user can input select the destination folder.

    Parameters:
    text - - text to be displayed in front of the field where the user can select the destination folder

    setWorkflow

    public void setWorkflow(Workflow workflow)
    Sets the workflow.

    Parameters:
    workflow - - the new workflow

    getWorkflow

    public Workflow getWorkflow()
    Gets the workflow.

    Returns:
    the workflow

    setEnabled

    public void setEnabled(boolean enabled)
    Overrides:
    setEnabled in class javax.swing.JComponent

    setEditable

    public void setEditable(boolean editable)
    Sets the specified boolean to indicate whether or not this Component should be editable.

    Parameters:
    editable - - the boolean to be set

    isEditable

    public boolean isEditable()
    Returns the boolean indicating whether this Component is editable or not.

    Returns:
    the boolean

    addStaticFolder

    public void addStaticFolder(java.io.File folder)
    Add a static folder to the "in folder" list. Use this function if you want the user to see a folder that can be selected directly from the list, without having to select "other..." and then choose a file.

    Parameters:
    folder - - folder to be added
    See Also:
    removeStaticFolder(java.io.File)

    removeStaticFolder

    public void removeStaticFolder(java.io.File folder)
    Remove a static folder.

    Parameters:
    folder - - folder to be removed.
    See Also:
    addStaticFolder(java.io.File)

    setSelectedFilePath

    public void setSelectedFilePath(java.lang.String path)
    Set the current path and the current selected file.

    Parameters:
    path - (String) Path of the selected file.

    getSelectedFilePath

    public java.lang.String getSelectedFilePath()
    Return the selected path.

    Returns:
    String

    setSelectedFile

    public void setSelectedFile(java.io.File file)
    Sets the selected file.

    Parameters:
    file - the new selected file

    getSelectedFile

    public java.io.File getSelectedFile()
    Returns the selected file.

    Returns:
    the selected file. If no file is specified, returns null

    displayPath

    public void displayPath(boolean d)
    If TRUE the whole path of the file will be display.
    Otherwise only the file name will be displayed in the list.

    Parameters:
    d - - If TRUE the whole path of the file will be display

    isPathDisplayed

    public boolean isPathDisplayed()
    Return TRUE if the whole path of the file will be display.
    Otherwise only the file name will be displayed in the list.

    Returns:
    true, if checks if is path displayed

    setFileName

    public void setFileName(java.lang.String fileName)
    Sets the file name.

    Parameters:
    fileName - the new file name

    getFileName

    public java.lang.String getFileName()
    Gets the file name.

    Returns:
    the file name

    setSelectedDirectory

    public void setSelectedDirectory(java.io.File directory)
    Sets the selected directory.

    Parameters:
    directory - the new selected directory

    getSelectedDirectory

    public java.io.File getSelectedDirectory()
    Returns the selected directory.

    Returns:
    the selected directory

    setCurrentDirectory

    public void setCurrentDirectory(java.io.File dir)
    Sets the current directory. Passing in null sets the file chooser to point to the user's default directory. This default depends on the operating system. It is typically the "My Documents" folder on Windows, and the user's home directory on Unix. If the file passed in as currentDirectory is not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable directory, or hits the root of the file system.

    Parameters:
    dir - - the current directory to point to

    getCurrentDirectory

    public java.io.File getCurrentDirectory()
    Returns the current directory.

    Returns:
    the current directory

    getProperties

    public java.util.Properties getProperties()
    Specified by:
    getProperties in interface com.jbbres.lib.PropertiesOwner

    setProperties

    public void setProperties(java.util.Properties properties)
    Specified by:
    setProperties in interface com.jbbres.lib.PropertiesOwner

    addActionListener

    public void addActionListener(java.awt.event.ActionListener l)
    Add a file selection listener.

    Parameters:
    l - - FilesSelectionListener

    removeActionListener

    public void removeActionListener(java.awt.event.ActionListener l)
    Remove a file selection listener.

    Parameters:
    l - - FilesSelectionListener

    fireActionPerformed

    public void fireActionPerformed()
    Reports a file selection.


    actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)
    Specified by:
    actionPerformed in interface java.awt.event.ActionListener

    changedUpdate

    public void changedUpdate(javax.swing.event.DocumentEvent e)
    Specified by:
    changedUpdate in interface javax.swing.event.DocumentListener

    insertUpdate

    public void insertUpdate(javax.swing.event.DocumentEvent e)
    Specified by:
    insertUpdate in interface javax.swing.event.DocumentListener

    removeUpdate

    public void removeUpdate(javax.swing.event.DocumentEvent e)
    Specified by:
    removeUpdate in interface javax.swing.event.DocumentListener


    To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

    Additional documentation available online at http://app.jbbres.com/actions/developers.

    Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.