if(value == null)\r
return false;\r
valueResource = g.newResource();\r
- g.claim(valueResource, g.getBuiltins().InstanceOf, \r
+ g.claim(valueResource, g.getBuiltins().InstanceOf, null,\r
valueType);\r
g.claim(element, relation, valueResource);\r
g.claimValue(valueResource, value); \r
rangeElement.toString()\r
);\r
Resource result = g.newResource();\r
- g.claim(result, g.getBuiltins().InstanceOf, domainType);\r
+ g.claim(result, g.getBuiltins().InstanceOf, null, domainType);\r
return result;\r
} catch(DatabaseException e) {\r
throw new MappingException(e);\r
import org.simantics.ui.SimanticsUI;\r
\r
public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor {\r
- \r
+\r
private Label equationLabel;\r
private ExpressionField expression;\r
- \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
expression.setFont(FONT);\r
expression.setExpression(equation);\r
GridDataFactory.fillDefaults().grab(true, true).applyTo(expression);\r
- \r
+\r
}\r
\r
@Override\r
public void readData(final Resource variable, Map<String, Object> data) {\r
- String equation = null; \r
+ String equation = null;\r
if (variable != null && data.get("equation") == null) {\r
try {\r
equation = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
e1.printStackTrace();\r
}\r
data.put("equation", equation);\r
- } \r
+ }\r
}\r
\r
@Override\r
g.deny(variable, sr.HasExpression);\r
}\r
expression = g.newResource();\r
- g.claim(expression, b.InstanceOf, sr.NormalExpression);\r
+ g.claim(expression, b.InstanceOf, null, sr.NormalExpression);\r
g.claim(variable, sr.HasExpression, expression);\r
g.claimValue(expression, sr.HasEquation, currentText);\r
}\r
\r
});\r
- } \r
+ }\r
}\r
\r
@Override\r
g.deny(variable, sr.HasExpression);\r
}\r
expression = g.newResource();\r
- g.claim(expression, b.InstanceOf, sr.ConstantExpression);\r
+ g.claim(expression, b.InstanceOf, null, sr.ConstantExpression);\r
g.claim(variable, sr.HasExpression, expression);\r
g.claimValue(expression, sr.HasEquation, currentText);\r
}\r
import org.simantics.ui.SimanticsUI;\r
\r
public class ParameterExpressionViewFactor implements IExpressionViewFactor {\r
- \r
+\r
private Label equationLabel;\r
private ExpressionField expression;\r
- \r
+\r
@Override\r
public void createView(Composite parent, Map<String, Object> data) {\r
- \r
+\r
final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
- \r
- \r
+\r
+\r
GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
equationLabel = new Label(parent, SWT.NONE);\r
equationLabel.setFont(FONT);\r
\r
@Override\r
public void readData(final Resource variable, Map<String, Object> data) {\r
- String equation = null; \r
+ String equation = null;\r
if (variable != null && data.get("equation") == null) {\r
try {\r
equation = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
e1.printStackTrace();\r
}\r
data.put("equation", equation);\r
- } \r
+ }\r
}\r
\r
@Override\r
g.deny(variable, sr.HasExpression);\r
}\r
expression = g.newResource();\r
- g.claim(expression, b.InstanceOf, sr.ParameterExpression);\r
+ g.claim(expression, b.InstanceOf, null, sr.ParameterExpression);\r
g.claim(variable, sr.HasExpression, expression);\r
g.claimValue(expression, sr.HasEquation, currentText);\r
}\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
+ data.put("equation", this.expression.getExpression());\r
}\r
\r
@Override\r
\r
final String initialEquation = data.get("initialEquation") != null ? (String)data.get("initialEquation") : "";\r
final String integralEquation = data.get("integral") != null ? (String)data.get("integral") : "";\r
- \r
+\r
GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
\r
integralLabel = new Label(parent, SWT.NONE);\r
e1.printStackTrace();\r
}\r
data.put("initialEquation", initialEquation);\r
- } \r
+ }\r
\r
data.put("integral", getIntegral(variable));\r
}\r
g.deny(variable, sr.HasExpression);\r
}\r
expression = g.newResource();\r
- g.claim(expression, b.InstanceOf, sr.StockExpression);\r
+ g.claim(expression, b.InstanceOf, null, sr.StockExpression);\r
g.claim(variable, sr.HasExpression, expression);\r
g.claimValue(expression, sr.HasInitialEquation, currentText);\r
}\r
\r
});\r
- } \r
+ }\r
}\r
\r
private String getIntegral(final Resource variable) {\r
Resource tail = graph.getPossibleObject(r, sr.HasTail);\r
if(tail != null) {\r
Object name = graph.getPossibleRelatedValue(tail, b.HasName);\r
- if (name != null) \r
+ if (name != null)\r
builder.append(" + " + name);\r
}\r
- } \r
+ }\r
}\r
for (Resource r : tails) {\r
if(graph.isInstanceOf(r, sr.Flow)) {\r
Resource head = graph.getPossibleObject(r, sr.HasHead);\r
if(head != null) {\r
Object name = graph.getPossibleRelatedValue(head, b.HasName);\r
- if (name != null) \r
+ if (name != null)\r
builder.append(" - " + name);\r
}\r
- } \r
+ }\r
}\r
if (builder.indexOf(" + ") == 0)\r
builder.delete(0, 3);\r
});\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
- } \r
+ }\r
return integral;\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
+ 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
public class WithLookupExpressionViewFactor implements IExpressionViewFactor {\r
\r
- \r
+\r
private Label expressionLabel;\r
private ExpressionField expression;\r
private Label lookupLabel;\r
private ExpressionField lookup;\r
private ExpressionField lastSelectedText = expression;\r
- \r
+\r
@Override\r
public void createView(Composite parent, Map<String, Object> data) {\r
\r
final String equation = data.get("equation") != null ? (String)data.get("equation") : "";\r
final String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : "";\r
- \r
+\r
GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent);\r
\r
expressionLabel = new Label(parent, SWT.NONE);\r
lastSelectedText = expression;\r
}\r
});\r
- \r
+\r
lookupLabel = new Label(parent, SWT.NONE);\r
lookupLabel.setFont(FONT);\r
lookupLabel.setText("Lookup\ntable");\r
\r
@Override\r
public void readData(final Resource variable, Map<String, Object> data) {\r
- String[] results = null; \r
+ String[] results = null;\r
if (variable != null && data.get("equation") == null) {\r
try {\r
results = SimanticsUI.getSession().syncRequest(new Read<String[]>() {\r
}\r
data.put("equation", results[0]);\r
data.put("lookup", results[1]);\r
- } \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
+\r
if(currentExpression != null && currentLookupTable != null) {\r
data.put("equation", currentExpression);\r
data.put("lookup", currentLookupTable);\r
g.deny(variable, sr.HasExpression);\r
}\r
expression = g.newResource();\r
- g.claim(expression, b.InstanceOf, sr.WithLookupExpression);\r
+ g.claim(expression, b.InstanceOf, null, sr.WithLookupExpression);\r
g.claim(variable, sr.HasExpression, expression);\r
g.claimValue(expression, sr.HasEquation, currentExpression);\r
g.claimValue(expression, sr.HasLookup, currentLookupTable);\r
}\r
\r
});\r
- } \r
+ }\r
}\r
\r
@Override\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
+ data.put("equation", this.expression.getExpression());\r
if(this.lookup != null && this.lookup.getExpression() != null)\r
- data.put("lookup", this.lookup.getExpression()); \r
+ data.put("lookup", this.lookup.getExpression());\r
}\r
\r
@Override\r
\r
public class SysdynProject extends AbstractProjectFeature {\r
private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective";\r
- \r
+\r
class ModelManager extends UIModelManagerBase {\r
@Override\r
public void create(ProjectElementType kind, Shell parentShell, Session session, Resource container,\r
SysdynResource sr = SysdynResource.getInstance(g);\r
Resource model = g.newResource();\r
g.claimValue(model, b.HasName, "Configuration");\r
- g.claim(model, b.InstanceOf, sr.Configuration);\r
+ g.claim(model, b.InstanceOf, null, sr.Configuration);\r
g.claim(model, b.PartOf, library);\r
g.claimValue(model, sr.HasStartTime, 0.0);\r
g.claimValue(model, sr.HasStopTime, 10.0);\r
};\r
\r
ModelManager mm;\r
- \r
+\r
@Override\r
public void configure() throws ProjectException {\r
addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE);\r
getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE);\r
- \r
+\r
mm = new ModelManager();\r
getProjectElement().setHint(UIModelManager.KEY_MODEL_MANAGER, mm);\r
}\r