io
Class OpenPreviewDialog

java.lang.Object
  |
  +--io.OpenPreviewDialog
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.ItemListener, java.awt.event.WindowListener
Direct Known Subclasses:
OIDReconstructor

public class OpenPreviewDialog
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener

Convenient file open dialog that can show header info (any you want, just extend this class). (c) 2003 Michael Abramoff. All rights reserved.


Field Summary
protected  java.awt.Button cancel
           
protected  boolean canceling
          Whether you are canceling at end of dialog.
protected  boolean canListRoots
           
protected  java.awt.Choice choiceDir
           
protected  java.awt.Dialog dialog
           
protected static java.lang.String directory
           
protected  FileAndString[] dirs
           
protected  java.lang.Object filter
           
protected  int indexOfCurrentDir
          Holds the index in the list of "directory".
protected  java.awt.List list
           
protected  java.lang.String[] names
          The names of the files that were selected, null if no selection.
protected  java.awt.Button open
           
protected  java.awt.Panel panel
           
protected  java.awt.TextArea textarea
           
protected  FileAndString[] validFiles
           
 
Constructor Summary
OpenPreviewDialog(java.lang.String title, java.lang.Object filter, java.lang.String directory)
          Open a preview open dialog, a dialog that shows a list of files in the directory, and shows a text (currently header text) related to that file, to ease selection.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
           
protected  void addPathTree(java.util.Vector v, java.io.File current)
          Add the whole path for File current to the end of v.
 java.lang.String getDirectory()
           
 java.lang.String[] getFileNames()
          End events coming from dialogwindow.
protected  FileAndString[] getTree(java.lang.String path)
          Build a sequence of File's representing the full path of the path String up to root, and also include the roots both before and after path.
 void itemStateChanged(java.awt.event.ItemEvent ie)
           
protected  void selectedFileNames()
          Get the filenames that were selected as an array of Strings.
protected  void showDirs(java.awt.Choice choiceDir, java.lang.String directory)
          Fill the choiceDir with all directory names up to the current directory and all roots.
protected  void showFileHeader(java.io.File file)
           
protected  void showFiles(java.awt.List list, java.lang.String directory, java.lang.Object filter)
          Fill the list with all files from the directory that fit filter.
protected  java.lang.String validFileDescription(java.io.File file)
          Return a descrpiptive String to display the file.
 void windowActivated(java.awt.event.WindowEvent e)
          All events coming from Dialog window.
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
           
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dialog

protected java.awt.Dialog dialog

directory

protected static java.lang.String directory

names

protected java.lang.String[] names
The names of the files that were selected, null if no selection.

textarea

protected java.awt.TextArea textarea

validFiles

protected FileAndString[] validFiles

dirs

protected FileAndString[] dirs

list

protected java.awt.List list

open

protected java.awt.Button open

cancel

protected java.awt.Button cancel

choiceDir

protected java.awt.Choice choiceDir

filter

protected java.lang.Object filter

canListRoots

protected boolean canListRoots

canceling

protected boolean canceling
Whether you are canceling at end of dialog.

panel

protected java.awt.Panel panel

indexOfCurrentDir

protected int indexOfCurrentDir
Holds the index in the list of "directory".
Constructor Detail

OpenPreviewDialog

public OpenPreviewDialog(java.lang.String title,
                         java.lang.Object filter,
                         java.lang.String directory)
Open a preview open dialog, a dialog that shows a list of files in the directory, and shows a text (currently header text) related to that file, to ease selection. The user can select Open or Cancel.
Parameters:
title - the title of the dialog
directory - the directory the dialog will open
filter - a FilenameFilter that filters names for display.
Method Detail

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent ie)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

actionPerformed

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

selectedFileNames

protected void selectedFileNames()
Get the filenames that were selected as an array of Strings. Modifies names. Uses list.

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
All events coming from Dialog window.
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
Specified by:
windowClosed in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Specified by:
windowClosing in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Specified by:
windowOpened in interface java.awt.event.WindowListener

getFileNames

public java.lang.String[] getFileNames()
End events coming from dialogwindow.

getDirectory

public java.lang.String getDirectory()

showFileHeader

protected void showFileHeader(java.io.File file)

showFiles

protected void showFiles(java.awt.List list,
                         java.lang.String directory,
                         java.lang.Object filter)
Fill the list with all files from the directory that fit filter. Modifies validFiles for navigating.
Parameters:
list - a java.awt.List with all filenames.
directory - the directory from which you want the files/filenames
filter - a FilenameFilter to accept the type of file to show up in files.

validFileDescription

protected java.lang.String validFileDescription(java.io.File file)
Return a descrpiptive String to display the file.
Parameters:
file - the File.
Returns:
a String.

showDirs

protected void showDirs(java.awt.Choice choiceDir,
                        java.lang.String directory)
Fill the choiceDir with all directory names up to the current directory and all roots. Modifies dirs.
Parameters:
choiceDir - a Choice GUI item that contains a list of directories.
directoy - the name of the directory you want to fill choiceDir with.

getTree

protected FileAndString[] getTree(java.lang.String path)
Build a sequence of File's representing the full path of the path String up to root, and also include the roots both before and after path. Modifies indexOfCurrentDir.
Parameters:
path - a String with the path for which you want the tree.

addPathTree

protected void addPathTree(java.util.Vector v,
                           java.io.File current)
Add the whole path for File current to the end of v.