Package com.illumon.iris.gui.workspace
Class WorkspaceManager
java.lang.Object
com.illumon.iris.gui.workspace.WorkspaceManager
public class WorkspaceManager extends Object
This class handles all instances of
Workspaces
including the saving and restoring of.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WorkspaceManager.Context
An ISavedWorkspaceData that contains the path to the workspace file.static interface
WorkspaceManager.LoadingWorkspaceListener
static class
WorkspaceManager.SaveType
static class
WorkspaceManager.WorkspaceException
-
Field Summary
Fields Modifier and Type Field Description static DateTimeFormatter
fileTimeFormatter
protected static WorkspaceManager
instance_
protected com.fishlib.io.logger.Logger
log
static String
TYPE_ATTR
static String
VERSION_ATTR
static String
WRITE_TIME_ATTR
static DateTimeFormatter
writeTimeFormatter
-
Constructor Summary
Constructors Modifier Constructor Description protected
WorkspaceManager()
-
Method Summary
Modifier and Type Method Description void
addLoadingWorkspaceListener(WorkspaceManager.LoadingWorkspaceListener listener)
void
addTranscoder(WorkspaceTranscoder transcoder)
void
addWorkSpace(String name, Workspace workspace)
Add a workspace to be managed, copying any previously stored workspace.void
addWorkSpace(String name, Workspace workspace, boolean copyPrevious)
Add a workspace to be managed, optionally copying any previously stored workspace.void
checkedSave()
Save the current workspace to a file with the same name, suffixed with the date and time.void
checkedSave(Path workspacePath)
Save the current workspace to a file with the same name, suffixed with the date and time.void
exportShare(Path workspacePath, WorkspaceExporter exporter)
Exports a subset the current workspace to a file.Collection<SavedWorkspace>
getAutoSavedWorkspaces()
Get a collection containing all of the loadable auto saved workspaces.static WorkspaceManager
getInstance()
Collection<SavedWorkspace>
getSavedWorkspaces()
Get a collection containing all of the loadable workspaces.Workspace
getWorkspace(String name)
void
load()
Load the most recently used workspace.void
load(SavedWorkspace workspace)
Load the specifiedSavedWorkspace
, attempting to convert it to the most recent version if requiredvoid
load(SavedWorkspace workspace, WorkspaceImporter importer)
Load the specifiedSavedWorkspace
, attempting to convert it to the most recent version if requiredvoid
removeWorkspace(Workspace workspace)
void
save()
Save the current workspace to a file with the same name suffixed with the date and time ignoring any exceptions.void
setStandAloneMode(boolean standAloneMode)
void
startAutoSave()
Starts the periodic execution of Auto Save.void
stopAutoSave()
Stops the periodic execution of Auto Save.SavedWorkspace
tryGetSavedWorkspace(com.fishlib.io.logger.Logger log, Path path)
Try to create a SavedWorkspace at any version from the specified path.SavedWorkspace
tryGetSavedWorkspace(com.fishlib.io.logger.Logger log, Path path, int desiredVersion)
Try to create a SavedWorkspace at the desired version from the specified path.
-
Field Details
-
VERSION_ATTR
- See Also:
- Constant Field Values
-
WRITE_TIME_ATTR
- See Also:
- Constant Field Values
-
TYPE_ATTR
- See Also:
- Constant Field Values
-
writeTimeFormatter
-
fileTimeFormatter
-
instance_
-
log
protected final com.fishlib.io.logger.Logger log
-
-
Constructor Details
-
WorkspaceManager
protected WorkspaceManager()
-
-
Method Details
-
addTranscoder
-
getInstance
-
setStandAloneMode
public void setStandAloneMode(boolean standAloneMode) -
startAutoSave
public void startAutoSave()Starts the periodic execution of Auto Save. -
stopAutoSave
public void stopAutoSave()Stops the periodic execution of Auto Save. -
load
Load the specifiedSavedWorkspace
, attempting to convert it to the most recent version if required- Parameters:
workspace
- The workspace to load- Throws:
WorkspaceManager.WorkspaceException
- If any problem occurs during the workspace load.
-
load
public void load(SavedWorkspace workspace, WorkspaceImporter importer) throws WorkspaceManager.WorkspaceExceptionLoad the specifiedSavedWorkspace
, attempting to convert it to the most recent version if required- Parameters:
workspace
- The workspace to loadimporter
- An optional workspace importer, can be null- Throws:
WorkspaceManager.WorkspaceException
- If any problem occurs during the workspace load.
-
load
Load the most recently used workspace.- Throws:
WorkspaceManager.WorkspaceException
- If a problem occurred during the load.
-
save
public void save()Save the current workspace to a file with the same name suffixed with the date and time ignoring any exceptions. -
exportShare
public void exportShare(Path workspacePath, WorkspaceExporter exporter) throws WorkspaceManager.WorkspaceExceptionExports a subset the current workspace to a file.- Parameters:
workspacePath
- the path to save the workspaceexporter
- the Workspace Export to perform the export- Throws:
WorkspaceManager.WorkspaceException
- If any problem occurred during the save.
-
checkedSave
Save the current workspace to a file with the same name, suffixed with the date and time.- Throws:
WorkspaceManager.WorkspaceException
- If any problem occurred during the save.
-
checkedSave
Save the current workspace to a file with the same name, suffixed with the date and time.- Parameters:
workspacePath
- the path to save the workspace- Throws:
WorkspaceManager.WorkspaceException
- If any problem occurred during the save.
-
addWorkSpace
Add a workspace to be managed, copying any previously stored workspace.- Parameters:
name
- The name of the workspaceworkspace
- The workspace to be saved.
-
addWorkSpace
Add a workspace to be managed, optionally copying any previously stored workspace.- Parameters:
name
- The name of the workspace.workspace
- The workspace to be saved.copyPrevious
- Iftrue
any previous workspace will be copied.
-
getWorkspace
-
removeWorkspace
-
addLoadingWorkspaceListener
-
getSavedWorkspaces
Get a collection containing all of the loadable workspaces.- Returns:
- All of the workspaces that can be directly loaded, or converted and loaded.
-
getAutoSavedWorkspaces
Get a collection containing all of the loadable auto saved workspaces.- Returns:
- All of the auto saved workspaces that can be directly loaded, or converted and loaded.
-
tryGetSavedWorkspace
public SavedWorkspace tryGetSavedWorkspace(com.fishlib.io.logger.Logger log, @NotNull Path path, int desiredVersion)Try to create a SavedWorkspace at the desired version from the specified path.- Parameters:
log
- the loggerpath
- The path to the workspace to try to parsedesiredVersion
- the desired version of the workspace- Returns:
- A SavedWorkspace or null if the workspace couldn't be parsed.
-
tryGetSavedWorkspace
Try to create a SavedWorkspace at any version from the specified path.- Parameters:
log
- the loggerpath
- The path to the workspace to try to parse- Returns:
- A SavedWorkspace or null if the workspace couldn't be parsed.
-