Package weka.gui.explorer
Class WorkspaceHelper
- java.lang.Object
-
- weka.gui.explorer.WorkspaceHelper
-
public class WorkspaceHelper extends Object
Helper class for loading/saving workspaces.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected static HashMap<Class,AbstractExplorerPanelHandler>
m_AdditionalHandlers
the additional associations betweenExplorer.ExplorerPanel
andAbstractExplorerPanelHandler
.
-
Constructor Summary
Constructors Constructor Description WorkspaceHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExplorerExt
copy(ExplorerExt expext, boolean skipHistory)
Copies an explorer instance.protected static Object[]
deserialize(ObjectInputStream ois)
Deserializes an explorer instance from the input stream.protected static Hashtable<String,Object>
getExplorerOptions(weka.gui.explorer.Explorer explorer)
Obtains the options from the explorer to be saved in the workspace.protected static AbstractExplorerPanelHandler[]
getHandlers()
Returns all available handlers, with theDefaultHandler
being the last one.static BaseFileChooser
newFileChooser()
Creates a filechooser for loading/saving workspaces.static void
read(File file, MultiExplorer explorer)
Reads the explorer session and initializes the explorer object.static void
registerAdditionalHandler(Class explorerPanel, AbstractExplorerPanelHandler handler)
Registers an additional handler for anExplorer.ExplorerPanel
.protected static void
serialize(ExplorerExt expext, String name, ObjectOutputStream oos, boolean skipHistory)
Serializes the explorer instance to the output stream.protected static void
setExplorerOptions(weka.gui.explorer.Explorer explorer, Hashtable<String,Object> options)
Restores the Explorer options from the hashtable.static void
write(MultiExplorer explorer, File file)
Saves the explorer session to the given file.
-
-
-
Field Detail
-
m_AdditionalHandlers
protected static HashMap<Class,AbstractExplorerPanelHandler> m_AdditionalHandlers
the additional associations betweenExplorer.ExplorerPanel
andAbstractExplorerPanelHandler
.
-
-
Method Detail
-
registerAdditionalHandler
public static void registerAdditionalHandler(Class explorerPanel, AbstractExplorerPanelHandler handler)
Registers an additional handler for anExplorer.ExplorerPanel
.- Parameters:
explorerPanel
- the panel to register the handler forhandler
- the handler to register
-
newFileChooser
public static BaseFileChooser newFileChooser()
Creates a filechooser for loading/saving workspaces.- Returns:
- the filechooser
-
getHandlers
protected static AbstractExplorerPanelHandler[] getHandlers() throws Exception
Returns all available handlers, with theDefaultHandler
being the last one.- Returns:
- the handlers
- Throws:
Exception
- if instantiation of handlers fails
-
getExplorerOptions
protected static Hashtable<String,Object> getExplorerOptions(weka.gui.explorer.Explorer explorer)
Obtains the options from the explorer to be saved in the workspace.- Parameters:
explorer
- the explorer to extract the options from- Returns:
- the options
-
serialize
protected static void serialize(ExplorerExt expext, String name, ObjectOutputStream oos, boolean skipHistory) throws Exception
Serializes the explorer instance to the output stream.- Parameters:
expext
- the explorer to serializename
- the name of the exploreroos
- the output streamskipHistory
- whether to skip copying the history- Throws:
Exception
- if serialization fails
-
write
public static void write(MultiExplorer explorer, File file) throws Exception
Saves the explorer session to the given file.- Parameters:
explorer
- the explorer to savefile
- the file to save the workspace to- Throws:
Exception
- if saving fails
-
setExplorerOptions
protected static void setExplorerOptions(weka.gui.explorer.Explorer explorer, Hashtable<String,Object> options)
Restores the Explorer options from the hashtable.- Parameters:
explorer
- the explorer to restoreoptions
- the settings of the session
-
deserialize
protected static Object[] deserialize(ObjectInputStream ois) throws Exception
Deserializes an explorer instance from the input stream.- Parameters:
ois
- the input stream to read- Returns:
- the name (= 0) and the explorer instance (= 1)
- Throws:
Exception
- if deserialization fails
-
read
public static void read(File file, MultiExplorer explorer) throws Exception
Reads the explorer session and initializes the explorer object.- Parameters:
file
- the file to load the session fromexplorer
- the explorer to initialize with the session- Throws:
Exception
- if loading fails
-
copy
public static ExplorerExt copy(ExplorerExt expext, boolean skipHistory) throws Exception
Copies an explorer instance.- Parameters:
expext
- the explorer instance to copyskipHistory
- whether to skip copying the history- Returns:
- the copy
- Throws:
Exception
- if copying fails
-
-