From 1d83cffe12d3aea366d154e952d2758e52b2c325 Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 17 Jun 2010 14:57:09 +0000 Subject: [PATCH] Additional information -tab for variables git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16193 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../ui/properties/VariableCommentTab.java | 5 --- .../ui/properties/widgets/TextWidget.java | 39 ++++++++++--------- .../factories/DoublePropertyFactory.java | 6 ++- .../org/simantics/sysdyn/SysdynResource.java | 9 +++++ sysdyn_ontologies/sysdyn.graph | 15 ++++++- 5 files changed, 48 insertions(+), 26 deletions(-) delete mode 100644 org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableCommentTab.java 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 index a82fb440..00000000 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableCommentTab.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.simantics.sysdyn.ui.properties; - -public class VariableCommentTab { - -} diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/TextWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/TextWidget.java index e220bcba..bf72c827 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/TextWidget.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/TextWidget.java @@ -10,6 +10,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory; import org.simantics.browsing.ui.swt.widgets.impl.ReadFactory; +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; import org.simantics.browsing.ui.swt.widgets.impl.Widget; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.Resource; @@ -98,32 +99,34 @@ public class TextWidget implements Widget { @SuppressWarnings("unchecked") public void save() { if(originalText.equals(textWidget.getText())) return; - - final String text = textWidget.getText(); - + + final String text = textWidget.getText().trim(); + SimanticsUI.getSession().asyncRequest(new WriteRequest() { - + @Override public void perform(WriteGraph graph) throws DatabaseException { - + Triple triple = null; Object object = null; + triple = (Triple) ((ReadFactoryImpl)readFactory).getIdentity(null); + if(triple == null) return; - if(readFactory instanceof DoublePropertyFactory) { - DoublePropertyFactory factory = (DoublePropertyFactory)readFactory; - triple = (Triple) factory.getIdentity(null); - object = Double.parseDouble(text); - } else if (readFactory instanceof StringPropertyFactory) { - StringPropertyFactory factory = (StringPropertyFactory)readFactory; - triple = (Triple) factory.getIdentity(null); - object = text; + if(!text.equals("")) { + if(readFactory instanceof DoublePropertyFactory) { + object = Double.parseDouble(text); + } else if (readFactory instanceof StringPropertyFactory) { + object = text; + } + graph.claimValue(resource, graph.getResource((String)triple.second), object); + } else { + Resource relation = graph.getResource((String)triple.second); + if (graph.hasStatement(resource, relation)) + graph.deny(resource, relation); } - - if(triple == null || object == null) return; - graph.claimValue(resource, graph.getResource((String)triple.second), object); } }); - + } public void addKeyListener(KeyListener listener) { @@ -133,7 +136,7 @@ public class TextWidget implements Widget { public void addVerifyListener(VerifyListener listener) { this.textWidget.addVerifyListener(listener); } - + public void addFocusListener(FocusListener listener) { this.textWidget.addFocusListener(listener); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyFactory.java index f7a5d666..dbd48b11 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/DoublePropertyFactory.java @@ -25,8 +25,10 @@ public class DoublePropertyFactory extends ReadFactoryImpl { public String perform(ReadGraph graph, Resource issue) throws DatabaseException { Double value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI)); - return value.toString(); - + if (value != null) + return value.toString(); + else + return ""; } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java index c6f7adaa..0377b37a 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java @@ -45,6 +45,9 @@ public class SysdynResource { public final Resource HasMinX; public final Resource HasMinY; public final Resource HasParameterFile; + public final Resource HasRangeEnd; + public final Resource HasRangeStart; + public final Resource HasRangeStep; public final Resource HasResult; public final Resource HasResultFile; public final Resource HasStartTime; @@ -107,6 +110,9 @@ public class SysdynResource { public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX"; public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY"; public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile"; + public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd"; + public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart"; + public static final String HasRangeStep = "http://www.simantics.org/Sysdyn-1.0/HasRangeStep"; public static final String HasResult = "http://www.simantics.org/Sysdyn-1.0/HasResult"; public static final String HasResultFile = "http://www.simantics.org/Sysdyn-1.0/HasResultFile"; public static final String HasStartTime = "http://www.simantics.org/Sysdyn-1.0/HasStartTime"; @@ -179,6 +185,9 @@ public class SysdynResource { HasMinX = getResourceOrNull(graph, URIs.HasMinX); HasMinY = getResourceOrNull(graph, URIs.HasMinY); HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile); + HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd); + HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart); + HasRangeStep = getResourceOrNull(graph, URIs.HasRangeStep); HasResult = getResourceOrNull(graph, URIs.HasResult); HasResultFile = getResourceOrNull(graph, URIs.HasResultFile); HasStartTime = getResourceOrNull(graph, URIs.HasStartTime); diff --git a/sysdyn_ontologies/sysdyn.graph b/sysdyn_ontologies/sysdyn.graph index 6cd7f836..01475b73 100644 --- a/sysdyn_ontologies/sysdyn.graph +++ b/sysdyn_ontologies/sysdyn.graph @@ -119,12 +119,25 @@ HasType