|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.Errorable
ewe.io.FileSaver
| Field Summary | |
String |
defaultExtension
This is the default extension for the file name. |
protected String |
defaultFileName
|
boolean |
dontAppendLineFeed
This applies for saving text. |
Exception |
exception
This is set to any exception that may have occured during loading/saving. |
File |
fileModel
This is the file model to use. |
boolean |
hasChanged
This says whether the current file has been changed. |
boolean |
ignoreParentFrame
Set this true to always ignore the parent Frame and have all new Frames appear in their own window. |
String |
lastSaved
This is the last file that was saved. |
Vector |
masks
This is a list of masks to be sent to the FileChooser. |
String |
openTitle
This is the title of the file open box. |
String |
persistentHistoryKey
This is assigned to the persistentHistoryKey of the FileChooser created. |
boolean |
reportIOErrors
If this is true then any IO errors encountered during doSave() or doOpen() is reported. |
String |
saveTitle
This is the title of the file save box. |
TextCodec |
textCodec
You can set this to a textCodec to use for reading and writing text data using this FileSaver. |
| Fields inherited from class ewe.util.Errorable |
error |
| Constructor Summary | |
FileSaver()
|
|
FileSaver(String defaultFileName)
|
|
FileSaver(String defaultFileName,
String actualFileName)
|
|
| Method Summary | |
boolean |
checkExit(Form f,
Object dataToSave,
int retCode)
A Form can call this when the user has requested to close the Form. |
boolean |
checkSave(Object data,
Frame parent)
If hasChanged is true, this will attempt to save the current object by prompting the user to confirm saving changes. |
protected boolean |
closeAndReturn(String fileName,
Frame parent,
Stream s,
boolean success)
|
boolean |
doOpen(Object toOpen,
String fileName,
Frame parent)
This attempts an open operation on the data - and you should override this as necessary. |
boolean |
doSave(Object toSave,
String fileName,
Frame parent)
This attempts a save operation on the data - and you should override this as necessary. |
Exception |
getException()
|
protected FileChooserParameters |
getFileChooser(String type,
String initial,
File model)
|
boolean |
getHasChanged()
|
String |
getInitialFile()
|
protected Stream |
getInputStream(String fileName,
Frame parent)
This creates a Stream to read from to the source file name. |
String |
getLastSaved()
|
protected Stream |
getOutputStream(String fileName,
Frame parent)
This creates a Stream to write to the destination file name. |
File |
getSavedFile()
This returns the last saved or opened File. |
boolean |
newData(Object oldData,
String newFileName,
Frame parent)
This tells the FileSaver that new data is about to be created and that the old data should be saved if it has been changed. |
void |
newData(String newFileName)
This sets hasChanged to false and lastSaved to newFileName. |
void |
onEvent(Event ev)
|
String |
open(Frame parent)
This brings up a FileChooser box to let the user select a file to open. |
boolean |
open(Object oldData,
Object newData,
Frame parent)
This attempts to open a file, after saving the old file if necessary. |
String |
open(String oldData,
Frame parent)
This opens and reads the file as a string. |
String |
openText(String fileName,
Frame parent)
|
protected boolean |
returnError(String error,
Frame parent)
|
boolean |
save(boolean saveAs,
Object data,
Frame parent)
This attempts to save the file. |
String |
save(Frame parent)
This returns a String which is the file name of the destination to save to. |
String |
saveAs(Frame parent)
This brings up the FileChooser box and lets the user select a file to save to. |
void |
setDefaultFileType(String extension,
String description)
This will sets the default file type and adds the mask to the list of masks. |
void |
setHasChanged(boolean hasChanged)
|
void |
setLastSaved(String lastSaved)
|
boolean |
tryOpen(Object data,
String file,
Frame parent)
|
String |
tryOpen(String file,
Frame parent)
This checks if the specified file is readable. |
| Methods inherited from class ewe.util.Errorable |
returnError, returnError, returnError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public File fileModel
public String lastSaved
protected String defaultFileName
public String defaultExtension
public String saveTitle
public String openTitle
public Vector masks
public Exception exception
public String persistentHistoryKey
public boolean ignoreParentFrame
public TextCodec textCodec
public boolean dontAppendLineFeed
public boolean hasChanged
public boolean reportIOErrors
| Constructor Detail |
public FileSaver()
public FileSaver(String defaultFileName)
public FileSaver(String defaultFileName,
String actualFileName)
| Method Detail |
public void setDefaultFileType(String extension,
String description)
public String save(Frame parent)
public String getInitialFile()
protected FileChooserParameters getFileChooser(String type,
String initial,
File model)
public String saveAs(Frame parent)
public String tryOpen(String file,
Frame parent)
public boolean tryOpen(Object data,
String file,
Frame parent)
public String open(Frame parent)
public void newData(String newFileName)
public boolean checkSave(Object data,
Frame parent)
This method return true if:
protected boolean returnError(String error,
Frame parent)
protected Stream getOutputStream(String fileName,
Frame parent)
throws IOException
fileName - The file name to write to.parent - The parent frame (may be null).
IOException - if no Stream to the file could be created. If reportIOErrors is true, then
the exception will be displayed in a standard exception dialog.
protected Stream getInputStream(String fileName,
Frame parent)
throws IOException
fileName - The file name to read from.parent - The parent frame (may be null).
IOException - if no Stream to the file could be created. If reportIOErrors is true, then
the exception will be displayed in a standard exception dialog.
protected boolean closeAndReturn(String fileName,
Frame parent,
Stream s,
boolean success)
public boolean doSave(Object toSave,
String fileName,
Frame parent)
public boolean doOpen(Object toOpen,
String fileName,
Frame parent)
public boolean open(Object oldData,
Object newData,
Frame parent)
public String openText(String fileName,
Frame parent)
public String open(String oldData,
Frame parent)
oldData - Data to check for saving first (may be null).parent - The parent Frame (may be null).
public boolean save(boolean saveAs,
Object data,
Frame parent)
public boolean newData(Object oldData,
String newFileName,
Frame parent)
public void onEvent(Event ev)
onEvent in interface EventListener
public boolean checkExit(Form f,
Object dataToSave,
int retCode)
f - The Form checking for exit.retCode - The return code the Form should exit with.
public File getSavedFile()
public String getLastSaved()
public boolean getHasChanged()
public Exception getException()
public void setHasChanged(boolean hasChanged)
public void setLastSaved(String lastSaved)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||