]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Additional information -tab for variables
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 17 Jun 2010 14:57:09 +0000 (14:57 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 17 Jun 2010 14:57:09 +0000 (14:57 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16193 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableCommentTab.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/TextWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyFactory.java
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
sysdyn_ontologies/sysdyn.graph

diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableCommentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableCommentTab.java
deleted file mode 100644 (file)
index a82fb44..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.simantics.sysdyn.ui.properties;\r
-\r
-public class VariableCommentTab {\r
-\r
-}\r
index e220bcba3013260eeab18458d939d1f053401c6f..bf72c8278e0046d42979b510157d7c4d5e1e6db2 100644 (file)
@@ -10,6 +10,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Text;\r
 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactory;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.db.Resource;\r
@@ -98,32 +99,34 @@ public class TextWidget implements Widget {
     @SuppressWarnings("unchecked")\r
     public void save() {\r
         if(originalText.equals(textWidget.getText())) return;\r
-        \r
-        final String text = textWidget.getText();\r
-        \r
+\r
+        final String text = textWidget.getText().trim();\r
+\r
         SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
-            \r
+\r
             @Override\r
             public void perform(WriteGraph graph) throws DatabaseException {\r
-                \r
+\r
                 Triple triple = null;\r
                 Object object = null;\r
+                triple = (Triple) ((ReadFactoryImpl)readFactory).getIdentity(null);\r
+                if(triple == null) return;\r
                 \r
-                if(readFactory instanceof DoublePropertyFactory) {\r
-                    DoublePropertyFactory factory = (DoublePropertyFactory)readFactory;\r
-                    triple = (Triple) factory.getIdentity(null);\r
-                    object = Double.parseDouble(text);\r
-                } else if (readFactory instanceof StringPropertyFactory) {\r
-                    StringPropertyFactory factory = (StringPropertyFactory)readFactory;\r
-                    triple = (Triple) factory.getIdentity(null);\r
-                    object = text;\r
+                if(!text.equals("")) {\r
+                    if(readFactory instanceof DoublePropertyFactory) {\r
+                        object = Double.parseDouble(text);\r
+                    } else if (readFactory instanceof StringPropertyFactory) {\r
+                        object = text;\r
+                    }\r
+                    graph.claimValue(resource,  graph.getResource((String)triple.second), object);\r
+                } else {\r
+                    Resource relation = graph.getResource((String)triple.second);\r
+                    if (graph.hasStatement(resource, relation))\r
+                        graph.deny(resource, relation);\r
                 }\r
-                \r
-                if(triple == null || object == null) return;\r
-                graph.claimValue(resource,  graph.getResource((String)triple.second), object);\r
             }\r
         });\r
-        \r
+\r
     }\r
 \r
     public void addKeyListener(KeyListener listener) {\r
@@ -133,7 +136,7 @@ public class TextWidget implements Widget {
     public void addVerifyListener(VerifyListener listener) {\r
         this.textWidget.addVerifyListener(listener);\r
     }\r
-    \r
+\r
     public void addFocusListener(FocusListener listener) {\r
         this.textWidget.addFocusListener(listener);\r
     }\r
index f7a5d666fed84dc40c92e9f5e61e4720db79618a..dbd48b1149e90f7f4dfabbf1e1e73298b305ee0a 100644 (file)
@@ -25,8 +25,10 @@ public class DoublePropertyFactory extends ReadFactoryImpl<Resource, String> {
     public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
         \r
         Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
-        return value.toString();\r
-        \r
+        if (value != null)\r
+            return value.toString();\r
+        else\r
+            return "";\r
     }\r
     \r
 }\r
index c6f7adaa0f87ac13a4c9aaccfb9eac0775acc15f..0377b37ab5b5dd05f586892efbd4ac6ea921d6d4 100644 (file)
@@ -45,6 +45,9 @@ public class SysdynResource {
     public final Resource HasMinX;\r
     public final Resource HasMinY;\r
     public final Resource HasParameterFile;\r
+    public final Resource HasRangeEnd;\r
+    public final Resource HasRangeStart;\r
+    public final Resource HasRangeStep;\r
     public final Resource HasResult;\r
     public final Resource HasResultFile;\r
     public final Resource HasStartTime;\r
@@ -107,6 +110,9 @@ public class SysdynResource {
         public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX";\r
         public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY";\r
         public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile";\r
+        public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd";\r
+        public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart";\r
+        public static final String HasRangeStep = "http://www.simantics.org/Sysdyn-1.0/HasRangeStep";\r
         public static final String HasResult = "http://www.simantics.org/Sysdyn-1.0/HasResult";\r
         public static final String HasResultFile = "http://www.simantics.org/Sysdyn-1.0/HasResultFile";\r
         public static final String HasStartTime = "http://www.simantics.org/Sysdyn-1.0/HasStartTime";\r
@@ -179,6 +185,9 @@ public class SysdynResource {
         HasMinX = getResourceOrNull(graph, URIs.HasMinX);\r
         HasMinY = getResourceOrNull(graph, URIs.HasMinY);\r
         HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile);\r
+        HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
+        HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
+        HasRangeStep = getResourceOrNull(graph, URIs.HasRangeStep);\r
         HasResult = getResourceOrNull(graph, URIs.HasResult);\r
         HasResultFile = getResourceOrNull(graph, URIs.HasResultFile);\r
         HasStartTime = getResourceOrNull(graph, URIs.HasStartTime);\r
index 6cd7f836917bd333185fde5ae8c57905651840c6..01475b73d4b37303067665ac45718ebfd75e2e5b 100644 (file)
@@ -119,12 +119,25 @@ HasType <R L0.HasProperty : L0.FunctionalRelation
 \r
 HasUnit <R L0.HasProperty\r
     L0.HasRange L0.String\r
+    \r
+HasRangeStart <R L0.HasProperty\r
+    L0.HasRange L0.Double    \r
+    \r
+HasRangeEnd <R L0.HasProperty\r
+    L0.HasRange L0.Double  \r
+    \r
+HasRangeStep <R L0.HasProperty\r
+    L0.HasRange L0.Double  \r
 \r
 IndependentVariable <T Variable\r
-    \r
     [HasType card "1"]\r
     [HasUnit card "0..1"]\r
     [HasExpression card "0..1"]    \r
+    [HasRangeStart card "0..1"]\r
+    [HasRangeEnd card "0..1"]\r
+    [HasRangeStep card "0..1"]\r
+    [L0.HasDescription card "0..1"]\r
+    \r
 \r
 Auxiliary <T IndependentVariable\r
 \r