From 4e804073584d04f9cd5f438bcb07a74a1b2d919d Mon Sep 17 00:00:00 2001 From: lempinen Date: Thu, 20 Dec 2012 12:26:26 +0000 Subject: [PATCH] Delete expression was still using OrderedSet. Removed all references to ordered sets (and also commented references to ordered sets) (fixes #3905) git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26531 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../NewEnumerationNodeHandler.java | 1 - .../sysdyn/ui/properties/ArrayIndexesTab.java | 12 -------- .../sysdyn/ui/properties/EnumerationTab.java | 5 ---- .../sysdyn/ui/properties/EquationTab.java | 30 +++++++------------ .../ResourceSelectionProcessor.java | 2 -- .../widgets/ArrayExpressionCombo.java | 1 - .../widgets/arrays/EnumerationIndexes.java | 1 - .../widgets/arrays/EnumerationLabeler.java | 1 - .../widgets/arrays/UsedEnumerations.java | 1 - .../arrays/UsedEnumerationsManyVariables.java | 9 ------ .../widgets/expressions/BasicExpression.java | 7 ----- .../widgets/expressions/DelayExpression.java | 3 -- .../widgets/expressions/StockExpression.java | 7 ----- .../expressions/WithLookupExpression.java | 3 -- .../chart/properties/RangeComposite.java | 2 -- .../sysdyn/ui/utils/ArrayVariableUtils.java | 2 +- .../sysdyn/ui/utils/ExpressionUtils.java | 8 +++++ .../sysdyn/ui/utils/VariableNameUtils.java | 2 -- .../ui/validation/DependencyFunction.java | 13 ++++++++ .../ui/validation/EnumerationFunction.java | 1 - .../sysdyn/ui/validation/ValidationUtils.java | 3 -- 21 files changed, 32 insertions(+), 82 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java index 270b11e5..6801225c 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java @@ -71,7 +71,6 @@ public class NewEnumerationNodeHandler extends AbstractHandler { } // Create the enumeartion -// Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes); String name = NameUtils.findFreshName(g, "Enum", configuration, l0.ConsistsOf, "%s%d"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java index 193e42a8..2b622ac8 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java @@ -103,10 +103,8 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg for(Resource r : input.resources) { Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList); if(arrayIndexes == null) { -// arrayIndexes = OrderedSetUtils.create(graph, sr.ArrayIndexes); graph.claim(r, sr.Variable_arrayIndexesList, ListUtils.create(graph, enumerationResources)); } else { -// OrderedSetUtils.addAll(graph, arrayIndexes, enumerationResources); ArrayList filtered = new ArrayList(); for(Resource enumeration : enumerationResources) { if(ListUtils.getNode(graph, arrayIndexes, enumeration) == null) @@ -188,7 +186,6 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg for(Resource variable : input) { Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList); if(arrayIndexes != null) { -// List enumerations = OrderedSetUtils.toList(graph, arrayIndexes); List enumerations = ListUtils.toList(graph, arrayIndexes); List toBeMoved = new ArrayList(); for(Integer index : selectedIndexes) { @@ -200,13 +197,10 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg } for(Resource enumeration : toBeMoved) { -// Resource prev = OrderedSetUtils.prev(graph, arrayIndexes, enumeration); Resource node = ListUtils.getNode(graph, arrayIndexes, enumeration); Resource prev = graph.getSingleObject(node, L0.List_Previous); if(!arrayIndexes.equals(prev) && !toBeMoved.contains(graph.getPossibleObject(prev, L0.List_Element))) { ListUtils.swapWithPrevious(graph, arrayIndexes, enumeration); -// OrderedSetUtils.remove(graph, arrayIndexes, enumeration); -// OrderedSetUtils.addBefore(graph, arrayIndexes, prev, enumeration); } } } @@ -262,7 +256,6 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg for(Resource variable : input) { Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList); if(arrayIndexes != null) { -// List enumerations = OrderedSetUtils.toList(graph, arrayIndexes); List enumerations = ListUtils.toList(graph, arrayIndexes); List toBeMoved = new ArrayList(); for(Integer index : selectedIndexes) { @@ -274,13 +267,10 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg } for(Resource enumeration : toBeMoved) { -// Resource next = OrderedSetUtils.next(graph, arrayIndexes, enumeration); Resource node = ListUtils.getNode(graph, arrayIndexes, enumeration); Resource next = graph.getSingleObject(node, L0.List_Next); if(!arrayIndexes.equals(next) && !toBeMoved.contains(graph.getPossibleObject(next, L0.List_Element))) { ListUtils.swapWithNext(graph, arrayIndexes, enumeration); -// OrderedSetUtils.remove(graph, arrayIndexes, enumeration); -// OrderedSetUtils.addAfter(graph, arrayIndexes, next, enumeration); } } } @@ -335,7 +325,6 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg for(Resource variable : input) { Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList); if(arrayIndexes != null) { -// List enumerations = OrderedSetUtils.toList(graph, arrayIndexes); List enumerations = ListUtils.toList(graph, arrayIndexes); List toBeRemoved = new ArrayList(); for(Integer index : selectedIndexes) { @@ -347,7 +336,6 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg } for(Resource enumeration : toBeRemoved) -// OrderedSetUtils.remove(graph, arrayIndexes, enumeration); ListUtils.removeElement(graph, arrayIndexes, enumeration); } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java index 84312521..cddbd10a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java @@ -180,7 +180,6 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge Layer0 l0 = Layer0.getInstance(graph); HashSet names = new HashSet(); -// for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexes)) { for(Resource r : ListUtils.toList(graph, enumerationIndexes)) { names.add(NameUtils.getSafeName(graph, r)); } @@ -188,7 +187,6 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge Resource ei = GraphUtils.create2(graph, sr.EnumerationIndex, l0.HasName, NameUtils.findFreshName(graph, "index", names, "")); -// OrderedSetUtils.add(graph, enumerationIndexes, ei); ArrayList index = new ArrayList(); index.add(ei); ListUtils.insertBack(graph, enumerationIndexes, index); @@ -245,7 +243,6 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge Resource r = AdaptionUtils.adaptToSingle(o, Resource.class); if(r == null) continue; -// OrderedSetUtils.remove(graph, enumerationIndexes, r); ListUtils.removeElement(graph, enumerationIndexes, r); } } @@ -286,7 +283,6 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge SysdynResource sr = SysdynResource.getInstance(graph); enumerationIndexes = graph.getSingleObject(enumeration, sr.Enumeration_enumerationIndexList); -// List indexes = OrderedSetUtils.toList(graph, enumerationIndexes); List indexes = ListUtils.toList(graph, enumerationIndexes); for(Resource index : indexes) { Boolean show = graph.getPossibleRelatedValue(index, sr.EnumerationIndex_showEnumerationIndexInCharts, Bindings.BOOLEAN); @@ -335,7 +331,6 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge @Override public void perform(WriteGraph graph) throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); -// List indexes = OrderedSetUtils.toList(graph, enumerationIndexes); List indexes = ListUtils.toList(graph, enumerationIndexes); for(Resource index : indexes) { Boolean show = graph.getPossibleRelatedValue(index, sr.EnumerationIndex_showEnumerationIndexInCharts, Bindings.BOOLEAN); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java index 2fde9843..6bde12f2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -60,7 +59,6 @@ import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.variable.Variable; import org.simantics.db.management.ISessionContext; @@ -247,7 +245,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { throws DatabaseException { SysdynResource sr = SysdynResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); -// Resource expressions = OrderedSetUtils.create(graph, sr.Expressions); Resource expressions = ListUtils.create(graph, Collections.emptyList()); graph.claim(variable, sr.Variable_expressionList, expressions); final Resource expression = graph.newResource(); @@ -261,7 +258,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { graph.claim(expression, l0.InstanceOf, null, sr.StockExpression); graph.claimLiteral(expression, sr.StockExpression_initialEquation, ""); } -// OrderedSetUtils.add(graph, expressions, expression); ArrayList addition = new ArrayList(1); addition.add(expression); ListUtils.insertBack(graph, expressions, addition); @@ -307,7 +303,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { if(expressions == null) { return new Pair(false, false); } -// List expressionList = OrderedSetUtils.toList(graph, expressions); List expressionList = ListUtils.toList(graph, expressions); if(expressionList.isEmpty()) { return new Pair(false, false); @@ -392,29 +387,26 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { SysdynResource sr = SysdynResource.getInstance(graph); Layer0 l0 = Layer0.getInstance(graph); - // Currently active expressin should be located in (Model sr.HasActiveExpression expression) + // Currently active expression should be located in (Model sr.HasActiveExpression expression) Resource activeExpression = graph.getPossibleObject(input, sr.IndependentVariable_activeExpression); if(activeExpression == null) return; - Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, activeExpression); - if(OrderedSetUtils.toList(graph, expressionList).size() <= 1) + Resource expressionList = graph.getPossibleObject(input, sr.Variable_expressionList); + + List list = ListUtils.toList(graph, expressionList); + if(list.size() <= 1) return; // Get the previous expression in expression list to be activated - Resource prev = OrderedSetUtils.prev(graph, expressionList, activeExpression); - OrderedSetUtils.remove(graph, expressionList, activeExpression); + int index = list.indexOf(activeExpression); + + ListUtils.removeElement(graph, expressionList, activeExpression); graph.deny(input, l0.ConsistsOf, activeExpression); - if(prev.equals(expressionList)) { - // If the removed expression was last on the list, prev returns the list. - // Get a proper list element to be activated - Iterator iterator = OrderedSetUtils.iterator(graph, expressionList); - prev = iterator.next(); - } + final Resource newActive = index == 0 ? list.get(1) : list.get(index - 1); - // Set prev as active in virtual graph - final Resource newActive = prev; + // Set newActive as active in virtual graph VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class); final Session session = graph.getSession(); session.asyncRequest(new WriteRequest(support.getWorkspacePersistent("expressions")) { @@ -462,7 +454,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { // If there was no active expression, create a normal expression graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression); } - //OrderedSetUtils.add(graph, expressions, newExpression); ArrayList addition = new ArrayList(1); addition.add(newExpression); ListUtils.insertBack(graph, expressions, addition); @@ -721,7 +712,6 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget { if(expressions == null) { return null; } - //List expressionList = OrderedSetUtils.toList(graph, expressions); List expressionList = ListUtils.toList(graph, expressions); if(expressionList.isEmpty()) { return null; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java index 44967509..fa40108a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java @@ -24,7 +24,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.utils.ListUtils; -import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ManyObjectsForFunctionalRelationException; import org.simantics.db.exception.ServiceException; @@ -187,7 +186,6 @@ public class ResourceSelectionProcessor implements SelectionProcessor expressionList = OrderedSetUtils.toList(backend, expressions); List expressionList = ListUtils.toList(backend, expressions); if(expressionList.isEmpty()) { System.err.println("expressionList is empty for " + r); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ArrayExpressionCombo.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ArrayExpressionCombo.java index b27d96a0..42607db5 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ArrayExpressionCombo.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ArrayExpressionCombo.java @@ -158,7 +158,6 @@ public class ArrayExpressionCombo extends TrackedCombo { if(hasArrayIndexes == null) return null; -// Iterator iterator = OrderedSetUtils.iterator(graph, hasArrayIndexes); Iterator iterator = ListUtils.toList(graph, hasArrayIndexes).iterator(); if(!iterator.hasNext()) return null; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexes.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexes.java index eafe4989..a4758fc2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexes.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexes.java @@ -25,7 +25,6 @@ public class EnumerationIndexes extends ViewpointContributorImpl { if(enumerationIndexList == null) return null; ArrayList> result = new ArrayList>(); -// for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexList)) { for(Resource r : ListUtils.toList(graph, enumerationIndexList)) { result.add(new EnumerationIndexNode(r)); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationLabeler.java index b8c367fb..f274331a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationLabeler.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationLabeler.java @@ -26,7 +26,6 @@ public class EnumerationLabeler extends ColumnLabelerContributorImpl indexes = OrderedSetUtils.iterator(graph, enumerationIndexes); Iterator indexes = ListUtils.toList(graph, enumerationIndexes).iterator(); StringBuilder sb = new StringBuilder(); sb.append("["); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerations.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerations.java index d3a6059f..29402910 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerations.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerations.java @@ -38,7 +38,6 @@ public class UsedEnumerations extends ViewpointContributorImpl { for(Resource variable : selection) { Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList); if(arrayIndexes != null) { -// variableEnumerations.add(OrderedSetUtils.toList(graph, arrayIndexes)); variableEnumerations.add(ListUtils.toList(graph, arrayIndexes)); } else { variableEnumerations.add(new ArrayList()); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerationsManyVariables.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerationsManyVariables.java index 4ce3cf5a..28defab2 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerationsManyVariables.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerationsManyVariables.java @@ -29,15 +29,6 @@ public class UsedEnumerationsManyVariables extends ViewpointContributorImpl> result = new ArrayList>(); -// SysdynResource sr = SysdynResource.getInstance(graph); - -// Resource arrayIndexes = graph.getPossibleObject(input, sr.HasArrayIndexes); -// if(arrayIndexes == null) { -// return result; -// } -// for(Resource r : OrderedSetUtils.toList(graph, arrayIndexes)) { -// result.add(new EnumerationNode(r)); -// } return result; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java index b469b00d..65487492 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java @@ -161,12 +161,6 @@ public class BasicExpression implements IExpression { if(arrayRange != null) g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange); -// Collection ownerLists = OrderedSetUtils.getOwnerLists(g, expression, l0.OrderedSet); -// if(ownerLists.size() != 1) -// return; -// Resource ownerList = ownerLists.iterator().next(); -// -// final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse); final Resource variable = g.getPossibleObject(expression, l0.PartOf); if(variable == null) return; @@ -174,7 +168,6 @@ public class BasicExpression implements IExpression { if(ownerList == null) return; -// OrderedSetUtils.replace(g, ownerList, expression, newExpression); ListUtils.replace(g, ownerList, expression, newExpression); g.deny(expression, l0.PartOf); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java index d672ec4a..9c9ac3e4 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java @@ -243,16 +243,13 @@ public class DelayExpression implements IExpression { if(!g.isInstanceOf(expression, sr.DelayExpression)) { // Create a new DelayExpression, if the old expression was something else -// Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression); final Resource newExpression = GraphUtils.create2(g, sr.DelayExpression); String arrayRange = g.getPossibleRelatedValue(expression, sr.Expression_arrayRange, Bindings.STRING); if(arrayRange != null) g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange); -// final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse); final Resource variable = g.getPossibleObject(expression, l0.PartOf); Resource ownerList = g.getPossibleObject(variable, sr.Variable_expressionList); -// OrderedSetUtils.replace(g, ownerList, expression, newExpression); ListUtils.replace(g, ownerList, expression, newExpression); g.deny(expression, l0.PartOf); g.claim(newExpression, l0.PartOf, variable); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java index f34ca73a..756818c3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java @@ -143,11 +143,9 @@ public class StockExpression implements IExpression { Layer0 l0 = Layer0.getInstance(g); if(!g.isInstanceOf(expression, sr.StockExpression)) { -// Resource expressionList = g.getSingleObject(expression, l0.HasNext); Resource variable = g.getPossibleObject(expression, l0.PartOf); Resource expressionList = g.getPossibleObject(variable, sr.Variable_expressionList); Resource temp = g.newResource(); -// OrderedSetUtils.replace(g, expressionList, expression, temp); ListUtils.replace(g, expressionList, expression, temp); for(Resource predicate : g.getPredicates(expression)) { @@ -155,11 +153,8 @@ public class StockExpression implements IExpression { } g.claim(expression, l0.InstanceOf, null, sr.StockExpression); -// Resource variable = g.getSingleObject(expressionList, sr.Variable_expressions_Inverse); -// OrderedSetUtils.replace(g, expressionList, temp, expression); ListUtils.replace(g, expressionList, temp, expression); -// g.deny(expression, l0.PartOf); // Should be temp? RemoverUtil.remove(g, temp); g.claim(expression, l0.PartOf, variable); @@ -195,8 +190,6 @@ public class StockExpression implements IExpression { Layer0 l0 = Layer0.getInstance(graph); // find the variable -// Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, expression); -// Resource variable = graph.getPossibleObject(expressionList, sr.Variable_expressions_Inverse); Resource variable = graph.getPossibleObject(expression, l0.PartOf); if(variable == null) return ""; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java index 67d51338..8a1a0b2d 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java @@ -273,7 +273,6 @@ public class WithLookupExpression implements IExpression { if(!g.isInstanceOf(expr, sr.WithLookupExpression)) { -// Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression); final Resource newExpression = GraphUtils.create2(g, sr.WithLookupExpression, sr.WithLookupExpression_minX, 0.0, sr.WithLookupExpression_maxX, 10.0, @@ -283,8 +282,6 @@ public class WithLookupExpression implements IExpression { if(arrayRange != null) g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange); -// final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse); -// OrderedSetUtils.replace(g, ownerList, expression, newExpression); final Resource variable = g.getSingleObject(expression, l0.PartOf); Resource expressions = g.getPossibleObject(variable, sr.Variable_expressionList); Resource node = ListUtils.getNode(g, expressions, expression); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java index 8e0b1c55..9af6be3a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java @@ -126,7 +126,6 @@ public class RangeComposite extends Composite implements Widget { Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList); if(arrayIndexes != null) { LinkedHashMap result = new LinkedHashMap(); -// for(Resource enumeration : OrderedSetUtils.toList(graph, arrayIndexes)) { for(Resource enumeration : ListUtils.toList(graph, arrayIndexes)) { // Find possible redeclarations for enumeration @@ -300,7 +299,6 @@ public class RangeComposite extends Composite implements Widget { SysdynResource sr = SysdynResource.getInstance(graph); LinkedHashMap result = new LinkedHashMap(); Resource enumerationIndexes = graph.getPossibleObject(enumeration, sr.Enumeration_enumerationIndexList); -// List indexes = OrderedSetUtils.toList(graph, enumerationIndexes); List indexes = ListUtils.toList(graph, enumerationIndexes); // First add "All" and "Sum", then all of the enumeration indexes in order result.put("All", "All"); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java index 26079fca..ba8950cb 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java @@ -92,7 +92,7 @@ public class ArrayVariableUtils { break; } } - if(!componentIsValid) { + if(!componentIsValid && r.length() > 0) { // Check if the range is an integer that is between 0 and enumeration indexes size try { int index = Integer.parseInt(r); diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java index bc3ddcca..88cf7e1b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ExpressionUtils.java @@ -178,6 +178,14 @@ public class ExpressionUtils { if(variables.contains("time")) variables.remove("time"); + + // Remove variable references to for indices + for(ExpressionField ef : forIndices.keySet()) { + for(Token t : forIndices.get(ef).keySet()) { + if(variables.contains(t.image)) + variables.remove(t.image); + } + } // Examine sheets for(ExpressionField ef : functionReferences.keySet()) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java index b3f4cc39..75743d35 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java @@ -22,7 +22,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.utils.ListUtils; -import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.request.Read; import org.simantics.layer0.Layer0; @@ -60,7 +59,6 @@ public class VariableNameUtils { if(graph.isInstanceOf(r, sr.IndependentVariable)) { Resource expressions = graph.getPossibleObject(r, sr.Variable_expressionList); if(expressions == null) continue; -// List expressionList = OrderedSetUtils.toList(graph, expressions); List expressionList = ListUtils.toList(graph, expressions); for(Resource s : expressionList) { for(Resource p : graph.getPredicates(s)) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java index fce73fd7..95106f03 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/DependencyFunction.java @@ -24,6 +24,7 @@ import org.simantics.db.layer0.variable.Variable; import org.simantics.layer0.Layer0; import org.simantics.scl.reflection.annotations.SCLValue; import org.simantics.sysdyn.SysdynResource; +import org.simantics.sysdyn.expressionParser.Token; import org.simantics.sysdyn.manager.SysdynModel; import org.simantics.sysdyn.manager.SysdynModelManager; import org.simantics.sysdyn.representation.Configuration; @@ -137,6 +138,18 @@ public class DependencyFunction { Configuration configuration = getConfiguration(graph, component); ArrayList result = new ArrayList(); + // Examine possible for-index references. Remove if found + for(Resource expressionResource : references.forIndices.keySet()) { + if(references.forIndices.containsKey(expressionResource)) { + for(Token token : references.forIndices.get(expressionResource).keySet()) { + if(references.references.containsKey(expressionResource) && + references.references.get(expressionResource).containsKey(token.image)) { + references.references.get(expressionResource).remove(token.image); + } + } + } + } + // Examine Sheet references for(Resource expressionResource : references.functionReferences.keySet()) { for(String functionKey : references.functionReferences.get(expressionResource).keySet()) { diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java index bffc0331..a6aab02e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java @@ -46,7 +46,6 @@ public class EnumerationFunction { try { Resource indexList = graph.getPossibleObject(component, sr.Enumeration_enumerationIndexList); -// List indexes = OrderedSetUtils.toList(graph, indexList); List indexes = ListUtils.toList(graph, indexList); if(indexes.size() == 0) noIndexes = true; diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java index c862ed63..7f75ada4 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java @@ -21,8 +21,6 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Statement; import org.simantics.db.common.utils.ListUtils; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.common.utils.OrderedSetUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.layer0.Layer0; import org.simantics.sysdyn.SysdynResource; @@ -106,7 +104,6 @@ public class ValidationUtils { SysdynResource sr = SysdynResource.getInstance(graph); Resource hasExpressions = graph.getPossibleObject(r, sr.Variable_expressionList); if(hasExpressions != null) -// return OrderedSetUtils.toList(graph, hasExpressions); return ListUtils.toList(graph, hasExpressions); else return null; -- 2.47.1