Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2011-05-18 19:37:14 +0000
committerRyan D. Brooks2011-05-18 19:37:14 +0000
commit2990406c32803b4b02552082b3613702568781a7 (patch)
tree07f54f36c56008dddb346355eb5b7913475a7cc3 /plugins/org.eclipse.osee.framework.plugin.core
parent1bb1a658ff009d68cdcef46391ae68f871a3dd31 (diff)
downloadorg.eclipse.osee-2990406c32803b4b02552082b3613702568781a7.tar.gz
org.eclipse.osee-2990406c32803b4b02552082b3613702568781a7.tar.xz
org.eclipse.osee-2990406c32803b4b02552082b3613702568781a7.zip
refactor: Remove StaticIdManager and auto-caching of all StaticId attributes
Diffstat (limited to 'plugins/org.eclipse.osee.framework.plugin.core')
-rw-r--r--plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java
index 8432f7b3581..96f36d2d3be 100644
--- a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/util/OseeData.java
@@ -36,7 +36,7 @@ import org.eclipse.osee.framework.plugin.core.internal.PluginCoreActivator;
*/
public class OseeData {
private static final IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- private static final String oseeDataPathName = ".osee.data";
+ private static final String oseeDataPathName = "osee.data";
private static final IPath oseeDataPath = workspacePath.append(oseeDataPathName);
private static final File oseeDir = oseeDataPath.toFile();
private static IProject project;
@@ -50,6 +50,22 @@ public class OseeData {
createProject();
}
+ public static void ensureProjectOpen() {
+ if (project != null) {
+ if (!project.isOpen()) {
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, oseeDataPathName + " project is closed; re-opening");
+ openProject();
+ }
+ }
+ }
+
+ public static boolean isProjectOpen() {
+ if (project != null) {
+ return project.isOpen();
+ }
+ return true;
+ }
+
public static IPath getPath() {
return oseeDataPath;
}
@@ -59,6 +75,7 @@ public class OseeData {
}
public static IFile getIFile(String fileName) {
+ ensureProjectOpen();
return project.getFile(fileName);
}
@@ -67,6 +84,7 @@ public class OseeData {
}
public static IFile getIFile(String fileName, InputStream in, boolean overwrite) throws OseeCoreException {
+ ensureProjectOpen();
IFile iFile = project.getFile(fileName);
if (!iFile.exists() || overwrite) {
AIFile.writeToFile(iFile, in);
@@ -80,35 +98,42 @@ public class OseeData {
}
private static boolean createProject() {
+ ensureProjectOpen();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
project = workspaceRoot.getProject(oseeDataPathName);
if (!project.exists()) {
try {
project.create(null);
} catch (CoreException ex) {
- ex.printStackTrace();
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, ex);
return false;
}
+ openProject();
}
+ return true;
+ }
+
+ private static void openProject() {
try {
project.open(null);
} catch (CoreException e) {
- e.printStackTrace();
- return false;
+ OseeLog.log(PluginCoreActivator.class, Level.SEVERE, e);
}
- return true;
}
/**
* @return Returns the project.
*/
public static IProject getProject() {
+ ensureProjectOpen();
return project;
}
public static IFolder getFolder(String name) throws OseeCoreException {
try {
+ ensureProjectOpen();
IFolder folder = project.getFolder(name);
+ ensureProjectOpen();
if (!folder.exists()) {
folder.create(true, true, null);

Back to the top