Class WorkspaceHelper


  • public class WorkspaceHelper
    extends Object
    Helper class for loading/saving workspaces.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • WorkspaceHelper

        public WorkspaceHelper()
    • Method Detail

      • registerAdditionalHandler

        public static void registerAdditionalHandler​(Class explorerPanel,
                                                     AbstractExplorerPanelHandler handler)
        Registers an additional handler for an Explorer.ExplorerPanel.
        Parameters:
        explorerPanel - the panel to register the handler for
        handler - the handler to register
      • newFileChooser

        public static BaseFileChooser newFileChooser()
        Creates a filechooser for loading/saving workspaces.
        Returns:
        the filechooser
      • 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 serialize
        name - the name of the explorer
        oos - the output stream
        skipHistory - 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 save
        file - 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 restore
        options - 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 from
        explorer - 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 copy
        skipHistory - whether to skip copying the history
        Returns:
        the copy
        Throws:
        Exception - if copying fails