]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Different expression types, some examples
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 11 Jan 2010 13:14:12 +0000 (13:14 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 11 Jan 2010 13:14:12 +0000 (13:14 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@13473 ac1ea38d-2e2b-0410-8846-a27921b304fc

15 files changed:
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/ExpressionController.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/TypeSelector.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/NormalExpressionView.java with 57% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionView.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionView.java with 61% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
sysdyn_ontologies/sysdyn.graph

index 23e93b938c0c0ec98629d94fe5fc07120ed511c3..0d6b6e73c31f72d8940f3a122f879ae7cf5936e8 100644 (file)
@@ -17,10 +17,8 @@ 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
@@ -40,9 +38,6 @@ public class TextElement extends RectangularElement implements Movable, Connecta
     @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
        double textY;\r
index 785deb0b3346294177449d8fdcdeabc27e025337..f3ac8a384705a667b8f06dc3eee66f109e2a57f3 100644 (file)
@@ -17,9 +17,7 @@ import org.eclipse.swt.events.MouseListener;
 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
-import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Label;\r
 import org.eclipse.swt.widgets.TabFolder;\r
 import org.eclipse.swt.widgets.TabItem;\r
@@ -37,9 +35,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.equation.expressions.ExpressionView;\r
-import org.simantics.sysdyn.ui.equation.expressions.NormalExpressionView;\r
-import org.simantics.sysdyn.ui.equation.expressions.StockExpressionView;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
@@ -59,20 +54,25 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
     Text nameText;\r
 \r
-    Composite equationComposite;\r
+    \r
 \r
+    Composite emptyComposite;\r
     String originalText;\r
     TabFolder tabFolder;\r
     TabItem variables;\r
     Table variableTable;\r
     TabItem functions;\r
+    \r
     Composite unitsAndRange;\r
-    Composite variableType;\r
-    Composite emptyComposite;\r
-    ExpressionView expressionView;\r
+    \r
+    Composite typeComposite;\r
+    ExpressionController expressionController;\r
+    \r
     Composite unitComposite;\r
     UnitSelector unitSelector;\r
-\r
+    \r
+    Composite equationComposite;\r
+    \r
     org.eclipse.ui.IPartListener2 focusLostListener;\r
 \r
     @Override    \r
@@ -91,7 +91,11 @@ public class EquationView extends ViewPart implements ISelectionListener {
             {\r
                 if(partRef.getPart(false) instanceof EquationView) {\r
                     // Save expressions\r
-                    if(expressionView != null) expressionView.save();\r
+                    if(expressionController != null) {\r
+                        expressionController.save();\r
+                    }\r
+\r
+                    \r
                     // Save unit\r
                     if(unitSelector != null) {\r
                         String unitNew = unitSelector.save();                       \r
@@ -119,16 +123,15 @@ public class EquationView extends ViewPart implements ISelectionListener {
         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
+        Composite variableType = new Composite(parent, SWT.NONE);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).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
+        \r
+        typeComposite = new Composite(variableType, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(typeComposite);\r
+        GridLayoutFactory.fillDefaults().applyTo(typeComposite);\r
+        expressionController = new ExpressionController(typeComposite, SWT.NONE, variable, equationComposite);\r
+        \r
         unitComposite = new Composite(variableType, SWT.NONE);\r
         GridDataFactory.fillDefaults().applyTo(unitComposite);\r
         GridLayoutFactory.fillDefaults().applyTo(unitComposite);\r
@@ -148,11 +151,11 @@ public class EquationView extends ViewPart implements ISelectionListener {
                 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
+                    equationComposite.getDisplay().asyncExec(new Runnable() {\r
 \r
                         @Override\r
                         public void run() {\r
-                            expressionView.replaceSelection(var);\r
+                            expressionController.getExpressionViewFactor().replaceSelection(var);\r
                         }\r
                     });\r
                 }\r
@@ -160,12 +163,12 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
             @Override\r
             public void mouseDown(MouseEvent e) {\r
-                expressionView.focus();\r
+                expressionController.getExpressionViewFactor().focus();\r
             }\r
 \r
             @Override\r
             public void mouseUp(MouseEvent e) {\r
-                expressionView.focus();\r
+                expressionController.getExpressionViewFactor().focus();\r
             }\r
 \r
         });\r
@@ -201,10 +204,10 @@ public class EquationView extends ViewPart implements ISelectionListener {
         GridLayoutFactory.fillDefaults().applyTo(emptyComposite);\r
 \r
         // Below variable name: Equation\r
+        // equationComposite content is controlled by ExpressionController \r
         equationComposite = new Composite(parent, SWT.NONE);\r
         GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(equationComposite);\r
         GridLayoutFactory.fillDefaults().applyTo(equationComposite);\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
@@ -212,7 +215,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
         RowLayout layout = new RowLayout();\r
         layout.spacing = 3;\r
         unitsAndRange.setLayout(layout);\r
-        label = new Label(unitsAndRange, SWT.SINGLE);\r
+        Label label = new Label(unitsAndRange, SWT.SINGLE);\r
         label.setText("Range:");\r
         label.setAlignment(SWT.RIGHT);\r
         Composite c =  new Composite(unitsAndRange, SWT.NONE);\r
@@ -300,19 +303,12 @@ public class EquationView extends ViewPart implements ISelectionListener {
                                             unitSelector = new UnitSelector(unitComposite, SWT.NONE, variable, units);\r
                                             unitComposite.layout();\r
                                             \r
-                                            nameText.setText(result.name);\r
+                                            if(expressionController!= null) expressionController.dispose();\r
+                                            expressionController = new ExpressionController(typeComposite, SWT.NONE, variable, equationComposite);\r
+                                            typeComposite.layout();\r
                                             \r
-                                            for(Control c : equationComposite.getChildren()) {\r
-                                                c.dispose();\r
-                                            }   \r
+                                            nameText.setText(result.name);\r
                                             \r
-                                            ExpressionView ev = null;\r
-                                            if (result.type.equalsIgnoreCase("NORMAL"))\r
-                                                ev = new NormalExpressionView(equationComposite, SWT.NONE, variable);\r
-                                            else if (result.type.equalsIgnoreCase("STOCK"))\r
-                                                ev = new StockExpressionView(equationComposite, SWT.NONE, variable);\r
-                                            expressionView = ev;\r
-                                            equationComposite.layout();\r
                                         }\r
                                     });      \r
 \r
@@ -331,8 +327,15 @@ public class EquationView extends ViewPart implements ISelectionListener {
 \r
     @Override\r
     public void setFocus() {\r
-        if(expressionView != null)\r
-            expressionView.focus();\r
+        if(expressionController.getExpressionViewFactor() != null)\r
+            expressionController.getExpressionViewFactor().focus();\r
+    }\r
+    \r
+    @Override\r
+    public void dispose() {\r
+        disposed = true;\r
+        getViewSite().getPage().removePartListener(focusLostListener);\r
+        super.dispose();\r
     }\r
     \r
     // Returns all the used units in the model\r
@@ -414,11 +417,4 @@ public class EquationView extends ViewPart implements ISelectionListener {
         return variables;\r
     }\r
 \r
-    @Override\r
-    public void dispose() {\r
-        disposed = true;\r
-        getViewSite().getPage().removePartListener(focusLostListener);\r
-        super.dispose();\r
-    }\r
-\r
 }
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/ExpressionController.java
new file mode 100644 (file)
index 0000000..1f60cd0
--- /dev/null
@@ -0,0 +1,229 @@
+package org.simantics.sysdyn.ui.equation;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\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.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\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.Control;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.equation.expressions.AuxiliaryExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.ConstantExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.DelayExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.IExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.LookupExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.ParameterExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.StockExpressionViewFactor;\r
+import org.simantics.sysdyn.ui.equation.expressions.WithLookupExpressionViewFactor;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ExpressionController extends Composite {\r
+\r
+    Combo typeCombo;\r
+    Resource variable;\r
+    Map<String, Object> data;\r
+    Map<String, Object> origData;\r
+    Composite equationComposite;\r
+    IExpressionViewFactor expressionViewFactor;\r
+\r
+    //private enum VariableClass {Auxiliary, Valve, Stock};\r
+    private enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay};\r
+\r
+    ExpressionType[] auxiliaryExpressions = new ExpressionType[] {\r
+            ExpressionType.Parameter, \r
+            ExpressionType.Auxiliary, \r
+            ExpressionType.Constant, \r
+            ExpressionType.Lookup, \r
+            ExpressionType.WithLookup};\r
+\r
+    ExpressionType[] valveExpressions = new ExpressionType[] {\r
+            ExpressionType.Auxiliary, \r
+            ExpressionType.Parameter, \r
+            ExpressionType.Constant, \r
+            ExpressionType.WithLookup};\r
+\r
+    ExpressionType[] stockExpressions = new ExpressionType[] {\r
+            ExpressionType.Stock, \r
+            ExpressionType.Delay};\r
+\r
+    ExpressionType[] expressionTypes;\r
+    ExpressionType originalExpressionType;\r
+\r
+    HashMap<String, Map<String, Object>> expressions = new HashMap<String,  Map<String, Object>>();\r
+\r
+    public ExpressionController(final Composite parent, int style, final Resource variable, Composite equationComposite) {\r
+        super(parent, style);\r
+        this.variable = variable;\r
+        this.equationComposite = equationComposite;\r
+        this.expressionViewFactor = null;\r
+        this.data = new HashMap<String, Object>();\r
+        this.origData = new HashMap<String, Object>();\r
+        GridDataFactory.fillDefaults().applyTo(this);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(this);\r
+\r
+        if(variable != null) {\r
+            try {\r
+                expressionTypes = SimanticsUI.getSession().syncRequest(new Read< ExpressionType[]>() {\r
+\r
+                    @Override\r
+                    public  ExpressionType[] perform(ReadGraph graph) throws DatabaseException {\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        ExpressionType[] expressionTypes;\r
+                        if(graph.isInstanceOf(variable, sr.Auxiliary)) {\r
+                            expressionTypes = auxiliaryExpressions;\r
+                            originalExpressionType = ExpressionType.Auxiliary;\r
+                        }\r
+                        else if(graph.isInstanceOf(variable, sr.Valve)) {\r
+                            expressionTypes = valveExpressions;\r
+                            originalExpressionType = ExpressionType.Auxiliary;\r
+                        }\r
+                        else if(graph.isInstanceOf(variable, sr.Stock)) {\r
+                            expressionTypes = stockExpressions;\r
+                            originalExpressionType = ExpressionType.Stock;\r
+                        }\r
+                        else\r
+                            expressionTypes = null;\r
+\r
+                        ExpressionType oet = getOriginalExpressionType(graph, graph.getPossibleObject(variable, sr.HasExpression));\r
+                        if (oet != null)  originalExpressionType = oet;\r
+                        return expressionTypes;\r
+                    }\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        }\r
+\r
+        Label label = new Label(this, SWT.SINGLE );\r
+        label.setFont(EquationView.FONT);\r
+        label.setText("Type:");\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
+\r
+        typeCombo = new Combo(this, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+        typeCombo.setFont(EquationView.FONT);\r
+\r
+        int columns = 6;\r
+        GC gc = new GC (typeCombo);\r
+        FontMetrics fm = gc.getFontMetrics ();\r
+        int width = columns * fm.getAverageCharWidth ();\r
+        int height = fm.getHeight ();\r
+        gc.dispose ();        \r
+        GridDataFactory.fillDefaults().hint(typeCombo.computeSize(width, height)).applyTo(typeCombo);\r
+\r
+        typeCombo.removeAll();\r
+        if(this.expressionTypes != null) {\r
+            for(ExpressionType et : this.expressionTypes) {\r
+                typeCombo.add(et.toString());\r
+            }\r
+        }\r
+\r
+        if(originalExpressionType != null) {\r
+            displayExpressionView(variable, originalExpressionType, true);\r
+        }\r
+\r
+        typeCombo.addSelectionListener(new SelectionListener() {\r
+\r
+            @Override\r
+            public void widgetSelected(SelectionEvent e) {\r
+                displayExpressionView(variable, ExpressionType.valueOf(typeCombo.getItem(typeCombo.getSelectionIndex())), false);\r
+\r
+            }\r
+\r
+            @Override\r
+            public void widgetDefaultSelected(SelectionEvent e) {\r
+            }\r
+        });\r
+    }\r
+\r
+    private ExpressionType getOriginalExpressionType(ReadGraph graph, Resource expression) {\r
+        if(expression == null)\r
+            return null;\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        ExpressionType et = null;\r
+        try {\r
+            if(graph.isInstanceOf(expression, sr.NormalExpression)) {\r
+                et = ExpressionType.Auxiliary;\r
+            } else if (graph.isInstanceOf(expression, sr.StockExpression)) {\r
+                et = ExpressionType.Stock;\r
+            } else if (graph.isInstanceOf(expression, sr.ParameterExpression)) {\r
+                et = ExpressionType.Parameter;\r
+            } else if (graph.isInstanceOf(expression, sr.ConstantExpression)) {\r
+                et = ExpressionType.Constant;\r
+            } else if (graph.isInstanceOf(expression, sr.DelayExpression)) {\r
+                et = ExpressionType.Delay;\r
+            } else if (graph.isInstanceOf(expression, sr.LookupExpression)) {\r
+                et = ExpressionType.Lookup;\r
+            } else if (graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+                et = ExpressionType.WithLookup;\r
+            } else {\r
+                et = ExpressionType.Auxiliary;\r
+            }\r
+        } catch (ServiceException e) {\r
+            e.printStackTrace();\r
+        }\r
+\r
+        return et;\r
+    }\r
+\r
+\r
+    private void displayExpressionView(Resource variable, ExpressionType et, boolean original) {\r
+        int index = typeCombo.indexOf(et.toString());\r
+        if (index > -1) {\r
+            typeCombo.select(index);\r
+        }\r
+\r
+        IExpressionViewFactor evf = null;\r
+        switch (et) {\r
+            case Auxiliary: \r
+                evf = new AuxiliaryExpressionViewFactor(); break;\r
+            case Parameter: \r
+                evf = new ParameterExpressionViewFactor(); break;\r
+            case Constant: \r
+                evf = new ConstantExpressionViewFactor(); break;\r
+            case Lookup: \r
+                evf = new LookupExpressionViewFactor(); break;\r
+            case WithLookup: \r
+                evf = new WithLookupExpressionViewFactor(); break;\r
+            case Stock: \r
+                evf = new StockExpressionViewFactor(); break;\r
+            case Delay: \r
+                evf = new DelayExpressionViewFactor(); break;\r
+            default: ;\r
+        }\r
+        if (evf != null) {\r
+            for(Control c : equationComposite.getChildren()) {\r
+                c.dispose();\r
+            } \r
+            if(original) {\r
+                evf.readData(variable, data);\r
+                for(String key : data.keySet()) {\r
+                    origData.put(key, data.get(key));\r
+                }\r
+            }\r
+            evf.createView(equationComposite, data);\r
+            expressionViewFactor = evf;\r
+            equationComposite.layout();\r
+        }\r
+    }\r
+\r
+    public IExpressionViewFactor getExpressionViewFactor() {\r
+        return this.expressionViewFactor;\r
+    }\r
+\r
+    public void save() {\r
+        this.expressionViewFactor.writeData(variable, data);\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/TypeSelector.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/TypeSelector.java
deleted file mode 100644 (file)
index 277b94c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-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.widgets.Combo;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class TypeSelector extends Composite {\r
-    \r
-    Combo typeCombo;\r
-    Resource variable;\r
-\r
-    public TypeSelector(Composite parent, int style, final Resource variable) {\r
-        super(parent, style);\r
-        \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
-\r
-\r
-                        return null;\r
-                    }\r
-                });\r
-            } catch (DatabaseException e1) {\r
-                e1.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..6828ef1
--- /dev/null
@@ -0,0 +1,139 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\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.events.FocusAdapter;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.KeyAdapter;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Text;\r
+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.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor {\r
+    \r
+    private Label equationLabel;\r
+    private Text expression;\r
+    private Point lastSelection = new Point(0,0);\r
+    \r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
+\r
+        final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
+        \r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
+        equationLabel = new Label(parent, SWT.NONE);\r
+        equationLabel.setFont(FONT);\r
+        equationLabel.setText("=");\r
+        GridDataFactory.fillDefaults().applyTo(equationLabel);\r
+\r
+\r
+        expression = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        expression.setFont(FONT);\r
+        expression.setText(equation);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
+\r
+        expression.addFocusListener(new FocusAdapter() {\r
+\r
+            @Override\r
+            public void focusLost(FocusEvent e) {\r
+                lastSelection = expression.getSelection();      \r
+            }\r
+        });\r
+\r
+        expression.addKeyListener(new KeyAdapter() {          \r
+\r
+            @Override\r
+            public void keyPressed(KeyEvent e) {\r
+                if(e.keyCode == SWT.ESC) {\r
+                    expression.setText(equation);\r
+                }\r
+            }\r
+\r
+        });\r
+\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void readData(final Resource variable, Map<String, Object> data) {\r
+        String equation = null;        \r
+        if (variable != null && data.get("equation") == null) {\r
+            try {\r
+                equation = 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
+                            return graph.getRelatedValue(expression, sr.HasEquation);\r
+                        } else {\r
+                            return "";\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+            data.put("equation", equation);\r
+        }         \r
+    }\r
+\r
+    @Override\r
+    public void writeData(final Resource variable, Map<String, Object> data) {\r
+        final String currentText = expression.getText();\r
+        if(currentText != null) {\r
+            data.put("equation", currentText);\r
+            SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                @Override\r
+                public void perform(WriteGraph g)\r
+                throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(g);\r
+                    Resource expression = g.getPossibleObject(variable, sr.HasExpression);\r
+                    Builtins b = g.getBuiltins();\r
+                    if(expression != null) {\r
+                        g.deny(variable, sr.HasExpression);\r
+                    }\r
+                    expression = g.newResource();\r
+                    g.claim(expression, b.InstanceOf, sr.NormalExpression);\r
+                    g.claim(variable, sr.HasExpression, expression);\r
+                    g.claimValue(expression, sr.HasEquation, currentText);\r
+                }\r
+\r
+            });\r
+        }        \r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        if(this.expression != null) this.expression.forceFocus();\r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        if(this.expression != null) {\r
+            String oldExpression = expression.getText();\r
+            if(lastSelection == null)\r
+                lastSelection = new Point(0,0);\r
+            String newExpression = oldExpression.substring(0, lastSelection.x) + var + oldExpression.substring(lastSelection.y);\r
+            expression.setText(newExpression);\r
+            expression.setSelection(lastSelection.x + var.length());\r
+        }\r
+    }\r
+}\r
similarity index 57%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/NormalExpressionView.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java
index 73144c123d5d95ea7db12e885dd1c339680a66e8..708ef86c26d3baa63725b07672feaac2b5a0ebfe 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.sysdyn.ui.equation.expressions;\r
 \r
+import java.util.Map;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.swt.SWT;\r
@@ -18,57 +20,30 @@ import org.simantics.db.WriteGraph;
 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.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
-@GraphType("http://www.simantics.org/Sysdyn#NormalExpression")\r
-public class NormalExpressionView extends ExpressionView {\r
+public class ConstantExpressionViewFactor implements IExpressionViewFactor {\r
 \r
-    Label equationLabel;\r
-    Text expression;\r
-    Point lastSelection = new Point(0,0);\r
+    private Label equationLabel;\r
+    private Text expression;\r
+    private Point lastSelection = new Point(0,0);\r
 \r
-    @RelatedValue("http://www.simantics.org/Sysdyn#HasEquation")\r
-    private String equation;\r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
 \r
-    public NormalExpressionView(Composite parent, int style, final Resource variable) {\r
-        super(parent, style, variable);\r
+        final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\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
-                        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
-\r
-                });\r
-            } catch (DatabaseException e1) {\r
-                e1.printStackTrace();\r
-            }\r
-        } else {\r
-            equation = "";\r
-        }\r
-\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(this);\r
-        equationLabel = new Label(this, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
+        equationLabel = new Label(parent, SWT.NONE);\r
         equationLabel.setFont(FONT);\r
         equationLabel.setText("=");\r
         GridDataFactory.fillDefaults().applyTo(equationLabel);\r
 \r
 \r
-        expression = new Text(this, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        expression = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
         expression.setFont(FONT);\r
         expression.setText(equation);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
@@ -87,17 +62,61 @@ public class NormalExpressionView extends ExpressionView {
             public void keyPressed(KeyEvent e) {\r
                 if(e.keyCode == SWT.ESC) {\r
                     expression.setText(equation);\r
-                }                \r
+                }\r
             }\r
 \r
         });\r
 \r
+\r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        if(this.expression != null) this.expression.forceFocus();\r
+    }\r
+\r
+    @Override\r
+    public void readData(final Resource variable, Map<String, Object> data) {\r
+        String equation = null;        \r
+        if (variable != null && data.get("equation") == null) {\r
+            try {\r
+                equation = 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.ConstantExpression)) {\r
+                            return graph.getRelatedValue(expression, sr.HasEquation);\r
+                        } else {\r
+                            return "";\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+            data.put("equation", equation);\r
+        } \r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        if(this.expression != null) {\r
+            String oldExpression = expression.getText();\r
+            if(lastSelection == null)\r
+                lastSelection = new Point(0,0);\r
+            String newExpression = oldExpression.substring(0, lastSelection.x) + var + oldExpression.substring(lastSelection.y);\r
+            expression.setText(newExpression);\r
+            expression.setSelection(lastSelection.x + var.length());\r
+        }\r
     }\r
 \r
     @Override\r
-    public void save() {  \r
+    public void writeData(final Resource variable, Map<String, Object> data) {\r
         final String currentText = expression.getText();\r
-        if(equation != null && !equation.equals(currentText)) {\r
+        if(currentText != null) {\r
             SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
 \r
                 @Override\r
@@ -106,27 +125,17 @@ public class NormalExpressionView extends ExpressionView {
                     SysdynResource sr = SysdynResource.getInstance(g);\r
                     Resource expression = g.getPossibleObject(variable, sr.HasExpression);\r
                     Builtins b = g.getBuiltins();\r
-                    if(expression == null) {\r
-                        expression = g.newResource();\r
-                        g.claim(expression, b.InstanceOf, sr.NormalExpression);\r
-                        g.claim(variable, sr.HasExpression, expression);\r
+                    if(expression != null) {\r
+                        g.deny(variable, sr.HasExpression);\r
                     }\r
+                    expression = g.newResource();\r
+                    g.claim(expression, b.InstanceOf, sr.ConstantExpression);\r
+                    g.claim(variable, sr.HasExpression, expression);\r
                     g.claimValue(expression, sr.HasEquation, currentText);\r
                 }\r
 \r
             });\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
 \r
-    public void focus() {\r
-        expression.forceFocus();\r
-    }\r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..a254551
--- /dev/null
@@ -0,0 +1,40 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public class DelayExpressionViewFactor implements IExpressionViewFactor {\r
+\r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void readData(Resource variable, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void writeData(Resource variable, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionView.java
deleted file mode 100644 (file)
index df47203..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.db.Resource;\r
-\r
-abstract public class ExpressionView extends Composite {\r
-\r
-    static final Font FONT = new Font(null, "Courier New", 12, SWT.NORMAL);\r
-    protected Resource variable;\r
-    \r
-    public ExpressionView(Composite parent, int style, Resource variable) {\r
-        super(parent, style);\r
-        this.variable = variable;\r
-    }\r
\r
-    abstract public void save();\r
-    abstract public void replaceSelection(String text);\r
-    abstract public void  focus();\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..0cee3b4
--- /dev/null
@@ -0,0 +1,47 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Font;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public interface IExpressionViewFactor {\r
+\r
+    static final Font FONT = new Font(null, "Courier New", 12, SWT.NORMAL);\r
+    \r
+    /**\r
+     * Creates expression type specific user interface and initializes\r
+     * the components by the given data. The given map is linked \r
+     * to the ui components and updated.\r
+     * @param parent\r
+     * @param data\r
+     */\r
+    void createView(Composite parent, Map<String, Object> data);\r
+    /**\r
+     * Reads expression type specific data from database.\r
+     * @param variable\r
+     * @return\r
+     */\r
+    void readData(Resource variable, Map<String, Object> data);\r
+    \r
+    /**\r
+     * Writes expression type specific data to database.\r
+     * @param variable\r
+     * @return\r
+     */\r
+    void writeData(Resource variable, Map<String, Object> data);\r
+    \r
+    /**\r
+     * Focuses to some part of the expression view.\r
+     */\r
+    void focus();\r
+    \r
+    /**\r
+     * Replaces the current selection with a variable name.\r
+     * @param var\r
+     */\r
+    void replaceSelection(String var);\r
+    \r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..129c64c
--- /dev/null
@@ -0,0 +1,40 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.db.Resource;\r
+\r
+public class LookupExpressionViewFactor implements IExpressionViewFactor {\r
+\r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void readData(Resource variable, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void writeData(Resource variable, Map<String, Object> data) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..a5c02fb
--- /dev/null
@@ -0,0 +1,142 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\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.events.FocusAdapter;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.KeyAdapter;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Text;\r
+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.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ParameterExpressionViewFactor implements IExpressionViewFactor {\r
+    \r
+    private Label equationLabel;\r
+    private Text expression;\r
+    private Point lastSelection = new Point(0,0);\r
+    \r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
+        \r
+        final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
+        \r
+        \r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
+        equationLabel = new Label(parent, SWT.NONE);\r
+        equationLabel.setFont(FONT);\r
+        equationLabel.setText("=");\r
+        GridDataFactory.fillDefaults().applyTo(equationLabel);\r
+\r
+\r
+        expression = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        expression.setFont(FONT);\r
+        expression.setText(equation);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
+\r
+        expression.addFocusListener(new FocusAdapter() {\r
+\r
+            @Override\r
+            public void focusLost(FocusEvent e) {\r
+                lastSelection = expression.getSelection();\r
+            }\r
+        });\r
+\r
+        expression.addKeyListener(new KeyAdapter() {          \r
+\r
+            @Override\r
+            public void keyPressed(KeyEvent e) {\r
+                if(e.keyCode == SWT.ESC) {\r
+                    expression.setText(equation);\r
+                }\r
+            }\r
+\r
+        });\r
+\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        if(this.expression != null) this.expression.forceFocus();\r
+    }\r
+\r
+    @Override\r
+    public void readData(final Resource variable, Map<String, Object> data) {\r
+        String equation = null;        \r
+        if (variable != null && data.get("equation") == null) {\r
+            try {\r
+                equation = 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.ParameterExpression)) {\r
+                            return graph.getRelatedValue(expression, sr.HasEquation);\r
+                        } else {\r
+                            return "";\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+            data.put("equation", equation);\r
+        } \r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        if(this.expression != null) {\r
+            String oldExpression = expression.getText();\r
+            if(lastSelection == null)\r
+                lastSelection = new Point(0,0);\r
+            String newExpression = oldExpression.substring(0, lastSelection.x) + var + oldExpression.substring(lastSelection.y);\r
+            expression.setText(newExpression);\r
+            expression.setSelection(lastSelection.x + var.length());\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void writeData(final Resource variable, Map<String, Object> data) {\r
+        final String currentText = expression.getText();\r
+        if(currentText != null) {\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
+                    Resource expression = g.getPossibleObject(variable, sr.HasExpression);\r
+                    Builtins b = g.getBuiltins();\r
+                    if(expression != null) {\r
+                        g.deny(variable, sr.HasExpression);\r
+                    }\r
+                    expression = g.newResource();\r
+                    g.claim(expression, b.InstanceOf, sr.ParameterExpression);\r
+                    g.claim(variable, sr.HasExpression, expression);\r
+                    g.claimValue(expression, sr.HasEquation, currentText);\r
+                }\r
+\r
+            });\r
+        }        \r
+    }\r
+\r
+}\r
+\r
similarity index 61%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionView.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java
index d7d24ac74e6ed9f9a040fd44ede93421870fb8d4..f10447b906553d4daad94376ee6913438a5ed424 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.sysdyn.ui.equation.expressions;\r
 \r
 import java.util.Collection;\r
+import java.util.Map;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.layout.GridLayoutFactory;\r
@@ -20,13 +21,10 @@ import org.simantics.db.WriteGraph;
 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.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
-@GraphType("http://www.simantics.org/Sysdyn#StockExpression")\r
-public class StockExpressionView extends ExpressionView {\r
+public class StockExpressionViewFactor implements IExpressionViewFactor {\r
 \r
     Label integralLabel;\r
     Text integral;\r
@@ -34,57 +32,37 @@ public class StockExpressionView extends ExpressionView {
     Text expression;\r
     Point lastSelection = new Point(0,0);\r
 \r
-    @RelatedValue("http://www.simantics.org/Sysdyn#HasInitialEquation")\r
-    private String initialEquation;\r
-    \r
-    public StockExpressionView(Composite parent, int style, final Resource variable) {\r
-        super(parent, style, variable);\r
-        \r
-        try {\r
-            SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\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.StockExpression)) {\r
-                        initialEquation = graph.getRelatedValue(expression, sr.HasInitialEquation);\r
-                    } else {\r
-                        initialEquation = "";\r
-                    }\r
-                    return null;\r
-                }\r
+        final String initialEquation = data.get("initialEquation") != null ? (String)data.get("initialEquation") : "";\r
+        final String integralEquation = data.get("integral") != null ? (String)data.get("integral") : "";\r
 \r
-            });\r
-        } catch (DatabaseException e1) {\r
-            e1.printStackTrace();\r
-        }\r
-        \r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
-        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(this);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
 \r
-        integralLabel = new Label(this, SWT.NONE);\r
+        integralLabel = new Label(parent, 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
+\r
+        integral = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
         integral.setEditable(false);\r
         integral.setFont(FONT);\r
-        integral.setText(getIntegral());\r
+        integral.setText(integralEquation);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(integral);\r
-        \r
-        equationLabel = new Label(this, SWT.NONE);\r
+\r
+        equationLabel = new Label(parent, SWT.NONE);\r
         equationLabel.setFont(FONT);\r
         equationLabel.setText("Initial\nValue");\r
         GridDataFactory.fillDefaults().applyTo(equationLabel);\r
 \r
 \r
-        expression = new Text(this, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        expression = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
         expression.setFont(FONT);\r
         expression.setText(initialEquation);\r
         GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-        \r
+\r
         expression.addFocusListener(new FocusAdapter() {\r
 \r
             @Override\r
@@ -106,19 +84,39 @@ public class StockExpressionView extends ExpressionView {
 \r
     }\r
 \r
-\r
     @Override\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
+    public void readData(final Resource variable, Map<String, Object> data) {\r
+        String initialEquation = null;\r
+\r
+        if (variable != null && data.get("initialEquation") == null) {\r
+            try {\r
+                initialEquation = 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.StockExpression)) {\r
+                            return graph.getRelatedValue(expression, sr.HasInitialEquation);\r
+                        } else {\r
+                            return "";\r
+                        }\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+            data.put("initialEquation", initialEquation);\r
+        } \r
+\r
+        data.put("integral", getIntegral(variable));\r
     }\r
 \r
     @Override\r
-    public void save() {\r
+    public void writeData(final Resource variable, Map<String, Object> data) {\r
         final String currentText = expression.getText();\r
-        if(initialEquation != null && !initialEquation.equals(currentText)) {\r
+        if(currentText != null) {\r
             SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
 \r
                 @Override\r
@@ -127,23 +125,20 @@ public class StockExpressionView extends ExpressionView {
                     SysdynResource sr = SysdynResource.getInstance(g);\r
                     Resource expression = g.getPossibleObject(variable, sr.HasExpression);\r
                     Builtins b = g.getBuiltins();\r
-                    if(expression == null) {\r
-                        expression = g.newResource();\r
-                        g.claim(expression, b.InstanceOf, sr.StockExpression);\r
-                        g.claim(variable, sr.HasExpression, expression);\r
+                    if(expression != null) {\r
+                        g.deny(variable, sr.HasExpression);\r
                     }\r
+                    expression = g.newResource();\r
+                    g.claim(expression, b.InstanceOf, sr.StockExpression);\r
+                    g.claim(variable, sr.HasExpression, expression);\r
                     g.claimValue(expression, sr.HasInitialEquation, currentText);\r
                 }\r
 \r
             });\r
         }        \r
     }\r
-    \r
-    public void focus() {\r
-        expression.forceFocus();\r
-    }\r
-    \r
-    private String getIntegral() {\r
+\r
+    private String getIntegral(final Resource variable) {\r
         String integral = "";\r
         try {\r
             integral = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
@@ -154,7 +149,7 @@ public class StockExpressionView extends ExpressionView {
                     Builtins b = graph.getBuiltins();\r
                     Collection<Resource> heads = graph.getObjects(variable, sr.IsHeadOf);\r
                     Collection<Resource> tails = graph.getObjects(variable, sr.IsTailOf);\r
-                    \r
+\r
                     StringBuilder builder = new StringBuilder();\r
                     builder.append("");\r
                     for (Resource r : heads) {\r
@@ -181,7 +176,7 @@ public class StockExpressionView extends ExpressionView {
                         builder.delete(0, 3);\r
                     return builder.toString().trim();\r
                 }\r
-                \r
+\r
             });\r
         } catch (DatabaseException e) {\r
             e.printStackTrace();\r
@@ -189,4 +184,23 @@ public class StockExpressionView extends ExpressionView {
         return integral;\r
     }\r
 \r
+    @Override\r
+    public void focus() {\r
+        if(this.expression != null) this.expression.forceFocus();\r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        if(this.expression != null) {\r
+            String oldExpression = expression.getText();\r
+            if(lastSelection == null)\r
+                lastSelection = new Point(0,0);\r
+            String newExpression = oldExpression.substring(0, lastSelection.x) + var + oldExpression.substring(lastSelection.y);\r
+            expression.setText(newExpression);      \r
+            expression.setSelection(lastSelection.x + var.length());\r
+        }\r
+\r
+    }\r
+\r
+\r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java
new file mode 100644 (file)
index 0000000..78a5d5a
--- /dev/null
@@ -0,0 +1,186 @@
+package org.simantics.sysdyn.ui.equation.expressions;\r
+\r
+import java.util.Map;\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.events.FocusAdapter;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.KeyAdapter;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Text;\r
+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.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class WithLookupExpressionViewFactor implements IExpressionViewFactor {\r
+\r
+    \r
+    Label expressionLabel;\r
+    Text expression;\r
+    Label lookupLabel;\r
+    Text lookup;\r
+    \r
+    private Point lastSelection = new Point(0,0);\r
+    private Text lastSelectedText = expression;\r
+    \r
+    @Override\r
+    public void createView(Composite parent, Map<String, Object> data) {\r
+\r
+        final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
+        final String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : "";\r
+        \r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
+\r
+        expressionLabel = new Label(parent, SWT.NONE);\r
+        expressionLabel.setFont(FONT);\r
+        expressionLabel.setText("With\nLookup");\r
+        GridDataFactory.fillDefaults().applyTo(expressionLabel);\r
+\r
+        expression = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        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
+            public void focusLost(FocusEvent e) {\r
+                lastSelection = expression.getSelection();\r
+                lastSelectedText = expression;\r
+            }\r
+        });\r
+\r
+        expression.addKeyListener(new KeyAdapter() {          \r
+\r
+            @Override\r
+            public void keyPressed(KeyEvent e) {\r
+                if(e.keyCode == SWT.ESC) {\r
+                    expression.setText(equation);\r
+                }                \r
+            }\r
+\r
+        });\r
+\r
+        lookupLabel = new Label(parent, SWT.NONE);\r
+        lookupLabel.setFont(FONT);\r
+        lookupLabel.setText("Lookup\ntable");\r
+        GridDataFactory.fillDefaults().applyTo(lookupLabel);\r
+\r
+\r
+        lookup = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
+        lookup.setFont(FONT);\r
+        lookup.setText(lookupTable);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(lookup);\r
+\r
+        lookup.addFocusListener(new FocusAdapter() {\r
+\r
+            @Override\r
+            public void focusLost(FocusEvent e) {\r
+                lastSelection = lookup.getSelection();\r
+                lastSelectedText = lookup;\r
+            }\r
+        });\r
+\r
+        lookup.addKeyListener(new KeyAdapter() {          \r
+\r
+            @Override\r
+            public void keyPressed(KeyEvent e) {\r
+                if(e.keyCode == SWT.ESC) {\r
+                    lookup.setText(lookupTable);\r
+                }                \r
+            }\r
+\r
+        });\r
+        \r
+    }\r
+\r
+    @Override\r
+    public void readData(final Resource variable, Map<String, Object> data) {\r
+        String[] results = null;        \r
+        if (variable != null && data.get("equation") == null) {\r
+            try {\r
+                results = SimanticsUI.getSession().syncRequest(new Read<String[]>() {\r
+\r
+                    @Override\r
+                    public String[] perform(ReadGraph graph) throws DatabaseException {\r
+                        String[] results = new String[2];\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        Resource expression = graph.getPossibleObject(variable, sr.HasExpression);\r
+                        if (expression != null && graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
+                            results[0] = graph.getRelatedValue(expression, sr.HasEquation);\r
+                            results[1] = graph.getRelatedValue(expression, sr.HasLookup);\r
+                        } else {\r
+                            results[0] = "";\r
+                            results[1] = "";\r
+                        }\r
+                        return results;\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+            data.put("equation", results[0]);\r
+            data.put("lookup", results[1]);\r
+        }         \r
+    }\r
+\r
+    @Override\r
+    public void writeData(final Resource variable, Map<String, Object> data) {\r
+        final String currentExpression = expression.getText();\r
+        final String currentLookupTable = lookup.getText();\r
+        \r
+        if(currentExpression != null && currentLookupTable != null) {\r
+            data.put("equation", currentExpression);\r
+            data.put("lookup", currentLookupTable);\r
+            SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                @Override\r
+                public void perform(WriteGraph g)\r
+                throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(g);\r
+                    Resource expression = g.getPossibleObject(variable, sr.HasExpression);\r
+                    Builtins b = g.getBuiltins();\r
+                    if(expression != null) {\r
+                        g.deny(variable, sr.HasExpression);\r
+                    }\r
+                    expression = g.newResource();\r
+                    g.claim(expression, b.InstanceOf, sr.WithLookupExpression);\r
+                    g.claim(variable, sr.HasExpression, expression);\r
+                    g.claimValue(expression, sr.HasEquation, currentExpression);\r
+                    g.claimValue(expression, sr.HasLookup, currentLookupTable);\r
+                }\r
+\r
+            });\r
+        }        \r
+    }\r
+\r
+    @Override\r
+    public void focus() {\r
+        if(this.lastSelectedText != null) this.lastSelectedText.forceFocus();\r
+    }\r
+\r
+    @Override\r
+    public void replaceSelection(String var) {\r
+        if(this.lastSelectedText != null) {\r
+            String oldExpression = lastSelectedText.getText();\r
+            if(lastSelection == null)\r
+                lastSelection = new Point(0,0);\r
+            String newExpression = oldExpression.substring(0, lastSelection.x) + var + oldExpression.substring(lastSelection.y);\r
+            lastSelectedText.setText(newExpression);\r
+            lastSelectedText.setSelection(lastSelection.x + var.length());\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 4987d1a981e20950116634a88d60ffc0cff2d8a0..e05b06da416c8bc77ab5eb7a7cc8283efead3eae 100644 (file)
@@ -21,6 +21,8 @@ public class SysdynResource {
     public final Resource Auxiliary;\r
     public final Resource Cloud;\r
     public final Resource Configuration;\r
+    public final Resource ConstantExpression;\r
+    public final Resource DelayExpression;\r
     public final Resource Dependency;\r
     public final Resource Expression;\r
     public final Resource Flow;\r
@@ -29,6 +31,7 @@ public class SysdynResource {
     public final Resource HasExpression;\r
     public final Resource HasHead;\r
     public final Resource HasInitialEquation;\r
+    public final Resource HasLookup;\r
     public final Resource HasTail;\r
     public final Resource HasType;\r
     public final Resource HasUnit;\r
@@ -37,6 +40,7 @@ public class SysdynResource {
     public final Resource IndependentVariable;\r
     public final Resource IsHeadOf;\r
     public final Resource IsTailOf;\r
+    public final Resource LookupExpression;\r
     public final Resource NormalExpression;\r
     public final Resource ParameterExpression;\r
     public final Resource Stock;\r
@@ -44,11 +48,14 @@ public class SysdynResource {
     public final Resource SysdynProject;\r
     public final Resource Valve;\r
     public final Resource Variable;\r
+    public final Resource WithLookupExpression;\r
     \r
     public static class URIs {\r
         public static final String Auxiliary = "http://www.simantics.org/Sysdyn#Auxiliary";\r
         public static final String Cloud = "http://www.simantics.org/Sysdyn#Cloud";\r
         public static final String Configuration = "http://www.simantics.org/Sysdyn#Configuration";\r
+        public static final String ConstantExpression = "http://www.simantics.org/Sysdyn#ConstantExpression";\r
+        public static final String DelayExpression = "http://www.simantics.org/Sysdyn#DelayExpression";\r
         public static final String Dependency = "http://www.simantics.org/Sysdyn#Dependency";\r
         public static final String Expression = "http://www.simantics.org/Sysdyn#Expression";\r
         public static final String Flow = "http://www.simantics.org/Sysdyn#Flow";\r
@@ -57,6 +64,7 @@ public class SysdynResource {
         public static final String HasExpression = "http://www.simantics.org/Sysdyn#HasExpression";\r
         public static final String HasHead = "http://www.simantics.org/Sysdyn#HasHead";\r
         public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn#HasInitialEquation";\r
+        public static final String HasLookup = "http://www.simantics.org/Sysdyn#HasLookup";\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
@@ -65,6 +73,7 @@ public class SysdynResource {
         public static final String IndependentVariable = "http://www.simantics.org/Sysdyn#IndependentVariable";\r
         public static final String IsHeadOf = "http://www.simantics.org/Sysdyn#IsHeadOf";\r
         public static final String IsTailOf = "http://www.simantics.org/Sysdyn#IsTailOf";\r
+        public static final String LookupExpression = "http://www.simantics.org/Sysdyn#LookupExpression";\r
         public static final String NormalExpression = "http://www.simantics.org/Sysdyn#NormalExpression";\r
         public static final String ParameterExpression = "http://www.simantics.org/Sysdyn#ParameterExpression";\r
         public static final String Stock = "http://www.simantics.org/Sysdyn#Stock";\r
@@ -72,6 +81,7 @@ public class SysdynResource {
         public static final String SysdynProject = "http://www.simantics.org/Sysdyn#SysdynProject";\r
         public static final String Valve = "http://www.simantics.org/Sysdyn#Valve";\r
         public static final String Variable = "http://www.simantics.org/Sysdyn#Variable";\r
+        public static final String WithLookupExpression = "http://www.simantics.org/Sysdyn#WithLookupExpression";\r
     }\r
     \r
     public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
@@ -87,6 +97,8 @@ public class SysdynResource {
         Auxiliary = getResourceOrNull(graph, URIs.Auxiliary);\r
         Cloud = getResourceOrNull(graph, URIs.Cloud);\r
         Configuration = getResourceOrNull(graph, URIs.Configuration);\r
+        ConstantExpression = getResourceOrNull(graph, URIs.ConstantExpression);\r
+        DelayExpression = getResourceOrNull(graph, URIs.DelayExpression);\r
         Dependency = getResourceOrNull(graph, URIs.Dependency);\r
         Expression = getResourceOrNull(graph, URIs.Expression);\r
         Flow = getResourceOrNull(graph, URIs.Flow);\r
@@ -95,6 +107,7 @@ public class SysdynResource {
         HasExpression = getResourceOrNull(graph, URIs.HasExpression);\r
         HasHead = getResourceOrNull(graph, URIs.HasHead);\r
         HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
+        HasLookup = getResourceOrNull(graph, URIs.HasLookup);\r
         HasTail = getResourceOrNull(graph, URIs.HasTail);\r
         HasType = getResourceOrNull(graph, URIs.HasType);\r
         HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
@@ -103,6 +116,7 @@ public class SysdynResource {
         IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
         IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
         IsTailOf = getResourceOrNull(graph, URIs.IsTailOf);\r
+        LookupExpression = getResourceOrNull(graph, URIs.LookupExpression);\r
         NormalExpression = getResourceOrNull(graph, URIs.NormalExpression);\r
         ParameterExpression = getResourceOrNull(graph, URIs.ParameterExpression);\r
         Stock = getResourceOrNull(graph, URIs.Stock);\r
@@ -110,6 +124,7 @@ public class SysdynResource {
         SysdynProject = getResourceOrNull(graph, URIs.SysdynProject);\r
         Valve = getResourceOrNull(graph, URIs.Valve);\r
         Variable = getResourceOrNull(graph, URIs.Variable);\r
+        WithLookupExpression = getResourceOrNull(graph, URIs.WithLookupExpression);\r
     }\r
     \r
     public static SysdynResource getInstance(ReadGraph graph) {\r
index d25d867e410a471eec251c41113235e7244298dc..4ead2e75bfd5365e343de1e1e88765985936e86f 100644 (file)
@@ -102,6 +102,9 @@ HasEquation <R L0.HasProperty
     L0.HasRange L0.String  \r
     \r
 HasInitialEquation <R L0.HasProperty\r
+    L0.HasRange L0.String\r
+    \r
+HasLookup <R L0.HasProperty\r
     L0.HasRange L0.String  \r
     \r
 Expression <T L0.Entity\r
@@ -112,9 +115,22 @@ NormalExpression <T Expression
 ParameterExpression <T Expression\r
     [HasEquation card "1"]   \r
 \r
+ConstantExpression <T Expression\r
+    [HasEquation card "1"]   \r
+\r
+DelayExpression <T Expression\r
+    [HasEquation card "1"]   \r
+\r
 StockExpression <T Expression\r
     [HasInitialEquation card "1"]\r
   \r
+LookupExpression <T Expression\r
+    [HasLookup card "1"]   \r
+    \r
+WithLookupExpression <T Expression\r
+    [HasLookup card "1"]  \r
+    [HasEquation card "1"]    \r
+\r
 ######################################################################\r
 # Test configuration\r
 ######################################################################\r