ewe.data
Class SaveableObject

java.lang.Object
  extended byewe.data.DataObject
      extended byewe.data.LiveObject
          extended byewe.data.SaveableObject
All Implemented Interfaces:
Comparable, Copyable, DataUnit, FieldListener, LiveData

public class SaveableObject
extends LiveObject


Field Summary
 MenuItem chosenMenuItem
           
static int ExitAction
           
static int NewAction
           
static int OpenAction
           
static int SaveAction
           
 
Constructor Summary
SaveableObject()
           
 
Method Summary
 void Exit_action(Editor ed)
           
protected  void fileExceptionOccured(int whichFileAction, Exception e, FileSaver saver)
          This will be called if an exception occured during processing of a File action.
 void New_action(Editor ed)
           
 void newObject()
          This is used to reset the Object to a "new" state.
 void Open_action(Editor ed)
           
protected  void openedFrom(File opened)
          This is called after a successful open.
 void openObject(File source)
          This is used to retrieve the Object state from a File.
 void Save_action(Editor ed)
           
 void Save_As_action(Editor ed)
           
protected  void savedTo(File saved)
          This is called after a successful save.
 void saveObject(File destination)
          This is used to save the Object state.
 boolean tryOpen(Object source, Editor ed)
          This attempts to open a file to load this object.
 boolean tryOpen(Object source, Editor ed, boolean showOpenIfFailed, boolean showException)
          This attempts to open a file to load this object.
 
Methods inherited from class ewe.data.LiveObject
action, action, addMeToPanel, addObjectToPanel, addToPanel, decode, decoded, decodeFields, enableEditorScrolling, encode, encoded, encodeFields, fieldChanged, fieldChanged, fieldEvent, getEditor, getEditorScroller, getIcon, getName, input, makeNewEditor, runAsApp, textDecode, textEncode
 
Methods inherited from class ewe.data.DataObject
_getSetField, appendAllFields, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, toString
 
Methods inherited from interface ewe.data.DataUnit
copyFrom, getNew
 
Methods inherited from interface ewe.util.Copyable
getCopy
 
Methods inherited from interface ewe.util.Comparable
compareTo
 

Field Detail

chosenMenuItem

public MenuItem chosenMenuItem

NewAction

public static final int NewAction
See Also:
Constant Field Values

OpenAction

public static final int OpenAction
See Also:
Constant Field Values

SaveAction

public static final int SaveAction
See Also:
Constant Field Values

ExitAction

public static final int ExitAction
See Also:
Constant Field Values
Constructor Detail

SaveableObject

public SaveableObject()
Method Detail

newObject

public void newObject()
This is used to reset the Object to a "new" state. By default it will copy from a new instance of this class.


saveObject

public void saveObject(File destination)
                throws IOException
This is used to save the Object state. By default it will convert the object to a text string and then save it.

Throws:
IOException

openObject

public void openObject(File source)
                throws IOException
This is used to retrieve the Object state from a File. By default it will treat the file as a text string and decode it.

Throws:
IOException

fileExceptionOccured

protected void fileExceptionOccured(int whichFileAction,
                                    Exception e,
                                    FileSaver saver)
This will be called if an exception occured during processing of a File action. By default it do nothing if the FileSaver is not null, otherwise it will display a standard ReportException box.

Parameters:
whichFileAction - one of NewAction, OpenAction, SaveAction.
e - The exception that occured.

New_action

public void New_action(Editor ed)

Save_action

public void Save_action(Editor ed)

Save_As_action

public void Save_As_action(Editor ed)

Open_action

public void Open_action(Editor ed)

Exit_action

public void Exit_action(Editor ed)

savedTo

protected void savedTo(File saved)
This is called after a successful save.

Parameters:
saved - The File the object was saved to.

openedFrom

protected void openedFrom(File opened)
This is called after a successful open.


tryOpen

public boolean tryOpen(Object source,
                       Editor ed,
                       boolean showOpenIfFailed,
                       boolean showException)
This attempts to open a file to load this object.

Parameters:
source - The File object or file name String.
ed - The editor used to edit the SaveableObject.
showOpenIfFailed - If this is true then the FileSaver associated with the editor (if any) will be displayed to attempt to open a new File instead.
showException - If this is true then the full file open error will be displayed if an error occured opening the file.
Returns:
true if a file was opened, false otherwise.

tryOpen

public boolean tryOpen(Object source,
                       Editor ed)
This attempts to open a file to load this object.

Parameters:
source - The File object or file name String.
ed - The editor used to edit the SaveableObject.
Returns:
true if a file was opened, false otherwise.