org.annotation.wordfreak
Class AnnotatedFileManager

java.lang.Object
  extended byorg.annotation.wordfreak.AnnotatedFileManager
All Implemented Interfaces:
EventListener, java.util.EventListener, FileRequestListener, ProgressListener, java.awt.event.WindowListener

public class AnnotatedFileManager
extends java.lang.Object
implements EventListener, FileRequestListener, java.awt.event.WindowListener, ProgressListener

Class that handles and disbatches file related events to AnnotatedFileListeners. These events come from this object when it is their FileRequestListener and from the EventManager.

See Also:
AnnotatedFileListener, FileRequestListener, EventManager

Constructor Summary
AnnotatedFileManager()
           
 
Method Summary
 void addAnnotatedFileListener(AnnotatedFileListener adl)
          Registers an AnnotatedFileListener to be notified of file related changes.
 void addGold(java.lang.String filename)
          Adds the annotated file name/path specified by fileName to the set of gold files.
 boolean allAnnotatedFilesSaved()
          Returns true is all annotated files have been saved, false otherwise.
 boolean closeAnnotatedFile(java.lang.String annFileName)
          Returns true if the the annotated file specified by annFileName could be closed.
 boolean eventTranspired(java.lang.String eventType, java.lang.Object source)
           
 java.io.File getAnnotatedFile(java.lang.String sourceFileName)
          Returns a likly annotated file for this source file name.
 int getFileCount()
          Returns the number of files which have been opened.
 FileFormat getFileFormat(javax.swing.filechooser.FileFilter ff)
          Returns the file format associated with the specified file filter.
 FileFormat getFileFormat(java.lang.String name)
          Returns the file format associated with the specified file format name.
 FileFormat getFileFormatForFile(java.lang.String fileName)
          Returns the file format associated with the specified file name.
 java.util.Iterator getFileFormatNames()
          Returns an iterator over the names of currently loaded file formats.
 AnnotationFile getFileFromPath(java.lang.String p)
          Returns the annotated file associated with the name/path of the file sent as a parameter.
 void incrementProgress()
           
 void incrementProgress(int v)
           
 java.util.Iterator iterator()
          Returns an iterator over the opened files.
 boolean openAnnotatedFile(java.lang.String annFileName)
          Returns true if the source file specified by fileName and its coresponding annotated file could be opened.
 boolean openAnnotatedFile(java.lang.String fileName, java.lang.String annFileName)
          Returns true if the source file specified by fileName and the annotated file specified by annFileName could be opened.'
 boolean openAnnotatedFile(java.lang.String fileName, java.lang.String annFileName, AnnotatedFileFormat format)
           
 boolean openAnnotationGraphFile(java.lang.String signal, java.lang.String fileName)
           
 void removeAnnotatedFileListener(AnnotatedFileListener adl)
          Un-registers an AnnotatedFileListener.
 void removeGold(java.lang.String filename)
          Removes the annotated file name/path specified by fileName from the set of gold files.
static boolean saveAnnotatedFile(AnnotationFile f, java.lang.String name)
           
 boolean saveAnnotatedFile(AnnotationFile af, java.lang.String name, java.awt.Component source)
           
 boolean saveAnnotatedFile(java.lang.String annFileName)
          Returns true if the the annotated file specified by annFileName could be saved.
static boolean saveTextFile(AnnotationFile f)
           
static boolean saveTextFile(AnnotationFile f, java.lang.String name)
           
 boolean scanAnnotatedFile(java.lang.String fileName, java.lang.String annFileName)
          Returns true if the source file specified by fileName and the annotated file specified by annFileName could be scaned.
 void setAnnotatorNameListener(FilterCriteriaManager l)
           
 java.lang.String[] setFileFormat(java.lang.String file, AnnotatedFileFormat format)
          Assigns the annotated file specified by file to the format specified by format and returns the name of the annotated file and the source file.
 void setFileFormats(java.lang.String[] classes)
           
 void setFilter(AnnotationFilter f)
          Set the saving filter for all files.
 void setProgress(int v)
           
 void windowActivated(java.awt.event.WindowEvent e)
           
 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
 

Constructor Detail

AnnotatedFileManager

public AnnotatedFileManager()
Method Detail

setFileFormats

public void setFileFormats(java.lang.String[] classes)

eventTranspired

public boolean eventTranspired(java.lang.String eventType,
                               java.lang.Object source)
Specified by:
eventTranspired in interface EventListener

setFilter

public void setFilter(AnnotationFilter f)
Description copied from interface: FileRequestListener
Set the saving filter for all files. Only annotations which match this filter will be saved.

Specified by:
setFilter in interface FileRequestListener
Parameters:
f - the filter.

getFileFormatForFile

public FileFormat getFileFormatForFile(java.lang.String fileName)
Description copied from interface: FileRequestListener
Returns the file format associated with the specified file name.

Specified by:
getFileFormatForFile in interface FileRequestListener
Parameters:
fileName - the nae of the file.
Returns:
the FileFormat object associated with the fileName parameter, or null of no file format handles this type of file.

getAnnotatedFile

public java.io.File getAnnotatedFile(java.lang.String sourceFileName)
Description copied from interface: FileRequestListener
Returns a likly annotated file for this source file name.

Specified by:
getAnnotatedFile in interface FileRequestListener
Returns:
Returns a likly annotated file for this source file name, or null if no annotated file could be found.

getFileFormatNames

public java.util.Iterator getFileFormatNames()
Description copied from interface: FileRequestListener
Returns an iterator over the names of currently loaded file formats.

Specified by:
getFileFormatNames in interface FileRequestListener
Returns:
iterator over the names of currently loaded file formats.

getFileFormat

public FileFormat getFileFormat(java.lang.String name)
Description copied from interface: FileRequestListener
Returns the file format associated with the specified file format name.

Specified by:
getFileFormat in interface FileRequestListener
Parameters:
name - the name of the file format.
Returns:
the file format associated with the specified file format name or null if no associated file format exists.

getFileFormat

public FileFormat getFileFormat(javax.swing.filechooser.FileFilter ff)
Description copied from interface: FileRequestListener
Returns the file format associated with the specified file filter.

Specified by:
getFileFormat in interface FileRequestListener
Parameters:
ff - the file filter.
Returns:
the FileFormat object associated with the ff parameter.

setFileFormat

public java.lang.String[] setFileFormat(java.lang.String file,
                                        AnnotatedFileFormat format)
Description copied from interface: FileRequestListener
Assigns the annotated file specified by file to the format specified by format and returns the name of the annotated file and the source file.

Specified by:
setFileFormat in interface FileRequestListener
Parameters:
file - the name of the source file.
format - the format of the file.
Returns:
the name of the annotated file and source file in position 0 and 1 of a String array respectively or null if no file name is appropiate.

scanAnnotatedFile

public boolean scanAnnotatedFile(java.lang.String fileName,
                                 java.lang.String annFileName)
Description copied from interface: FileRequestListener
Returns true if the source file specified by fileName and the annotated file specified by annFileName could be scaned.

Specified by:
scanAnnotatedFile in interface FileRequestListener
Parameters:
fileName - the name/path of the source file to be opene.
annFileName - the name/path of the annotated file to be opened.
Returns:
true if the source file and annotated file were could be scaned.

openAnnotatedFile

public boolean openAnnotatedFile(java.lang.String annFileName)
Description copied from interface: FileRequestListener
Returns true if the source file specified by fileName and its coresponding annotated file could be opened. The annotated file is deduced from the name of the source file.

Specified by:
openAnnotatedFile in interface FileRequestListener
Parameters:
annFileName - the name/path of the source file to be opened.
Returns:
true if the source file and coresponding annotated file were opened.

openAnnotatedFile

public boolean openAnnotatedFile(java.lang.String fileName,
                                 java.lang.String annFileName,
                                 AnnotatedFileFormat format)

openAnnotatedFile

public boolean openAnnotatedFile(java.lang.String fileName,
                                 java.lang.String annFileName)
Description copied from interface: FileRequestListener
Returns true if the source file specified by fileName and the annotated file specified by annFileName could be opened.'

Specified by:
openAnnotatedFile in interface FileRequestListener
Parameters:
fileName - the name/path of the source file to be opene.
annFileName - the name/path of the annotated file to be opened.
Returns:
true if the source file and annotated file were successfully opened.

openAnnotationGraphFile

public boolean openAnnotationGraphFile(java.lang.String signal,
                                       java.lang.String fileName)

getFileCount

public int getFileCount()
Description copied from interface: FileRequestListener
Returns the number of files which have been opened.

Specified by:
getFileCount in interface FileRequestListener
Returns:
the number of files which have been opened.

iterator

public java.util.Iterator iterator()
Description copied from interface: FileRequestListener
Returns an iterator over the opened files.

Specified by:
iterator in interface FileRequestListener
Returns:
an iterator over the opens files.

addAnnotatedFileListener

public void addAnnotatedFileListener(AnnotatedFileListener adl)
Description copied from interface: FileRequestListener
Registers an AnnotatedFileListener to be notified of file related changes.

Specified by:
addAnnotatedFileListener in interface FileRequestListener
Parameters:
adl - the annotated file listener.

removeAnnotatedFileListener

public void removeAnnotatedFileListener(AnnotatedFileListener adl)
Description copied from interface: FileRequestListener
Un-registers an AnnotatedFileListener.

Specified by:
removeAnnotatedFileListener in interface FileRequestListener
Parameters:
adl - the annotated file listener.

saveTextFile

public static boolean saveTextFile(AnnotationFile f)

saveTextFile

public static boolean saveTextFile(AnnotationFile f,
                                   java.lang.String name)

saveAnnotatedFile

public boolean saveAnnotatedFile(AnnotationFile af,
                                 java.lang.String name,
                                 java.awt.Component source)

saveAnnotatedFile

public static boolean saveAnnotatedFile(AnnotationFile f,
                                        java.lang.String name)

saveAnnotatedFile

public boolean saveAnnotatedFile(java.lang.String annFileName)
Description copied from interface: FileRequestListener
Returns true if the the annotated file specified by annFileName could be saved.

Specified by:
saveAnnotatedFile in interface FileRequestListener
Parameters:
annFileName - the name/path of the annotated file to be saved.
Returns:
true if the annotated file was succ.

closeAnnotatedFile

public boolean closeAnnotatedFile(java.lang.String annFileName)
Description copied from interface: FileRequestListener
Returns true if the the annotated file specified by annFileName could be closed.

Specified by:
closeAnnotatedFile in interface FileRequestListener
Parameters:
annFileName - the name/path of the annotated file to be closed.
Returns:
true if the annotated file was succussfully closed, false otherwise.

allAnnotatedFilesSaved

public boolean allAnnotatedFilesSaved()
Description copied from interface: FileRequestListener
Returns true is all annotated files have been saved, false otherwise.

Specified by:
allAnnotatedFilesSaved in interface FileRequestListener
Returns:
returns true is all annotated files have been saved, false otherwise.

getFileFromPath

public AnnotationFile getFileFromPath(java.lang.String p)
Description copied from interface: FileRequestListener
Returns the annotated file associated with the name/path of the file sent as a parameter.

Specified by:
getFileFromPath in interface FileRequestListener
Parameters:
p - the file name/path.
Returns:
the annotated file associated with the parameter p.

setProgress

public void setProgress(int v)
Specified by:
setProgress in interface ProgressListener

incrementProgress

public void incrementProgress()
Specified by:
incrementProgress in interface ProgressListener

incrementProgress

public void incrementProgress(int v)
Specified by:
incrementProgress in interface ProgressListener

windowOpened

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

windowClosing

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

windowClosed

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

windowIconified

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

windowDeiconified

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

windowActivated

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

windowDeactivated

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

setAnnotatorNameListener

public void setAnnotatorNameListener(FilterCriteriaManager l)

addGold

public void addGold(java.lang.String filename)
Description copied from interface: FileRequestListener
Adds the annotated file name/path specified by fileName to the set of gold files.

Specified by:
addGold in interface FileRequestListener
Parameters:
filename - the name/path of the annotated file.

removeGold

public void removeGold(java.lang.String filename)
Description copied from interface: FileRequestListener
Removes the annotated file name/path specified by fileName from the set of gold files.

Specified by:
removeGold in interface FileRequestListener
Parameters:
filename - the name/path of the annotated file.


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.