]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.project/src/org/simantics/project/management/SPMUtil.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.project / src / org / simantics / project / management / SPMUtil.java
index d739d1a851f2975bd623f8c3fff3c293acebcd9b..a498e9ade82cd0866257ed2d3c897effaf868df6 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.project.management;\r
-\r
-import java.io.File;\r
-import java.net.URI;\r
-\r
-import org.eclipse.core.runtime.IPath;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.core.runtime.preferences.DefaultScope;\r
-import org.eclipse.core.runtime.preferences.IScopeContext;\r
-import org.eclipse.core.runtime.preferences.InstanceScope;\r
-import org.eclipse.equinox.p2.core.IProvisioningAgent;\r
-import org.eclipse.equinox.p2.core.ProvisionException;\r
-import org.simantics.project.internal.Activator;\r
-import org.simantics.utils.strings.EString;\r
-\r
-/**\r
- * This utility class contains methods for handling bundles in SPM application.\r
- *\r
- * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
- */\r
-public class SPMUtil {\r
-\r
-       private static IProvisioningAgent localAgent;\r
-       private static File workspacesLocation;\r
-       private static File coresLocation;\r
-\r
-       /**\r
-        * Get bundle repository location in Simantics Project Management workspace.\r
-        *\r
-        * @return Bundle repository location\r
-        */\r
-       public static URI getRepositoryLocation() {\r
-               return Platform.getLocation().append("repository").toFile().toURI();\r
-       }\r
-\r
-       /**\r
-        * Create provisioning agent that handles local bundle repository.\r
-        *\r
-        * @return\r
-        * @throws ProvisionException\r
-        * @throws Exception\r
-        */\r
-       public synchronized static IProvisioningAgent getLocalAgent() throws ProvisionException {\r
-               if (localAgent == null) {\r
-                       IPath agentLocation = Platform.getLocation().append("P2");\r
-                       localAgent = P2Util.createAgent( agentLocation );\r
-               }\r
-               return localAgent;\r
-       }\r
-\r
-\r
-\r
-\r
-       public static String[] getSourceLocations() {\r
-               IScopeContext[] scopes = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };\r
-               String yyy = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, RepositoryPreference.P_REPOSITY_SOURCES, "", scopes);\r
-               return EString.explode(yyy, "\n");\r
-       }\r
-\r
-       /**\r
-        * Get diretory that contains project workspaces\r
-        *\r
-        * @return\r
-        */\r
-       public synchronized static File getWorkspacesLocation() {\r
-               if (workspacesLocation == null) {\r
-                       workspacesLocation = new File( Platform.getLocation().toFile(), "workspaces" );\r
-               }\r
-               return workspacesLocation;\r
-       }\r
-\r
-       /**\r
-        * Get diretory that contains cores\r
-        *\r
-        * @return\r
-        */\r
-       public synchronized static File getCoresLocation() {\r
-               if (coresLocation == null) {\r
-                       coresLocation = new File( Platform.getLocation().toFile(), "cores" );\r
-               }\r
-               return coresLocation;\r
-       }\r
-\r
-       public static boolean isWorkspace(File path) {\r
-               if (!path.exists()) return false;\r
-               File db = new File(path, "db");\r
-               if (!db.exists()) return false;\r
-//             if (!isDatabase(db)) return false;\r
-//             File p2 = new File(path, "p2");\r
-//             if (!p2.exists()) return false;\r
-               File props = new File(path, "simantics.cfg");\r
-               if (!props.exists()) return false;\r
-               return true;\r
-       }\r
-\r
-//     public static boolean isDatabase(File path) {\r
-//             File config = new File(path, ProCoreConfigFile);\r
-//             return config.exists();\r
-//     }\r
-\r
-\r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.project.management;
+
+import java.io.File;
+import java.net.URI;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.simantics.project.internal.Activator;
+import org.simantics.utils.strings.EString;
+
+/**
+ * This utility class contains methods for handling bundles in SPM application.
+ *
+ * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
+ */
+public class SPMUtil {
+
+       private static IProvisioningAgent localAgent;
+       private static File workspacesLocation;
+       private static File coresLocation;
+
+       /**
+        * Get bundle repository location in Simantics Project Management workspace.
+        *
+        * @return Bundle repository location
+        */
+       public static URI getRepositoryLocation() {
+               return Platform.getLocation().append("repository").toFile().toURI();
+       }
+
+       /**
+        * Create provisioning agent that handles local bundle repository.
+        *
+        * @return
+        * @throws ProvisionException
+        * @throws Exception
+        */
+       public synchronized static IProvisioningAgent getLocalAgent() throws ProvisionException {
+               if (localAgent == null) {
+                       IPath agentLocation = Platform.getLocation().append("P2");
+                       localAgent = P2Util.createAgent( agentLocation );
+               }
+               return localAgent;
+       }
+
+
+
+
+       public static String[] getSourceLocations() {
+               IScopeContext[] scopes = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
+               String yyy = Platform.getPreferencesService().getString(Activator.PLUGIN_ID, RepositoryPreference.P_REPOSITY_SOURCES, "", scopes);
+               return EString.explode(yyy, "\n");
+       }
+
+       /**
+        * Get diretory that contains project workspaces
+        *
+        * @return
+        */
+       public synchronized static File getWorkspacesLocation() {
+               if (workspacesLocation == null) {
+                       workspacesLocation = new File( Platform.getLocation().toFile(), "workspaces" );
+               }
+               return workspacesLocation;
+       }
+
+       /**
+        * Get diretory that contains cores
+        *
+        * @return
+        */
+       public synchronized static File getCoresLocation() {
+               if (coresLocation == null) {
+                       coresLocation = new File( Platform.getLocation().toFile(), "cores" );
+               }
+               return coresLocation;
+       }
+
+       public static boolean isWorkspace(File path) {
+               if (!path.exists()) return false;
+               File db = new File(path, "db");
+               if (!db.exists()) return false;
+//             if (!isDatabase(db)) return false;
+//             File p2 = new File(path, "p2");
+//             if (!p2.exists()) return false;
+               File props = new File(path, "simantics.cfg");
+               if (!props.exists()) return false;
+               return true;
+       }
+
+//     public static boolean isDatabase(File path) {
+//             File config = new File(path, ProCoreConfigFile);
+//             return config.exists();
+//     }
+
+
+}
+