]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Old equation view, not needed
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 5 Nov 2010 13:03:45 +0000 (13:03 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 5 Nov 2010 13:03:45 +0000 (13:03 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18582 ac1ea38d-2e2b-0410-8846-a27921b304fc

16 files changed:
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/AuxiliaryExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ColorManager.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/DelayExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/EmptyExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/IExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ParameterExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/WithLookupExpressionViewFactor.java [deleted file]

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
deleted file mode 100644 (file)
index 49aa803..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Point;\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.layer0.Layer0;\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 ExpressionField 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
-\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 ExpressionField(parent, SWT.BORDER);\r
-        expression.setFont(FONT);\r
-        expression.setExpression(equation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\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.getExpression();\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
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    if(expression != null) {\r
-                        g.deny(variable, sr.HasExpression);\r
-                    }\r
-                    expression = g.newResource();\r
-                    g.claim(expression, l0.InstanceOf, null, sr.NormalExpression);\r
-                    g.claim(variable, sr.HasExpression, expression);\r
-                    g.claimLiteral(expression, sr.HasEquation, currentText);\r
-                }\r
-\r
-            });\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void focus() {\r
-        if(this.expression != null) this.expression.focus();\r
-    }\r
-\r
-    @Override\r
-    public void replaceSelection(String var) {\r
-        if(expression != null) {\r
-            IDocument doc = expression.getDocument();\r
-            try {\r
-                Point selection = expression.getSelection();\r
-                doc.replace(selection.x, selection.y, var);\r
-                expression.setSelection(selection.x + var.length());\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        if(this.expression != null && this.expression.getExpression() != null)\r
-            data.put("equation", this.expression.getExpression());\r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        return Arrays.asList(this.expression);\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ColorManager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ColorManager.java
deleted file mode 100644 (file)
index 4325a92..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.HashMap;\r
-\r
-import org.eclipse.jface.text.source.ISharedTextColors;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-public class ColorManager implements ISharedTextColors {\r
-\r
-    protected HashMap<RGB, Color> colorTable = new HashMap<RGB, Color>();\r
-\r
-    @Override\r
-    public void dispose() {\r
-        for(Color c : colorTable.values())\r
-            c.dispose();\r
-        colorTable.clear();\r
-    }\r
-\r
-    @Override\r
-    public Color getColor(RGB rgb) {\r
-        Color color = colorTable.get(rgb);\r
-        if (color == null) {\r
-            color = new Color(Display.getCurrent(), rgb);\r
-            colorTable.put(rgb, color);\r
-        }\r
-        return color;\r
-\r
-\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ConstantExpressionViewFactor.java
deleted file mode 100644 (file)
index 3d7a65e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Point;\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.layer0.Layer0;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class ConstantExpressionViewFactor implements IExpressionViewFactor {\r
-\r
-    private Label equationLabel;\r
-    private ExpressionField 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
-\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 ExpressionField(parent, SWT.BORDER);\r
-        expression.setFont(FONT);\r
-        expression.setExpression(equation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-    }\r
-\r
-    @Override\r
-    public void focus() {\r
-        if(this.expression != null) this.expression.focus();\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(expression != null) {\r
-            IDocument doc = expression.getDocument();\r
-            try {\r
-                Point selection = expression.getSelection();\r
-                doc.replace(selection.x, selection.y, var);\r
-                expression.setSelection(selection.x + var.length());\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void writeData(final Resource variable, Map<String, Object> data) {\r
-        final String currentText = expression.getExpression();\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
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    if(expression != null) {\r
-                        g.deny(variable, sr.HasExpression);\r
-                    }\r
-                    expression = g.newResource();\r
-                    g.claim(expression, l0.InstanceOf, null, sr.ConstantExpression);\r
-                    g.claim(variable, sr.HasExpression, expression);\r
-                    g.claimLiteral(expression, sr.HasEquation, currentText);\r
-                }\r
-\r
-            });\r
-        }        \r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        if(this.expression != null && this.expression.getExpression() != null)\r
-            data.put("equation", this.expression.getExpression());        \r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        return Arrays.asList(this.expression);\r
-    }\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
deleted file mode 100644 (file)
index da9702f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.List;\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
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/EmptyExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/EmptyExpressionViewFactor.java
deleted file mode 100644 (file)
index a3ea40d..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.simantics.db.Resource;\r
-\r
-public class EmptyExpressionViewFactor 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 List<ExpressionField> getExpressionFields() {\r
-        // TODO Auto-generated method stub\r
-        return null;\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 updateData(Map<String, Object> data) {\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/ExpressionField.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionField.java
deleted file mode 100644 (file)
index dde64a0..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.Document;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.jface.text.PaintManager;\r
-import org.eclipse.jface.text.Position;\r
-import org.eclipse.jface.text.source.Annotation;\r
-import org.eclipse.jface.text.source.AnnotationModel;\r
-import org.eclipse.jface.text.source.AnnotationPainter;\r
-import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;\r
-import org.eclipse.jface.text.source.IAnnotationAccess;\r
-import org.eclipse.jface.text.source.MatchingCharacterPainter;\r
-import org.eclipse.jface.text.source.SourceViewer;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.simantics.sysdyn.expressionParser.Token;\r
-\r
-public class ExpressionField extends Composite {\r
-\r
-    protected SourceViewer                  _sourceViewer;\r
-    protected IDocument                     _document;\r
-    protected AnnotationModel               _annotationModel;\r
-\r
-    ColorManager cManager = new ColorManager();\r
-\r
-    IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess();\r
-\r
-    public ExpressionField(Composite parent, int style) {\r
-        super(parent, style);\r
-\r
-        GridLayoutFactory.fillDefaults().applyTo(this);\r
-\r
-        int styles = SWT.V_SCROLL\r
-        | SWT.MULTI\r
-        | SWT.FULL_SELECTION\r
-        | SWT.WRAP;\r
-\r
-        _document = new Document();\r
-        _document.set("");\r
-\r
-        _annotationModel = new AnnotationModel();\r
-        _annotationModel.connect(_document);\r
-\r
-        _sourceViewer = new SourceViewer(this,\r
-\r
-                null,\r
-                null,\r
-                true,\r
-                styles);\r
-        _sourceViewer.configure(new ExpressionFieldConfiguration(cManager));\r
-\r
-        AnnotationPainter painter = new AnnotationPainter(_sourceViewer, annotationAccess);\r
-        _sourceViewer.addPainter(painter);\r
-\r
-        painter.addAnnotationType("MissingLink");\r
-        painter.setAnnotationTypeColor("MissingLink", new Color(this.getDisplay(), 255,0,0));\r
-        painter.addAnnotationType("NoSuchVariable");\r
-        painter.setAnnotationTypeColor("NoSuchVariable", new Color(this.getDisplay(), 255,0,0));\r
-        \r
-        _sourceViewer.setDocument(_document, _annotationModel);\r
-\r
-        _sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL,\r
-                SWT.FILL,\r
-                true,\r
-                true)); \r
-\r
-        PaintManager paintManager = new PaintManager(_sourceViewer);\r
-        MatchingCharacterPainter matchingCharacterPainter = new MatchingCharacterPainter(_sourceViewer,\r
-                new DefaultCharacterPairMatcher( new char[] {'(', ')', '{', '}', '[', ']'} ));\r
-        matchingCharacterPainter.setColor(new Color(Display.getCurrent(), new RGB(160, 160, 160)));\r
-        paintManager.addPainter(matchingCharacterPainter);\r
-\r
-\r
-    }\r
-\r
-    public SourceViewer getSourceViewer() {\r
-        return this._sourceViewer;\r
-    }\r
-\r
-    public void setMissingLinkAnnotations(List<Position> positions){\r
-        for(Position p : positions) {\r
-            Annotation annotation = new Annotation(false);\r
-            annotation.setType("MissingLink");\r
-            annotation.setText("No link to this variable");\r
-            _annotationModel.addAnnotation(annotation, p);        \r
-        }\r
-    }\r
-    \r
-    public void setNoSuchVariableAnnotations(List<Position> positions){\r
-        for(Position p : positions) {\r
-            Annotation annotation = new Annotation(false);\r
-            annotation.setType("NoSuchVariable");\r
-            annotation.setText("No such variable in model");\r
-            _annotationModel.addAnnotation(annotation, p);        \r
-        }\r
-    }\r
-\r
-    public void setSyntaxError(Token token){\r
-        int start = 0;\r
-        int offset = this._document.getLength();\r
-        if(token.image != null && this._document.getLength() > 0) {\r
-            try {\r
-                start = this._document.getLineOffset(token.beginLine - 1) + token.beginColumn - 1;\r
-                offset = this._document.getLineOffset(token.endLine - 1) + token.endColumn - start;\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-\r
-        Annotation annotation = new Annotation(false);\r
-        annotation.setType("MissingLink");\r
-        annotation.setText("Syntax error");\r
-        Position p = new Position(start, offset);\r
-        _annotationModel.addAnnotation(annotation, p);      \r
-    }\r
-\r
-    public void resetAnnotations() {\r
-        _annotationModel.removeAllAnnotations();\r
-    }\r
-    public void setExpression(String expression) {\r
-        _document.set(expression);\r
-    }\r
-\r
-    public String getExpression() {\r
-        return this._document.get();\r
-    }\r
-\r
-    public Point getSelection() {\r
-        return _sourceViewer.getSelectedRange();\r
-    }\r
-\r
-    public void setSelection(int selection) {\r
-        this._sourceViewer.setSelectedRange(selection, 0);\r
-    }\r
-\r
-    public IDocument getDocument() {\r
-        return _document;\r
-    }\r
-\r
-    public void focus() {\r
-        this._sourceViewer.getTextWidget().forceFocus();\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/ExpressionFieldConfiguration.java
deleted file mode 100644 (file)
index c9b0022..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.eclipse.jface.text.DefaultTextHover;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.jface.text.ITextHover;\r
-import org.eclipse.jface.text.TextAttribute;\r
-import org.eclipse.jface.text.presentation.IPresentationReconciler;\r
-import org.eclipse.jface.text.presentation.PresentationReconciler;\r
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;\r
-import org.eclipse.jface.text.rules.IRule;\r
-import org.eclipse.jface.text.rules.ITokenScanner;\r
-import org.eclipse.jface.text.rules.IWordDetector;\r
-import org.eclipse.jface.text.rules.RuleBasedScanner;\r
-import org.eclipse.jface.text.rules.Token;\r
-import org.eclipse.jface.text.rules.WordRule;\r
-import org.eclipse.jface.text.source.DefaultAnnotationHover;\r
-import org.eclipse.jface.text.source.IAnnotationHover;\r
-import org.eclipse.jface.text.source.ISourceViewer;\r
-import org.eclipse.jface.text.source.SourceViewerConfiguration;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.RGB;\r
-\r
-public class ExpressionFieldConfiguration extends SourceViewerConfiguration {\r
-\r
-\r
-    ColorManager colorManager;\r
-\r
-    public ExpressionFieldConfiguration(ColorManager colorManager) {\r
-        super();\r
-        this.colorManager = colorManager;\r
-    }\r
-\r
-    public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {\r
-        return new String[] {\r
-                IDocument.DEFAULT_CONTENT_TYPE\r
-        };\r
-    }\r
-\r
-    /*\r
-    @Override\r
-    public IAutoEditStrategy[] getAutoEditStrategies(\r
-            ISourceViewer sourceViewer, String contentType) {\r
-        return new IAutoEditStrategy[] {\r
-                new ReplaceTabsBySpaces(),\r
-                new IndentLineEditStrategy(),\r
-                new MatchingBracketsEditStrategy()\r
-        };\r
-    }\r
-    */\r
-\r
-    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\r
-        PresentationReconciler reconciler = new PresentationReconciler();\r
-\r
-        DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getSclTokenScanner());\r
-\r
-        reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);\r
-        reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);\r
-\r
-        return reconciler;\r
-    }\r
-\r
-    /*\r
-     * \r
-     */\r
-     ITokenScanner getSclTokenScanner() {\r
-        RuleBasedScanner scanner = new RuleBasedScanner();\r
-\r
-        final Token reserved = new Token(\r
-                new TextAttribute(\r
-                        colorManager.getColor(new RGB(127, 0, 85)),\r
-                        null,\r
-                        SWT.BOLD\r
-                ));\r
-        \r
-\r
-        WordRule reservedWord = new WordRule(new IWordDetector() {   \r
-            @Override\r
-            public boolean isWordStart(char c) {\r
-                return Character.isLetter(c);\r
-            }\r
-\r
-            @Override\r
-            public boolean isWordPart(char c) {\r
-                return Character.isLetter(c);\r
-            }\r
-        });\r
-\r
-        for(String s : keywords) {\r
-            reservedWord.addWord(s, reserved);\r
-        }\r
-\r
-        IRule[] rules = new IRule[] {\r
-                reservedWord\r
-        };\r
-        scanner.setRules(rules);\r
-\r
-        return scanner;  \r
-     }\r
-\r
-     @Override\r
-     public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {\r
-         return new DefaultTextHover(sourceViewer);\r
-     }\r
-\r
-     @Override\r
-     public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {\r
-         return new DefaultAnnotationHover();\r
-     }\r
-\r
-     static final Set<String> keywords = new HashSet<String>();\r
-     \r
-     static {\r
-         keywords.add("within");\r
-         keywords.add("final");\r
-         keywords.add("public");\r
-         keywords.add("protected");\r
-         keywords.add("connect");\r
-         keywords.add("when");\r
-         keywords.add("then");\r
-         keywords.add("elsewhen");\r
-         keywords.add("if");\r
-         keywords.add("end");\r
-         keywords.add("elseif");\r
-         keywords.add("else");\r
-         keywords.add("for");\r
-         keywords.add("while");\r
-         keywords.add("loop");\r
-         keywords.add("der");\r
-         keywords.add("enumeration");\r
-         keywords.add("extends");\r
-         keywords.add("class");\r
-         keywords.add("partial");\r
-         keywords.add("encapsulated");\r
-         keywords.add("model");\r
-         keywords.add("record");\r
-         keywords.add("block");\r
-         keywords.add("expandable");\r
-         keywords.add("connector");\r
-         keywords.add("type");\r
-         keywords.add("package");\r
-         keywords.add("function");\r
-         keywords.add("import");\r
-         keywords.add("external");\r
-         keywords.add("constrainedby");\r
-         keywords.add("redeclare");\r
-         keywords.add("replaceable");\r
-         keywords.add("flow");\r
-         keywords.add("discrete");\r
-         keywords.add("parameter");\r
-         keywords.add("constant");\r
-         keywords.add("input");\r
-         keywords.add("output");\r
-         keywords.add("annotation");\r
-         keywords.add("false");\r
-         keywords.add("true");\r
-         keywords.add("each");\r
-         keywords.add("initial");\r
-         keywords.add("algorithm");\r
-         keywords.add("equation");\r
-         keywords.add("or");\r
-         keywords.add("and");\r
-         keywords.add("not");\r
-         keywords.add("break");\r
-         keywords.add("return");     \r
-     }\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
deleted file mode 100644 (file)
index 360776b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.List;\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
-     * Updates data from text inputs to the data map\r
-     * @param data\r
-     */\r
-    void updateData(Map<String, Object> data);\r
-    \r
-    /**\r
-     * @return all individual expression fields for modelica validation\r
-     */\r
-    List<ExpressionField> getExpressionFields();\r
-   \r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartInfo.java
deleted file mode 100644 (file)
index 96ec9b4..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Map;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ReadRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class LookupChartInfo {\r
-\r
-    String lookupTable, expression;\r
-    Double minX, maxX, minY, maxY;\r
-\r
-    private static Double MINX = 0.0;\r
-    private static Double MAXX = 10.0;\r
-    private static Double MINY = 0.0;\r
-    private static Double MAXY = 10.0;\r
-\r
-    public LookupChartInfo(String expression, String lookupTable, final Resource variable, Map<String, Object> data) {\r
-        this.lookupTable = lookupTable != null ? lookupTable : "";\r
-        this.expression = expression != null ? expression : "";\r
-        this.minX = (Double)data.get("minX");\r
-        this.maxX = (Double)data.get("maxX");\r
-        this.minY = (Double)data.get("minY");\r
-        this.maxY = (Double)data.get("maxY");\r
-        if(variable != null && (minX == null || maxX == null || minY == null || maxY == null)) {\r
-            try {\r
-                SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
-                    @Override\r
-                    public void run(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.WithLookupExpression)) { \r
-                            minX = graph.getPossibleRelatedValue(expression, sr.HasMinX);  \r
-                            if(minX == null) minX = MINX;\r
-                            maxX = graph.getPossibleRelatedValue(expression, sr.HasMaxX); \r
-                            if(maxX == null) maxX = MAXX;\r
-                            minY = graph.getPossibleRelatedValue(expression, sr.HasMinY); \r
-                            if(minY == null) minY = MINY;\r
-                            maxY = graph.getPossibleRelatedValue(expression, sr.HasMaxY);\r
-                            if(maxY == null) maxY = MAXY;\r
-                        } else {\r
-                            defaultValues();\r
-                        }\r
-\r
-                    }\r
-                });\r
-            } catch (DatabaseException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-    \r
-    private void defaultValues() {\r
-        minX = MINX;\r
-        maxX = MAXX;\r
-        minY = MINY;\r
-        maxY = MAXY;\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupChartPanel.java
deleted file mode 100644 (file)
index 8118d79..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.awt.Point;\r
-import java.awt.event.MouseEvent;\r
-import java.awt.geom.Point2D;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.jfree.chart.ChartPanel;\r
-import org.jfree.chart.ChartRenderingInfo;\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.ValueAxis;\r
-import org.jfree.chart.entity.ChartEntity;\r
-import org.jfree.chart.entity.PlotEntity;\r
-import org.jfree.chart.entity.XYItemEntity;\r
-import org.jfree.chart.plot.XYPlot;\r
-import org.jfree.data.xy.XYSeries;\r
-import org.jfree.data.xy.XYSeriesCollection;\r
-\r
-@SuppressWarnings("serial")\r
-public class LookupChartPanel extends ChartPanel {\r
-\r
-    private XYItemEntity dragPrevEntity;\r
-    private boolean drawing;\r
-    private XYSeries series; \r
-    private JFreeChart chart;\r
-    private LookupInputOutputTable table;\r
-\r
-    public LookupChartPanel(JFreeChart chart) {\r
-        super(chart);\r
-        this.chart = chart;\r
-        XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset();\r
-        series = collection.getSeries(0); \r
-    }\r
-\r
-    public void setTable(LookupInputOutputTable table) {\r
-        this.table = table;\r
-    }\r
-\r
-    public void mouseDragged(MouseEvent e)\r
-    {\r
-        if(dragPrevEntity != null) {\r
-\r
-            int item = dragPrevEntity.getItem();\r
-            XYPlot plot = (XYPlot)chart.getPlot();\r
-            ValueAxis rangeAxis = plot.getRangeAxis();\r
-            ValueAxis domainAxis = plot.getDomainAxis();\r
-            Point2D location = getLocationOnChart(getMouseLocation(e));\r
-            Number prevX = item == 0 ? null : series.getX(item - 1);\r
-            Number nextX = item == series.getItemCount() - 1 ? null : series.getX(item + 1);\r
-\r
-\r
-            if(series.indexOf(location.getX()) >= 0 && series.indexOf(location.getX()) != item)\r
-                return;\r
-            else if (prevX != null && location.getX() < prevX.doubleValue())\r
-                location.setLocation(series.getX(item).doubleValue(), location.getY());\r
-            else if (nextX != null && location.getX() > nextX.doubleValue())\r
-                location.setLocation(series.getX(item).doubleValue(), location.getY());\r
-            else if (location.getX() > domainAxis.getUpperBound())\r
-                location.setLocation(domainAxis.getUpperBound(), location.getY());\r
-            else if (location.getX() < domainAxis.getLowerBound()) \r
-                location.setLocation(domainAxis.getLowerBound(), location.getY());    \r
-\r
-            if (location.getY() > rangeAxis.getUpperBound())\r
-                location.setLocation(location.getX(), rangeAxis.getUpperBound());\r
-            else if (location.getY() < rangeAxis.getLowerBound()) \r
-                location.setLocation(location.getX(), rangeAxis.getLowerBound());    \r
-\r
-            removeItemFromSeries(dragPrevEntity.getItem());\r
-            addLocationToSeries(location);\r
-        } else {\r
-            ChartEntity currEntity = this.getEntityForPoint(e.getX(),e.getY());\r
-            if(!drawing && currEntity instanceof XYItemEntity) {\r
-                dragPrevEntity = ((XYItemEntity)currEntity);\r
-            } else if (currEntity instanceof PlotEntity){\r
-                drawing = true;\r
-                Point2D locationOnChart = getLocationOnChart(getMouseLocation(e));\r
-                int item = series.indexOf(locationOnChart.getX());\r
-                if (item >= 0) {\r
-                    Point2D location = new Point2D.Double(series.getX(item).doubleValue(), series.getY(item).doubleValue());\r
-                    Point2D javaLocation = getLocationOnJava2D(location);\r
-                    removeItemFromSeries(item);\r
-                    addLocationToSeries(getLocationOnChart(new Point2D.Double(javaLocation.getX(), e.getY())));\r
-                }\r
-            }\r
-        }\r
-\r
-    }\r
-\r
-    public void mouseReleased(MouseEvent e) {\r
-\r
-        dragPrevEntity = null;\r
-        drawing = false;\r
-    }\r
-\r
-    public void mouseClicked(MouseEvent e)\r
-    {\r
-        if(e.getButton() == MouseEvent.BUTTON1) {\r
-            addLocationToSeries(getLocationOnChart(getMouseLocation(e)));\r
-        } else if (e.getButton() == MouseEvent.BUTTON3) {\r
-            ChartEntity entity = this.getEntityForPoint(e.getX(),e.getY());\r
-            if(entity instanceof XYItemEntity) {\r
-                XYItemEntity xyentity = ((XYItemEntity)entity);\r
-                removeItemFromSeries(xyentity.getItem());\r
-            }\r
-        }\r
-    }         \r
-\r
-    private Point2D getLocationOnChart(Point2D coordinates) {\r
-        XYPlot plot = (XYPlot)chart.getPlot();\r
-        ChartRenderingInfo info = getChartRenderingInfo();\r
-        Rectangle2D dataArea = info.getPlotInfo().getDataArea();\r
-        double chartX = plot.getDomainAxis().java2DToValue(coordinates.getX(), dataArea,\r
-                plot.getDomainAxisEdge());\r
-        double chartY = plot.getRangeAxis().java2DToValue(coordinates.getY(), dataArea,\r
-                plot.getRangeAxisEdge());\r
-        return new Point2D.Double(chartX, chartY);\r
-    }\r
-\r
-    private Point2D getLocationOnJava2D(Point2D location) {\r
-        XYPlot plot = (XYPlot)chart.getPlot();\r
-        ChartRenderingInfo info = getChartRenderingInfo();\r
-        Rectangle2D dataArea = info.getPlotInfo().getDataArea();\r
-        double javaX = plot.getDomainAxis().valueToJava2D(location.getX(), dataArea,\r
-                plot.getDomainAxisEdge());\r
-        double javaY = plot.getRangeAxis().valueToJava2D(location.getY(), dataArea,\r
-                plot.getRangeAxisEdge());\r
-        return new Point2D.Double(javaX, javaY);\r
-    }\r
-\r
-    public void addLocationToSeries(Point2D location) {\r
-        if(series.indexOf(location.getX()) < 0) {\r
-            series.add(location.getX(), location.getY());\r
-            table.addLocation(location);\r
-        }\r
-    }\r
-\r
-    public void removeItemFromSeries(int item){\r
-        Point2D location = new Point2D.Double(series.getX(item).doubleValue(),series.getY(item).doubleValue()); \r
-        series.remove(item);\r
-        table.removeLocation(location);\r
-    }\r
-\r
-    private Point2D getMouseLocation(MouseEvent e) {\r
-        int mouseX = e.getX();\r
-        int mouseY = e.getY();\r
-        Point2D p = translateScreenToJava2D(\r
-                new Point(mouseX, mouseY));\r
-        return p;\r
-    }\r
-\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
deleted file mode 100644 (file)
index 15ce9b2..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.List;\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
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        // TODO Auto-generated method stub\r
-        return null;\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupInputOutputTable.java
deleted file mode 100644 (file)
index 1bfb824..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.awt.geom.Point2D;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.viewers.ArrayContentProvider;\r
-import org.eclipse.jface.viewers.CellEditor;\r
-import org.eclipse.jface.viewers.ITableLabelProvider;\r
-import org.eclipse.jface.viewers.LabelProvider;\r
-import org.eclipse.jface.viewers.TableViewer;\r
-import org.eclipse.jface.viewers.TextCellEditor;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.jface.viewers.ViewerComparator;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Table;\r
-import org.eclipse.swt.widgets.TableColumn;\r
-\r
-public class LookupInputOutputTable extends Composite {\r
-\r
-    public static final String INPUT = "Input";\r
-    public static final String OUTPUT = "Output";\r
-    public static final String[] PROPS = { INPUT, OUTPUT };\r
-\r
-    Table table;\r
-    TableViewer tableViewer;\r
-    List<InputOutput> tableRows;\r
-\r
-    public LookupInputOutputTable(Composite parent, int style) {\r
-        super(parent, style);\r
-\r
-        GridLayoutFactory.fillDefaults().applyTo(this);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(this);\r
-        table = new Table(this, SWT.BORDER|SWT.SINGLE|SWT.FULL_SELECTION);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(table);\r
-        table.setHeaderVisible (true);\r
-        table.setLinesVisible(true);\r
-        table.getVerticalBar().setVisible(true);\r
-        TableColumn column1 = new TableColumn (table, SWT.LEFT);\r
-        column1.setText (INPUT);\r
-        column1.setWidth (85);\r
-        \r
-        TableColumn column2 = new TableColumn (table, SWT.LEFT);\r
-        column2.setText (OUTPUT);\r
-        column2.setWidth (85);\r
-\r
-        // Create the viewer and connect it to the view\r
-        tableViewer = new TableViewer (table);\r
-\r
-        tableViewer.setContentProvider (new ArrayContentProvider());\r
-        tableViewer.setLabelProvider (new InputOutputLabelProvider());\r
-\r
-        tableRows = new ArrayList<InputOutput>();     \r
-        tableViewer.setInput(tableRows);\r
-\r
-        CellEditor[] editors = new CellEditor[2];\r
-        editors[0] = new TextCellEditor(table);\r
-        editors[1] = new TextCellEditor(table);\r
-        tableViewer.setCellEditors(editors);\r
-        tableViewer.setColumnProperties(PROPS);\r
-        \r
-    }\r
-\r
-    private class InputOutputLabelProvider extends LabelProvider implements ITableLabelProvider {\r
-        public Image getColumnImage (Object element, int columnIndex) {\r
-            return null;\r
-        }\r
-        public String getColumnText (Object element, int columnIndex) {\r
-            if(element instanceof InputOutput) {\r
-                InputOutput io = (InputOutput)element;\r
-                switch (columnIndex) {\r
-                    case 0: return (String)io.getInput(String.class);\r
-                    case 1: return (String)io.getOutput(String.class);\r
-                }\r
-            }\r
-            return "";\r
-        }\r
-    }\r
-\r
-    public void addLocation(Point2D location) {\r
-        tableRows.add(new InputOutput(location.getX(), location.getY()));\r
-        tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
-\r
-            @Override\r
-            public void run() {\r
-                refresh();\r
-            }\r
-        });\r
-\r
-    }\r
-\r
-    public void removeLocation(Point2D location) {\r
-        for(InputOutput io : tableRows) {\r
-            if((Double)io.getInput(Double.class) == location.getX()) {\r
-                tableRows.remove(io);\r
-                tableViewer.getTable().getDisplay().asyncExec(new Runnable() {\r
-\r
-                    @Override\r
-                    public void run() {\r
-                        refresh();\r
-                    }\r
-                });\r
-                break;\r
-            }\r
-        }\r
-\r
-    }\r
-\r
\r
-    class InputOutput {\r
-        private double input, output;\r
-\r
-        public InputOutput(double input, double output) {\r
-            this.input = input;\r
-            this.output = output;\r
-        }\r
-\r
-        /**\r
-         * \r
-         * @param clazz String.class or Double.class\r
-         * @return input as string or double or null if asked for something else\r
-         */\r
-        @SuppressWarnings("rawtypes")\r
-               public Object getInput(Class clazz) {\r
-            if(clazz == String.class) {\r
-                return "" + input;\r
-            } else if (clazz == Double.class) {\r
-                return input;\r
-            }\r
-            return null;\r
-        }\r
-\r
-        public Double setInput(String input) {\r
-            try {\r
-                this.input = Double.parseDouble(input);\r
-                return this.input;\r
-            } catch (NumberFormatException e) {\r
-                return null;\r
-            }\r
-        }\r
-\r
-        public void setInput(double input) {\r
-            this.input = input;\r
-        }\r
-\r
-        /**\r
-         * \r
-         * @param clazz String.class or Double.class\r
-         * @return output as string or double or null if asked for something else\r
-         */\r
-        @SuppressWarnings("rawtypes")\r
-        public Object getOutput(Class clazz) {\r
-            if(clazz == String.class) {\r
-                return "" + output;\r
-            } else if (clazz == Double.class) {\r
-                return output;\r
-            }\r
-            return null;\r
-        }\r
-\r
-        public void setOutput(String output) {\r
-            try {\r
-                this.output = Double.parseDouble(output);\r
-            } catch (NumberFormatException e) {\r
-\r
-            }\r
-        }\r
-\r
-        public void setOutput(double output) {\r
-            this.output = output;\r
-        }\r
-\r
-    }\r
-\r
-    class InputOutputComparator extends ViewerComparator {\r
-        @Override\r
-        public int compare(Viewer viewer, Object e1, Object e2) {\r
-            if ((e1 instanceof InputOutput) &&\r
-                    (e2 instanceof InputOutput)) {\r
-                InputOutput io1 = (InputOutput)e1;\r
-                InputOutput io2 = (InputOutput)e2;\r
-                Double d1 = (Double)io1.getInput((Double.class));\r
-                Double d2 = (Double)io2.getInput((Double.class));\r
-                return d1.compareTo(d2);\r
-            }\r
-            return 0;\r
-        }\r
-    }\r
-    \r
-    public TableViewer getTableViewer() {\r
-        return this.tableViewer;\r
-    }\r
-    \r
-    public void refresh() {\r
-        tableViewer.setComparator(new InputOutputComparator());\r
-        tableViewer.refresh();\r
-    }\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/LookupPopup.java
deleted file mode 100644 (file)
index b3700cf..0000000
+++ /dev/null
@@ -1,446 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.awt.BasicStroke;\r
-import java.awt.Color;\r
-import java.awt.GridLayout;\r
-import java.awt.event.MouseEvent;\r
-import java.awt.geom.Ellipse2D;\r
-import java.awt.geom.Point2D;\r
-import java.io.StringReader;\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import javax.swing.JComponent;\r
-import javax.swing.JPanel;\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.viewers.ICellModifier;\r
-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.KeyEvent;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.MouseListener;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Item;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Table;\r
-import org.eclipse.swt.widgets.TableItem;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.eclipse.swt.widgets.Widget;\r
-import org.jfree.chart.ChartFactory;\r
-import org.jfree.chart.JFreeChart;\r
-import org.jfree.chart.axis.ValueAxis;\r
-import org.jfree.chart.plot.PlotOrientation;\r
-import org.jfree.chart.plot.XYPlot;\r
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;\r
-import org.jfree.data.xy.XYDataItem;\r
-import org.jfree.data.xy.XYDataset;\r
-import org.jfree.data.xy.XYSeries;\r
-import org.jfree.data.xy.XYSeriesCollection;\r
-import org.simantics.sysdyn.tableParser.ParseException;\r
-import org.simantics.sysdyn.tableParser.Token;\r
-import org.simantics.sysdyn.tableParser.TableParser;\r
-import org.simantics.sysdyn.ui.equation.expressions.LookupInputOutputTable.InputOutput;\r
-import org.simantics.utils.ui.SWTAWTComponent;\r
-\r
-public class LookupPopup extends Dialog {\r
-\r
-    JFreeChart chart;\r
-    LookupInputOutputTable table;\r
-    ArrayList<Point2D> dataPoints;\r
-    Text input, output;\r
-    Text minX, maxX, minY, maxY;\r
-    Label unit;\r
-    LookupChartInfo chartInfo;\r
-\r
-    protected LookupPopup(Shell parentShell, LookupChartInfo chartInfo) {\r
-        super(parentShell);\r
-        this.chartInfo = chartInfo;\r
-        this.dataPoints = new ArrayList<Point2D>();\r
-        TableParser parser = new TableParser(new StringReader(""));\r
-        parser.ReInit(new StringReader(chartInfo.lookupTable));\r
-        try {\r
-            parser.table();\r
-            ArrayList<Token> xTokens = parser.getXTokens();\r
-            for(Token token : xTokens) {\r
-                dataPoints.add(new Point2D.Double(\r
-                        Double.parseDouble(token.image), \r
-                        Double.parseDouble(token.next.next.image)));\r
-            }\r
-        } catch (ParseException e1) {\r
-        }\r
-\r
-    }\r
-\r
-    @Override\r
-    protected Control createDialogArea(Composite parent) {\r
-        KeyListener enterListener = new KeyListener() {\r
-\r
-            @Override\r
-            public void keyReleased(KeyEvent e) {}\r
-\r
-            @Override\r
-            public void keyPressed(KeyEvent e) {\r
-                if(e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)\r
-                    getButton(IDialogConstants.OK_ID).forceFocus();\r
-            }\r
-        };\r
-\r
-        final LookupChartPanel chartPanel = new LookupChartPanel(createChart());\r
-        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));\r
-        chartPanel.setMouseZoomable(true, false);\r
-        chartPanel.setDomainZoomable(false);\r
-        chartPanel.setRangeZoomable(false);\r
-\r
-        XYPlot plot = (XYPlot) chart.getPlot();\r
-        ValueAxis rangeAxis = plot.getRangeAxis();\r
-        ValueAxis domainAxis = plot.getDomainAxis();\r
-\r
-        Composite container = new Composite(parent, SWT.None);\r
-        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(3).applyTo(container);\r
-\r
-        Composite yAxis = new Composite(container, SWT.NONE);\r
-        GridLayoutFactory.fillDefaults().applyTo(yAxis);\r
-        GridDataFactory.fillDefaults().grab(false, true).applyTo(yAxis);\r
-        maxY = new Text(yAxis, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(maxY);\r
-        maxY.addKeyListener(enterListener);\r
-        maxY.addModifyListener(getAxisBoundModifyListener());\r
-        maxY.setText("" + rangeAxis.getUpperBound());\r
-        Composite fillY = new Composite(yAxis, SWT.NONE);\r
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(false, true).applyTo(fillY);\r
-        GridLayoutFactory.fillDefaults().applyTo(fillY);\r
-        unit = new Label(fillY, SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(unit);\r
-        unit.setText(""); //TODO: how to get and update units?\r
-        unit.addKeyListener(enterListener);\r
-        minY = new Text(yAxis, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(minY);\r
-        minY.addKeyListener(enterListener);\r
-        minY.addModifyListener(getAxisBoundModifyListener());\r
-        minY.setText("" + rangeAxis.getLowerBound());\r
-\r
-        SWTAWTComponent c = new SWTAWTComponent(container, SWT.BORDER) {\r
-            @Override\r
-            protected JComponent createSwingComponent() {\r
-                JPanel panel = new JPanel();\r
-                panel.setLayout(new GridLayout(1, 1));\r
-                panel.setPreferredSize(new java.awt.Dimension(500, 270));\r
-                panel.add(chartPanel);\r
-                panel.doLayout();\r
-                return panel;\r
-            }\r
-        };\r
-        GridDataFactory.fillDefaults().hint(500, 300).applyTo(c);\r
-        c.populate();\r
-\r
-\r
-        Composite valueTableComposite = new Composite(container, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(valueTableComposite);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(valueTableComposite);\r
-\r
-\r
-        table = new LookupInputOutputTable(valueTableComposite, SWT.NONE);\r
-        GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(table);\r
-        chartPanel.setTable(table);\r
-        table.getTableViewer().setCellModifier(new InputOutputCellModifier());\r
-        table.getTableViewer().getTable().addMouseListener(new MouseListener() {\r
-\r
-            @Override\r
-            public void mouseUp(org.eclipse.swt.events.MouseEvent e) {\r
-                if(e.button == MouseEvent.BUTTON3) {\r
-                    Table table = (Table)e.widget;\r
-                    TableItem item = (TableItem)table.getItem(new org.eclipse.swt.graphics.Point(e.x, e.y));\r
-                    chartPanel.removeItemFromSeries(table.indexOf(item));\r
-                }\r
-            }\r
-            @Override\r
-            public void mouseDown(org.eclipse.swt.events.MouseEvent e) { }\r
-            @Override\r
-            public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) { }\r
-        });\r
-        for(Point2D location : this.dataPoints) {\r
-            chartPanel.addLocationToSeries(location);\r
-        }\r
-\r
-        input = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(60, SWT.DEFAULT).applyTo(input);\r
-        input.setText("");\r
-        output = new Text(valueTableComposite, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(60, SWT.DEFAULT).applyTo(output);\r
-        output.setText("");\r
-\r
-        Button add = new Button(valueTableComposite, SWT.None);\r
-        add.setText("Add");\r
-        add.addSelectionListener(new SelectionListener() {\r
-\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                try {\r
-                    Double in = Double.parseDouble(input.getText());\r
-                    Double out = Double.parseDouble(output.getText());\r
-                    chartPanel.addLocationToSeries(new Point2D.Double(in, out));\r
-                } catch (NumberFormatException e1) {\r
-                    input.setText("");\r
-                    output.setText("");\r
-                }\r
-            }\r
-\r
-            @Override\r
-            public void widgetDefaultSelected(SelectionEvent e) {}\r
-        });\r
-\r
-        FocusListener flistener = new FocusListener() {\r
-            @Override\r
-            public void focusGained(FocusEvent e) {\r
-                Text text = (Text)e.widget;\r
-                text.setSelection(0, text.getCharCount());\r
-            }\r
-            @Override\r
-            public void focusLost(FocusEvent e) { }\r
-        };\r
-\r
-\r
-        KeyListener listener = new KeyListener() {\r
-\r
-            @Override\r
-            public void keyPressed(KeyEvent e) {\r
-                if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {\r
-                    try {\r
-                        Double in = Double.parseDouble(input.getText());\r
-                        Double out = Double.parseDouble(output.getText());\r
-                        chartPanel.addLocationToSeries(new Point2D.Double(in, out));\r
-                    } catch (NumberFormatException e1) {\r
-                        if(input.getText().isEmpty() && output.getText().isEmpty()) {\r
-                            getButton(IDialogConstants.OK_ID).forceFocus();\r
-                            return;\r
-                        }\r
-                    }\r
-                    input.setText("");\r
-                    output.setText("");\r
-                    input.setFocus();\r
-                }          \r
-            }\r
-\r
-            @Override\r
-            public void keyReleased(KeyEvent e) { }\r
-\r
-        };\r
-\r
-        input.addFocusListener(flistener);\r
-        input.addKeyListener(listener);\r
-        output.addFocusListener(flistener);\r
-        output.addKeyListener(listener);\r
-\r
-        Label l = new Label(container, SWT.NONE);\r
-        l.setText("");\r
-\r
-        Composite xAxis = new Composite(container, SWT.NONE);\r
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(xAxis);\r
-        GridLayoutFactory.fillDefaults().numColumns(3).applyTo(xAxis);\r
-        minX = new Text(xAxis, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(minX); \r
-        minX.addKeyListener(enterListener);\r
-        minX.addModifyListener(getAxisBoundModifyListener());\r
-        minX.setText("" + domainAxis.getLowerBound());\r
-        Composite fillX = new Composite(xAxis, SWT.CENTER);\r
-        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).grab(true, false).applyTo(fillX);\r
-        GridLayoutFactory.fillDefaults().applyTo(fillX);\r
-        l = new Label(fillX, SWT.NONE);\r
-        l.setText(chartInfo.expression);\r
-        maxX = new Text(xAxis, SWT.BORDER | SWT.RIGHT);\r
-        GridDataFactory.fillDefaults().hint(40, SWT.DEFAULT).applyTo(maxX);\r
-        maxX.addKeyListener(enterListener);\r
-        maxX.addModifyListener(getAxisBoundModifyListener());\r
-        maxX.setText("" + domainAxis.getUpperBound());\r
-\r
-        return null;\r
-    }\r
-\r
-    protected void createButtonsForButtonBar(Composite parent) {\r
-        // create OK and Cancel buttons by default\r
-        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
-                false);\r
-        createButton(parent, IDialogConstants.CANCEL_ID,\r
-                IDialogConstants.CANCEL_LABEL, false);\r
-    }\r
-\r
-    public LookupChartInfo open(Boolean bool) {\r
-        Shell shell = this.getShell();\r
-        if (shell == null || shell.isDisposed()) {\r
-            shell = null;\r
-            create();\r
-            shell = this.getShell();\r
-        }\r
-        constrainShellSize();\r
-        shell.open();\r
-        getButton(IDialogConstants.OK_ID).setFocus();\r
-        Display display = getParentShell().getDisplay();\r
-        while (!shell.isDisposed()) {\r
-            if (!display.readAndDispatch()) {\r
-                display.sleep();\r
-            }\r
-        }\r
-        return chartInfo;\r
-    }\r
-   \r
-    @Override\r
-    public void okPressed() {\r
-        chartInfo.lookupTable = graphToModelicaTable();\r
-        chartInfo.minX = Double.parseDouble(minX.getText());\r
-        chartInfo.maxX = Double.parseDouble(maxX.getText());\r
-        chartInfo.minY = Double.parseDouble(minY.getText());\r
-        chartInfo.maxY = Double.parseDouble(maxY.getText());\r
-        super.okPressed();\r
-    }\r
-    \r
-    private String graphToModelicaTable() {\r
-        StringBuilder b = new StringBuilder();\r
-        b.append("{");\r
-        XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset();\r
-        XYSeries series = collection.getSeries(0);\r
-        if(series.isEmpty())\r
-            return "";\r
-        @SuppressWarnings("rawtypes")\r
-               Iterator iterator = series.getItems().iterator();\r
-        while(iterator.hasNext()){\r
-            XYDataItem item = (XYDataItem)iterator.next();\r
-            b.append("{" + item.getX() + "," + item.getY() + "}");\r
-            if(iterator.hasNext())\r
-                b.append(",");\r
-        }\r
-        b.append("}");\r
-        return b.toString();\r
-    }\r
-\r
-    private JFreeChart createChart() {\r
-        XYDataset dataset = createDataset();\r
-        chart = ChartFactory.createXYLineChart(null, null, null,\r
-                dataset, PlotOrientation.VERTICAL, false, true, false);\r
-        XYPlot plot = (XYPlot) chart.getPlot();\r
-        XYLineAndShapeRenderer renderer\r
-        = (XYLineAndShapeRenderer) plot.getRenderer();\r
-        renderer.setBaseShapesVisible(true);\r
-        renderer.setDrawOutlines(true);\r
-        renderer.setUseFillPaint(true);\r
-        renderer.setBaseFillPaint(Color.white);\r
-        renderer.setSeriesStroke(0, new BasicStroke(3.0f));\r
-        renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));\r
-        renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));\r
-\r
-        ValueAxis rangeAxis = plot.getRangeAxis();\r
-        rangeAxis.setAutoRange(false);\r
-        rangeAxis.setRange(chartInfo.minY, chartInfo.maxY);\r
-        ValueAxis domainAxis = plot.getDomainAxis();\r
-        domainAxis.setAutoRange(false);\r
-        domainAxis.setRange(chartInfo.minX, chartInfo.maxX);\r
-        return chart;\r
-    }\r
-\r
-    public XYDataset createDataset() {\r
-        XYSeries series = new XYSeries("Series");\r
-        XYSeriesCollection dataset = new XYSeriesCollection();\r
-        dataset.addSeries(series);\r
-        return dataset;\r
-    }\r
-\r
-    private ModifyListener getAxisBoundModifyListener() {\r
-        return new ModifyListener() {\r
-\r
-            @Override\r
-            public void modifyText(ModifyEvent e) {\r
-                Widget widget = e.widget;\r
-                if(widget instanceof Text) {\r
-                    Text text = (Text)widget;\r
-                    Double value;\r
-                    try {\r
-                        value = Double.parseDouble(text.getText());\r
-                    } catch (NumberFormatException e1 ) {\r
-                        return;\r
-                    }\r
-                    XYPlot plot = (XYPlot) chart.getPlot();\r
-                    ValueAxis rangeAxis = plot.getRangeAxis();\r
-                    ValueAxis domainAxis = plot.getDomainAxis();\r
-                    if(text == minX) {\r
-                        domainAxis.setLowerBound(value);\r
-                    } else if (text == maxX) {\r
-                        domainAxis.setUpperBound(value);\r
-                    } else if (text == minY) {\r
-                        rangeAxis.setLowerBound(value);\r
-                    } else if (text == maxY) {\r
-                        rangeAxis.setUpperBound(value);\r
-                    }\r
-                }\r
-            }\r
-        };\r
-    }\r
-\r
-    private class InputOutputCellModifier implements ICellModifier {\r
-\r
-        XYSeries series;\r
-\r
-        public InputOutputCellModifier() {\r
-            XYSeriesCollection collection = (XYSeriesCollection) ((XYPlot)chart.getPlot()).getDataset();\r
-            series = collection.getSeries(0); \r
-        }\r
-\r
-        public boolean canModify(Object element, String property) {\r
-            return true;\r
-        }\r
-\r
-        public Object getValue(Object element, String property) {\r
-            InputOutput io = (InputOutput)element;\r
-            if (LookupInputOutputTable.INPUT.equals(property))\r
-                return (String)io.getInput(String.class);\r
-            else if (LookupInputOutputTable.OUTPUT.equals(property))\r
-                return (String)io.getOutput(String.class);\r
-            else\r
-                return null;\r
-        }\r
-\r
-        public void modify(Object element, String property, Object value) {\r
-            if (element instanceof Item) element = ((Item) element).getData();\r
-\r
-            InputOutput io = (InputOutput)element;\r
-            Double x = (Double)io.getInput(Double.class);\r
-            int item = series.indexOf(x);\r
-            series.remove(item);\r
-\r
-            if (LookupInputOutputTable.INPUT.equals(property)) {\r
-                Double newX = io.setInput((String)value);\r
-                // if has the same x-value, revert back\r
-                if(newX != null && series.indexOf(newX) >= 0) {\r
-                    io.setInput(x);\r
-                }\r
-            } else if (LookupInputOutputTable.OUTPUT.equals(property)) {\r
-                io.setOutput((String)value);\r
-            }\r
-\r
-            series.add((Double)io.getInput(Double.class), (Double)io.getOutput(Double.class));\r
-\r
-            table.refresh();\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
deleted file mode 100644 (file)
index f03218e..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Point;\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.layer0.Layer0;\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 ExpressionField 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
-\r
-\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 ExpressionField(parent, SWT.BORDER);\r
-        expression.setFont(FONT);\r
-        expression.setExpression(equation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-    }\r
-\r
-    @Override\r
-    public void focus() {\r
-        if(this.expression != null) this.expression.focus();\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(expression != null) {\r
-            IDocument doc = expression.getDocument();\r
-            try {\r
-                Point selection = expression.getSelection();\r
-                doc.replace(selection.x, selection.y, var);\r
-                expression.setSelection(selection.x + var.length());\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void writeData(final Resource variable, Map<String, Object> data) {\r
-        final String currentText = expression.getExpression();\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
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    if(expression != null) {\r
-                        g.deny(variable, sr.HasExpression);\r
-                    }\r
-                    expression = g.newResource();\r
-                    g.claim(expression, l0.InstanceOf, null, sr.ParameterExpression);\r
-                    g.claim(variable, sr.HasExpression, expression);\r
-                    g.claimLiteral(expression, sr.HasEquation, currentText);\r
-                }\r
-\r
-            });\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        if(this.expression != null && this.expression.getExpression() != null)\r
-            data.put("equation", this.expression.getExpression());\r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        return Arrays.asList(this.expression);\r
-    }\r
-\r
-}\r
-\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/expressions/StockExpressionViewFactor.java
deleted file mode 100644 (file)
index 16948ab..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\r
-import org.eclipse.swt.SWT;\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.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.layer0.Layer0;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class StockExpressionViewFactor implements IExpressionViewFactor {\r
-\r
-    private Label integralLabel;\r
-    private Text integral;\r
-    private Label equationLabel;\r
-    private ExpressionField expression;\r
-\r
-    @Override\r
-    public void createView(Composite parent, Map<String, Object> data) {\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
-        GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
-\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(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);\r
-        integral.setEditable(false);\r
-        integral.setFont(FONT);\r
-        integral.setText(integralEquation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(integral);\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 ExpressionField(parent, SWT.BORDER);\r
-        expression.setFont(FONT);\r
-        expression.setExpression(initialEquation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-\r
-    }\r
-\r
-    @Override\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 writeData(final Resource variable, Map<String, Object> data) {\r
-        final String currentText = expression.getExpression();\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
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    if(expression != null) {\r
-                        g.deny(variable, sr.HasExpression);\r
-                    }\r
-                    expression = g.newResource();\r
-                    g.claim(expression, l0.InstanceOf, null, sr.StockExpression);\r
-                    g.claim(variable, sr.HasExpression, expression);\r
-                    g.claimLiteral(expression, sr.HasInitialEquation, currentText);\r
-                }\r
-\r
-            });\r
-        }\r
-    }\r
-\r
-    private String getIntegral(final Resource variable) {\r
-        String integral = "";\r
-        try {\r
-            integral = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
-\r
-                @Override\r
-                public String perform(ReadGraph graph) throws DatabaseException {\r
-                    SysdynResource sr = SysdynResource.getInstance(graph);\r
-                    Layer0 l0 = Layer0.getInstance(graph);\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, l0.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, l0.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
-    @Override\r
-    public void focus() {\r
-        if(this.expression != null) this.expression.focus();\r
-    }\r
-\r
-    @Override\r
-    public void replaceSelection(String var) {\r
-        if(expression != null) {\r
-            IDocument doc = expression.getDocument();\r
-            try {\r
-                Point selection = expression.getSelection();\r
-                doc.replace(selection.x, selection.y, var);\r
-                expression.setSelection(selection.x + var.length());\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        if(this.expression != null && this.expression.getExpression() != null)\r
-            data.put("initialEquation", this.expression.getExpression());\r
-        if(this.integral != null && this.integral.getText() != null)\r
-            data.put("integral", this.integral.getText());\r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        return Arrays.asList(this.expression);\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
deleted file mode 100644 (file)
index 0edf625..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.equation.expressions;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.jface.text.BadLocationException;\r
-import org.eclipse.jface.text.IDocument;\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.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.widgets.Button;\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.layer0.Layer0;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class WithLookupExpressionViewFactor implements IExpressionViewFactor {\r
-\r
-\r
-    private Label expressionLabel;\r
-    private ExpressionField expression;\r
-    private Label lookupLabel;\r
-    private ExpressionField lookup;\r
-    private Button asGraph;\r
-    private ExpressionField lastSelectedText = expression;\r
-    private Resource variable;\r
-    private LookupChartInfo chartInfo;\r
-\r
-    public WithLookupExpressionViewFactor(Resource variable) {\r
-        super();\r
-        this.variable = variable;\r
-    }\r
-    \r
-    @Override\r
-    public void createView(Composite parent, final Map<String, Object> data) {\r
-        String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
-        String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : "";\r
-\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 ExpressionField(parent, SWT.BORDER);\r
-        expression.setFont(FONT);\r
-        expression.setExpression(equation);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
-\r
-        expression.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
-\r
-            @Override\r
-            public void focusLost(FocusEvent e) {\r
-                lastSelectedText = expression;\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
-        lookup = new ExpressionField(parent, SWT.BORDER);\r
-        lookup.setFont(FONT);\r
-        lookup.setExpression(lookupTable);\r
-        GridDataFactory.fillDefaults().grab(true, true).applyTo(lookup);\r
-\r
-        lookup.getSourceViewer().getTextWidget().addFocusListener(new FocusAdapter() {\r
-\r
-            @Override\r
-            public void focusLost(FocusEvent e) {\r
-                lastSelectedText = lookup;\r
-            }\r
-        });\r
-\r
-        asGraph = new Button(parent, SWT.None);\r
-        asGraph.setText("As graph");\r
-        asGraph.setFont(FONT);\r
-        asGraph.addSelectionListener(new SelectionAdapter() {\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if(e.widget == asGraph) {\r
-                    if(chartInfo == null) chartInfo = new LookupChartInfo(expression.getExpression(), lookup.getExpression(), variable, data);\r
-                    LookupPopup pud = new LookupPopup(asGraph.getParent().getShell(), chartInfo);\r
-                    LookupChartInfo newInfo = pud.open(false);\r
-                    if(pud.getReturnCode() == org.eclipse.jface.window.Window.OK) {\r
-                        chartInfo = newInfo;\r
-                        lookup.setExpression(chartInfo.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.getExpression();\r
-        final String currentLookupTable = lookup.getExpression();\r
-\r
-        if(currentExpression != null && currentLookupTable != null) {\r
-            data.putAll(data);\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
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    if(expression != null) {\r
-                        g.deny(variable, sr.HasExpression);\r
-                    }\r
-                    expression = g.newResource();\r
-                    g.claim(expression, l0.InstanceOf, null, sr.WithLookupExpression);\r
-                    g.claim(variable, sr.HasExpression, expression);\r
-                    g.claimLiteral(expression, sr.HasEquation, currentExpression);\r
-                    g.claimLiteral(expression, sr.HasLookup, currentLookupTable);\r
-                    g.claimLiteral(expression, sr.HasMinX, chartInfo.minX);\r
-                    g.claimLiteral(expression, sr.HasMaxX, chartInfo.maxX);\r
-                    g.claimLiteral(expression, sr.HasMinY, chartInfo.minY);\r
-                    g.claimLiteral(expression, sr.HasMaxY, chartInfo.maxY);\r
-                }\r
-            });\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void focus() {\r
-        if(this.lastSelectedText != null) this.lastSelectedText.focus();\r
-    }\r
-\r
-    @Override\r
-    public void replaceSelection(String var) {\r
-        if(lastSelectedText != null) {\r
-            IDocument doc = lastSelectedText.getDocument();\r
-            try {\r
-                Point selection = lastSelectedText.getSelection();\r
-                doc.replace(selection.x, selection.y, var);\r
-                lastSelectedText.setSelection(selection.x + var.length());\r
-            } catch (BadLocationException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        if(this.expression != null && this.expression.getExpression() != null)\r
-            data.put("equation", this.expression.getExpression());\r
-        if(this.lookup != null && this.lookup.getExpression() != null)\r
-            data.put("lookup", this.lookup.getExpression());\r
-        if(this.chartInfo != null) {\r
-            data.put("minX", chartInfo.minX);\r
-            data.put("maxX", chartInfo.maxX);\r
-            data.put("minY", chartInfo.minY);\r
-            data.put("maxY", chartInfo.maxY);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        return Arrays.asList(this.expression, this.lookup);\r
-    }\r
-}
\ No newline at end of file