From cbb2aea66d114b3574dc6fa5c62191893be97bd1 Mon Sep 17 00:00:00 2001 From: lehtonen Date: Tue, 16 Mar 2010 21:34:59 +0000 Subject: [PATCH] Changed remaining places where InstanceOf statements are claimed to not claim an inverse HasInstance by using null inverse relation. This was done because in almost all cases HasInstance statements should not be created. In general, HasInstance statements can be used only when it is known that there will never be vast amounts of instances of some type. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15007 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../rules/domain/RelatedValueAccessor.java | 2 +- .../objmap/schema/SimpleLinkType.java | 2 +- .../AuxiliaryExpressionViewFactor.java | 16 +++++++------- .../ConstantExpressionViewFactor.java | 2 +- .../ParameterExpressionViewFactor.java | 20 ++++++++--------- .../StockExpressionViewFactor.java | 20 ++++++++--------- .../WithLookupExpressionViewFactor.java | 22 +++++++++---------- .../sysdyn/ui/project/SysdynProject.java | 8 +++---- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedValueAccessor.java b/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedValueAccessor.java index 8716fab6..592d0e0c 100644 --- a/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedValueAccessor.java +++ b/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedValueAccessor.java @@ -57,7 +57,7 @@ public class RelatedValueAccessor implements IDomainAccessor { if(value == null) return false; valueResource = g.newResource(); - g.claim(valueResource, g.getBuiltins().InstanceOf, + g.claim(valueResource, g.getBuiltins().InstanceOf, null, valueType); g.claim(element, relation, valueResource); g.claimValue(valueResource, value); diff --git a/org.simantics.objmap/src/org/simantics/objmap/schema/SimpleLinkType.java b/org.simantics.objmap/src/org/simantics/objmap/schema/SimpleLinkType.java index 0d25d531..f0366ca4 100644 --- a/org.simantics.objmap/src/org/simantics/objmap/schema/SimpleLinkType.java +++ b/org.simantics.objmap/src/org/simantics/objmap/schema/SimpleLinkType.java @@ -66,7 +66,7 @@ public class SimpleLinkType implements ILinkType { rangeElement.toString() ); Resource result = g.newResource(); - g.claim(result, g.getBuiltins().InstanceOf, domainType); + g.claim(result, g.getBuiltins().InstanceOf, null, domainType); return result; } catch(DatabaseException e) { throw new MappingException(e); 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 index 96b7e6ea..9a74a19c 100644 --- 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 @@ -34,15 +34,15 @@ import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.SimanticsUI; public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor { - + private Label equationLabel; private ExpressionField expression; - + @Override public void createView(Composite parent, Map data) { final String equation = data.get("equation") != null ? (String)data.get("equation") : ""; - + GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent); equationLabel = new Label(parent, SWT.NONE); equationLabel.setFont(FONT); @@ -54,12 +54,12 @@ public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor { expression.setFont(FONT); expression.setExpression(equation); GridDataFactory.fillDefaults().grab(true, true).applyTo(expression); - + } @Override public void readData(final Resource variable, Map data) { - String equation = null; + String equation = null; if (variable != null && data.get("equation") == null) { try { equation = SimanticsUI.getSession().syncRequest(new Read() { @@ -80,7 +80,7 @@ public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor { e1.printStackTrace(); } data.put("equation", equation); - } + } } @Override @@ -99,13 +99,13 @@ public class AuxiliaryExpressionViewFactor implements IExpressionViewFactor { g.deny(variable, sr.HasExpression); } expression = g.newResource(); - g.claim(expression, b.InstanceOf, sr.NormalExpression); + g.claim(expression, b.InstanceOf, null, sr.NormalExpression); g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasEquation, currentText); } }); - } + } } @Override 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 index 35f411ef..1994fd0c 100644 --- 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 @@ -117,7 +117,7 @@ public class ConstantExpressionViewFactor implements IExpressionViewFactor { g.deny(variable, sr.HasExpression); } expression = g.newResource(); - g.claim(expression, b.InstanceOf, sr.ConstantExpression); + g.claim(expression, b.InstanceOf, null, sr.ConstantExpression); g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasEquation, currentText); } 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 index 008a7779..fe234848 100644 --- 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 @@ -34,16 +34,16 @@ import org.simantics.sysdyn.SysdynResource; import org.simantics.ui.SimanticsUI; public class ParameterExpressionViewFactor implements IExpressionViewFactor { - + private Label equationLabel; private ExpressionField expression; - + @Override public void createView(Composite parent, Map data) { - + final String equation = data.get("equation") != null ? (String)data.get("equation") : ""; - - + + GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent); equationLabel = new Label(parent, SWT.NONE); equationLabel.setFont(FONT); @@ -64,7 +64,7 @@ public class ParameterExpressionViewFactor implements IExpressionViewFactor { @Override public void readData(final Resource variable, Map data) { - String equation = null; + String equation = null; if (variable != null && data.get("equation") == null) { try { equation = SimanticsUI.getSession().syncRequest(new Read() { @@ -85,7 +85,7 @@ public class ParameterExpressionViewFactor implements IExpressionViewFactor { e1.printStackTrace(); } data.put("equation", equation); - } + } } @Override @@ -118,19 +118,19 @@ public class ParameterExpressionViewFactor implements IExpressionViewFactor { g.deny(variable, sr.HasExpression); } expression = g.newResource(); - g.claim(expression, b.InstanceOf, sr.ParameterExpression); + g.claim(expression, b.InstanceOf, null, sr.ParameterExpression); g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasEquation, currentText); } }); - } + } } @Override public void updateData(Map data) { if(this.expression != null && this.expression.getExpression() != null) - data.put("equation", this.expression.getExpression()); + data.put("equation", this.expression.getExpression()); } @Override 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 index 411446dd..ac8b7455 100644 --- 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 @@ -47,7 +47,7 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { final String initialEquation = data.get("initialEquation") != null ? (String)data.get("initialEquation") : ""; final String integralEquation = data.get("integral") != null ? (String)data.get("integral") : ""; - + GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent); integralLabel = new Label(parent, SWT.NONE); @@ -98,7 +98,7 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { e1.printStackTrace(); } data.put("initialEquation", initialEquation); - } + } data.put("integral", getIntegral(variable)); } @@ -119,13 +119,13 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { g.deny(variable, sr.HasExpression); } expression = g.newResource(); - g.claim(expression, b.InstanceOf, sr.StockExpression); + g.claim(expression, b.InstanceOf, null, sr.StockExpression); g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasInitialEquation, currentText); } }); - } + } } private String getIntegral(final Resource variable) { @@ -147,20 +147,20 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { Resource tail = graph.getPossibleObject(r, sr.HasTail); if(tail != null) { Object name = graph.getPossibleRelatedValue(tail, b.HasName); - if (name != null) + if (name != null) builder.append(" + " + name); } - } + } } for (Resource r : tails) { if(graph.isInstanceOf(r, sr.Flow)) { Resource head = graph.getPossibleObject(r, sr.HasHead); if(head != null) { Object name = graph.getPossibleRelatedValue(head, b.HasName); - if (name != null) + if (name != null) builder.append(" - " + name); } - } + } } if (builder.indexOf(" + ") == 0) builder.delete(0, 3); @@ -170,7 +170,7 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { }); } catch (DatabaseException e) { e.printStackTrace(); - } + } return integral; } @@ -196,7 +196,7 @@ public class StockExpressionViewFactor implements IExpressionViewFactor { @Override public void updateData(Map data) { if(this.expression != null && this.expression.getExpression() != null) - data.put("initialEquation", this.expression.getExpression()); + data.put("initialEquation", this.expression.getExpression()); if(this.integral != null && this.integral.getText() != null) data.put("integral", this.integral.getText()); } 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 index 81fd4b47..5a3cda31 100644 --- 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 @@ -37,19 +37,19 @@ import org.simantics.ui.SimanticsUI; public class WithLookupExpressionViewFactor implements IExpressionViewFactor { - + private Label expressionLabel; private ExpressionField expression; private Label lookupLabel; private ExpressionField lookup; private ExpressionField lastSelectedText = expression; - + @Override public void createView(Composite parent, Map data) { final String equation = data.get("equation") != null ? (String)data.get("equation") : ""; final String lookupTable = data.get("lookup") != null ? (String)data.get("lookup") : ""; - + GridLayoutFactory.fillDefaults().numColumns(2).spacing(3, 3).applyTo(parent); expressionLabel = new Label(parent, SWT.NONE); @@ -69,7 +69,7 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { lastSelectedText = expression; } }); - + lookupLabel = new Label(parent, SWT.NONE); lookupLabel.setFont(FONT); lookupLabel.setText("Lookup\ntable"); @@ -91,7 +91,7 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { @Override public void readData(final Resource variable, Map data) { - String[] results = null; + String[] results = null; if (variable != null && data.get("equation") == null) { try { results = SimanticsUI.getSession().syncRequest(new Read() { @@ -117,14 +117,14 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { } data.put("equation", results[0]); data.put("lookup", results[1]); - } + } } @Override public void writeData(final Resource variable, Map data) { final String currentExpression = expression.getExpression(); final String currentLookupTable = lookup.getExpression(); - + if(currentExpression != null && currentLookupTable != null) { data.put("equation", currentExpression); data.put("lookup", currentLookupTable); @@ -139,14 +139,14 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { g.deny(variable, sr.HasExpression); } expression = g.newResource(); - g.claim(expression, b.InstanceOf, sr.WithLookupExpression); + g.claim(expression, b.InstanceOf, null, sr.WithLookupExpression); g.claim(variable, sr.HasExpression, expression); g.claimValue(expression, sr.HasEquation, currentExpression); g.claimValue(expression, sr.HasLookup, currentLookupTable); } }); - } + } } @Override @@ -171,9 +171,9 @@ public class WithLookupExpressionViewFactor implements IExpressionViewFactor { @Override public void updateData(Map data) { if(this.expression != null && this.expression.getExpression() != null) - data.put("equation", this.expression.getExpression()); + data.put("equation", this.expression.getExpression()); if(this.lookup != null && this.lookup.getExpression() != null) - data.put("lookup", this.lookup.getExpression()); + data.put("lookup", this.lookup.getExpression()); } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java index 9a3c2534..8cfabfcb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java @@ -35,7 +35,7 @@ import org.simantics.utils.ui.workbench.WorkbenchUtils; public class SysdynProject extends AbstractProjectFeature { private static final String DEFAULT_PERSPECTIVE = "org.simantics.sysdyn.ui.perspective"; - + class ModelManager extends UIModelManagerBase { @Override public void create(ProjectElementType kind, Shell parentShell, Session session, Resource container, @@ -73,7 +73,7 @@ public class SysdynProject extends AbstractProjectFeature { SysdynResource sr = SysdynResource.getInstance(g); Resource model = g.newResource(); g.claimValue(model, b.HasName, "Configuration"); - g.claim(model, b.InstanceOf, sr.Configuration); + g.claim(model, b.InstanceOf, null, sr.Configuration); g.claim(model, b.PartOf, library); g.claimValue(model, sr.HasStartTime, 0.0); g.claimValue(model, sr.HasStopTime, 10.0); @@ -85,13 +85,13 @@ public class SysdynProject extends AbstractProjectFeature { }; ModelManager mm; - + @Override public void configure() throws ProjectException { addToCollectionHint(ProjectKeys.PERSPECTIVES, DEFAULT_PERSPECTIVE); addToCollectionHint(ProjectKeys.OPEN_PERSPECTIVES, DEFAULT_PERSPECTIVE); getProjectElement().setHint(ProjectKeys.DEFAULT_PERSPECTIVE, DEFAULT_PERSPECTIVE); - + mm = new ModelManager(); getProjectElement().setHint(UIModelManager.KEY_MODEL_MANAGER, mm); } -- 2.47.1