]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Moved displaying cheat sheet from perspective to project
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 11 Aug 2010 10:19:59 +0000 (10:19 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 11 Aug 2010 10:19:59 +0000 (10:19 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17100 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java

index 15371b07b9d92e91c29c06740e8c1c6554ec0abd..0d86050ec12cce74df4e8dbcf421f81f8c37dedc 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.project;\r
 \r
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
-import org.eclipse.core.runtime.preferences.InstanceScope;\r
 import org.eclipse.ui.IFolderLayout;\r
 import org.eclipse.ui.IPageLayout;\r
 import org.eclipse.ui.IPerspectiveFactory;\r
-import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;\r
 import org.eclipse.ui.console.IConsoleConstants;\r
-import org.osgi.service.prefs.BackingStoreException;\r
-import org.simantics.sysdyn.ui.Activator;\r
-import org.simantics.utils.ui.ErrorLogger;\r
 \r
 public class SysdynPerspectiveFactory implements IPerspectiveFactory {\r
 \r
-    private static final String CHEATSHEET_ID        = "org.simantics.sysdyn.ui.cheatsheet1";\r
-\r
-    private static final String FIRST_SYSDYN_PROJECT = "firstSysdynProject";\r
-\r
     @Override\r
     public void createInitialLayout(IPageLayout layout) {\r
         layout.setEditorAreaVisible(true);\r
@@ -45,22 +35,6 @@ public class SysdynPerspectiveFactory implements IPerspectiveFactory {
         \r
         IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.7f, editorArea);\r
         right.addView("org.simantics.diagram.symbollibrary");\r
-\r
-        // Open cheatsheets view on the first time the user creates a sysdyn project\r
-        // for a particular workspace.\r
-        IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);\r
-        boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true);\r
-        if (firstSysdynProject) {\r
-            new OpenCheatSheetAction(CHEATSHEET_ID).run();\r
-\r
-            // Make a note that the user has created a sysdyn project.\r
-            try {\r
-                prefs.putBoolean(FIRST_SYSDYN_PROJECT, false);\r
-                prefs.flush();\r
-            } catch (BackingStoreException e) {\r
-                ErrorLogger.defaultLogError(e);\r
-            }\r
-        }\r
     }\r
 \r
 }\r
index 7b26b65a1eada97b136f069df2a7bd8d98b52701..5fe9a53af6b4b3b1a9adf589eeebfea8572265de 100644 (file)
@@ -4,6 +4,10 @@ import java.io.File;
 import java.util.HashMap;\r
 \r
 import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;\r
+import org.eclipse.core.runtime.preferences.InstanceScope;\r
+import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;\r
+import org.osgi.service.prefs.BackingStoreException;\r
 import org.simantics.databoard.accessor.Accessor;\r
 import org.simantics.db.Builtins;\r
 import org.simantics.db.ReadGraph;\r
@@ -16,8 +20,6 @@ import org.simantics.db.common.procedure.single.SingleSetListener;
 import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.ServiceException;\r
-import org.simantics.db.exception.ValidationException;\r
 import org.simantics.db.layer0.adapter.ActivationManager;\r
 import org.simantics.db.layer0.adapter.RuntimeValuations;\r
 import org.simantics.db.layer0.adapter.TrendVariable;\r
@@ -25,41 +27,34 @@ import org.simantics.db.layer0.util.Simantics;
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.project.IProject;\r
 import org.simantics.project.IProjectLifeCycle;\r
 import org.simantics.simulation.experiment.IExperiment;\r
 import org.simantics.simulation.project.IExperimentManager;\r
 import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
 import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
+import org.simantics.utils.ui.ErrorLogger;\r
 \r
 public class SysdynProjectLifeCycle implements IProjectLifeCycle{\r
 \r
-    public static final Key INITIALIZED = new KeyOf(Boolean.class, "SYSDYN_LIFECYCLE_INITIALIZED");\r
-\r
+    public static final Key     INITIALIZED             = new KeyOf(Boolean.class, "SYSDYN_LIFECYCLE_INITIALIZED");\r
+    private static final String CHEATSHEET_ID           = "org.simantics.sysdyn.ui.cheatsheet1";\r
+    private static final String FIRST_SYSDYN_PROJECT    = "firstSysdynProject";\r
+    \r
     @Override\r
     public void onCreate(WriteGraph g, Resource project) {\r
-//        System.out.println("onCreate Sysdyn Project: " + GraphUtils.getReadableName(g, project));\r
     }\r
 \r
     @Override\r
     public void onDestroy(WriteGraph g, Resource project) {\r
-        try {\r
-            System.out.println("onDestroy Sysdyn Project: " + GraphUtils.getReadableName(g, project));\r
-        } catch (ValidationException e) {\r
-            e.printStackTrace();\r
-        } catch (ServiceException e) {\r
-            e.printStackTrace();\r
-        }\r
     }\r
 \r
     @Override\r
     public void onActivated(RequestProcessor processor, final IProject project) {\r
 \r
-        System.out.println("onActivated Sysdyn Project");\r
-\r
         ISessionContext context = SimanticsUI.getSessionContext();\r
         if (context.getHint(INITIALIZED) == null) {\r
 \r
@@ -96,7 +91,6 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{
                 });\r
 \r
 \r
-//                System.out.println("A1");\r
 \r
                 final Builtins b = session.getBuiltins();\r
                 ActivationManager activationManager = session.getService(ActivationManager.class);\r
@@ -104,12 +98,10 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{
                     activationManager.activate(processor, projectResource);\r
                 }\r
 \r
-//                System.out.println("A2");\r
 \r
                 VirtualGraphSupport support = session.getService(VirtualGraphSupport.class);\r
                 final VirtualGraph graph = session.getService(VirtualGraph.class);\r
 \r
-//                System.out.println("A3");\r
 \r
                 session.asyncRequest(new ObjectsWithType(projectResource, b.ConsistsOf, b.Model), new SingleSetListener<Resource>() {\r
 \r
@@ -156,6 +148,23 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{
 \r
             cleanProjectFolder(project.get());\r
             context.setHint(INITIALIZED, Boolean.TRUE);\r
+            \r
+            \r
+            // Open cheatsheets view on the first time the user creates a sysdyn project\r
+            // for a particular workspace.\r
+            IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID);\r
+            boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true);\r
+            if (firstSysdynProject) {\r
+                new OpenCheatSheetAction(CHEATSHEET_ID).run();\r
+\r
+                // Make a note that the user has created a sysdyn project.\r
+                try {\r
+                    prefs.putBoolean(FIRST_SYSDYN_PROJECT, false);\r
+                    prefs.flush();\r
+                } catch (BackingStoreException e) {\r
+                    ErrorLogger.defaultLogError(e);\r
+                }\r
+            }\r
 \r
         }\r
 \r
@@ -163,11 +172,9 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{
 \r
     @Override\r
     public void onDeactivated(IProject project) {\r
-//        System.out.println("onDeactivated Sysdyn Project: " + project.getName());\r
     }\r
 \r
     public void cleanProjectFolder(final Resource projectResource) {\r
-        System.out.println("cleaning up project folder");\r
         ISessionContext context = SimanticsUI.getSessionContext();\r
         final Session session = context.getSession();\r
         String projectName = null;\r