summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2014-12-22 15:47:21 +0000
committerMarko Živković <[email protected]>2014-12-22 15:47:21 +0000
commit028c461e8a007afe291de3be31c1b685465cea29 (patch)
treeeb7de8ade53c7d1ef08f69fe982498054d068fc3
parent781d9f845a421b7cf04c3a1344a20637ba5f9e4e (diff)
Eliminated bug when creating default workspace
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@19 3b0d7934-f7ef-4143-9606-b51f2e2281fd
-rw-r--r--logo/src/xlogo/storage/global/GlobalConfig.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/logo/src/xlogo/storage/global/GlobalConfig.java b/logo/src/xlogo/storage/global/GlobalConfig.java
index 7e1a6e3..d78ee51 100644
--- a/logo/src/xlogo/storage/global/GlobalConfig.java
+++ b/logo/src/xlogo/storage/global/GlobalConfig.java
@@ -63,7 +63,7 @@ public class GlobalConfig extends StorableObject implements Serializable {
private static Logger logger = LogManager.getLogger(GlobalConfig.class.getSimpleName());
public static final String LOGO_FILE_EXTENSION = ".lgo";
- public static boolean DEBUG = true; // TODO set false
+ public static boolean DEBUG = true; // TODO set false
/**
* Creates the global config at default location, together with a virtual workspace
@@ -75,7 +75,7 @@ public class GlobalConfig extends StorableObject implements Serializable {
catch (IllegalArgumentException ignore) {} // This is thrown if name illegal, but it is legal
workspaces = new TreeMap<String, String>();
workspaces.put(WorkspaceConfig.VIRTUAL_WORKSPACE, "");
- workspaces.put(WorkspaceConfig.USER_DEFAULT_WORKSPACE, WorkspaceConfig.getDefaultWorkspaceDirectory().getAbsolutePath());
+ workspaces.put(WorkspaceConfig.USER_DEFAULT_WORKSPACE, getDefaultLocation().getAbsolutePath());
}
/**
@@ -150,7 +150,7 @@ public class GlobalConfig extends StorableObject implements Serializable {
if(!existingWorkspaces.containsKey(WorkspaceConfig.USER_DEFAULT_WORKSPACE)){
// This might be the case if the GlobalConfig version stored on the disk comes from a version
// that did not contain a default workspace
- existingWorkspaces.put(WorkspaceConfig.USER_DEFAULT_WORKSPACE, WorkspaceConfig.getDefaultWorkspaceLocation().getAbsolutePath());
+ existingWorkspaces.put(WorkspaceConfig.USER_DEFAULT_WORKSPACE, getDefaultLocation().getAbsolutePath());
}
if (lostWorkspaces.size() > 0) {
@@ -202,7 +202,7 @@ public class GlobalConfig extends StorableObject implements Serializable {
* @throws IOException
*/
private WorkspaceConfig retrieveWorkspace(String workspaceName) throws IOException {
- WorkspaceConfig wsc = getLoadedWorkspace(workspaceName);
+ WorkspaceConfig wsc = getCachedWorkspace(workspaceName);
if (wsc != null) {
logger.trace("Retrieving cached workspace: " + workspaceName);
return wsc;
@@ -238,9 +238,10 @@ public class GlobalConfig extends StorableObject implements Serializable {
}
private WorkspaceConfig getDefaultWorkspace() throws IOException{
+ logger.trace("Get Default Workspace");
File wsDir = WorkspaceConfig.getDefaultWorkspaceDirectory();
File wsFile = getFile(wsDir, WorkspaceConfig.class);
- File wsLocation = WorkspaceConfig.getDefaultWorkspaceLocation();
+ File wsLocation = getDefaultLocation();
WorkspaceConfig wsc = null;
if (wsFile.exists()) {
wsc = WorkspaceConfig.loadWorkspace(wsLocation, WorkspaceConfig.USER_DEFAULT_WORKSPACE);
@@ -261,7 +262,7 @@ public class GlobalConfig extends StorableObject implements Serializable {
*/
private transient Map<String, WorkspaceConfig> cachedWorkspaces;
- private WorkspaceConfig getLoadedWorkspace(String workspaceName) {
+ private WorkspaceConfig getCachedWorkspace(String workspaceName) {
if (cachedWorkspaces == null) {
cachedWorkspaces = new TreeMap<String, WorkspaceConfig>();
}
@@ -295,6 +296,10 @@ public class GlobalConfig extends StorableObject implements Serializable {
enterInitialWorkspace();
}
+ public void addWorkspace(String workspaceName, File location) {
+ addWorkspace(workspaceName, location.getAbsolutePath());
+ }
+
public void removeWorkspace(String workspaceName) {
logger.trace("Removing workspace: " + workspaceName);
workspaces.remove(workspaceName);