1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.sysdyn.ui.properties.widgets.expressions;
\r
14 import java.util.Map;
\r
16 import org.eclipse.jface.layout.GridDataFactory;
\r
17 import org.eclipse.jface.layout.GridLayoutFactory;
\r
18 import org.eclipse.swt.SWT;
\r
19 import org.eclipse.swt.widgets.Composite;
\r
20 import org.eclipse.swt.widgets.Label;
\r
21 import org.eclipse.swt.widgets.Table;
\r
22 import org.simantics.db.ReadGraph;
\r
23 import org.simantics.db.Resource;
\r
24 import org.simantics.db.exception.DatabaseException;
\r
25 import org.simantics.db.request.Read;
\r
26 import org.simantics.sysdyn.SysdynResource;
\r
27 import org.simantics.ui.SimanticsUI;
\r
29 public class ConstantExpression extends BasicExpression {
\r
31 public ConstantExpression(ExpressionWidgetInput input) {
\r
34 this.expressionType = SimanticsUI.getSession().syncRequest(new Read<Resource>() {
\r
37 public Resource perform(ReadGraph graph) throws DatabaseException {
\r
38 return SysdynResource.getInstance(graph).ConstantExpression;
\r
41 } catch (DatabaseException e) {
\r
42 e.printStackTrace();
\r
47 public void createExpressionFields(Composite parent, Map<String, Object> data, Table allowedVariables) {
\r
48 // Create the single field
\r
49 GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent);
\r
50 String equation = data.get("equation") != null ? (String)data.get("equation") : "";
\r
52 Label l = new Label(parent, SWT.NONE);
\r
54 //System.out.println("ConstantExpression");
\r
55 expression = new ExpressionField(parent, SWT.BORDER, null, false, input);
\r
56 expression.setExpression(equation);
\r
57 GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);
\r