Home about services products contact login
   com.smardec.asc

Advanced Swing Components

  animatepanel
  autocomplete
  dropdown
  filechooser
  fontchooser
  gradient
  hyperlink
  outlookpanel
  outlookpanel.renderers
  quick
  rotate
  sliderpanel
  spantable
  splashscreen
  statusbar
  table
  table.renderers
  table.wrappers
  tree
  treetable
  util
  xmlbars
  xmlbars.menubar
  xmlbars.toolbar
  xmlbars.toolbar.layouts
com.smardec.asc.filechooser
Class FileChooserManager

java.lang.Object
|
+--com.smardec.asc.filechooser.FileChooserManager

public class FileChooserManager
extends java.lang.Object

FileChooserManager builds file choosers and file filter using the information from the xml.

Sample usage:


   FileChooserManager fileChooserManager = new FileChooserManager(getClass().getClassLoader().getResourceAsStream("com/smardec/asc/demo/filechoosers.xml"));
   fileChooserManager.buildFileChooser();

   JAscFileChooser fileChooser = fileChooserManager.getFileChooserById("FileChooser.Xml");
   if (fileChooser != null)
       fileChooser.showOpenDialog(this);
  
Xml file has the following structure:
 <!--
     The root element of the filechoosers.xml file. It contains all the information used by
     com.smardec.asc.filechooser.FileChooserManager to build filechoosers and filefilters.
     -->
 <!ELEMENT root (filters, filechoosers)>

 <!--
     The filters element contains information about the filters and groups of filters.
     -->
 <!ELEMENT filters (filter-group+)>

 <!--
     'icon-base-path' base path that is used with 'icon' to complete icon's path in filter element.
     -->
 <!ATTLIST filters icon-base-path CDATA  #IMPLIED>

 <!--
     The filter-group element defines information about the group of filters that is used in filechooser element.
     -->
 <!ELEMENT filter-group (filter)>

 <!--
     'id'                            unique filter group id
     'file-hiding-enabled'           overrides the corresponding attribute of the file chooser
                                     that is used with filter group
     'accept-all-file-filter-used'   overrides the corresponding attribute of the file chooser
                                     that is used with filter group
     'show-hidden-files'             overrides the corresponding attribute of the file chooser
                                     that is used with filter group
     -->
 <!ATTLIST filter-group
     id                              CDATA                       #REQUIRED
     file-hiding-enabled             (yes | true | no | false)   #IMPLIED
     accept-all-file-filter-used     (yes | true | no | false)   #IMPLIED
     show-hidden-files               (yes | true | no | false)   #IMPLIED
 >

 <!--
     The filter element defines information about the file filter that is used in filechooser element.
     -->
 <!ELEMENT filter EMPTY>

 <!--
     'filename'      specifies file name that are shown by the filter
     'extension'     specifies file extension that are shown by the filter
     'description'   specifies description of the file that are shown by the filter
     'icon'          specifies icon of the file that are shown by the filter
     -->
 <!ATTLIST filter
     filename        CDATA   #IMPLIED
     extension       CDATA   #IMPLIED
     description     CDATA   #IMPLIED
     icon            CDATA   #IMPLIED
 >

 <!--
     The filechoosers element contains information about the filechoosers.
     -->
 <!ELEMENT filechoosers (filechooser+)>

 <!--
     The filechooser element contains information about the filechooser.
     -->
 <!ELEMENT filechooser (filter-group-ref, selection-mode, root-dir)>

 <!--
     'id'    unique filechooser id
     -->
 <!ATTLIST filechooser
     id  CDATA    #REQUIRED>

 <!--
     The filter-group-ref element contains reference to filter group that is used in file chooser.
     -->
 <!ELEMENT filter-group-ref EMPTY>

 <!--
     'id'    filter group id that defines information about the filters
     -->
 <!ATTLIST filter-group-ref id CDATA #REQUIRED>

 <!--
     The selection-mode element specifies information about file selection mode.
     -->
 <!ELEMENT selection-mode EMPTY>

 <!--
     'type'              defines selection mode
     'multi-selection'   defines multiple file selections
     -->
 <!ATTLIST selection-mode
     type                (files_only | directories_only | files_and_directories)     #REQUIRED
     multi-selection     (yes | true | no | false)                                   #REQUIRED
 >

 <!--
     The root-dir element specifies root directory for file chooser.
     -->
 <!ELEMENT root-dir EMPTY>

 <!--
     'dir-path' file chooser's root directory path
     -->
 <!ATTLIST root-dir dir-path CDATA #REQUIRED>
 


Constructor Summary
FileChooserManager(java.io.InputStream inputStream)
Creates new FileChooserManager given the InputStream to read from.
FileChooserManager(java.lang.String menuFileChooserFileName)
Creates new FileChooserManager given the name of the xml file to read from.
Method Summary
void buildFileChooser()
Builds file choosers using specified data.
JAscFileChooser getFileChooserById(java.lang.String fileChooserId)
Returns JAscFileChooser object with specified file chooser id fileChooserId.
JAscFileChooser putFileChooser(java.lang.String fileChooserId, JAscFileChooser jAscFileChooser)
Maps the specified fileChooserId to the specified jAscFileChooser.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail
FileChooserManager
public FileChooserManager(java.lang.String menuFileChooserFileName) throws java.lang.Exception

Creates new FileChooserManager given the name of the xml file to read from.

Parameters:
menuFileChooserFileName - xml file name to read data from
Throws:
java.lang.Exception - if failed to read file

FileChooserManager
public FileChooserManager(java.io.InputStream inputStream) throws java.lang.Exception
Creates new FileChooserManager given the InputStream to read from.

Parameters:
inputStream - InputStream to read from
Throws:
java.lang.Exception - if failed to read stream
Method Detail
buildFileChooser
public void buildFileChooser() throws java.lang.Exception
Builds file choosers using specified data.

Throws:
java.lang.Exception - if failed to build

getFileChooserById
public JAscFileChooser getFileChooserById(java.lang.String fileChooserId)
Returns JAscFileChooser object with specified file chooser id fileChooserId. fileChooserId cannot be null.

Parameters:
fileChooserId - id of JAscFileChooser
Returns:
JAscFileChooser object with specified file chooser id fileChooserId.

putFileChooser
public JAscFileChooser putFileChooser(java.lang.String fileChooserId, JAscFileChooser jAscFileChooser)
Maps the specified fileChooserId to the specified jAscFileChooser. Neither the fileChooserId nor the jAscFileChooser can be null.

The jAscFileChooser can be retrieved by calling the getFileChooserById(String) method with a id that is equal to the original id.

Parameters:
fileChooserId - id of the specified file chooser
jAscFileChooser - file chooser to hold in this FileChooserManager
Returns:
the previous value of the specified id in this FileChooserManager, or null if it did not have one.
Home about services products contact login