Class EdalFileChooser

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class EdalFileChooser
    extends EdalTitleDialog
    EDALFileChooser provides a simple mechanism for the user to choose a file from EDAL File System. The following code pops up a file chooser for the user that sees only .jpg and .gif images:
     EDALFileChooser chooser = new EDALFileChooser((Frame) window, rootDirectory);
     EdalFileNameExtensionFilter filter = new EdalFileNameExtensionFilter("JPG & GIF Images", "jpg", "gif");
     chooser.setFileFilter(filter);
     int returnVal = chooser.showOpenDialog();
     if (returnVal == EDALFileChooser.APPROVE_OPTION) {
            System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());
     }
     
    attribute: isContainer false description: A component which allows for the interactive selection of a file.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int APPROVE_OPTION
      Return value if approve (yes, ok) is chosen.
      static int CANCEL_OPTION
      Return value if cancel is chosen.
      protected ClientPrimaryDataDirectory currentdir  
      static int DIRECTORIES_ONLY
      Instruction to display only directories.
      static int ERROR_OPTION
      Return value if an error occured.
      static int FILES_AND_DIRECTORIES
      Instruction to display both files and directories.
      static int FILES_ONLY
      Instruction to display only files.
      protected javax.swing.JButton okbutton  
      protected javax.swing.JTextField pathtext  
      protected ClientPrimaryDataEntity selectedFile  
      • Fields inherited from class javax.swing.JDialog

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • 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
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Constructor Summary

      Constructors 
      Constructor Description
      EdalFileChooser​(java.awt.Dialog owner, ClientDataManager client)
      Constructs a EDALFileChooser that is initialized with owner as the swing container owner(JDialog), rootDirectory as the root directory, and client as the rmi client datamanager.
      EdalFileChooser​(java.awt.Frame owner, ClientDataManager client)
      Constructs a EDALFileChooser that is initialized with owner as the swing container owner(JFrame), rootDirectory as the root directory, and client as the rmi client datamanager.
    • Method Summary

      Modifier and Type Method Description
      EdalAbstractFileFilter getFileFilter()
      Returns the currently selected file filter.
      int getFileSelectionMode()
      Returns the current file-selection mode.
      ClientPrimaryDataEntity getSelectedFile()
      Returns the selected file.
      ClientPrimaryDataEntity[] getSelectedFiles()
      Returns a list of selected files if the file chooser is set to allow multiple selection.
      protected void init​(ClientPrimaryDataDirectory rootDirectory)  
      protected void initViewers()  
      void setFileFilter​(EdalAbstractFileFilter filter)
      Sets the current file filter.
      void setFileSelectionMode​(int mode)
      Sets the EDALFileChooser to allow the user to just select files, just select directories, or select both files and directories.
      void setMultiSelectionEnabled​(boolean b)
      Sets the file chooser to allow multiple file selections.
      void showConnectionButton​(boolean showconnbutton)
      show the "changeconnection" or not.
      int showOpenDialog()
      Pops up an "Open File" file chooser dialog.
      int showSaveDialog()
      Pops up a "Save File" file chooser dialog.
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setShape, setVisible, show, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • pathtext

        protected final javax.swing.JTextField pathtext
      • okbutton

        protected javax.swing.JButton okbutton
      • CANCEL_OPTION

        public static final int CANCEL_OPTION
        Return value if cancel is chosen.
        See Also:
        Constant Field Values
      • APPROVE_OPTION

        public static final int APPROVE_OPTION
        Return value if approve (yes, ok) is chosen.
        See Also:
        Constant Field Values
      • ERROR_OPTION

        public static final int ERROR_OPTION
        Return value if an error occured.
        See Also:
        Constant Field Values
      • FILES_ONLY

        public static final int FILES_ONLY
        Instruction to display only files.
        See Also:
        Constant Field Values
      • DIRECTORIES_ONLY

        public static final int DIRECTORIES_ONLY
        Instruction to display only directories.
        See Also:
        Constant Field Values
      • FILES_AND_DIRECTORIES

        public static final int FILES_AND_DIRECTORIES
        Instruction to display both files and directories.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EdalFileChooser

        public EdalFileChooser​(java.awt.Dialog owner,
                               ClientDataManager client)
        Constructs a EDALFileChooser that is initialized with owner as the swing container owner(JDialog), rootDirectory as the root directory, and client as the rmi client datamanager. If any of the parameters are null this method will not initialize.
        Parameters:
        owner - the swing container owner
        client - the rmi client datamanager
      • EdalFileChooser

        public EdalFileChooser​(java.awt.Frame owner,
                               ClientDataManager client)
        Constructs a EDALFileChooser that is initialized with owner as the swing container owner(JFrame), rootDirectory as the root directory, and client as the rmi client datamanager. If any of the parameters are null this method will not initialize.
        Parameters:
        owner - the swing container owner
        client - the rmi client datamanager
    • Method Detail

      • getFileSelectionMode

        public int getFileSelectionMode()
        Returns the current file-selection mode. The default is EDALFileChooser.FILES_ONLY.
        Returns:
        the type of files to be displayed, one of the following:
        • EDALFileChooser.FILES_ONLY
        • EDALFileChooser.DIRECTORIES_ONLY
        • EDALFileChooser.FILES_AND_DIRECTORIES
        See Also:
        setFileSelectionMode(int)
      • getSelectedFile

        public ClientPrimaryDataEntity getSelectedFile()
        Returns the selected file. This can be set by a user action, such as selecting the file from a list in the UI.
        Returns:
        the selected file
      • getSelectedFiles

        public ClientPrimaryDataEntity[] getSelectedFiles()
        Returns a list of selected files if the file chooser is set to allow multiple selection.
        Returns:
        the selected files
      • initViewers

        protected void initViewers()
      • setFileFilter

        public void setFileFilter​(EdalAbstractFileFilter filter)
        Sets the current file filter. The file filter is used by the file chooser to filter out files from the user's view. Beaninfo preferred: true bound: true description: Sets the File Filter used to filter out files of type.
        Parameters:
        filter - the new current file filter to use
        See Also:
        getFileFilter()
      • setFileSelectionMode

        public void setFileSelectionMode​(int mode)
        Sets the EDALFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is EDALFileChooser.FILES_ONLY.
        Parameters:
        mode - the type of files to be displayed:
        • EDALFileChooser.FILES_ONLY
        • EDALFileChooser.DIRECTORIES_ONLY
        • EDALFileChooser.FILES_AND_DIRECTORIES
        Throws:
        java.lang.IllegalArgumentException - if mode is an illegal file selection mode Beaninfo preferred: true bound: true description: Sets the types of files that the JFileChooser can choose. enum: FILES_ONLY EDALFileChooser.FILES_ONLY DIRECTORIES_ONLY EDALFileChooser.DIRECTORIES_ONLY EDALFileChooser.FILES_AND_DIRECTORIES
        See Also:
        getFileSelectionMode()
      • setMultiSelectionEnabled

        public void setMultiSelectionEnabled​(boolean b)
        Sets the file chooser to allow multiple file selections.
        Parameters:
        b - true if multiple files may be selected Beaninfo bound: true description: Sets multiple file selection mode.
      • showOpenDialog

        public int showOpenDialog()
        Pops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L and F.
        Returns:
        the return state of the file chooser on popdown:
        • EDALFileChooser.CANCEL_OPTION
        • EDALFileChooser.APPROVE_OPTION
        • EDALFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
      • showSaveDialog

        public int showSaveDialog()
        Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L and F.
        Returns:
        the return state of the file chooser on popdown:
        • EDALFileChooser.CANCEL_OPTION
        • EDALFileChooser.APPROVE_OPTION
        • EDALFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
      • showConnectionButton

        public void showConnectionButton​(boolean showconnbutton)
        show the "changeconnection" or not.
        Parameters:
        showconnbutton - false if you want to hidden the button