From cb1368a45b078722ec964d1351d640d3371af9d9 Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 11 Aug 2010 10:19:59 +0000 Subject: [PATCH] Moved displaying cheat sheet from perspective to project git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17100 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/project/SysdynPerspectiveFactory.java | 26 ---------- .../ui/project/SysdynProjectLifeCycle.java | 47 +++++++++++-------- 2 files changed, 27 insertions(+), 46 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java index 15371b07..0d86050e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java @@ -11,23 +11,13 @@ *******************************************************************************/ package org.simantics.sysdyn.ui.project; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; -import org.eclipse.ui.cheatsheets.OpenCheatSheetAction; import org.eclipse.ui.console.IConsoleConstants; -import org.osgi.service.prefs.BackingStoreException; -import org.simantics.sysdyn.ui.Activator; -import org.simantics.utils.ui.ErrorLogger; public class SysdynPerspectiveFactory implements IPerspectiveFactory { - private static final String CHEATSHEET_ID = "org.simantics.sysdyn.ui.cheatsheet1"; - - private static final String FIRST_SYSDYN_PROJECT = "firstSysdynProject"; - @Override public void createInitialLayout(IPageLayout layout) { layout.setEditorAreaVisible(true); @@ -45,22 +35,6 @@ public class SysdynPerspectiveFactory implements IPerspectiveFactory { IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, 0.7f, editorArea); right.addView("org.simantics.diagram.symbollibrary"); - - // Open cheatsheets view on the first time the user creates a sysdyn project - // for a particular workspace. - IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID); - boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true); - if (firstSysdynProject) { - new OpenCheatSheetAction(CHEATSHEET_ID).run(); - - // Make a note that the user has created a sysdyn project. - try { - prefs.putBoolean(FIRST_SYSDYN_PROJECT, false); - prefs.flush(); - } catch (BackingStoreException e) { - ErrorLogger.defaultLogError(e); - } - } } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java index 7b26b65a..5fe9a53a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProjectLifeCycle.java @@ -4,6 +4,10 @@ import java.io.File; import java.util.HashMap; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.ui.cheatsheets.OpenCheatSheetAction; +import org.osgi.service.prefs.BackingStoreException; import org.simantics.databoard.accessor.Accessor; import org.simantics.db.Builtins; import org.simantics.db.ReadGraph; @@ -16,8 +20,6 @@ import org.simantics.db.common.procedure.single.SingleSetListener; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; import org.simantics.db.layer0.adapter.ActivationManager; import org.simantics.db.layer0.adapter.RuntimeValuations; import org.simantics.db.layer0.adapter.TrendVariable; @@ -25,41 +27,34 @@ import org.simantics.db.layer0.util.Simantics; import org.simantics.db.management.ISessionContext; import org.simantics.db.request.Read; import org.simantics.db.service.VirtualGraphSupport; -import org.simantics.layer0.utils.direct.GraphUtils; import org.simantics.project.IProject; import org.simantics.project.IProjectLifeCycle; import org.simantics.simulation.experiment.IExperiment; import org.simantics.simulation.project.IExperimentManager; import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.ui.Activator; import org.simantics.ui.SimanticsUI; import org.simantics.utils.datastructures.hints.IHintContext.Key; import org.simantics.utils.datastructures.hints.IHintContext.KeyOf; +import org.simantics.utils.ui.ErrorLogger; public class SysdynProjectLifeCycle implements IProjectLifeCycle{ - public static final Key INITIALIZED = new KeyOf(Boolean.class, "SYSDYN_LIFECYCLE_INITIALIZED"); - + public static final Key INITIALIZED = new KeyOf(Boolean.class, "SYSDYN_LIFECYCLE_INITIALIZED"); + private static final String CHEATSHEET_ID = "org.simantics.sysdyn.ui.cheatsheet1"; + private static final String FIRST_SYSDYN_PROJECT = "firstSysdynProject"; + @Override public void onCreate(WriteGraph g, Resource project) { -// System.out.println("onCreate Sysdyn Project: " + GraphUtils.getReadableName(g, project)); } @Override public void onDestroy(WriteGraph g, Resource project) { - try { - System.out.println("onDestroy Sysdyn Project: " + GraphUtils.getReadableName(g, project)); - } catch (ValidationException e) { - e.printStackTrace(); - } catch (ServiceException e) { - e.printStackTrace(); - } } @Override public void onActivated(RequestProcessor processor, final IProject project) { - System.out.println("onActivated Sysdyn Project"); - ISessionContext context = SimanticsUI.getSessionContext(); if (context.getHint(INITIALIZED) == null) { @@ -96,7 +91,6 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{ }); -// System.out.println("A1"); final Builtins b = session.getBuiltins(); ActivationManager activationManager = session.getService(ActivationManager.class); @@ -104,12 +98,10 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{ activationManager.activate(processor, projectResource); } -// System.out.println("A2"); VirtualGraphSupport support = session.getService(VirtualGraphSupport.class); final VirtualGraph graph = session.getService(VirtualGraph.class); -// System.out.println("A3"); session.asyncRequest(new ObjectsWithType(projectResource, b.ConsistsOf, b.Model), new SingleSetListener() { @@ -156,6 +148,23 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{ cleanProjectFolder(project.get()); context.setHint(INITIALIZED, Boolean.TRUE); + + + // Open cheatsheets view on the first time the user creates a sysdyn project + // for a particular workspace. + IEclipsePreferences prefs = new InstanceScope().getNode(Activator.PLUGIN_ID); + boolean firstSysdynProject = prefs.getBoolean(FIRST_SYSDYN_PROJECT, true); + if (firstSysdynProject) { + new OpenCheatSheetAction(CHEATSHEET_ID).run(); + + // Make a note that the user has created a sysdyn project. + try { + prefs.putBoolean(FIRST_SYSDYN_PROJECT, false); + prefs.flush(); + } catch (BackingStoreException e) { + ErrorLogger.defaultLogError(e); + } + } } @@ -163,11 +172,9 @@ public class SysdynProjectLifeCycle implements IProjectLifeCycle{ @Override public void onDeactivated(IProject project) { -// System.out.println("onDeactivated Sysdyn Project: " + project.getName()); } public void cleanProjectFolder(final Resource projectResource) { - System.out.println("cleaning up project folder"); ISessionContext context = SimanticsUI.getSessionContext(); final Session session = context.getSession(); String projectName = null; -- 2.47.1