*******************************************************************************/\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
\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
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
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
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
});\r
\r
\r
-// System.out.println("A1");\r
\r
final Builtins b = session.getBuiltins();\r
ActivationManager activationManager = session.getService(ActivationManager.class);\r
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
\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
\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