Package adams.gui.workspace
Class AbstractWorkspaceHelper<P extends AbstractWorkspacePanel,M extends AbstractWorkspaceManagerPanel<P>>
- java.lang.Object
-
- adams.gui.workspace.AbstractWorkspaceHelper<P,M>
-
- Direct Known Subclasses:
InvestigatorWorkspaceHelper
public abstract class AbstractWorkspaceHelper<P extends AbstractWorkspacePanel,M extends AbstractWorkspaceManagerPanel<P>> extends Object
Helper class for loading/saving workspaces.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description AbstractWorkspaceHelper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description P
copy(M manager, P panel, MessageCollection errors)
Copies a panel.protected abstract void
deserialize(P panel, Object data, MessageCollection errors)
Deserializes the data for the panel.SerializationFileChooser
newFileChooser()
Creates a filechooser for loading/saving workspaces.void
read(File file, AbstractObjectReader reader, M manager, MessageCollection errors)
Reads the session and initializes the manager panel.protected abstract Object
serialize(P panel)
Returns the object that represents the panel's serialized state.String
write(M manager, File file, AbstractObjectWriter writer)
Saves the panel session to the given file.
-
-
-
Method Detail
-
serialize
protected abstract Object serialize(P panel) throws Exception
Returns the object that represents the panel's serialized state.- Parameters:
panel
- the panel to serialize- Returns:
- the object to serialize
- Throws:
Exception
- if serialization fails
-
write
public String write(M manager, File file, AbstractObjectWriter writer) throws Exception
Saves the panel session to the given file.- Parameters:
manager
- the panel to savefile
- the file to save the workspace to- Returns:
- null if successful, otherwise error message
- Throws:
Exception
- if serialization/saving fails
-
deserialize
protected abstract void deserialize(P panel, Object data, MessageCollection errors) throws Exception
Deserializes the data for the panel.- Parameters:
panel
- the panel to populatedata
- the data to deserializeerrors
- for storing errors- Throws:
Exception
- if deserialization fails
-
read
public void read(File file, AbstractObjectReader reader, M manager, MessageCollection errors) throws Exception
Reads the session and initializes the manager panel.- Parameters:
file
- the file to load the session fromreader
- the reader to use for loading the serialized filemanager
- the manager panel to initialize with the sessionerrors
- for storing errors- Throws:
Exception
- if loading fails
-
copy
public P copy(M manager, P panel, MessageCollection errors) throws Exception
Copies a panel.- Parameters:
manager
- the manager panel to usepanel
- the panel to copyerrors
- for storing errors- Returns:
- the copy
- Throws:
Exception
- if copying fails
-
newFileChooser
public SerializationFileChooser newFileChooser()
Creates a filechooser for loading/saving workspaces.- Returns:
- the filechooser
-
-