From 855047c2004937bc7fd62eab4fb67a39aa368ecf Mon Sep 17 00:00:00 2001 From: lehtonen Date: Wed, 17 Mar 2010 00:49:28 +0000 Subject: [PATCH] Added a "first-time cheat sheet view opening" feature to SysdynPerspectiveFactory. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15020 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn.ui/META-INF/MANIFEST.MF | 3 +- .../cheatsheet/tutorial.xml | 18 ++++++++++ org.simantics.sysdyn.ui/plugin.xml | 17 ++++++++++ .../org/simantics/sysdyn/ui/Activator.java | 5 ++- .../ui/project/SysdynPerspectiveFactory.java | 34 ++++++++++++++++--- 5 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 org.simantics.sysdyn.ui/cheatsheet/tutorial.xml diff --git a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF index f9c46635..b6d60bb3 100644 --- a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF +++ b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF @@ -22,6 +22,7 @@ Require-Bundle: org.simantics.h2d;bundle-version="1.0.0", org.apache.log4j;bundle-version="1.2.15", org.eclipse.ui.console;bundle-version="3.4.0", org.simantics.browsing.ui.graph;bundle-version="0.9.0", - org.simantics.modeling.ui;bundle-version="1.0.0" + org.simantics.modeling.ui;bundle-version="1.0.0", + org.eclipse.ui.cheatsheets Bundle-Activator: org.simantics.sysdyn.ui.Activator Bundle-ActivationPolicy: lazy diff --git a/org.simantics.sysdyn.ui/cheatsheet/tutorial.xml b/org.simantics.sysdyn.ui/cheatsheet/tutorial.xml new file mode 100644 index 00000000..4b5ad865 --- /dev/null +++ b/org.simantics.sysdyn.ui/cheatsheet/tutorial.xml @@ -0,0 +1,18 @@ + + + + + This cheatsheet helps with basic system dynamics modeling. + + + + + + Press the ? button on the right to open the tutorial. + + + diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 9c99c0d1..019312e1 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -279,5 +279,22 @@ + + + + + + + Simple System Dynamics Tutorials + + diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/Activator.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/Activator.java index f7dc7f23..20d0e65b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/Activator.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/Activator.java @@ -21,10 +21,13 @@ import org.osgi.framework.BundleContext; public class Activator extends AbstractUIPlugin { + // The plug-in ID + public static final String PLUGIN_ID = "org.simantics.sysdyn.ui"; + @Override public void start(BundleContext context) throws Exception { super.start(context); - ConsoleAppender appender = + ConsoleAppender appender = new ConsoleAppender(new SimpleLayout()); BasicConfigurator.configure(appender); Logger.getRootLogger().setLevel(Level.WARN); 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 d97f495a..2777b630 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,29 +11,53 @@ *******************************************************************************/ 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); String editorArea = layout.getEditorArea(); - + IFolderLayout bottom1 = layout.createFolder("bottom1", IPageLayout.BOTTOM, 0.75f, editorArea); - IFolderLayout bottom2 = layout.createFolder("bottom2", IPageLayout.LEFT, 0.4f, "bottom1"); + IFolderLayout bottom2 = layout.createFolder("bottom2", IPageLayout.LEFT, 0.4f, "bottom1"); bottom1.addView("org.simantics.sysdyn.ui.equation.view"); bottom1.addView(IConsoleConstants.ID_CONSOLE_VIEW); bottom1.addView("org.simantics.sysdyn.ui.configurationView"); bottom2.addView("org.simantics.sysdyn.ui.trend.view"); - + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.25f, editorArea); - //left.addView("org.simantics.ode.views.ontologyBrowser"); left.addView("org.simantics.sysdyn.ui.browser"); - + + // 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); + } + } } } -- 2.47.1