summaryrefslogtreecommitdiffstats
path: root/logo/src/xlogo/storage/global/GlobalConfig.java
diff options
context:
space:
mode:
authorMarko Živković <[email protected]>2015-03-04 01:41:52 +0000
committerMarko Živković <[email protected]>2015-03-04 01:41:52 +0000
commit23316d54f1070101a4e5d618e8689d8edaea0b34 (patch)
tree1fe0b9d10a4b8691988735b4edb9243d116158ae /logo/src/xlogo/storage/global/GlobalConfig.java
parent094911feca43980c4f81582dfd8cdc0ad8faed71 (diff)
Fix USB drive detection problems by using USBWorkspaceManager and refactoring related things
git-svn-id: https://svn.code.sf.net/p/xlogo4schools/svn/trunk@35 3b0d7934-f7ef-4143-9606-b51f2e2281fd
Diffstat (limited to 'logo/src/xlogo/storage/global/GlobalConfig.java')
-rw-r--r--logo/src/xlogo/storage/global/GlobalConfig.java34
1 files changed, 11 insertions, 23 deletions
diff --git a/logo/src/xlogo/storage/global/GlobalConfig.java b/logo/src/xlogo/storage/global/GlobalConfig.java
index 6195142..61beb9f 100644
--- a/logo/src/xlogo/storage/global/GlobalConfig.java
+++ b/logo/src/xlogo/storage/global/GlobalConfig.java
@@ -25,7 +25,6 @@ package xlogo.storage.global;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.io.File;
-import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
@@ -109,6 +108,12 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
* Logical Workspaces (name and location stored in Map)
*/
private Map<String, String> workspaces;
+
+ public void addWorkspace(StorableObject<WorkspaceConfig, WorkspaceProperty> wc) {
+ File location = wc.getLocation();
+ String name = wc.get().getWorkspaceName();
+ addWorkspace(name, location.getParentFile().toString());
+ }
/**
* @param workspaceName
@@ -118,13 +123,6 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
logger.trace("Adding workspace: '" + workspaceName + "' at " + location);
workspaces.put(workspaceName, location);
publisher.publishEvent(GlobalProperty.WORKSPACES);
- setLastUsedWorkspace(workspaceName);
- }
-
- public void addWorkspace(StorableObject<WorkspaceConfig, WorkspaceProperty> wc) {
- File location = wc.getLocation();
- String name = wc.get().getWorkspaceName();
- addWorkspace(name, location.getParentFile().toString());
}
public void removeWorkspace(String workspaceName) {
@@ -134,7 +132,7 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
leaveWorkspace();
}
- if (lastUsedWorkspace.equals(workspaceName)) {
+ if (workspaceName.equals(lastUsedWorkspace)) {
lastUsedWorkspace = null;
publisher.publishEvent(GlobalProperty.LAST_USED_WORKSPACE);
}
@@ -228,9 +226,8 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
* Load the workspace
* <p>Always succeeds if workspaceName equals {@link WorkspaceConfig#VIRTUAL_WORKSPACE}
* @param workspaceName - the workspace to load and enter
- * @throws IOException - if the workspace could not be loaded
*/
- public void enterWorkspace(StorableObject<WorkspaceConfig, WorkspaceConfig.WorkspaceProperty> wc) throws IOException {
+ public void enterWorkspace(StorableObject<WorkspaceConfig, WorkspaceConfig.WorkspaceProperty> wc) {
String name = wc.get().getWorkspaceName();
logger.trace("Entering workspace: " + name);
if (currentWorkspace != null) {
@@ -241,13 +238,10 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
setLastUsedWorkspace(name);
publisher.publishEvent(GlobalProperty.CURRENT_WORKSPACE);
-
- currentWorkspace.get().enterInitialUserSpace();
}
/**
* Afterwards, currentWorkspace is null
- * @throws IOException If workspace could not be saved.
*/
public void leaveWorkspace() {
if (currentWorkspace == null)
@@ -256,13 +250,7 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
logger.trace("Leaving workspace: " + currentWorkspace.get().getWorkspaceName());
if (currentWorkspace.get().getActiveUser() != null) {
- try {
- currentWorkspace.get().leaveUserSpace();
- }
- catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ currentWorkspace.get().leaveUserSpace();
}
if (currentWorkspace.isDirty())
@@ -458,12 +446,12 @@ public class GlobalConfig implements Serializable, Observable<GlobalConfig.Globa
PATH, PASSWORD, LAST_USED_WORKSPACE, CURRENT_WORKSPACE, WORKSPACES;
}
- private transient PropertyChangePublisher<GlobalProperty> publisher = new PropertyChangePublisher<>();
+ private transient PropertyChangePublisher<GlobalProperty> publisher = new PropertyChangePublisher<GlobalProperty>();
@Override
public void addPropertyChangeListener(GlobalProperty property, PropertyChangeListener listener) {
if (publisher == null){
- publisher = new PropertyChangePublisher<>();
+ publisher = new PropertyChangePublisher<GlobalProperty>();
}
publisher.addPropertyChangeListener(property, listener);
}