From 419c1ac1d4a56e6e90f1e3590fce9d3d4fa2fc58 Mon Sep 17 00:00:00 2001 From: niemisto Date: Wed, 18 Nov 2009 11:07:28 +0000 Subject: [PATCH] sysdyn project git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13115 ac1ea38d-2e2b-0410-8846-a27921b304fc --- org.simantics.sysdyn.ui/META-INF/MANIFEST.MF | 3 +- org.simantics.sysdyn.ui/adapters.xml | 9 +++++ org.simantics.sysdyn.ui/plugin.xml | 8 ++++ .../sysdyn/ui/equation/EquationView.java | 22 +++++++++- .../ui/project/SysdynPerspectiveFactory.java | 21 ++++++++++ .../sysdyn/ui/project/SysdynProject.java | 21 ++++++++++ .../org/simantics/sysdyn/SysdynResource.java | 6 +-- sysdyn_ontologies/install.map | 2 +- sysdyn_ontologies/sysdyn.graph | 40 +++++++++---------- 9 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 org.simantics.sysdyn.ui/adapters.xml create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java create mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java diff --git a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF index 4274ee39..a71d5a05 100644 --- a/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF +++ b/org.simantics.sysdyn.ui/META-INF/MANIFEST.MF @@ -14,4 +14,5 @@ Require-Bundle: org.simantics.h2d;bundle-version="1.0.0", org.eclipse.ui;bundle-version="3.5.0", org.eclipse.core.runtime;bundle-version="3.5.0", org.simantics.objmap;bundle-version="0.1.0", - org.simantics.sysdyn;bundle-version="1.0.0" + org.simantics.sysdyn;bundle-version="1.0.0", + org.simantics.project;bundle-version="1.0.0" diff --git a/org.simantics.sysdyn.ui/adapters.xml b/org.simantics.sysdyn.ui/adapters.xml new file mode 100644 index 00000000..3af512f2 --- /dev/null +++ b/org.simantics.sysdyn.ui/adapters.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/plugin.xml b/org.simantics.sysdyn.ui/plugin.xml index 19dc2d0c..6092710c 100644 --- a/org.simantics.sysdyn.ui/plugin.xml +++ b/org.simantics.sysdyn.ui/plugin.xml @@ -39,5 +39,13 @@ restorable="true"> + + + + diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java index ed3d8812..9a513a89 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java @@ -80,7 +80,7 @@ public class EquationView extends ViewPart implements ISelectionListener { public void run(ReadGraph g) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(g); Builtins b = g.getBuiltins(); - if(g.isInstanceOf(resource, sr.Auxiliary)) { + if(g.isInstanceOf(resource, sr.Auxiliary) || g.isInstanceOf(resource, sr.Valve)) { auxiliary = resource; final String name = g.getRelatedValue(resource, b.HasName); final String value = g.getPossibleRelatedValue(resource, sr.HasValue); @@ -93,7 +93,25 @@ public class EquationView extends ViewPart implements ISelectionListener { else originalText = value; text.setText(originalText); - setPartName(name + " equation"); + setPartName("Value of " + name); + } + + }); + } + else if(g.isInstanceOf(resource, sr.Stock)) { + auxiliary = resource; + final String name = g.getRelatedValue(resource, b.HasName); + final String value = g.getPossibleRelatedValue(resource, sr.HasValue); + text.getDisplay().asyncExec(new Runnable() { + + @Override + public void run() { + if(value == null) + originalText = ""; + else + originalText = value; + text.setText(originalText); + setPartName("Initial value of " + name); } }); 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 new file mode 100644 index 00000000..9f6b2570 --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynPerspectiveFactory.java @@ -0,0 +1,21 @@ +package org.simantics.sysdyn.ui.project; + +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class SysdynPerspectiveFactory implements IPerspectiveFactory { + + @Override + public void createInitialLayout(IPageLayout layout) { + layout.setEditorAreaVisible(true); + String editorArea = layout.getEditorArea(); + + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.25f, editorArea); + left.addView("org.simantics.ode.views.ontologyBrowser"); + + IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.75f, editorArea); + bottom.addView("org.simantics.sysdyn.ui.equation.view"); + } + +} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java new file mode 100644 index 00000000..7324bc4a --- /dev/null +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java @@ -0,0 +1,21 @@ +package org.simantics.sysdyn.ui.project; + +import org.simantics.project.ProjectKeys; +import org.simantics.project.exception.ProjectException; +import org.simantics.project.features.AbstractProjectFeature; + +public class SysdynProject extends AbstractProjectFeature { + private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective"; + + @Override + public void configure() throws ProjectException { + addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE); + addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE); + getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE); + } + + @Override + public void deconfigure() throws ProjectException { + } + +} diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java index 5281df8f..01448ff3 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java @@ -33,7 +33,7 @@ public class SysdynResource { public final Resource IsHeadOf; public final Resource IsTailOf; public final Resource Stock; - public final Resource TestConfiguration; + public final Resource SysdynProject; public final Resource Valve; public final Resource Variable; @@ -53,7 +53,7 @@ public class SysdynResource { public static final String IsHeadOf = "http://www.simantics.org/Sysdyn#IsHeadOf"; public static final String IsTailOf = "http://www.simantics.org/Sysdyn#IsTailOf"; public static final String Stock = "http://www.simantics.org/Sysdyn#Stock"; - public static final String TestConfiguration = "http://www.simantics.org/Sysdyn#TestConfiguration"; + public static final String SysdynProject = "http://www.simantics.org/Sysdyn#SysdynProject"; public static final String Valve = "http://www.simantics.org/Sysdyn#Valve"; public static final String Variable = "http://www.simantics.org/Sysdyn#Variable"; } @@ -83,7 +83,7 @@ public class SysdynResource { IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf); IsTailOf = getResourceOrNull(graph, URIs.IsTailOf); Stock = getResourceOrNull(graph, URIs.Stock); - TestConfiguration = getResourceOrNull(graph, URIs.TestConfiguration); + SysdynProject = getResourceOrNull(graph, URIs.SysdynProject); Valve = getResourceOrNull(graph, URIs.Valve); Variable = getResourceOrNull(graph, URIs.Variable); } diff --git a/sysdyn_ontologies/install.map b/sysdyn_ontologies/install.map index 15cfc257..a3fbef17 100644 --- a/sysdyn_ontologies/install.map +++ b/sysdyn_ontologies/install.map @@ -1 +1 @@ -copy=org/simantics/sysdyn=../org.simantics.sysdyn.ui/src +copy=org/simantics/sysdyn=../org.simantics.sysdyn/src diff --git a/sysdyn_ontologies/sysdyn.graph b/sysdyn_ontologies/sysdyn.graph index eadd105a..14f13607 100644 --- a/sysdyn_ontologies/sysdyn.graph +++ b/sysdyn_ontologies/sysdyn.graph @@ -1,5 +1,6 @@ %import "layer0.graph" L0 %import "structural2.graph" ST +%import "project.graph" PROJ %deflib L0.Type Sysdyn %deflib L0.Relation Sysdyn @@ -9,17 +10,25 @@ ###################################################################### Sysdyn @ "Sysdyn-1.0" : L0.Ontology - L0.PartOf L0.TypeSystemProject - L0.PartOf L0.SimanticsDomain - L0.HasNamespace "http://www.simantics.org/Sysdyn" : L0.URI - L0.HasVersion "1.0" : L0.Version - L0.HasResourceClass "org.simantics.sysdyn.SysdynResource" : L0.String - L0.HasPackageName "sysdyn" : L0.String + L0.PartOf L0.TypeSystemProject + L0.PartOf L0.SimanticsDomain + L0.HasNamespace "http://www.simantics.org/Sysdyn" : L0.URI + L0.HasVersion "1.0" : L0.Version + L0.HasResourceClass "org.simantics.sysdyn.SysdynResource" : L0.String + L0.HasPackageName "sysdyn" : L0.String SysdynNamespace : L0.Namespace - L0.PartOf L0.TypeSystemNamespaces - L0.HasNamespace "http://www.simantics.org/Sysdyn" : L0.URI - L0.HasNamespaceRoot Sysdyn + L0.PartOf L0.TypeSystemNamespaces + L0.HasNamespace "http://www.simantics.org/Sysdyn" : L0.URI + L0.HasNamespaceRoot Sysdyn +SysdynProject : PROJ.Feature + L0.PartOf Sysdyn + L0.PartOf PROJ.PublishedProjectFeatures + +SysdynTest : PROJ.Project2 + PROJ.HasFeature SysdynProject + L0.PartOf L0.Projects + ###################################################################### # Configuration ###################################################################### @@ -78,18 +87,7 @@ Flow