uk.ac.essex.common.io
Class FileOpImpl<T extends ApplicationFile>

java.lang.Object
  extended by uk.ac.essex.common.io.FileOp<T>
      extended by uk.ac.essex.common.io.FileOpImpl<T>
Direct Known Subclasses:
ImageFileOp, OperationFileOp

public abstract class FileOpImpl<T extends ApplicationFile>
extends FileOp<T>

A default implementation of a FileOp that provides implementations that use a JFileChooser to obtain the file the user wants to open/save. This can be a custom file chosser if necessary
Date: 15-Jul-2002


Field Summary
protected  java.awt.Component currentCaller
           
protected  javax.swing.JFileChooser fileChooser
          The file fileChooser
static java.lang.String LAST_DIR
           
protected  java.io.File lastDir
           
 
Fields inherited from class uk.ac.essex.common.io.FileOp
file
 
Constructor Summary
FileOpImpl()
          The file fileChooser is just a plain old JFileChooser.
FileOpImpl(javax.swing.JFileChooser chooser)
          Sets the file fileChooser to be whatever you want
 
Method Summary
abstract  java.lang.String getDefaultEnding()
          Gets the default file ending to postfix to the file name, this is only used if the file to save to has not been given by the user.
 javax.swing.JFileChooser getFileChooser()
           
protected  boolean hasEnding(java.io.File f)
           
 T open(java.awt.Component caller)
          Open an operation from disk.
abstract  T openFile(java.io.File file)
           
 boolean saveAs(T applicationFile, java.awt.Component caller)
          Save a given app file under a new name/file.
 void setFileChooser(javax.swing.JFileChooser fileChooser)
           
 
Methods inherited from class uk.ac.essex.common.io.FileOp
getFile, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAST_DIR

public static final java.lang.String LAST_DIR
See Also:
Constant Field Values

fileChooser

protected javax.swing.JFileChooser fileChooser
The file fileChooser


lastDir

protected java.io.File lastDir

currentCaller

protected java.awt.Component currentCaller
Constructor Detail

FileOpImpl

public FileOpImpl()
The file fileChooser is just a plain old JFileChooser.


FileOpImpl

public FileOpImpl(javax.swing.JFileChooser chooser)
Sets the file fileChooser to be whatever you want

Parameters:
chooser -
Method Detail

getDefaultEnding

public abstract java.lang.String getDefaultEnding()
Gets the default file ending to postfix to the file name, this is only used if the file to save to has not been given by the user.

Returns:
String - The default file ending to postfix to the file name

openFile

public abstract T openFile(java.io.File file)
Parameters:
file -

getFileChooser

public javax.swing.JFileChooser getFileChooser()
Returns:
JFileChooser - the file fileChooser being used

setFileChooser

public void setFileChooser(javax.swing.JFileChooser fileChooser)
Parameters:
fileChooser - - The file fileChooser to use to get the required File from the user

open

public T open(java.awt.Component caller)
Open an operation from disk. Shows a dialog so users can choose the file to open. The object returned can be casted to the type OperationGraph.

Specified by:
open in class FileOp<T extends ApplicationFile>
Parameters:
caller - - The parent Component of the file fileChooser dialog
Returns:
the OperationGraph selected
See Also:
openFile(java.io.File)

saveAs

public boolean saveAs(T applicationFile,
                      java.awt.Component caller)
Save a given app file under a new name/file. Users are presented with a file fileChooser dialog so they can select where to save the file. If the file is choosen, then this just calls FileOp.save(T) to do the actual saving of the file.

Specified by:
saveAs in class FileOp<T extends ApplicationFile>
Parameters:
applicationFile - - The file to save
caller - - The parent Component of the file fileChooser dialog
Returns:
boolean - true if the file saved ok, false otherwise
See Also:
FileOp.save(T)

hasEnding

protected boolean hasEnding(java.io.File f)
Parameters:
f - - The file whose name to check
Returns:
true if the file has an ending ie/ '.XXX', false otherwise