]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Unit selector, variable table focus fix
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 23 Dec 2009 14:56:28 +0000 (14:56 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 23 Dec 2009 14:56:28 +0000 (14:56 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13353 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/TextElement.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/UnitSelector.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/NormalExpressionView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionView.java
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
sysdyn_ontologies/sysdyn.graph

index 474fbd7e1747479f2de1f7669a92a1ce5ce514ae..23e93b938c0c0ec98629d94fe5fc07120ed511c3 100644 (file)
@@ -17,8 +17,10 @@ import org.simantics.h2d.event.handler.IEventHandler;
 import org.simantics.h2d.node.ITextListener;\r
 import org.simantics.h2d.node.TextNode;\r
 import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.sysdyn.ui.equation.expressions.ExpressionView;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn#Auxiliary")\r
 public class TextElement extends RectangularElement implements Movable, Connectable, IEventHandler {\r
@@ -37,6 +39,9 @@ public class TextElement extends RectangularElement implements Movable, Connecta
     \r
     @RelatedValue("http://www.vtt.fi/Simantics/Layer0/1.0/Relations#HasType")\r
     public String type = "Real";\r
+    \r
+    @RelatedElement("http://www.simantics.org/Sysdyn#HasExpression")\r
+    public ExpressionView expression;\r
        \r
        // Auxiliary fields\r
        double textX;\r
index 095bec4e3a42afa3b74e45401fe8451568c85d01..4fbd7345e391058ad01433cd46a2ea2a8fb5bbe6 100644 (file)
@@ -11,9 +11,12 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.FocusEvent;\r
 import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyAdapter;\r
+import org.eclipse.swt.events.KeyEvent;\r
 import org.eclipse.swt.events.MouseEvent;\r
 import org.eclipse.swt.events.MouseListener;\r
 import org.eclipse.swt.graphics.Font;\r
+import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.layout.RowLayout;\r
 import org.eclipse.swt.widgets.Combo;\r
 import org.eclipse.swt.widgets.Composite;\r
@@ -31,7 +34,11 @@ import org.eclipse.ui.part.ViewPart;
 import org.simantics.db.Builtins;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
+import org.simantics.db.exception.ServiceException;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -48,6 +55,8 @@ public class EquationView extends ViewPart implements ISelectionListener {
     Resource variable;\r
     ArrayList<String> dependencies;\r
     boolean disposed = false;\r
+    \r
+    Composite parent;\r
 \r
     Text nameText;\r
 \r
@@ -62,11 +71,14 @@ public class EquationView extends ViewPart implements ISelectionListener {
     Composite variableType;\r
     Composite emptyComposite;\r
     ExpressionView expressionView;\r
+    Composite unitComposite;\r
+    UnitSelector unitSelector;\r
 \r
     org.eclipse.ui.IPartListener2 focusLostListener;\r
 \r
     @Override    \r
     public void createPartControl(Composite parent) {\r
+        this.parent = parent;\r
         // Listeners\r
         getSite().getPage().addPostSelectionListener(this);\r
         focusLostListener = new org.eclipse.ui.IPartListener2()\r
@@ -78,8 +90,12 @@ public class EquationView extends ViewPart implements ISelectionListener {
             public void partDeactivated(IWorkbenchPartReference partRef)\r
             {\r
                 if(partRef.getPart(false) instanceof EquationView) {\r
+                    // Save expressions\r
                     if(expressionView != null) expressionView.save();\r
+                    // Save unit\r
+                    if(unitSelector != null) unitSelector.save();\r
                 }\r
+\r
             }\r
             public void partClosed(IWorkbenchPartReference partRef) {}\r
             public void partBroughtToTop(IWorkbenchPartReference partRef) {}\r
@@ -94,8 +110,24 @@ public class EquationView extends ViewPart implements ISelectionListener {
         // Upper part of the view: Name (and renaming)\r
         nameText = new Text(parent, SWT.SINGLE | SWT.BORDER);\r
         nameText.setFont(FONT);\r
-        GridDataFactory.fillDefaults().span(2, 1).applyTo(nameText);\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);\r
 \r
+        // After the variable name: Variable type\r
+        variableType = new Composite(parent, SWT.NONE);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).spacing(3, 0).applyTo(variableType);\r
+        GridDataFactory.fillDefaults().applyTo(variableType);\r
+        Label label = new Label(variableType, SWT.SINGLE);\r
+        label.setText("Type:");\r
+        Combo comboDropDown = new Combo(variableType, SWT.DROP_DOWN | SWT.BORDER);\r
+        comboDropDown.add("Auxiliary");\r
+        comboDropDown.add("Parameter");\r
+        comboDropDown.add("Constant");\r
+\r
+        unitComposite = new Composite(variableType, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(unitComposite);\r
+        GridLayoutFactory.fillDefaults().applyTo(unitComposite);\r
+        unitSelector = new UnitSelector(unitComposite, SWT.NONE, variable);\r
\r
         // Center side of the view: (related) variables and possible functions\r
         TabFolder tabFolder = new TabFolder (parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(1, 4).applyTo(tabFolder);\r
@@ -106,9 +138,9 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
             @Override\r
             public void mouseDoubleClick(MouseEvent e) {\r
-                TableItem[] selection = variableTable.getSelection();\r
-                if(selection.length > 0) {\r
-                    final String var = selection[0].getText();\r
+                TableItem item = variableTable.getItem(new Point(e.x, e.y));\r
+                if(item != null) {\r
+                    final String var = item.getText();\r
                     expressionView.getDisplay().asyncExec(new Runnable() {\r
 \r
                         @Override\r
@@ -120,10 +152,14 @@ public class EquationView extends ViewPart implements ISelectionListener {
             }\r
 \r
             @Override\r
-            public void mouseDown(MouseEvent e) {}\r
+            public void mouseDown(MouseEvent e) {\r
+                expressionView.focus();\r
+            }\r
 \r
             @Override\r
-            public void mouseUp(MouseEvent e) {}\r
+            public void mouseUp(MouseEvent e) {\r
+                expressionView.focus();\r
+            }\r
 \r
         });\r
 \r
@@ -157,36 +193,11 @@ public class EquationView extends ViewPart implements ISelectionListener {
         GridDataFactory.fillDefaults().span(1,4).grab(true, true).applyTo(emptyComposite);\r
         GridLayoutFactory.fillDefaults().applyTo(emptyComposite);\r
 \r
-\r
-        // Below the variable name: Variable type\r
-        variableType = new Composite(parent, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().numColumns(5).spacing(3, 0).applyTo(variableType);\r
-        GridDataFactory.fillDefaults().span(2, 1).applyTo(variableType);\r
-        Label label = new Label(variableType, SWT.SINGLE);\r
-        label.setText("Type:");\r
-        Combo comboDropDown = new Combo(variableType, SWT.DROP_DOWN | SWT.BORDER);\r
-        comboDropDown.add("Auxiliary");\r
-        comboDropDown.add("Lookup");\r
-        comboDropDown.add("Delay");\r
-        comboDropDown = new Combo(variableType, SWT.DROP_DOWN | SWT.BORDER);\r
-        comboDropDown.add("Normal");\r
-        comboDropDown.add("With Lookup");\r
-\r
-        label = new Label(variableType, SWT.SINGLE );\r
-        label.setText("Unit:");\r
-        label.setAlignment(SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().grab(true, false).align(SWT.END, SWT.CENTER).applyTo(label);\r
-        comboDropDown = new Combo(variableType, SWT.DROP_DOWN | SWT.BORDER);\r
-        comboDropDown.add("m");\r
-        comboDropDown.add("V");\r
-        comboDropDown.add("euro");\r
-\r
-        // Below variable type: Equation\r
+        // Below variable name: Equation\r
         equationComposite = new Composite(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(equationComposite);\r
         GridLayoutFactory.fillDefaults().applyTo(equationComposite);\r
-\r
-\r
+        expressionView = new NormalExpressionView(equationComposite, SWT.NONE, variable);  \r
 \r
         // Lower part of the view: Units and Range\r
         unitsAndRange = new Composite(parent, SWT.NONE); \r
@@ -235,7 +246,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
                 a.type = "NORMAL";\r
             else if (graph.isInstanceOf(variable, sr.Stock))\r
                 a.type = "STOCK";\r
-            \r
+\r
             return a;\r
         }\r
     }\r
@@ -273,9 +284,13 @@ public class EquationView extends ViewPart implements ISelectionListener {
                                             }\r
                                             nameText.setText(result.name);\r
 \r
+                                            if(unitSelector!= null) unitSelector.dispose();\r
+                                            unitSelector = new UnitSelector(unitComposite, SWT.NONE, variable);\r
+                                            unitComposite.layout();\r
+                                            \r
                                             for(Control c : equationComposite.getChildren()) {\r
                                                 c.dispose();\r
-                                            }        \r
+                                            }   \r
                                             \r
                                             ExpressionView ev = null;\r
                                             if (result.type.equalsIgnoreCase("NORMAL"))\r
@@ -284,7 +299,6 @@ public class EquationView extends ViewPart implements ISelectionListener {
                                                 ev = new StockExpressionView(equationComposite, SWT.NONE, variable);\r
                                             expressionView = ev;\r
                                             equationComposite.layout();\r
-\r
                                         }\r
                                     });      \r
 \r
@@ -303,7 +317,8 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
     @Override\r
     public void setFocus() {\r
-        //text.setFocus();\r
+        if(expressionView != null)\r
+            expressionView.focus();\r
     }\r
 \r
     // Returns the names of the related variables (dependencies)\r
@@ -322,11 +337,13 @@ public class EquationView extends ViewPart implements ISelectionListener {
                     Collection<Resource> dependencies = graph.getObjects(r, sr.IsHeadOf);\r
 \r
                     for(Resource d : dependencies) {\r
-                        Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
-                        if(tail != null) {\r
-                            Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
-                            if(name != null)\r
-                                variables.add((String)name);\r
+                        if(graph.isInstanceOf(d, sr.Dependency)) {\r
+                            Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
+                            if(tail != null) {\r
+                                Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
+                                if(name != null)\r
+                                    variables.add((String)name);\r
+                            }\r
                         }\r
                     }\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/UnitSelector.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/UnitSelector.java
new file mode 100644 (file)
index 0000000..238f981
--- /dev/null
@@ -0,0 +1,96 @@
+package org.simantics.sysdyn.ui.equation;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.FontMetrics;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class UnitSelector extends Composite {\r
+\r
+    Combo unitCombo;\r
+    Resource variable;\r
+    String unit = "";\r
+\r
+    public UnitSelector(Composite parent, int style, final Resource variable) {\r
+        super(parent, style);\r
+        this.variable = variable;\r
+        GridDataFactory.fillDefaults().applyTo(this);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(this);\r
+\r
+        if(variable != null) {\r
+            try {\r
+                SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+                    @Override\r
+                    public String perform(ReadGraph graph) throws DatabaseException {\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        unit = graph.getPossibleRelatedValue(variable, sr.HasUnit);\r
+                        return null;\r
+                    }\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        }\r
+\r
+\r
+        Label label = new Label(this, SWT.SINGLE );\r
+        label.setFont(EquationView.FONT);\r
+        label.setText("Unit:");\r
+        //label.setAlignment(SWT.RIGHT);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+\r
+        unitCombo = new Combo(this, SWT.DROP_DOWN | SWT.BORDER);\r
+        unitCombo.setFont(EquationView.FONT);\r
+        \r
+        int columns = 6;\r
+        GC gc = new GC (unitCombo);\r
+        FontMetrics fm = gc.getFontMetrics ();\r
+        int width = columns * fm.getAverageCharWidth ();\r
+        int height = fm.getHeight ();\r
+        gc.dispose ();        \r
+        GridDataFactory.fillDefaults().hint(unitCombo.computeSize(width, height)).applyTo(unitCombo);\r
+        \r
+        unitCombo.add("m");\r
+        unitCombo.add("V");\r
+        unitCombo.add("euro");\r
+        if (unit != null)\r
+            if(unitCombo.indexOf(unit) >= 0)\r
+                unitCombo.select(unitCombo.indexOf(unit));\r
+            else\r
+                unitCombo.setText(unit);\r
+    }\r
+\r
+    public void save(){\r
+        final String unitNew = unitCombo.getText();\r
+        if(unitNew != null && !unitNew.equals(unit)) {\r
+            SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+                @Override\r
+                public void perform(WriteGraph g)\r
+                throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(g);\r
+                    if (!unitNew.equals(""))\r
+                        g.claimValue(variable, sr.HasUnit, unitNew);\r
+                    else if (g.getPossibleRelatedValue(variable, sr.HasUnit) != null)\r
+                        g.deny(variable, sr.HasUnit);\r
+                }\r
+            });\r
+        }\r
+\r
+    }\r
+\r
+}\r
index 8b55b095dd09d07189bd0ec1941ef5ce13480b3c..df47203ce3f40ab6a3d1ab52c80af38278d80834 100644 (file)
@@ -17,4 +17,5 @@ abstract public class ExpressionView extends Composite {
  \r
     abstract public void save();\r
     abstract public void replaceSelection(String text);\r
+    abstract public void  focus();\r
 }\r
index 7fb0bc652ffff89acfd90d646a9ec1529fd69e3a..73144c123d5d95ea7db12e885dd1c339680a66e8 100644 (file)
@@ -36,24 +36,28 @@ public class NormalExpressionView extends ExpressionView {
     public NormalExpressionView(Composite parent, int style, final Resource variable) {\r
         super(parent, style, variable);\r
 \r
-        try {\r
-            SimanticsUI.getSession().syncRequest(new Read<String>() {\r
-\r
-                @Override\r
-                public String perform(ReadGraph graph) throws DatabaseException {\r
-                    SysdynResource sr = SysdynResource.getInstance(graph);\r
-                    Resource expression = graph.getPossibleObject(variable, sr.HasExpression);\r
-                    if (expression != null && graph.isInstanceOf(expression, sr.NormalExpression)) {\r
-                        equation = graph.getRelatedValue(expression, sr.HasEquation);\r
-                    } else {\r
-                        equation = "";\r
+        if (variable != null) {\r
+            try {\r
+                SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+\r
+                    @Override\r
+                    public String perform(ReadGraph graph) throws DatabaseException {\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        Resource expression = graph.getPossibleObject(variable, sr.HasExpression);\r
+                        if (expression != null && graph.isInstanceOf(expression, sr.NormalExpression)) {\r
+                            equation = graph.getRelatedValue(expression, sr.HasEquation);\r
+                        } else {\r
+                            equation = "";\r
+                        }\r
+                        return null;\r
                     }\r
-                    return null;\r
-                }\r
 \r
-            });\r
-        } catch (DatabaseException e1) {\r
-            e1.printStackTrace();\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        } else {\r
+            equation = "";\r
         }\r
 \r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
@@ -68,7 +72,7 @@ public class NormalExpressionView extends ExpressionView {
         expression.setFont(FONT);\r
         expression.setText(equation);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-        \r
+\r
         expression.addFocusListener(new FocusAdapter() {\r
 \r
             @Override\r
@@ -114,10 +118,15 @@ public class NormalExpressionView extends ExpressionView {
         }\r
 \r
     }\r
-    \r
+\r
     public void replaceSelection(String text) {\r
         String oldExpression = expression.getText();\r
         String newExpression = oldExpression.substring(0, lastSelection.x) + text + oldExpression.substring(lastSelection.y);\r
         expression.setText(newExpression);\r
+        expression.setSelection(lastSelection.x + text.length());\r
+    }\r
+\r
+    public void focus() {\r
+        expression.forceFocus();\r
     }\r
 }\r
index e640eedf7ebe0b3dc9d2b7a1def5a5857d10a3ae..d7d24ac74e6ed9f9a040fd44ede93421870fb8d4 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.sysdyn.ui.equation.expressions;\r
 \r
+import java.util.Collection;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.swt.SWT;\r
@@ -26,6 +28,8 @@ import org.simantics.ui.SimanticsUI;
 @GraphType("http://www.simantics.org/Sysdyn#StockExpression")\r
 public class StockExpressionView extends ExpressionView {\r
 \r
+    Label integralLabel;\r
+    Text integral;\r
     Label equationLabel;\r
     Text expression;\r
     Point lastSelection = new Point(0,0);\r
@@ -58,6 +62,18 @@ public class StockExpressionView extends ExpressionView {
         \r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
         GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(this);\r
+\r
+        integralLabel = new Label(this, SWT.NONE);\r
+        integralLabel.setFont(FONT);\r
+        integralLabel.setText("Integral");\r
+        GridDataFactory.fillDefaults().applyTo(integralLabel);\r
+        \r
+        integral = new Text(this, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        integral.setEditable(false);\r
+        integral.setFont(FONT);\r
+        integral.setText(getIntegral());\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(integral);\r
+        \r
         equationLabel = new Label(this, SWT.NONE);\r
         equationLabel.setFont(FONT);\r
         equationLabel.setText("Initial\nValue");\r
@@ -95,7 +111,8 @@ public class StockExpressionView extends ExpressionView {
     public void replaceSelection(String text) {\r
         String oldExpression = expression.getText();\r
         String newExpression = oldExpression.substring(0, lastSelection.x) + text + oldExpression.substring(lastSelection.y);\r
-        expression.setText(newExpression);        \r
+        expression.setText(newExpression);      \r
+        expression.setSelection(lastSelection.x + text.length());\r
     }\r
 \r
     @Override\r
@@ -119,9 +136,57 @@ public class StockExpressionView extends ExpressionView {
                 }\r
 \r
             });\r
-        }\r
+        }        \r
+    }\r
+    \r
+    public void focus() {\r
+        expression.forceFocus();\r
+    }\r
+    \r
+    private String getIntegral() {\r
+        String integral = "";\r
+        try {\r
+            integral = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
 \r
-        \r
+                @Override\r
+                public String perform(ReadGraph graph) throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    Builtins b = graph.getBuiltins();\r
+                    Collection<Resource> heads = graph.getObjects(variable, sr.IsHeadOf);\r
+                    Collection<Resource> tails = graph.getObjects(variable, sr.IsTailOf);\r
+                    \r
+                    StringBuilder builder = new StringBuilder();\r
+                    builder.append("");\r
+                    for (Resource r : heads) {\r
+                        if(graph.isInstanceOf(r, sr.Flow)) {\r
+                            Resource tail = graph.getPossibleObject(r, sr.HasTail);\r
+                            if(tail != null) {\r
+                                Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
+                                if (name != null) \r
+                                    builder.append(" + " + name);\r
+                            }\r
+                        }  \r
+                    }\r
+                    for (Resource r : tails) {\r
+                        if(graph.isInstanceOf(r, sr.Flow)) {\r
+                            Resource head = graph.getPossibleObject(r, sr.HasHead);\r
+                            if(head != null) {\r
+                                Object name = graph.getPossibleRelatedValue(head, b.HasName);\r
+                                if (name != null) \r
+                                    builder.append(" - " + name);\r
+                            }\r
+                        }  \r
+                    }\r
+                    if (builder.indexOf(" + ") == 0)\r
+                        builder.delete(0, 3);\r
+                    return builder.toString().trim();\r
+                }\r
+                \r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }      \r
+        return integral;\r
     }\r
 \r
 }\r
index 3546148fe4f4012ae0cee627f7460b094509573e..4987d1a981e20950116634a88d60ffc0cff2d8a0 100644 (file)
@@ -31,6 +31,7 @@ public class SysdynResource {
     public final Resource HasInitialEquation;\r
     public final Resource HasTail;\r
     public final Resource HasType;\r
+    public final Resource HasUnit;\r
     public final Resource HasX;\r
     public final Resource HasY;\r
     public final Resource IndependentVariable;\r
@@ -58,6 +59,7 @@ public class SysdynResource {
         public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn#HasInitialEquation";\r
         public static final String HasTail = "http://www.simantics.org/Sysdyn#HasTail";\r
         public static final String HasType = "http://www.simantics.org/Sysdyn#HasType";\r
+        public static final String HasUnit = "http://www.simantics.org/Sysdyn#HasUnit";\r
         public static final String HasX = "http://www.simantics.org/Sysdyn#HasX";\r
         public static final String HasY = "http://www.simantics.org/Sysdyn#HasY";\r
         public static final String IndependentVariable = "http://www.simantics.org/Sysdyn#IndependentVariable";\r
@@ -95,6 +97,7 @@ public class SysdynResource {
         HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
         HasTail = getResourceOrNull(graph, URIs.HasTail);\r
         HasType = getResourceOrNull(graph, URIs.HasType);\r
+        HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
         HasX = getResourceOrNull(graph, URIs.HasX);\r
         HasY = getResourceOrNull(graph, URIs.HasY);\r
         IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
index 97cae434e1fb788aeabb58806f497c25b0720139..d25d867e410a471eec251c41113235e7244298dc 100644 (file)
@@ -52,18 +52,23 @@ HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation
     \r
 HasType <R L0.HasProperty\r
     L0.HasRange L0.String\r
-    \r
+\r
+HasUnit <R L0.HasProperty\r
+    L0.HasRange L0.String\r
+\r
 IndependentVariable <T Variable\r
     [L0.HasName card "1"]\r
     [HasType card "1"]\r
+    [HasUnit card "0..1"]\r
+    [HasExpression card "0..1"]\r
     \r
 \r
 Auxiliary <T IndependentVariable\r
-    [HasExpression card "0..1"]\r
+    \r
 Stock <T IndependentVariable\r
-    [HasExpression card "0..1"]\r
+\r
 Valve <T IndependentVariable\r
-    [HasExpression card "0..1"]\r
+\r
 Cloud <T IndependentVariable      \r
 \r
 ######################################################################\r