Class FileSelectorImpl

  • All Implemented Interfaces:
    FileSelector

    public class FileSelectorImpl
    extends java.lang.Object
    implements FileSelector
    The implementation of the FileSelector interface for the local file system, for the remote file system you should have different implementation, basically this class is a wrapper of the JFileChooser.
    Version:
    1.0, 06/21/2006
    Author:
    Hailong Wang, Ph.D
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.JFileChooser fileChooser  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FileSelectorImpl()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.swing.filechooser.FileFilter getFileFilter()
      Returns the file filter used by FileSelector.
      private javax.swing.filechooser.FileFilter getFileFilter​(int index)
      A private helper function to get the current used FileFilter from JFileChooser.
      java.lang.String[] getSelectedFileNames()
      Returns the selected file names.
      static void main​(java.lang.String[] args)  
      static FileSelectorImpl newInstance()  
      void setFileFilter​(javax.swing.filechooser.FileFilter fileFilter)
      Sets the file filter to the FileSelector.
      private void showDialog​(java.awt.Component parent, java.lang.String title, java.lang.String approveButtonName)
      Sets up the parameters and show the dialog to let user make selection.
      void showOpenDialog​(java.awt.Component parent)
      Shows the open dialog to retrieve the user's input, the approve button will be "Open", and title will be "Open Image", only files are displayed, multi selection will be allowed.
      void showSaveAsDialog​(java.awt.Component parent)
      Shows the save as dialog to retrieve the user's input, the approve button will be "Save", and title will be "Save Image As", only file are displayed, multi selection is not allowed.
      void showSaveDialog​(java.awt.Component parent)
      Shows the open dialog to retrieve the user's input, the approve button will be "Save", and title will be "Save Image", only directory are displayed, multi selection is not allowed.
      • Methods inherited from class java.lang.Object

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

      • fileChooser

        private javax.swing.JFileChooser fileChooser
    • Constructor Detail

      • FileSelectorImpl

        private FileSelectorImpl()
    • Method Detail

      • getSelectedFileNames

        public java.lang.String[] getSelectedFileNames()
        Description copied from interface: FileSelector
        Returns the selected file names. Notes: I want this interface to cover the SRB file selection. So I used the string array as the return type.
        Specified by:
        getSelectedFileNames in interface FileSelector
        Returns:
        the selected file names.
        See Also:
        FileSelector.getSelectedFileNames()
      • showOpenDialog

        public void showOpenDialog​(java.awt.Component parent)
        Description copied from interface: FileSelector
        Shows the open dialog to retrieve the user's input, the approve button will be "Open", and title will be "Open Image", only files are displayed, multi selection will be allowed.
        Specified by:
        showOpenDialog in interface FileSelector
        Parameters:
        parent - the parent component
        See Also:
        FileSelector.showOpenDialog(Component)
      • showSaveDialog

        public void showSaveDialog​(java.awt.Component parent)
        Description copied from interface: FileSelector
        Shows the open dialog to retrieve the user's input, the approve button will be "Save", and title will be "Save Image", only directory are displayed, multi selection is not allowed.
        Specified by:
        showSaveDialog in interface FileSelector
        Parameters:
        parent - the parent component
        See Also:
        FileSelector.showSaveDialog(Component)
      • showSaveAsDialog

        public void showSaveAsDialog​(java.awt.Component parent)
        Description copied from interface: FileSelector
        Shows the save as dialog to retrieve the user's input, the approve button will be "Save", and title will be "Save Image As", only file are displayed, multi selection is not allowed.
        Specified by:
        showSaveAsDialog in interface FileSelector
        Parameters:
        parent - the parent component
        See Also:
        FileSelector#showSaveAsDailog(Component)
      • showDialog

        private void showDialog​(java.awt.Component parent,
                                java.lang.String title,
                                java.lang.String approveButtonName)
        Sets up the parameters and show the dialog to let user make selection. If user approves the selection, then stores the image directory.
        Parameters:
        parent - the parent component of the dialog.
        title - the title of the dialog.
        approveButtonName - the approve button name of the dialog.
      • getFileFilter

        private javax.swing.filechooser.FileFilter getFileFilter​(int index)
        A private helper function to get the current used FileFilter from JFileChooser.
        Parameters:
        index - the index of the choosable file filters.
        Returns:
        the current used file filter.
      • main

        public static void main​(java.lang.String[] args)