]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Sync git svn branch with SVN repository r33199.
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 16 Sep 2016 08:14:02 +0000 (11:14 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 16 Sep 2016 08:14:02 +0000 (11:14 +0300)
refs #6694

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ModeledActions.java
bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java
bundles/org.simantics.project/src/org/simantics/project/management/ServerManagerFactory.java
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java
bundles/org.simantics/src/org/simantics/Simantics.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index ba53b9223cb98a234c0e4d410b8161fc7c0acdab..47d5643a17557b4a1208917bb2707323c98cab8e 100644 (file)
@@ -54,7 +54,7 @@ public class ModeledActions extends DynamicMenuContribution implements IExecutab
 \r
     protected Set<String> browseContexts = defaultBrowseContexts;\r
 \r
 \r
     protected Set<String> browseContexts = defaultBrowseContexts;\r
 \r
-    protected static final Comparator<Action> ACTION_COMPARATOR = new Comparator<Action>() {\r
+    public static final Comparator<Action> ACTION_COMPARATOR = new Comparator<Action>() {\r
         @Override\r
         public int compare(Action o1, Action o2) {\r
             String t1 = o1.getText();\r
         @Override\r
         public int compare(Action o1, Action o2) {\r
             String t1 = o1.getText();\r
index 691d82961e892389eb91b5842c03c36cfa49926c..555401327c89b48c4bd7cb73355f35a611710796 100644 (file)
@@ -44,7 +44,7 @@ public class SCL {
         SimanticsPlatform.INSTANCE.shutdown(null);\r
     }\r
     public static void reconnectPlatform() throws Exception {\r
         SimanticsPlatform.INSTANCE.shutdown(null);\r
     }\r
     public static void reconnectPlatform() throws Exception {\r
-        SimanticsPlatform.INSTANCE.reconnect(null);\r
+        SimanticsPlatform.INSTANCE.reconnect(Simantics.getDefaultDatabaseDriver());\r
     }\r
     public static void synchronizeOntologies() throws Exception {\r
        SimanticsPlatform.INSTANCE.synchronizeOntologies(new NullProgressMonitor(), OntologyRecoveryPolicy.Merge, true);\r
     }\r
     public static void synchronizeOntologies() throws Exception {\r
        SimanticsPlatform.INSTANCE.synchronizeOntologies(new NullProgressMonitor(), OntologyRecoveryPolicy.Merge, true);\r
index 3bde5dc422a4a2a810f32ba4f6faf67d101e0b6e..bbeb7541e0892e86c1eb45c8a8c9c5a8c168bed5 100644 (file)
@@ -30,12 +30,12 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.utils.FileUtils;\r
 \r
 public class ServerManagerFactory {\r
 import org.simantics.utils.FileUtils;\r
 \r
 public class ServerManagerFactory {\r
-    public static ServerManager create(String databaseId, String address) throws IOException, DatabaseException {\r
-        Driver driver = Manager.getDriver(databaseId);\r
+    public static ServerManager create(String databaseDriverId, String address) throws IOException, DatabaseException {\r
+        Driver driver = Manager.getDriver(databaseDriverId);\r
         if (driver == null)\r
         if (driver == null)\r
-            throw new IllegalArgumentException("Database driver for ID " + databaseId + " Could not be found!");\r
-        System.out.println("ServerManagerFactory.create called with databaseId=" + databaseId + " and driver is " + driver.toString());\r
-        DatabaseUserAgent agent = Manager.getUserAgent(databaseId);\r
+            throw new IllegalArgumentException("Database driver for ID " + databaseDriverId + " Could not be found!");\r
+        System.out.println("ServerManagerFactory.create called with databaseId=" + databaseDriverId + " and driver is " + driver.toString());\r
+        DatabaseUserAgent agent = Manager.getUserAgent(databaseDriverId);\r
         if (agent != null)\r
             driver.setDatabaseUserAgent(address, agent);\r
         return new ServerManager(driver);\r
         if (agent != null)\r
             driver.setDatabaseUserAgent(address, agent);\r
         return new ServerManager(driver);\r
index 2d054eaa7d0d7a1fa2367fce88996772f4023f5a..67a8101cf7a87ff7e0a8e9d8e2b68bde52279bef 100644 (file)
@@ -61,7 +61,6 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;\r
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.ui.IPerspectiveDescriptor;\r
 import org.eclipse.swt.widgets.Listener;\r
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.ui.IPerspectiveDescriptor;\r
-import org.eclipse.ui.IWorkbench;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.application.IWorkbenchConfigurer;\r
 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;\r
 import org.eclipse.ui.PlatformUI;\r
 import org.eclipse.ui.application.IWorkbenchConfigurer;\r
 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;\r
@@ -98,7 +97,6 @@ import org.simantics.db.common.Indexing;
 import org.simantics.db.indexing.DatabaseIndexing;\r
 import org.simantics.db.procore.server.environment.RebootRequiredException;\r
 import org.simantics.db.procore.server.environment.windows.Product;\r
 import org.simantics.db.indexing.DatabaseIndexing;\r
 import org.simantics.db.procore.server.environment.RebootRequiredException;\r
 import org.simantics.db.procore.server.environment.windows.Product;\r
-import org.simantics.db.procore.ui.ProCoreUserAgent;\r
 import org.simantics.internal.TimedSessionCache;\r
 import org.simantics.project.IProject;\r
 import org.simantics.project.ProjectKeys;\r
 import org.simantics.internal.TimedSessionCache;\r
 import org.simantics.project.IProject;\r
 import org.simantics.project.ProjectKeys;\r
@@ -131,11 +129,6 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
      */\r
     private static final String INSTALLED_FEATURES = "installedFeatures"; //$NON-NLS-1$\r
 \r
      */\r
     private static final String INSTALLED_FEATURES = "installedFeatures"; //$NON-NLS-1$\r
 \r
-    /**\r
-     * Default database ID\r
-     */\r
-    private static final String DEFAULT_DATABASE_ID = "procore";\r
-    \r
     /**\r
      * The arguments received by the application.\r
      */\r
     /**\r
      * The arguments received by the application.\r
      */\r
@@ -428,17 +421,16 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
                 throw new PlatformException("Argument not supported: " + SimanticsArguments.SERVER + " " + serverAddress);\r
             }\r
 \r
                 throw new PlatformException("Argument not supported: " + SimanticsArguments.SERVER + " " + serverAddress);\r
             }\r
 \r
-            // TODO: Default to procore for now;\r
-            String databaseId = DEFAULT_DATABASE_ID;\r
+            String databaseDriverId = Simantics.getDefaultDatabaseDriver();\r
             if (args.contains(SimanticsArguments.DATABASE_ID)) {\r
             if (args.contains(SimanticsArguments.DATABASE_ID)) {\r
-                databaseId = args.get(SimanticsArguments.DATABASE_ID);\r
+                databaseDriverId = args.get(SimanticsArguments.DATABASE_ID);\r
+                Simantics.setDefaultDatabaseDriver(databaseDriverId);\r
             }\r
             \r
             IProgressMonitor mon = null;\r
             if (PROFILE_PLATFORM_STARTUP)\r
                 mon = new TimingProgressMonitor();\r
             }\r
             \r
             IProgressMonitor mon = null;\r
             if (PROFILE_PLATFORM_STARTUP)\r
                 mon = new TimingProgressMonitor();\r
-            IWorkbench wb = PlatformUI.getWorkbench();\r
-            SimanticsPlatform.INSTANCE.startUp(databaseId, mon, workspacePolicy, ontologyPolicy, requireSynchronize, new JFaceUserAgent());\r
+            SimanticsPlatform.INSTANCE.startUp(databaseDriverId, mon, workspacePolicy, ontologyPolicy, requireSynchronize, new JFaceUserAgent());\r
 \r
             // Make sure that the default perspective comes from the project if\r
             // the project has set ProjectKeys#DEFAULT_PERSPECTIVE.\r
 \r
             // Make sure that the default perspective comes from the project if\r
             // the project has set ProjectKeys#DEFAULT_PERSPECTIVE.\r
index 1e01acf71f1c7cc097a418ac18deaa82c214add5..50110cb0375b51232cd78860b6a91ac5e96e0a28 100644 (file)
@@ -68,9 +68,33 @@ import org.simantics.utils.threads.ThreadUtils;
  */\r
 public class Simantics {\r
 \r
  */\r
 public class Simantics {\r
 \r
+    /**\r
+     * Default database driver ID\r
+     */\r
+    private static final String DEFAULT_DATABASE_DRIVER_ID = "procore";\r
+\r
+    private static String defaultDatabaseDriverId = DEFAULT_DATABASE_DRIVER_ID;\r
+\r
     private static ISessionContextProviderSource providerSource = null;\r
     private static volatile FileServiceImpl fileService = null;\r
 \r
     private static ISessionContextProviderSource providerSource = null;\r
     private static volatile FileServiceImpl fileService = null;\r
 \r
+    /**\r
+     * Sets the database driver to be used by the platform. To have any effect,\r
+     * this must be set before platform startup.\r
+     * \r
+     * @param id driver id\r
+     */\r
+    public static void setDefaultDatabaseDriver(String id) {\r
+        defaultDatabaseDriverId = id;\r
+    }\r
+\r
+    /**\r
+     * Returns currently set default database driver id.\r
+     */\r
+    public static String getDefaultDatabaseDriver() {\r
+        return defaultDatabaseDriverId;\r
+    }\r
+\r
     /**\r
      * @param args\r
      * @param progress\r
     /**\r
      * @param args\r
      * @param progress\r
@@ -142,7 +166,7 @@ public class Simantics {
 \r
         if (progress == null)\r
             progress = new NullProgressMonitor();\r
 \r
         if (progress == null)\r
             progress = new NullProgressMonitor();\r
-        return SimanticsPlatform.INSTANCE.startUp(null, progress, workspacePolicy, ontologyPolicy, true, new ConsoleUserAgent());\r
+        return SimanticsPlatform.INSTANCE.startUp(defaultDatabaseDriverId, progress, workspacePolicy, ontologyPolicy, true, new ConsoleUserAgent());\r
     }\r
 \r
     /**\r
     }\r
 \r
     /**\r
index 89a5d3dbd52df2e7376cafb836b9b7f7724145ec..40bbc04ed3e7ba70dac8648d5b8aaa6c56458ebc 100644 (file)
@@ -39,8 +39,6 @@ import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;\r
 import org.eclipse.core.runtime.SubMonitor;\r
 import org.eclipse.osgi.service.resolver.BundleDescription;\r
 import org.eclipse.core.runtime.Status;\r
 import org.eclipse.core.runtime.SubMonitor;\r
 import org.eclipse.osgi.service.resolver.BundleDescription;\r
-import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;\r
-import org.simantics.SimanticsPlatform.RecoveryPolicy;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.Databoard;\r
 import org.simantics.datatypes.literal.Font;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.Databoard;\r
 import org.simantics.datatypes.literal.Font;\r
@@ -199,13 +197,13 @@ public class SimanticsPlatform implements LifecycleListener {
         return application != null ? application : UUID.randomUUID().toString();\r
     }\r
 \r
         return application != null ? application : UUID.randomUUID().toString();\r
     }\r
 \r
-    private Session setupDatabase(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
+    private Session setupDatabase(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
         if (progressMonitor == null)\r
             progressMonitor = new NullProgressMonitor();\r
         File dbLocation = Platform.getLocation().append("db").toFile();\r
         ServerManager serverManager;\r
         try {\r
         if (progressMonitor == null)\r
             progressMonitor = new NullProgressMonitor();\r
         File dbLocation = Platform.getLocation().append("db").toFile();\r
         ServerManager serverManager;\r
         try {\r
-            serverManager = ServerManagerFactory.create(databaseId, dbLocation.getAbsolutePath());\r
+            serverManager = ServerManagerFactory.create(databaseDriverId, dbLocation.getAbsolutePath());\r
         } catch (DatabaseException | IOException e) {\r
             throw new PlatformException("Failed to initialize Server Manager", e);\r
         }\r
         } catch (DatabaseException | IOException e) {\r
             throw new PlatformException("Failed to initialize Server Manager", e);\r
         }\r
@@ -702,7 +700,7 @@ public class SimanticsPlatform implements LifecycleListener {
      *        startup or <code>null</code> to resort to default measures\r
      * @throws PlatformException\r
      */\r
      *        startup or <code>null</code> to resort to default measures\r
      * @throws PlatformException\r
      */\r
-    public SessionContext startUp(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
+    public SessionContext startUp(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
             OntologyRecoveryPolicy ontologyPolicy, boolean requireSynchronize, PlatformUserAgent userAgent)\r
     throws PlatformException\r
     {\r
             OntologyRecoveryPolicy ontologyPolicy, boolean requireSynchronize, PlatformUserAgent userAgent)\r
     throws PlatformException\r
     {\r
@@ -729,7 +727,7 @@ public class SimanticsPlatform implements LifecycleListener {
         VariableRepository.clear();\r
         \r
         // 1. Assert there is a database at <workspace>/db\r
         VariableRepository.clear();\r
         \r
         // 1. Assert there is a database at <workspace>/db\r
-        session = setupDatabase(databaseId, progressMonitor, workspacePolicy, userAgent);\r
+        session = setupDatabase(databaseDriverId, progressMonitor, workspacePolicy, userAgent);\r
         TimeLogger.log("Database setup complete");\r
 \r
         // 2. Assert all graphs, and correct versions, are installed to the database\r
         TimeLogger.log("Database setup complete");\r
 \r
         // 2. Assert all graphs, and correct versions, are installed to the database\r
@@ -1014,9 +1012,9 @@ public class SimanticsPlatform implements LifecycleListener {
         return false;\r
     }\r
 \r
         return false;\r
     }\r
 \r
-    public void reconnect(String databaseId) throws Exception {\r
+    public void reconnect(String databaseDriverId) throws Exception {\r
         // Starts database server.\r
         // Starts database server.\r
-        SimanticsPlatform.INSTANCE.startUp(databaseId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
+        SimanticsPlatform.INSTANCE.startUp(databaseDriverId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
     }\r
 \r
     private void dumpPlatformBundleState() {\r
     }\r
 \r
     private void dumpPlatformBundleState() {\r