]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fixed copy issues. Changed ordered sets from sysdyn ontology to lists and added requi...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 5 Dec 2012 12:15:42 +0000 (12:15 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 5 Dec 2012 12:15:42 +0000 (12:15 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26505 ac1ea38d-2e2b-0410-8846-a27921b304fc

52 files changed:
org.simantics.objmap/src/org/simantics/objmap/annotations/RelatedListElements.java [new file with mode: 0644]
org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedListElementsRuleFactory.java [new file with mode: 0644]
org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedListElementsAccessor.java [new file with mode: 0644]
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Migration.pgraph
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/SysdynBrowser.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/actions/newActions/NewEnumerationAction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/EnumerationNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynComponentCopyAdvisor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynElementFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ArrayExpressionCombo.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/AvailableEnumerations.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationIndexes.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/EnumerationLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/arrays/UsedEnumerations.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/modules/ModuleParameterOverrideUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/chart/properties/RangeComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/ImportUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynImportFormatHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/EnumerationFunction.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/validation/ValidationUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/mdlElements/Subscript.java
org.simantics.sysdyn/src/org/simantics/sysdyn/mdlImport/mdlElements/Variable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/ArrayIndexes.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Enumeration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/EnumerationIndexes.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IndependentVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Input.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Stock.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variability.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/Expressions.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/FormatUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/IndexUtils.java

diff --git a/org.simantics.objmap/src/org/simantics/objmap/annotations/RelatedListElements.java b/org.simantics.objmap/src/org/simantics/objmap/annotations/RelatedListElements.java
new file mode 100644 (file)
index 0000000..0c38770
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 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.objmap.annotations;\r
+\r
+import java.lang.annotation.ElementType;\r
+import java.lang.annotation.Retention;\r
+import java.lang.annotation.RetentionPolicy;\r
+import java.lang.annotation.Target;\r
+\r
+import org.simantics.objmap.annotations.factories.RelatedListElementsRuleFactory;\r
+import org.simantics.objmap.annotations.meta.HasFieldRuleFactory;\r
+\r
+@Retention(RetentionPolicy.RUNTIME)\r
+@Target(ElementType.FIELD)\r
+@HasFieldRuleFactory(RelatedListElementsRuleFactory.class)\r
+public @interface RelatedListElements {\r
+    String value();\r
+}\r
+\r
diff --git a/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedListElementsRuleFactory.java b/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedListElementsRuleFactory.java
new file mode 100644 (file)
index 0000000..eff5354
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 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.objmap.annotations.factories;\r
+\r
+import java.lang.annotation.Annotation;\r
+import java.lang.reflect.Field;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.exception.ServiceException;\r
+import org.simantics.db.exception.ValidationException;\r
+import org.simantics.objmap.IMappingRule;\r
+import org.simantics.objmap.annotations.RelatedListElements;\r
+import org.simantics.objmap.rules.MappedElementsRule;\r
+import org.simantics.objmap.rules.domain.RelatedListElementsAccessor;\r
+import org.simantics.objmap.rules.factory.IFieldRuleFactory;\r
+import org.simantics.objmap.rules.range.FieldAccessor;\r
+\r
+public class RelatedListElementsRuleFactory  implements IFieldRuleFactory {\r
+\r
+    @Override\r
+    public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
+        RelatedListElements annotation = (RelatedListElements)_annotation;\r
+        return new MappedElementsRule(\r
+                new RelatedListElementsAccessor(g.getResource(annotation.value())),\r
+                new FieldAccessor<Collection<Object>>(field)\r
+                );\r
+    }\r
+}\r
diff --git a/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedListElementsAccessor.java b/org.simantics.objmap/src/org/simantics/objmap/rules/domain/RelatedListElementsAccessor.java
new file mode 100644 (file)
index 0000000..59b544f
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management\r
+ * in 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.objmap.rules.domain;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+import org.apache.log4j.Logger;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.objmap.MappingException;\r
+\r
+public class RelatedListElementsAccessor implements IDomainAccessor<Collection<Resource>> {\r
+\r
+    static Logger LOGGER = Logger.getLogger("org.simantics.objmap");\r
+    \r
+    Resource relation;\r
+\r
+       public RelatedListElementsAccessor(Resource relation) {\r
+        super();\r
+        this.relation = relation;\r
+    }\r
+\r
+    @Override\r
+       public Collection<Resource> get(ReadGraph g, Resource element) throws MappingException {\r
+               try {\r
+                   LOGGER.info("        RelatedListElementsAccessor.get");\r
+                   Resource listResource = g.getPossibleObject(element, relation);\r
+                   if(listResource != null)\r
+                       return ListUtils.toList(g, listResource);\r
+                   else\r
+                       return Collections.emptyList();\r
+               } catch (DatabaseException e) {\r
+                       throw new MappingException(e);\r
+               }\r
+       }\r
+       \r
+       @Override\r
+       public boolean set(WriteGraph g, Resource element, Collection<Resource> value)\r
+                       throws MappingException {\r
+               try {\r
+                   LOGGER.info("        RelatedListElementsAccessor.set");\r
+               Resource listResource = g.getPossibleObject(element, relation);\r
+               if(listResource != null)\r
+                   ListUtils.createExisting(g, listResource, value);\r
+               else {\r
+                   listResource = ListUtils.create(g, value);\r
+                   g.claim(element, relation, listResource);\r
+               }\r
+                   \r
+                   return true;\r
+                   // FIXME Implement deleteExtraObjects\r
+               } catch (DatabaseException e) {\r
+                       throw new MappingException(e);\r
+               }\r
+               \r
+       }\r
+\r
+}\r
index c4a93709ad77c849edd5029eefd9eeab56778808..926b1bf3884ed424260ad03311ccd694fb316ac7 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index a1d6d1ffa1f4f3fdc9ac4fea6bcdaa36e2ffe7d7..42345d3128af4256110dcdff490573a2f37fa9fa 100644 (file)
@@ -13,6 +13,7 @@ MIGRATION = SYSDYN."from1.6to1.7" : L0.MigrationSequence
         MIGRATION.Ontologies\r
         MIGRATION.Spreadsheets\r
         MIGRATION.SysdynChanges\r
+        MIGRATION.OrderedSetsToLists\r
 \r
 MIGRATION.Ontologies : L0.NamespaceMigrationStep\r
   @L0.list\r
@@ -98,3 +99,25 @@ MIGRATION.SysdynChanges : L0.NamespaceMigrationStep
       @move "http://www.simantics.org/Sysdyn-1.1/" "HasHead" "Variable/HasHead"\r
     _\r
       @move "http://www.simantics.org/Sysdyn-1.1/" "SharedModuleOntolofgy" "SharedModuleOntology"\r
+      \r
+                  \r
+MIGRATION.OrderedSetsToLists : L0.OrderedSetToListMigrationStep\r
+    @L0.list\r
+        _ : L0.OrderedSetToListMigrationStep.Change\r
+            L0.OrderedSetToListMigrationStep.entityType "http://www.simantics.org/Sysdyn-1.1/Variable"\r
+            L0.OrderedSetToListMigrationStep.orderedSetRelation "http://www.simantics.org/Sysdyn-1.1/Variable/expressions"\r
+            L0.OrderedSetToListMigrationStep.orderedSetType "http://www.simantics.org/Sysdyn-1.1/Expressions"\r
+            L0.OrderedSetToListMigrationStep.listRelation "http://www.simantics.org/Sysdyn-1.1/Variable/expressionList"\r
+            L0.OrderedSetToListMigrationStep.listType "http://www.simantics.org/Layer0-1.1/List"\r
+        _ : L0.OrderedSetToListMigrationStep.Change\r
+            L0.OrderedSetToListMigrationStep.entityType "http://www.simantics.org/Sysdyn-1.1/Variable"\r
+            L0.OrderedSetToListMigrationStep.orderedSetRelation "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexes"\r
+            L0.OrderedSetToListMigrationStep.orderedSetType "http://www.simantics.org/Sysdyn-1.1/ArrayIndexes"\r
+            L0.OrderedSetToListMigrationStep.listRelation "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexesList"\r
+            L0.OrderedSetToListMigrationStep.listType "http://www.simantics.org/Layer0-1.1/List"\r
+        _ : L0.OrderedSetToListMigrationStep.Change\r
+            L0.OrderedSetToListMigrationStep.entityType "http://www.simantics.org/Sysdyn-1.1/Enumeration"\r
+            L0.OrderedSetToListMigrationStep.orderedSetRelation "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexes"\r
+            L0.OrderedSetToListMigrationStep.orderedSetType "http://www.simantics.org/Sysdyn-1.1/EnumerationIndexes"\r
+            L0.OrderedSetToListMigrationStep.listRelation "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexList"\r
+            L0.OrderedSetToListMigrationStep.listType "http://www.simantics.org/Layer0-1.1/List"\r
index 33c0c64202e3705b21b1c87c1eba8890238e61c1..11bd59fe85c9b5cddf1e134497167849231e98db 100644 (file)
@@ -87,7 +87,9 @@ SYSDYN.DefaultRealization <T L0X.Realization
 SYSDYN.Variable <T STR.Component    
     >-- SYSDYN.Variable.type --> L0.String <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.Variable.expressions --> SYSDYN.Expressions <R L0.IsComposedOf : L0.FunctionalRelation
+    >-- SYSDYN.Variable.expressionList --> L0.List <R L0.IsComposedOf : L0.FunctionalRelation
     >-- SYSDYN.Variable.arrayIndexes --> SYSDYN.ArrayIndexes <R L0.IsComposedOf : L0.FunctionalRelation
+    >-- SYSDYN.Variable.arrayIndexesList --> L0.List <R L0.IsComposedOf : L0.FunctionalRelation    
     >-- SYSDYN.Variable.unit --> L0.String <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.Variable.variability --> L0.String <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.Variable.isTailOf --> STR.Connection <R STR.IsConnectedTo
@@ -151,7 +153,7 @@ SYSDYN.IndependentVariable <T SYSDYN.Variable
     >-- SYSDYN.IndependentVariable.rangeEnd --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     >-- SYSDYN.IndependentVariable.rangeStep --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
     // To be used in transient graphs for showing the correct experiment in equation editor
-    >-- SYSDYN.IndependentVariable.activeExpression --> SYSDYN.Expression <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.IndependentVariable.activeExpression --> SYSDYN.Expression <R L0.IsWeaklyRelatedTo : L0.FunctionalRelation
 
 SYSDYN.Auxiliary <T SYSDYN.IndependentVariable
     @L0.assert SYSDYN.Variable.type "Real"
@@ -171,6 +173,7 @@ SYSDYN.Input <T SYSDYN.Variable
     
 SYSDYN.Enumeration <T SYSDYN.Variable
     >-- SYSDYN.Enumeration.enumerationIndexes --> SYSDYN.EnumerationIndexes <R L0.DependsOn : L0.FunctionalRelation
+    >-- SYSDYN.Enumeration.enumerationIndexList --> L0.List <R L0.DependsOn : L0.FunctionalRelation    
     >-- SYSDYN.Enumeration.isReplaceable --> L0.Boolean <R L0.HasProperty : L0.FunctionalRelation 
     @L0.assert SYSDYN.Variable.type "type"
     @L0.assert SYSDYN.Enumeration.isReplaceable false
index 35ae91005f7d5da5eeb97ff73190213dc5ac5a6a..2eae76fd17e4181eb95ac39af5c42f086604db3c 100644 (file)
@@ -99,6 +99,8 @@ public class SysdynResource {
     public final Resource EnumerationIndexes;\r
     public final Resource EnumerationIndexes_Inverse;\r
     public final Resource EnumerationReplacement;\r
+    public final Resource Enumeration_enumerationIndexList;\r
+    public final Resource Enumeration_enumerationIndexList_Inverse;\r
     public final Resource Enumeration_enumerationIndexes;\r
     public final Resource Enumeration_enumerationIndexes_Inverse;\r
     public final Resource Enumeration_isReplaceable;\r
@@ -167,7 +169,6 @@ public class SysdynResource {
     public final Resource ImportedOntologies;\r
     public final Resource IndependentVariable;\r
     public final Resource IndependentVariable_activeExpression;\r
-    public final Resource IndependentVariable_activeExpression_Inverse;\r
     public final Resource IndependentVariable_rangeEnd;\r
     public final Resource IndependentVariable_rangeEnd_Inverse;\r
     public final Resource IndependentVariable_rangeStart;\r
@@ -362,7 +363,11 @@ public class SysdynResource {
     public final Resource Variable_activeDatasets;\r
     public final Resource Variable_activeDatasets_Inverse;\r
     public final Resource Variable_arrayIndexes;\r
+    public final Resource Variable_arrayIndexesList;\r
+    public final Resource Variable_arrayIndexesList_Inverse;\r
     public final Resource Variable_arrayIndexes_Inverse;\r
+    public final Resource Variable_expressionList;\r
+    public final Resource Variable_expressionList_Inverse;\r
     public final Resource Variable_expressions;\r
     public final Resource Variable_expressions_Inverse;\r
     public final Resource Variable_isHeadOf;\r
@@ -395,6 +400,7 @@ public class SysdynResource {
     public final Resource WithLookupExpression_minY;\r
     public final Resource from1$6to1$7;\r
     public final Resource from1$6to1$7_Ontologies;\r
+    public final Resource from1$6to1$7_OrderedSetsToLists;\r
     public final Resource from1$6to1$7_Spreadsheets;\r
     public final Resource from1$6to1$7_SysdynChanges;\r
         \r
@@ -489,6 +495,8 @@ public class SysdynResource {
         public static final String EnumerationIndexes = "http://www.simantics.org/Sysdyn-1.1/EnumerationIndexes";\r
         public static final String EnumerationIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.1/EnumerationIndexes/Inverse";\r
         public static final String EnumerationReplacement = "http://www.simantics.org/Sysdyn-1.1/EnumerationReplacement";\r
+        public static final String Enumeration_enumerationIndexList = "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexList";\r
+        public static final String Enumeration_enumerationIndexList_Inverse = "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexList/Inverse";\r
         public static final String Enumeration_enumerationIndexes = "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexes";\r
         public static final String Enumeration_enumerationIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.1/Enumeration/enumerationIndexes/Inverse";\r
         public static final String Enumeration_isReplaceable = "http://www.simantics.org/Sysdyn-1.1/Enumeration/isReplaceable";\r
@@ -557,7 +565,6 @@ public class SysdynResource {
         public static final String ImportedOntologies = "http://www.simantics.org/Sysdyn-1.1/ImportedOntologies";\r
         public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable";\r
         public static final String IndependentVariable_activeExpression = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable/activeExpression";\r
-        public static final String IndependentVariable_activeExpression_Inverse = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable/activeExpression/Inverse";\r
         public static final String IndependentVariable_rangeEnd = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable/rangeEnd";\r
         public static final String IndependentVariable_rangeEnd_Inverse = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable/rangeEnd/Inverse";\r
         public static final String IndependentVariable_rangeStart = "http://www.simantics.org/Sysdyn-1.1/IndependentVariable/rangeStart";\r
@@ -752,7 +759,11 @@ public class SysdynResource {
         public static final String Variable_activeDatasets = "http://www.simantics.org/Sysdyn-1.1/Variable/activeDatasets";\r
         public static final String Variable_activeDatasets_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/activeDatasets/Inverse";\r
         public static final String Variable_arrayIndexes = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexes";\r
+        public static final String Variable_arrayIndexesList = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexesList";\r
+        public static final String Variable_arrayIndexesList_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexesList/Inverse";\r
         public static final String Variable_arrayIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexes/Inverse";\r
+        public static final String Variable_expressionList = "http://www.simantics.org/Sysdyn-1.1/Variable/expressionList";\r
+        public static final String Variable_expressionList_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/expressionList/Inverse";\r
         public static final String Variable_expressions = "http://www.simantics.org/Sysdyn-1.1/Variable/expressions";\r
         public static final String Variable_expressions_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/expressions/Inverse";\r
         public static final String Variable_isHeadOf = "http://www.simantics.org/Sysdyn-1.1/Variable/isHeadOf";\r
@@ -785,6 +796,7 @@ public class SysdynResource {
         public static final String WithLookupExpression_minY = "http://www.simantics.org/Sysdyn-1.1/WithLookupExpression/minY";\r
         public static final String from1$6to1$7 = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7";\r
         public static final String from1$6to1$7_Ontologies = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Ontologies";\r
+        public static final String from1$6to1$7_OrderedSetsToLists = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/OrderedSetsToLists";\r
         public static final String from1$6to1$7_Spreadsheets = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/Spreadsheets";\r
         public static final String from1$6to1$7_SysdynChanges = "http://www.simantics.org/Sysdyn-1.1/from1.6to1.7/SysdynChanges";\r
     }\r
@@ -889,6 +901,8 @@ public class SysdynResource {
         EnumerationIndexes = getResourceOrNull(graph, URIs.EnumerationIndexes);\r
         EnumerationIndexes_Inverse = getResourceOrNull(graph, URIs.EnumerationIndexes_Inverse);\r
         EnumerationReplacement = getResourceOrNull(graph, URIs.EnumerationReplacement);\r
+        Enumeration_enumerationIndexList = getResourceOrNull(graph, URIs.Enumeration_enumerationIndexList);\r
+        Enumeration_enumerationIndexList_Inverse = getResourceOrNull(graph, URIs.Enumeration_enumerationIndexList_Inverse);\r
         Enumeration_enumerationIndexes = getResourceOrNull(graph, URIs.Enumeration_enumerationIndexes);\r
         Enumeration_enumerationIndexes_Inverse = getResourceOrNull(graph, URIs.Enumeration_enumerationIndexes_Inverse);\r
         Enumeration_isReplaceable = getResourceOrNull(graph, URIs.Enumeration_isReplaceable);\r
@@ -957,7 +971,6 @@ public class SysdynResource {
         ImportedOntologies = getResourceOrNull(graph, URIs.ImportedOntologies);\r
         IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
         IndependentVariable_activeExpression = getResourceOrNull(graph, URIs.IndependentVariable_activeExpression);\r
-        IndependentVariable_activeExpression_Inverse = getResourceOrNull(graph, URIs.IndependentVariable_activeExpression_Inverse);\r
         IndependentVariable_rangeEnd = getResourceOrNull(graph, URIs.IndependentVariable_rangeEnd);\r
         IndependentVariable_rangeEnd_Inverse = getResourceOrNull(graph, URIs.IndependentVariable_rangeEnd_Inverse);\r
         IndependentVariable_rangeStart = getResourceOrNull(graph, URIs.IndependentVariable_rangeStart);\r
@@ -1152,7 +1165,11 @@ public class SysdynResource {
         Variable_activeDatasets = getResourceOrNull(graph, URIs.Variable_activeDatasets);\r
         Variable_activeDatasets_Inverse = getResourceOrNull(graph, URIs.Variable_activeDatasets_Inverse);\r
         Variable_arrayIndexes = getResourceOrNull(graph, URIs.Variable_arrayIndexes);\r
+        Variable_arrayIndexesList = getResourceOrNull(graph, URIs.Variable_arrayIndexesList);\r
+        Variable_arrayIndexesList_Inverse = getResourceOrNull(graph, URIs.Variable_arrayIndexesList_Inverse);\r
         Variable_arrayIndexes_Inverse = getResourceOrNull(graph, URIs.Variable_arrayIndexes_Inverse);\r
+        Variable_expressionList = getResourceOrNull(graph, URIs.Variable_expressionList);\r
+        Variable_expressionList_Inverse = getResourceOrNull(graph, URIs.Variable_expressionList_Inverse);\r
         Variable_expressions = getResourceOrNull(graph, URIs.Variable_expressions);\r
         Variable_expressions_Inverse = getResourceOrNull(graph, URIs.Variable_expressions_Inverse);\r
         Variable_isHeadOf = getResourceOrNull(graph, URIs.Variable_isHeadOf);\r
@@ -1185,6 +1202,7 @@ public class SysdynResource {
         WithLookupExpression_minY = getResourceOrNull(graph, URIs.WithLookupExpression_minY);\r
         from1$6to1$7 = getResourceOrNull(graph, URIs.from1$6to1$7);\r
         from1$6to1$7_Ontologies = getResourceOrNull(graph, URIs.from1$6to1$7_Ontologies);\r
+        from1$6to1$7_OrderedSetsToLists = getResourceOrNull(graph, URIs.from1$6to1$7_OrderedSetsToLists);\r
         from1$6to1$7_Spreadsheets = getResourceOrNull(graph, URIs.from1$6to1$7_Spreadsheets);\r
         from1$6to1$7_SysdynChanges = getResourceOrNull(graph, URIs.from1$6to1$7_SysdynChanges);\r
     }\r
index 751a84fb7e045c37c76155e6c9d61fec43120203..74eeb77d7ec174f8710f1e2db275550ad72257a2 100644 (file)
@@ -51,7 +51,7 @@ public class SysdynBrowser extends GraphExplorerView {
             "http://www.simantics.org/Sysdyn-1.1/Browser",  \r
             /*"http://www.simantics.org/Operating-1.1/Browser", \r
              * Operating interfaces are not functioning properly. They have not been maintained. */ \r
-            //"http://www.simantics.org/Documentation-1.1/OldBrowser",\r
+            "http://www.simantics.org/Documentation-1.1/OldBrowser",\r
             "http://www.simantics.org/Image-1.1/Browser"));    \r
 \r
     private BinaryFunction<Object[], GraphExplorer, Object[]> selectionTransformation = new BinaryFunction<Object[], GraphExplorer, Object[]>() {\r
index dc3d4d0d692a8da70d2f0f1b8e7def4824674d31..ffc74ba175a32e4cf0b82bab05287d0c13f6a8db 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.browser.actions.newActions;\r
 \r
+import java.util.Collections;\r
+\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.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.ActionFactory;\r
 import org.simantics.layer0.Layer0;\r
@@ -75,7 +77,7 @@ public class NewEnumerationAction implements ActionFactory{
                         GraphUtils.create2(g, \r
                                 sr.Enumeration,\r
                                 l0.HasName, name,\r
-                                sr.Enumeration_enumerationIndexes, OrderedSetUtils.create(g, sr.EnumerationIndexes),\r
+                                sr.Enumeration_enumerationIndexList, ListUtils.create(g, Collections.<Resource>emptyList()),\r
                                 l0.PartOf, configuration);\r
                     }\r
                 });\r
index 4194c0b022305cdb4e6d2422ee84e9eb8f3a9ba3..2c104fc3239932b492058e116a2a5f83c6da87b3 100644 (file)
@@ -4,12 +4,15 @@ import org.simantics.browsing.ui.common.node.DeleteException;
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
@@ -35,12 +38,21 @@ public class EnumerationNode extends VariableNode<Resource> implements IDeletabl
                        graph.deny(redeclaration, sr.Module_redeclaration_Inverse);\r
                     }\r
                     \r
-                    for(Resource redeclaration : graph.getObjects(data, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
+                    for(Resource redeclaration : graph.getObjects(data, sr.Redeclaration_replacingEnumeration_Inverse)) {\r
                        graph.deny(redeclaration, sr.Module_redeclaration_Inverse);\r
                     }\r
                     \r
-                    for(Resource list : OrderedSetUtils.getOwnerLists(graph, data, sr.ArrayIndexes)) {\r
-                       OrderedSetUtils.remove(graph, list, data);\r
+                    Layer0 L0 = Layer0.getInstance(graph);\r
+                    Resource conf = graph.getPossibleObject(data, L0.PartOf);\r
+                    System.out.println(NameUtils.getSafeName(graph, conf, true));\r
+                    for(Resource var : graph.syncRequest(new ObjectsWithType(conf, L0.ConsistsOf, sr.Variable))) {\r
+                        System.out.println(NameUtils.getSafeName(graph, var, true));\r
+                        Resource arrayIndexes = graph.getPossibleObject(var, sr.Variable_arrayIndexesList);\r
+                        if(arrayIndexes != null) {\r
+                            if(ListUtils.getNode(graph, arrayIndexes, data) != null) {\r
+                                ListUtils.removeElement(graph, arrayIndexes, data);\r
+                            }\r
+                        }\r
                     }\r
                     \r
                     RemoverUtil.remove(graph, data);\r
index d42556ef35a4d8b60c00687b3d661e09d269f211..93ff24b0cbd0cd94b7a3d02edcb60002f9efd3e2 100644 (file)
@@ -20,51 +20,71 @@ import org.simantics.db.Statement;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.exception.ServiceException;\r
 import org.simantics.diagram.synchronization.ISynchronizationContext;\r
+import org.simantics.diagram.synchronization.StatementEvaluation;\r
+import org.simantics.diagram.synchronization.SynchronizationHints;\r
 import org.simantics.diagram.synchronization.graph.CopyAdvisorUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ComponentUtils;\r
 import org.simantics.modeling.mapping.ComponentCopyAdvisor;\r
 import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.datastructures.BinaryFunction;\r
 \r
 public class SysdynComponentCopyAdvisor extends ComponentCopyAdvisor {\r
 \r
+    private Layer0 L0;\r
+    private StructuralResource2 STR;\r
+    private SysdynResource SYSDYN;\r
+\r
     @Override\r
     public Object copy(ISynchronizationContext context, WriteGraph graph, Resource source, Resource sourceContainer, Resource targetContainer, Map<Object, Object> map) throws DatabaseException {\r
-       \r
-       BinaryFunction<Boolean, ReadGraph, Statement> tester = new BinaryFunction<Boolean, ReadGraph, Statement>() {\r
+//        Object copy = super.copy(context, graph, source, sourceContainer, targetContainer, map);\r
+        \r
+      BinaryFunction<StatementEvaluation, ReadGraph, Statement> tester = new BinaryFunction<StatementEvaluation, ReadGraph, Statement>() {\r
+          @Override\r
+          public StatementEvaluation call(ReadGraph graph, Statement statement) {\r
+              try {\r
+                  if(statement.getPredicate().equals(L0.List_Next) ||\r
+                          statement.getPredicate().equals(L0.List_Previous)) {\r
+                      return StatementEvaluation.INCLUDE_AND_FOLLOW;\r
+                  } else if(statement.getPredicate().equals(L0.List_Element)){\r
+                      if(graph.isInstanceOf(statement.getObject(), SYSDYN.Enumeration))\r
+                          return StatementEvaluation.INCLUDE;\r
+                      else\r
+                          return StatementEvaluation.INCLUDE_AND_FOLLOW;\r
+                  }\r
+              } catch (ServiceException e) {\r
+                  e.printStackTrace();\r
+              }\r
+              return StatementEvaluation.USE_DEFAULT;\r
+          }\r
+          \r
+      };\r
+        \r
+      SYSDYN = SysdynResource.getInstance(graph);\r
+      L0 = Layer0.getInstance(graph);\r
+        STR = StructuralResource2.getInstance(graph);\r
+        Resource copy = null;\r
+        if (graph.isInstanceOf(source, STR.Connection)) {\r
+            // Configuration connections are not named, can't use TG copy for\r
+            // them at the moment.\r
+            copy = CopyAdvisorUtil.copy2(graph, source, null, map);\r
+        } else {\r
+//            Resource model = graph.syncRequest(new PossibleModel(targetContainer));\r
+//            copy = CopyAdvisorUtil.copy4(graph, source, model);\r
+            copy = CopyAdvisorUtil.copy2(graph, source, tester, map);\r
+        }\r
 \r
-                       @Override\r
-                       public Boolean call(ReadGraph graph, Statement statement) {\r
-                               /*\r
-                               SysdynResource sr = SysdynResource.getInstance(graph);\r
-                               try {\r
-                                       if(graph.isInstanceOf(statement.getSubject(), sr.IndependentVariable)) {\r
-                                               if(statement.getPredicate().equals(sr.HasExpressions) ||\r
-                                                               statement.getPredicate().equals(sr.HasArrayIndexes) )\r
-                                                       return false;\r
-                                       }\r
-                               } catch (ServiceException e) {\r
-                                       e.printStackTrace();\r
-                               }\r
-                               */\r
-                               return false;\r
-                       }\r
-               \r
-       };\r
-       \r
-       Resource copy;\r
-       \r
-       StructuralResource2 sr2 = StructuralResource2.getInstance(graph);\r
-       if(graph.isInstanceOf(source, sr2.Connection)) {\r
-                copy = CopyAdvisorUtil.copy(graph, source, tester, map);\r
-       } else {\r
-            copy = CopyAdvisorUtil.copy4(graph, source);\r
-       }\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        if (graph.hasStatement(sourceContainer, L0.ConsistsOf, source))\r
+            graph.claim(targetContainer, L0.ConsistsOf, copy);\r
 \r
+        if (context.get(SynchronizationHints.NO_RENAME) == null)\r
+//            renameComponent(context, graph, source, copy, sourceContainer, targetContainer);\r
+            rename(context, graph, source, (Resource)copy, sourceContainer, targetContainer);\r
         \r
-        rename(context, graph, source, copy, sourceContainer, targetContainer);\r
         return copy;\r
     }\r
     \r
index f71225be5c77dbedef102e4cae4618986e876e3b..a3975bdf1f39a80a5bdba2f2792f71c0af1fd936 100644 (file)
@@ -97,7 +97,7 @@ public abstract class SysdynElementFactory extends SyncElementFactory {
         \r
         if (graph.isInstanceOf(element, dr.FontProvider)) {\r
             Resource fontResource = graph.getPossibleObject(element, g2d.HasFont);\r
-            if (fontResource != null)\r
+            if (fontResource != null && graph.hasStatement(fontResource))\r
                 ElementUtils.setTextFont(e, G2DUtils.getFont(graph, fontResource));\r
         }\r
         if (graph.isInstanceOf(element, dr.ColorProvider)) {\r
index e0e60a14b0fa3a7061fea770293298231da18eaa..270b11e5ece81ad133b38ffa8361bd9a3eccce1d 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.handlers.newComponents;\r
 \r
+import java.util.ArrayList;\r
+\r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
@@ -19,8 +21,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -28,7 +30,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new Enumeration node to a configuration or module\r
@@ -69,14 +71,14 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
                }\r
 \r
                // Create the enumeartion\r
-               Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
+//             Resource enumerationIndexes = OrderedSetUtils.create(g, sr.EnumerationIndexes);\r
                \r
                String name = NameUtils.findFreshName(g, "Enum", configuration, l0.ConsistsOf, "%s%d");\r
                \r
                GraphUtils.create2(g, \r
                                sr.Enumeration,\r
                                l0.HasName, name,\r
-                               sr.Enumeration_enumerationIndexes, enumerationIndexes,\r
+                               sr.Enumeration_enumerationIndexList, ListUtils.create(g, new ArrayList<Resource>()),\r
                                l0.PartOf, configuration);\r
             }\r
         });\r
index 964a141722f2ee11692a952692a56a38278ae67c..193e42a85dc39775755b2a668fa4758c7d3ab2da 100644 (file)
@@ -33,10 +33,11 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.ResourceArray;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
 import org.simantics.utils.RunnableWithObject;\r
@@ -100,12 +101,19 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                                        throws DatabaseException {\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                for(Resource r : input.resources) {\r
-                                   Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexes);\r
+                                   Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList);\r
                                    if(arrayIndexes == null) {\r
-                                       arrayIndexes = OrderedSetUtils.create(graph, sr.ArrayIndexes);\r
-                                       graph.claim(r, sr.Variable_arrayIndexes, arrayIndexes);\r
+//                                     arrayIndexes = OrderedSetUtils.create(graph, sr.ArrayIndexes);\r
+                                       graph.claim(r, sr.Variable_arrayIndexesList, ListUtils.create(graph, enumerationResources));\r
+                                   } else {\r
+//                                     OrderedSetUtils.addAll(graph, arrayIndexes, enumerationResources);\r
+                                       ArrayList<Resource> filtered = new ArrayList<Resource>();\r
+                                       for(Resource enumeration : enumerationResources) {\r
+                                           if(ListUtils.getNode(graph, arrayIndexes, enumeration) == null)\r
+                                               filtered.add(enumeration);\r
+                                       }\r
+                                       ListUtils.insertBack(graph, arrayIndexes, filtered);\r
                                    }\r
-                                   OrderedSetUtils.addAll(graph, arrayIndexes, enumerationResources);\r
                                }\r
                        }\r
                });\r
@@ -174,13 +182,14 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                    public void apply(WriteGraph graph, ResourceArray input)\r
                            throws DatabaseException {\r
                        \r
-                       \r
+                       Layer0 L0 = Layer0.getInstance(graph);\r
                        SysdynResource sr = SysdynResource.getInstance(graph);\r
 \r
                 for(Resource variable : input) {\r
-                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
                     if(arrayIndexes != null) {\r
-                        List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+//                        List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+                        List<Resource> enumerations = ListUtils.toList(graph, arrayIndexes);\r
                         List<Resource> toBeMoved = new ArrayList<Resource>();\r
                         for(Integer index : selectedIndexes) {\r
                             if(index < enumerations.size()) {\r
@@ -191,10 +200,13 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                         }\r
 \r
                         for(Resource enumeration : toBeMoved) {\r
-                            Resource prev = OrderedSetUtils.prev(graph, arrayIndexes, enumeration);\r
-                            if(!prev.equals(arrayIndexes) && !toBeMoved.contains(prev)) {\r
-                                OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
-                                OrderedSetUtils.addBefore(graph, arrayIndexes, prev, enumeration);\r
+//                            Resource prev = OrderedSetUtils.prev(graph, arrayIndexes, enumeration);\r
+                            Resource node = ListUtils.getNode(graph, arrayIndexes, enumeration);\r
+                            Resource prev = graph.getSingleObject(node, L0.List_Previous);\r
+                            if(!arrayIndexes.equals(prev) && !toBeMoved.contains(graph.getPossibleObject(prev, L0.List_Element))) {\r
+                                ListUtils.swapWithPrevious(graph, arrayIndexes, enumeration);\r
+//                                OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+//                                OrderedSetUtils.addBefore(graph, arrayIndexes, prev, enumeration);\r
                             }\r
                         }\r
                     }\r
@@ -244,13 +256,14 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                    public void apply(WriteGraph graph, ResourceArray input)\r
                            throws DatabaseException {\r
 \r
-\r
+                       Layer0 L0 = Layer0.getInstance(graph);\r
                        SysdynResource sr = SysdynResource.getInstance(graph);\r
 \r
                        for(Resource variable : input) {\r
-                           Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+                           Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
                            if(arrayIndexes != null) {\r
-                               List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+//                             List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+                               List<Resource> enumerations = ListUtils.toList(graph, arrayIndexes);\r
                                List<Resource> toBeMoved = new ArrayList<Resource>();\r
                                for(Integer index : selectedIndexes) {\r
                                    if(index < enumerations.size()) {\r
@@ -261,10 +274,13 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                                }\r
 \r
                                for(Resource enumeration : toBeMoved) {\r
-                                   Resource next = OrderedSetUtils.next(graph, arrayIndexes, enumeration);\r
-                                   if(!next.equals(arrayIndexes) && !toBeMoved.contains(next)) {\r
-                                       OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
-                                       OrderedSetUtils.addAfter(graph, arrayIndexes, next, enumeration);\r
+//                                 Resource next = OrderedSetUtils.next(graph, arrayIndexes, enumeration);\r
+                            Resource node = ListUtils.getNode(graph, arrayIndexes, enumeration);\r
+                            Resource next = graph.getSingleObject(node, L0.List_Next);\r
+                            if(!arrayIndexes.equals(next) && !toBeMoved.contains(graph.getPossibleObject(next, L0.List_Element))) {\r
+                                ListUtils.swapWithNext(graph, arrayIndexes, enumeration);\r
+//                                     OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+//                                     OrderedSetUtils.addAfter(graph, arrayIndexes, next, enumeration);\r
                                    }\r
                                }\r
                            }\r
@@ -317,9 +333,10 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                        SysdynResource sr = SysdynResource.getInstance(graph);\r
 \r
                        for(Resource variable : input) {\r
-                           Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+                           Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
                            if(arrayIndexes != null) {\r
-                               List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+//                             List<Resource> enumerations = OrderedSetUtils.toList(graph, arrayIndexes);\r
+                               List<Resource> enumerations = ListUtils.toList(graph, arrayIndexes);\r
                                List<Resource> toBeRemoved = new ArrayList<Resource>();\r
                                for(Integer index : selectedIndexes) {\r
                                if(index < enumerations.size()) {\r
@@ -330,7 +347,8 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                                }\r
                                \r
                                for(Resource enumeration : toBeRemoved)\r
-                                   OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+//                                 OrderedSetUtils.remove(graph, arrayIndexes, enumeration);\r
+                                   ListUtils.removeElement(graph, arrayIndexes, enumeration);\r
                            }\r
                        }\r
                    }\r
index 08be0f8b2f8dcc793b1994d463c90b599126870b..84312521a085c1fe899d62e9be849014bdb8e206 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.properties;\r
 \r
+import java.util.ArrayList;\r
 import java.util.HashSet;\r
 import java.util.List;\r
 \r
@@ -43,8 +44,8 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
@@ -61,8 +62,8 @@ import org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableIndexesWidge
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 public class EnumerationTab extends LabelPropertyTabContributor implements Widget {\r
 \r
@@ -160,7 +161,7 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
 \r
                                        @Override\r
                                        public void run(ReadGraph graph) throws DatabaseException {\r
-                                               enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).Enumeration_enumerationIndexes);\r
+                                               enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).Enumeration_enumerationIndexList);\r
                                        }\r
                                });\r
                        } catch (DatabaseException e) {\r
@@ -179,14 +180,18 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
                                                Layer0 l0 = Layer0.getInstance(graph);\r
                                                \r
                                                HashSet<String> names = new HashSet<String>();\r
-                                               for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexes)) {\r
+//                                             for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexes)) {\r
+                        for(Resource r : ListUtils.toList(graph, enumerationIndexes)) {\r
                                                        names.add(NameUtils.getSafeName(graph, r));\r
                                                }\r
                                                \r
                                                Resource ei = GraphUtils.create2(graph, \r
                                                                sr.EnumerationIndex,\r
                                                                l0.HasName, NameUtils.findFreshName(graph, "index", names, ""));\r
-                                               OrderedSetUtils.add(graph, enumerationIndexes, ei);\r
+//                                             OrderedSetUtils.add(graph, enumerationIndexes, ei);\r
+                                               ArrayList<Resource> index = new ArrayList<Resource>();\r
+                                               index.add(ei);\r
+                                               ListUtils.insertBack(graph, enumerationIndexes, index);\r
                                        }\r
                                });\r
                        } catch (DatabaseException e1) {\r
@@ -218,7 +223,7 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
 \r
                                        @Override\r
                                        public void run(ReadGraph graph) throws DatabaseException {\r
-                                               enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).Enumeration_enumerationIndexes);\r
+                                               enumerationIndexes = graph.getSingleObject(enumeration, SysdynResource.getInstance(graph).Enumeration_enumerationIndexList);\r
                                        }\r
                                });\r
                        } catch (DatabaseException e) {\r
@@ -240,7 +245,8 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
                                                        Resource r = AdaptionUtils.adaptToSingle(o, Resource.class);\r
                                                        if(r == null)\r
                                                                continue;\r
-                                                       OrderedSetUtils.remove(graph, enumerationIndexes, r);\r
+//                                                     OrderedSetUtils.remove(graph, enumerationIndexes, r);\r
+                                                       ListUtils.removeElement(graph, enumerationIndexes, r);\r
                                                }\r
                                        }\r
                                });\r
@@ -275,9 +281,13 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
                                        @Override\r
                                        public Boolean perform(ReadGraph graph)\r
                                                        throws DatabaseException {\r
+                                           if(!graph.hasStatement(enumeration))\r
+                                               return null;\r
+                                           \r
                                                SysdynResource sr = SysdynResource.getInstance(graph);\r
-                                               enumerationIndexes = graph.getSingleObject(enumeration, sr.Enumeration_enumerationIndexes);\r
-                                               List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+                                               enumerationIndexes = graph.getSingleObject(enumeration, sr.Enumeration_enumerationIndexList);\r
+//                                             List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+                                               List<Resource> indexes = ListUtils.toList(graph, enumerationIndexes);\r
                                                for(Resource index : indexes) {\r
                                                        Boolean show = graph.getPossibleRelatedValue(index, sr.EnumerationIndex_showEnumerationIndexInCharts, Bindings.BOOLEAN);\r
                                                        if(!Boolean.TRUE.equals(show))\r
@@ -294,7 +304,8 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
 \r
                                                        @Override\r
                                                        public void run() {\r
-                                                               showAll.getWidget().setSelection(result.booleanValue());\r
+                                                           if(result != null)\r
+                                                               showAll.getWidget().setSelection(result.booleanValue());\r
                                                        }\r
                                                });\r
                                        }\r
@@ -324,7 +335,8 @@ public class EnumerationTab extends LabelPropertyTabContributor implements Widge
                                                @Override\r
                                                public void perform(WriteGraph graph) throws DatabaseException {\r
                                                        SysdynResource sr = SysdynResource.getInstance(graph);\r
-                                                       List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+//                                                     List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+                                                       List<Resource> indexes = ListUtils.toList(graph, enumerationIndexes);\r
                                                        for(Resource index : indexes) {\r
                                                                Boolean show = graph.getPossibleRelatedValue(index, sr.EnumerationIndex_showEnumerationIndexInCharts, Bindings.BOOLEAN);\r
                                                                if(selected && !Boolean.TRUE.equals(show)) {\r
index 7e57c1fcf7952160c7db73be422e5808856342e1..ebda5b9c1d98f751035df65242f73c0e8f691ae6 100644 (file)
@@ -11,7 +11,9 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.properties;\r
 \r
+import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.Collections;\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -56,10 +58,11 @@ import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.request.WriteResultRequest;\r
+import org.simantics.db.common.utils.ListUtils;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
@@ -76,8 +79,8 @@ import org.simantics.sysdyn.ui.properties.widgets.arrays.NameAndArrayRangeModify
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionWidgetInput;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameValidator;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Tab for displaying equation information of a variable\r
@@ -112,6 +115,9 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                                                        @Override\r
                                                        public Resource perform(ReadGraph graph)\r
                                                                        throws DatabaseException {\r
+                                                           System.out.println(var.getURI(graph));\r
+                                                            System.out.println(NameUtils.getSafeName(graph, var.getRepresents(graph)));\r
+\r
                                                                return var.getRepresents(graph);\r
                                                        }\r
                                                });\r
@@ -202,7 +208,7 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
 \r
                                        @Override\r
                                        public Resource perform(ReadGraph graph) throws DatabaseException {\r
-                                               return (Resource)var.getPropertyValue(graph, Variables.REPRESENTS);\r
+                                               return var.getRepresents(graph);\r
                                        }\r
                                });\r
                        } catch (DatabaseException e) {\r
@@ -222,6 +228,8 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
 \r
                                @Override\r
                                public Resource perform(ReadGraph graph) throws DatabaseException {\r
+                               System.out.println(NameUtils.getSafeName(graph, variable, true));\r
+\r
                                        return getActiveExpression(graph, variable);\r
                                }\r
                        });\r
@@ -239,8 +247,9 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                                        throws DatabaseException {\r
                                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                                Layer0 l0 = Layer0.getInstance(graph);\r
-                                               Resource expressions = OrderedSetUtils.create(graph, sr.Expressions);\r
-                                               graph.claim(variable, sr.Variable_expressions, expressions);\r
+//                                             Resource expressions = OrderedSetUtils.create(graph, sr.Expressions);\r
+                                               Resource expressions = ListUtils.create(graph, Collections.<Resource>emptyList());\r
+                                               graph.claim(variable, sr.Variable_expressionList, expressions);\r
                                                final Resource expression = graph.newResource();\r
 \r
                                                if(graph.isInstanceOf(variable, sr.Auxiliary) ||\r
@@ -252,7 +261,11 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                                                        graph.claim(expression, l0.InstanceOf, null, sr.StockExpression);\r
                                                        graph.claimLiteral(expression, sr.StockExpression_initialEquation, "");\r
                                                }\r
-                                               OrderedSetUtils.add(graph, expressions, expression);\r
+//                                             OrderedSetUtils.add(graph, expressions, expression);\r
+                                               ArrayList<Resource> addition = new ArrayList<Resource>(1);\r
+                                               addition.add(expression);\r
+                                               ListUtils.insertBack(graph, expressions, addition);\r
+\r
                                                graph.claim(variable, l0.ConsistsOf, expression);\r
 \r
                                                VirtualGraphSupport support = graph.getService(VirtualGraphSupport.class);\r
@@ -290,11 +303,12 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                        @Override\r
                        public Pair<Boolean, Boolean> perform(ReadGraph graph) throws DatabaseException {\r
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
-                               Resource expressions = graph.getPossibleObject(variable, sr.Variable_expressions);\r
+                               Resource expressions = graph.getPossibleObject(variable, sr.Variable_expressionList);\r
                                if(expressions == null) {\r
                                        return new Pair<Boolean, Boolean>(false, false);\r
                                }\r
-                               List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+//                             List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+                               List<Resource> expressionList = ListUtils.toList(graph, expressions);\r
                                if(expressionList.isEmpty()) {\r
                                        return new Pair<Boolean, Boolean>(false, false);\r
                                }\r
@@ -431,7 +445,7 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                Layer0 l0 = Layer0.getInstance(graph);\r
 \r
-                               Resource expressions = graph.getPossibleObject(input, sr.Variable_expressions);\r
+                               Resource expressions = graph.getPossibleObject(input, sr.Variable_expressionList);\r
                                if(expressions == null) {\r
                                        return;\r
                                }\r
@@ -448,7 +462,10 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
                                    // If there was no active expression, create a normal expression\r
                                        graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression);\r
                                }\r
-                               OrderedSetUtils.add(graph, expressions, newExpression);\r
+                               //OrderedSetUtils.add(graph, expressions, newExpression);\r
+                               ArrayList<Resource> addition = new ArrayList<Resource>(1);\r
+                               addition.add(newExpression);\r
+                               ListUtils.insertBack(graph, expressions, addition);\r
                                graph.claim(input, l0.ConsistsOf, newExpression);\r
                        }\r
                });\r
@@ -698,13 +715,16 @@ public class EquationTab extends LabelPropertyTabContributor implements Widget {
         */\r
        private Resource getActiveExpression(ReadGraph graph, Resource variable) throws DatabaseException {\r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
+               System.out.println("Active expression for " + NameUtils.getSafeName(graph, variable));\r
                Resource expression = graph.getPossibleObject(variable, sr.IndependentVariable_activeExpression);\r
+               System.out.println("    " + NameUtils.getSafeName(graph, expression));\r
                if(expression == null) {\r
-                       Resource expressions = graph.getPossibleObject(variable, sr.Variable_expressions);\r
+                       Resource expressions = graph.getPossibleObject(variable, sr.Variable_expressionList);\r
                        if(expressions == null) {\r
                                return null;\r
                        }\r
-                       List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+                       //List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+                       List<Resource> expressionList = ListUtils.toList(graph, expressions);\r
                        if(expressionList.isEmpty()) {\r
                                return null;\r
                        }\r
index 1d5c8616772f91516f6361a79e7d06e58acc9f75..449675097edfd3906cd48cace68a94b0bdec15d2 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.browsing.ui.model.nodetypes.SpecialNodeType;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
@@ -183,10 +184,11 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 if(activeExpression != null)\r
                     // if variable has active expression, display it\r
                     expression = activeExpression;\r
-                else if (backend.hasStatement(r, sr.Variable_expressions)){\r
+                else if (backend.hasStatement(r, sr.Variable_expressionList)){\r
                     // else display the first expression of the variable\r
-                    Resource expressions = backend.getPossibleObject(r, sr.Variable_expressions);\r
-                    List<Resource> expressionList = OrderedSetUtils.toList(backend, expressions);\r
+                    Resource expressions = backend.getPossibleObject(r, sr.Variable_expressionList);\r
+                    // List<Resource> expressionList = OrderedSetUtils.toList(backend, expressions);\r
+                    List<Resource> expressionList = ListUtils.toList(backend, expressions);\r
                     if(expressionList.isEmpty()) {\r
                         System.err.println("expressionList is empty for " + r);\r
                         return Collections.emptyList();\r
index bab2c3952765f5bec04d3352ac1884766d8745b7..b27d96a0dfaf4eccf66cc6b822e78a5a92342074 100644 (file)
@@ -12,8 +12,8 @@ import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.Listener;\r
@@ -144,21 +144,22 @@ public class ArrayExpressionCombo extends TrackedCombo {
 \r
        private ArrayList<Resource> getExpressions(ReadGraph graph, Resource variable) throws DatabaseException {\r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Resource hasExpressions = graph.getPossibleObject(variable, sr.Variable_expressions);\r
+               Resource hasExpressions = graph.getPossibleObject(variable, sr.Variable_expressionList);\r
                if(hasExpressions == null)\r
                        return new ArrayList<Resource>();\r
                else\r
-                       return new ArrayList<Resource>(OrderedSetUtils.toList(graph, hasExpressions));\r
+                       return new ArrayList<Resource>(ListUtils.toList(graph, hasExpressions));\r
        }\r
 \r
        public static String getDefaultRange(ReadGraph graph, Resource variable) throws DatabaseException {\r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
-               Resource hasArrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+               Resource hasArrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
 \r
                if(hasArrayIndexes == null)\r
                        return null;\r
 \r
-               Iterator<Resource> iterator = OrderedSetUtils.iterator(graph, hasArrayIndexes);\r
+//             Iterator<Resource> iterator = OrderedSetUtils.iterator(graph, hasArrayIndexes);\r
+               Iterator<Resource> iterator = ListUtils.toList(graph, hasArrayIndexes).iterator();\r
                if(!iterator.hasNext())\r
                        return null;\r
 \r
index 0b1c36cf2eba27262565e07a2b885638e107d1b9..95a6e95b6133eacfde4c3dea3cbc64b066349bb3 100644 (file)
@@ -13,37 +13,26 @@ package org.simantics.sysdyn.ui.properties.widgets;
 \r
 import java.awt.event.ActionEvent;\r
 import java.awt.event.ActionListener;\r
-import java.util.Collection;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
-import java.util.concurrent.CopyOnWriteArrayList;\r
 \r
 import javax.swing.Timer;\r
 \r
-import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Control;\r
 import org.eclipse.swt.widgets.Table;\r
-import org.eclipse.swt.widgets.TableItem;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.management.ISessionContext;\r
-import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
-import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.AuxiliaryExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ConstantExpression;\r
@@ -55,12 +44,9 @@ import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupExpression;
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ParameterExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.StockExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.WithLookupExpression;\r
-import org.simantics.sysdyn.ui.trend.chart.properties.VariableProposalProvider;\r
 import org.simantics.sysdyn.ui.utils.ExpressionUtils;\r
-import org.simantics.sysdyn.ui.validation.ValidationUtils;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
-import org.simantics.utils.ui.ISelectionUtils;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Widget for displaying an expression. Widget creates the IExpression for displaying\r
@@ -240,13 +226,8 @@ public class ExpressionWidget implements Widget {
 \r
                                @Override\r
                                public Resource perform(ReadGraph graph) throws DatabaseException {\r
-                                       SysdynResource sr = SysdynResource.getInstance(graph);\r
                                        Layer0 l0 = Layer0.getInstance(graph);\r
-                                       Collection<Resource> expressionLists = OrderedSetUtils.getOwnerLists(graph, expr, l0.OrderedSet);\r
-                                       Resource variable = null;\r
-                                       if(expressionLists.size() == 1)\r
-                                               variable = graph.getPossibleObject(expressionLists.iterator().next(), sr.Variable_expressions_Inverse);\r
-                                       return variable;\r
+                                       return graph.getPossibleObject(expr, l0.PartOf);\r
                                }\r
                        });\r
                        // Validate the variable\r
index ea785c0a189caf2a48f895b31347019db59a2a65..76a46f00cccec194fdf7298ec49186d1c7f75952 100644 (file)
@@ -46,7 +46,7 @@ public class AvailableEnumerations extends ViewpointContributorImpl<ResourceArra
 \r
        @Override\r
        public String getViewpointId() {\r
-               return "Used enumerations";\r
+               return "Available enumerations";\r
        }\r
 \r
 \r
index dc9c290a4e19178806b8b59b86e2117bea16292f..eafe498918ac231e2da8c16af3bcc270013e3bd8 100644 (file)
@@ -7,7 +7,7 @@ import org.simantics.browsing.ui.common.node.AbstractNode;
 import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
@@ -21,11 +21,12 @@ public class EnumerationIndexes extends ViewpointContributorImpl<Resource> {
                SysdynResource sr = SysdynResource.getInstance(graph);\r
                if(!graph.isInstanceOf(input, sr.Enumeration))\r
                        return null;\r
-               Resource enumerationIndexList = graph.getPossibleObject(input, sr.Enumeration_enumerationIndexes);\r
+               Resource enumerationIndexList = graph.getPossibleObject(input, sr.Enumeration_enumerationIndexList);\r
                if(enumerationIndexList == null)\r
                        return null;\r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
-        for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexList)) {\r
+//        for(Resource r : OrderedSetUtils.toList(graph, enumerationIndexList)) {\r
+        for(Resource r : ListUtils.toList(graph, enumerationIndexList)) {\r
             result.add(new EnumerationIndexNode(r));\r
     }\r
         return result;\r
index 801b48530cf32c4813b17ee04a4653163e5a2a53..b8c367fbd5f40460239c5f8d36b920282a72f98b 100644 (file)
@@ -1,14 +1,14 @@
 package org.simantics.sysdyn.ui.properties.widgets.arrays;\r
 \r
 import java.util.HashMap;\r
-import java.util.ListIterator;\r
+import java.util.Iterator;\r
 import java.util.Map;\r
 \r
 import org.simantics.browsing.ui.graph.impl.contributor.labeler.ColumnLabelerContributorImpl;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
@@ -25,8 +25,9 @@ public class EnumerationLabeler extends ColumnLabelerContributorImpl<Enumeration
                \r
                SysdynResource sr = SysdynResource.getInstance(graph);\r
                \r
-               Resource enumerationIndexes = graph.getPossibleObject(input.data, sr.Enumeration_enumerationIndexes);\r
-               ListIterator<Resource> indexes = OrderedSetUtils.iterator(graph, enumerationIndexes);\r
+               Resource enumerationIndexes = graph.getPossibleObject(input.data, sr.Enumeration_enumerationIndexList);\r
+//             ListIterator<Resource> indexes = OrderedSetUtils.iterator(graph, enumerationIndexes);\r
+               Iterator<Resource> indexes = ListUtils.toList(graph, enumerationIndexes).iterator();\r
                StringBuilder sb = new StringBuilder();\r
                sb.append("[");\r
                while(indexes.hasNext()) {\r
index 681b9ef2a6327e00b27a29e8dd80fd19ef562f6b..d3a6059f38342f76713a880fafae4603b2468fc2 100644 (file)
@@ -10,7 +10,7 @@ import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContr
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.ResourceArray;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.SysdynResource;\r
 \r
@@ -36,9 +36,10 @@ public class UsedEnumerations extends ViewpointContributorImpl<ResourceArray> {
                 */\r
                ArrayList<List<Resource>> variableEnumerations = new ArrayList<List<Resource>>();\r
                for(Resource variable : selection) {\r
-                   Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+                   Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
                    if(arrayIndexes != null) {\r
-                       variableEnumerations.add(OrderedSetUtils.toList(graph, arrayIndexes));\r
+//                     variableEnumerations.add(OrderedSetUtils.toList(graph, arrayIndexes));\r
+                       variableEnumerations.add(ListUtils.toList(graph, arrayIndexes));\r
                    } else {\r
                        variableEnumerations.add(new ArrayList<Resource>());\r
                    }\r
@@ -110,6 +111,6 @@ public class UsedEnumerations extends ViewpointContributorImpl<ResourceArray> {
 \r
                @Override\r
                public String getViewpointId() {\r
-                       return "Available enumerations";\r
+                       return "Used enumerations";\r
                }\r
 }\r
index 062d452a889d0585e37d47580eae3ecf18db4178..b469b00dc8761ee7cecd37342a9ee26927626b21 100644 (file)
@@ -12,7 +12,6 @@
 package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
 \r
 import java.util.Arrays;\r
-import java.util.Collection;\r
 import java.util.List;\r
 import java.util.Map;\r
 \r
@@ -32,12 +31,12 @@ import org.eclipse.swt.widgets.Table;
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -155,24 +154,36 @@ public class BasicExpression implements IExpression {
                     \r
                     // If the current expression type is different than the target expression type, create a new expression\r
                     if(!g.isInstanceOf(expression, expressionType)) {\r
-                       Collection<Resource> ownerLists = OrderedSetUtils.getOwnerLists(g, expression, l0.OrderedSet);\r
-                       if(ownerLists.size() != 1)\r
-                           return;\r
-                       Resource ownerList = ownerLists.iterator().next();\r
+\r
                        final Resource newExpression = GraphUtils.create2(g, expressionType, \r
                                        sr.Expression_equation, currentText);\r
                        String arrayRange = g.getPossibleRelatedValue(expression, sr.Expression_arrayRange, Bindings.STRING);\r
                        if(arrayRange != null)\r
                                g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange);\r
                        \r
-                       final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
-                       OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+//                        Collection<Resource> ownerLists = OrderedSetUtils.getOwnerLists(g, expression, l0.OrderedSet);\r
+//                        if(ownerLists.size() != 1)\r
+//                            return;\r
+//                        Resource ownerList = ownerLists.iterator().next();\r
+//                        \r
+//                     final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
+                       final Resource variable = g.getPossibleObject(expression, l0.PartOf);\r
+                       if(variable == null)\r
+                           return;\r
+                       Resource ownerList = g.getPossibleObject(variable, sr.Variable_expressionList);\r
+                       if(ownerList == null)\r
+                           return;\r
+                       \r
+//                     OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+                       ListUtils.replace(g, ownerList, expression, newExpression);\r
+                       \r
                        g.deny(expression, l0.PartOf);\r
+                       \r
                        g.claim(newExpression, l0.PartOf, variable);\r
                        \r
                        \r
-                                               VirtualGraph runtime = g.getService(VirtualGraph.class);\r
-                                               g.syncRequest(new WriteRequest(runtime) {\r
+                        VirtualGraphSupport support = g.getService(VirtualGraphSupport.class);\r
+                                               g.syncRequest(new WriteRequest(support.getWorkspacePersistent("expressions")) {\r
                                                        @Override\r
                                                        public void perform(WriteGraph graph) throws DatabaseException {\r
                                                                SysdynResource sr = SysdynResource.getInstance(graph);\r
index ab5f6749602cb7860ca3a35f40deee668b2e5a4d..ce8cdb81b000de98800b1ba6ed8a5b038f87d4af 100644 (file)
@@ -39,7 +39,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
@@ -243,14 +243,17 @@ public class DelayExpression implements IExpression {
 \r
                     if(!g.isInstanceOf(expression, sr.DelayExpression)) {\r
                         // Create a new DelayExpression, if the old expression was something else\r
-                        Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+//                        Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
                         final Resource newExpression = GraphUtils.create2(g, sr.DelayExpression);\r
                         String arrayRange = g.getPossibleRelatedValue(expression, sr.Expression_arrayRange, Bindings.STRING);\r
                         if(arrayRange != null)\r
                             g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange);\r
 \r
-                        final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
-                        OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+//                        final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
+                        final Resource variable = g.getPossibleObject(expression, l0.PartOf);\r
+                        Resource ownerList = g.getPossibleObject(expression, sr.Variable_expressionList);\r
+//                        OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+                        ListUtils.replace(g, ownerList, expression, newExpression);\r
                         g.deny(expression, l0.PartOf);\r
                         g.claim(newExpression, l0.PartOf, variable);\r
 \r
index 0e3e7f5d7b16a2944720e502e243055f743f7135..f34ca73a6b8c05c7e0ebbc57d234d686b0bacfe9 100644 (file)
@@ -33,8 +33,9 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -142,18 +143,26 @@ public class StockExpression implements IExpression {
                     Layer0 l0 = Layer0.getInstance(g);\r
                     \r
                     if(!g.isInstanceOf(expression, sr.StockExpression)) {\r
-                       Resource expressionList = g.getSingleObject(expression, l0.HasNext);\r
+//                     Resource expressionList = g.getSingleObject(expression, l0.HasNext);\r
+                        Resource variable = g.getPossibleObject(expression, l0.PartOf);\r
+                        Resource expressionList = g.getPossibleObject(variable, sr.Variable_expressionList);\r
                        Resource temp = g.newResource();\r
-                       OrderedSetUtils.replace(g, expressionList, expression, temp);\r
+//                     OrderedSetUtils.replace(g, expressionList, expression, temp);\r
+                       ListUtils.replace(g, expressionList, expression, temp);\r
+                       \r
                        for(Resource predicate : g.getPredicates(expression)) {\r
-                               g.deny(expression, predicate);\r
+                           g.deny(expression, predicate);\r
                        }\r
                        g.claim(expression, l0.InstanceOf, null, sr.StockExpression);\r
-                       \r
-                        Resource variable = g.getSingleObject(expressionList, sr.Variable_expressions_Inverse);\r
-                        OrderedSetUtils.replace(g, expressionList, temp, expression);\r
-                        g.deny(expression, l0.PartOf);\r
-                        g.claim(expression, l0.PartOf, variable);\r
+\r
+//                        Resource variable = g.getSingleObject(expressionList, sr.Variable_expressions_Inverse);\r
+//                        OrderedSetUtils.replace(g, expressionList, temp, expression);\r
+                        ListUtils.replace(g, expressionList, temp, expression);\r
+\r
+//                        g.deny(expression, l0.PartOf); // Should be temp?\r
+                       RemoverUtil.remove(g, temp);\r
+\r
+                       g.claim(expression, l0.PartOf, variable);\r
                     }\r
                     g.claimLiteral(expression, sr.StockExpression_initialEquation, currentText);\r
                 }\r
@@ -186,8 +195,9 @@ public class StockExpression implements IExpression {
                     Layer0 l0 = Layer0.getInstance(graph);\r
                     \r
                     // find the variable\r
-                    Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, expression);\r
-                    Resource variable = graph.getPossibleObject(expressionList, sr.Variable_expressions_Inverse);\r
+//                    Resource expressionList = OrderedSetUtils.getSingleOwnerList(graph, expression);\r
+//                    Resource variable = graph.getPossibleObject(expressionList, sr.Variable_expressions_Inverse);\r
+                    Resource variable = graph.getPossibleObject(expression, l0.PartOf);\r
                     if(variable == null)\r
                        return "";\r
                     \r
index 8da88f5ddaabdd5c9e349283d494bc7d20dfcfba..67d513384093243a77da093a446985893feafd82 100644 (file)
@@ -54,7 +54,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -273,7 +273,7 @@ public class WithLookupExpression implements IExpression {
                     if(!g.isInstanceOf(expr, sr.WithLookupExpression)) {\r
                        \r
                        \r
-                       Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+//                     Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
                        final Resource newExpression = GraphUtils.create2(g, sr.WithLookupExpression,\r
                                        sr.WithLookupExpression_minX, 0.0,\r
                                        sr.WithLookupExpression_maxX, 10.0,\r
@@ -283,8 +283,14 @@ public class WithLookupExpression implements IExpression {
                        if(arrayRange != null)\r
                                g.claimLiteral(newExpression, sr.Expression_arrayRange, arrayRange);\r
                        \r
-                        final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
-                        OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+//                        final Resource variable = g.getSingleObject(ownerList, sr.Variable_expressions_Inverse);\r
+//                        OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+                        final Resource variable = g.getSingleObject(expression, l0.PartOf);\r
+                       Resource expressions = g.getPossibleObject(variable, sr.Variable_expressionList);\r
+                       Resource node = ListUtils.getNode(g, expressions, expression);\r
+                       g.deny(node, l0.List_Element);\r
+                       g.claim(node, l0.List_Element, newExpression);\r
+                       \r
                         g.deny(expression, l0.PartOf);\r
                         g.claim(newExpression, l0.PartOf, variable);\r
                         \r
index ee6fad6b88378e8896df5071a79f95a48daff529..b4d5521e16056011bc87ccf0f0f97a8434549c06 100644 (file)
@@ -16,8 +16,8 @@ import java.util.List;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -42,7 +42,7 @@ public class ModuleParameterOverrideUtils {
     public static String getParameterExpression(IndependentVariable variable) throws DatabaseException {\r
         String result = null;\r
         try {\r
-            result = variable.getExpressions().getExpressions().get(0).getExpression(variable);\r
+            result = variable.getExpressions().get(0).getExpression(variable);\r
         if(result.contains("/* Actual value read from init file */"))\r
             result = result.substring(0, result.indexOf("/* Actual value read from init file */"));\r
         } catch (NullPointerException e) {\r
@@ -89,9 +89,9 @@ public class ModuleParameterOverrideUtils {
     public static boolean hasParameterExpression(ReadGraph graph, Resource variable) throws DatabaseException {\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
         boolean result = false;\r
-        Resource expressionsResource = graph.getPossibleObject(variable, sr.Variable_expressions);\r
+        Resource expressionsResource = graph.getPossibleObject(variable, sr.Variable_expressionList);\r
         if(expressionsResource != null) {\r
-            List<Resource> expressions = OrderedSetUtils.toList(graph, expressionsResource);\r
+            List<Resource> expressions = ListUtils.toList(graph, expressionsResource);\r
             if(expressions.size() == 1 && graph.isInstanceOf(expressions.get(0), sr.ParameterExpression)) {\r
                 result = true;\r
             }\r
index 7ccce0297e21e4e2f1786ee9aeb34dc08c12e79c..8e0b1c55a2196c5fcc95d1c26575732e920ef5e4 100644 (file)
@@ -36,8 +36,8 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
@@ -48,10 +48,10 @@ import org.simantics.layer0.Layer0;
 import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.trend.chart.ChartUtils;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.RunnableWithObject;\r
 import org.simantics.utils.datastructures.Quad;\r
 import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Composite for range controls in chart series properties\r
@@ -123,10 +123,11 @@ public class RangeComposite extends Composite implements Widget {
                     Resource variable = v.getRepresents(graph);\r
                     \r
                     // Return the enumerations assigned to that variable\r
-                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexes);\r
+                    Resource arrayIndexes = graph.getPossibleObject(variable, sr.Variable_arrayIndexesList);\r
                     if(arrayIndexes != null) {\r
                         LinkedHashMap<String, Resource> result = new LinkedHashMap<String, Resource>();\r
-                        for(Resource enumeration : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
+//                        for(Resource enumeration : OrderedSetUtils.toList(graph, arrayIndexes)) {\r
+                        for(Resource enumeration : ListUtils.toList(graph, arrayIndexes)) {\r
                                \r
                                // Find possible redeclarations for enumeration\r
                                Resource redeclaration = enumeration;\r
@@ -298,8 +299,9 @@ public class RangeComposite extends Composite implements Widget {
         public Map<String, Object> perform(ReadGraph graph, Resource series) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
             LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>();\r
-            Resource enumerationIndexes = graph.getPossibleObject(enumeration, sr.Enumeration_enumerationIndexes);\r
-            List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+            Resource enumerationIndexes = graph.getPossibleObject(enumeration, sr.Enumeration_enumerationIndexList);\r
+//            List<Resource> indexes = OrderedSetUtils.toList(graph, enumerationIndexes);\r
+            List<Resource> indexes = ListUtils.toList(graph, enumerationIndexes);\r
             // First add "All" and "Sum", then all of the enumeration indexes in order\r
             result.put("All", "All");\r
             result.put("Sum", "Sum");\r
index 88cc72299143839aaabb8efd745867cca2925e13..ef49ba467a17a0ae6c8c8e6551968681799df641 100644 (file)
@@ -33,8 +33,8 @@ public class ArrayVariableUtils {
         Map<Integer, SyntaxError> result = new HashMap<Integer, SyntaxError>();\r
         // Not an array variable\r
         if(variable.getArrayIndexes() == null || \r
-                variable.getArrayIndexes().getEnumerations() == null || \r
-                variable.getArrayIndexes().getEnumerations().size() == 0) {\r
+                variable.getArrayIndexes() == null || \r
+                variable.getArrayIndexes().size() == 0) {\r
             for(int i = 0; i < elements.length ; i++) {\r
                 error = new SyntaxError();\r
                 error.setMessage("Variable is not an array variable");\r
@@ -44,7 +44,7 @@ public class ArrayVariableUtils {
 \r
             return result;\r
         }\r
-        ArrayList<Enumeration> enumerations = variable.getArrayIndexes().getEnumerations();\r
+        ArrayList<Enumeration> enumerations = variable.getArrayIndexes();\r
         // Too many elements\r
         if(elements.length > enumerations.size()) {\r
             error = new SyntaxError();\r
index 9438d48c91cac56f013c3a249ddfd7954f09ebc1..b3f4cc3900afc9eb6542bf45783baffaaf791c37 100644 (file)
@@ -21,6 +21,7 @@ import java.util.regex.Pattern;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
@@ -57,9 +58,10 @@ public class VariableNameUtils {
                Resource configuration = graph.getSingleObject(variable, l0.PartOf);\r
                for(Resource r : graph.getObjects(configuration, l0.ConsistsOf)) {\r
                        if(graph.isInstanceOf(r, sr.IndependentVariable)) {\r
-                               Resource expressions = graph.getPossibleObject(r, sr.Variable_expressions);\r
+                               Resource expressions = graph.getPossibleObject(r, sr.Variable_expressionList);\r
                                if(expressions == null) continue;\r
-                               List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+//                             List<Resource> expressionList = OrderedSetUtils.toList(graph, expressions);\r
+                               List<Resource> expressionList = ListUtils.toList(graph, expressions);\r
                                for(Resource s : expressionList) {\r
                                        for(Resource p : graph.getPredicates(s)) {\r
                                                Resource o = graph.getPossibleObject(s, p);\r
index 82416ea8f72d64a7aa7e56dafc0bca8c74ccde88..d69272b1ffb986373292fcfd9a6461972a15574f 100644 (file)
@@ -146,7 +146,7 @@ public class ImportUtils {
         Object result = ImportUtils.readFile(path, handlers);\r
 \r
         if(result == null || !(result instanceof Resource)) {\r
-            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", null);\r
+            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: File could not be read.", null);\r
         } else {\r
             try {\r
                 final Resource ModelRoot = (Resource) result;\r
@@ -224,7 +224,7 @@ public class ImportUtils {
                         }\r
                     }\r
                 } catch(Throwable t) {\r
-                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import model failed: Model could not be imported.", t);\r
+                    return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Batch validate failed: Model could not be imported.", t);\r
                 } \r
 \r
                 worked(monitor, 1);\r
index 05d0271447a16739d12f1168484558387bfaae98..713041e298356057954b47093b7465814a759679 100644 (file)
@@ -21,7 +21,6 @@ import org.simantics.databoard.container.DataFormatException;
 import org.simantics.databoard.container.FormatHandler;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
-import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
 import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
 import org.simantics.db.layer0.migration.MigrationState;\r
 import org.simantics.db.layer0.migration.MigrationStateKeys;\r
@@ -89,15 +88,20 @@ public class SysdynImportFormatHandler implements FormatHandler<Object> {
             MigrationState state = MigrationUtils.newState();\r
             state.setProperty(MigrationStateKeys.CURRENT_TG, tg);\r
             step.applyTo(session, state);\r
-            tg = state.getProperty(MigrationStateKeys.CURRENT_TG);\r
+//            tg = state.getProperty(MigrationStateKeys.CURRENT_TG);\r
 \r
             worked(1);\r
             subTask("Import");\r
             \r
-            DefaultPasteHandler.defaultExecute(tg, parent, ia);\r
+//            DefaultPasteHandler.defaultExecute(tg, parent, ia);\r
+            MigrationUtils.importTo(session, state, parent, ia);\r
             worked(1);\r
             \r
-            return ia.getRoot();\r
+            Resource result = state.getProperty(MigrationStateKeys.CURRENT_RESOURCE);\r
+            if(result == null)\r
+                result = ia.getRoot();\r
+            \r
+            return result;\r
 \r
         } catch (Exception e) {\r
             return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import module failed", e);\r
index 21e9bb953f9dada5d1639c43d6bf161893bf30c2..bffc0331e281340624b002f6f747479d922df2fd 100644 (file)
@@ -17,7 +17,7 @@ import java.util.List;
 import org.simantics.db.Issue;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.issues.common.StandardIssue;\r
@@ -45,8 +45,9 @@ public class EnumerationFunction  {
         boolean noIndexes = false;\r
 \r
         try {\r
-            Resource indexList = graph.getPossibleObject(component, sr.Enumeration_enumerationIndexes);\r
-            List<Resource> indexes = OrderedSetUtils.toList(graph, indexList);\r
+            Resource indexList = graph.getPossibleObject(component, sr.Enumeration_enumerationIndexList);\r
+//            List<Resource> indexes = OrderedSetUtils.toList(graph, indexList);\r
+            List<Resource> indexes = ListUtils.toList(graph, indexList);\r
             if(indexes.size() == 0)\r
                 noIndexes = true;\r
         } catch (DatabaseException e) {\r
index 5088e5b3b93d511683e96ed77529b93ec7ec3d24..c862ed635577b5e0dd042130dab4793f4b400b7f 100644 (file)
@@ -20,6 +20,7 @@ import java.util.List;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Statement;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
@@ -103,9 +104,10 @@ public class ValidationUtils {
      */\r
     public static List<Resource> getExpressions(ReadGraph graph, Resource r) throws DatabaseException {\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
-        Resource hasExpressions = graph.getPossibleObject(r, sr.Variable_expressions);\r
+        Resource hasExpressions = graph.getPossibleObject(r, sr.Variable_expressionList);\r
         if(hasExpressions != null)\r
-            return OrderedSetUtils.toList(graph, hasExpressions);\r
+//            return OrderedSetUtils.toList(graph, hasExpressions);\r
+            return ListUtils.toList(graph, hasExpressions);\r
         else\r
             return null;\r
     }\r
index 09f7f5d7e030b5bb18bbec91d04be4cd6cb9bd60..0f24cc580059018bceec79914e3a727712a4f915 100644 (file)
@@ -20,7 +20,7 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
@@ -79,10 +79,10 @@ public class VariableRVIUtils {
     private static void traverseIndexes(ReadGraph g, String rvi, HashMap<String, String> rvis, List<Resource> arrayIndexes, int currentIndex, String indexesSoFar, String indexNamesSoFar) throws DatabaseException {\r
         SysdynResource sr = SysdynResource.getInstance(g);\r
         // Enumeration indexes of the current enumeration (e.g. the first EnumIndexes in Var[EnumIndexes, EnumIndexes, EnumIndexes])\r
-        Resource enumerationIndexes = g.getPossibleObject(arrayIndexes.get(currentIndex), sr.Enumeration_enumerationIndexes);\r
+        Resource enumerationIndexes = g.getPossibleObject(arrayIndexes.get(currentIndex), sr.Enumeration_enumerationIndexList);\r
         if(enumerationIndexes == null)\r
             return;\r
-        List<Resource> indexes = OrderedSetUtils.toList(g, enumerationIndexes);\r
+        List<Resource> indexes = ListUtils.toList(g, enumerationIndexes);\r
         for(int i = 0; i < indexes.size(); i++) {\r
             Boolean b = g.getPossibleRelatedValue(indexes.get(i), sr.EnumerationIndex_showEnumerationIndexInCharts, Bindings.BOOLEAN);\r
             // If this index is not wanted to be shown in charts, the recursion does not go any further and rvis.put() is not called for this enumeration\r
@@ -166,13 +166,13 @@ public class VariableRVIUtils {
 \r
         Resource r = variable.getRepresents(graph);\r
 \r
-        Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexes);\r
+        Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList);\r
         if(arrayIndexes == null) {\r
             // If variable is single-dimensional, use the same rvi\r
             rvis.put(rvi, rvi);\r
         } else {\r
             // If variable is multidimensional, get all indexes that are active and add them to rvis-map\r
-            List<Resource> arrayIndexList= OrderedSetUtils.toList(graph, arrayIndexes);\r
+            List<Resource> arrayIndexList = ListUtils.toList(graph, arrayIndexes);\r
             resolveActiveArrayIndexes(graph, variable, arrayIndexList);\r
 \r
             if(arrayIndexList.size() > 0)\r
index 4b74e5f5fc3b89f436470c07d2a01678cf32802e..b5c5e6e079d1d2b5c7cb60a5b11397e4c9f0331d 100644 (file)
@@ -468,8 +468,8 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
             } else if (element instanceof IndependentVariable) {\r
                IndependentVariable variable = (IndependentVariable) element;\r
                //FIXME: more general solution for finding out if the variable is a parameter\r
-               if(variable != null && variable.getExpressions() != null && variable.getExpressions().getExpressions() != null && variable.getExpressions().getExpressions().get(0) != null) {\r
-                       IExpression expression = variable.getExpressions().getExpressions().get(0);\r
+               if(variable != null && variable.getExpressions() != null && variable.getExpressions() != null && variable.getExpressions().get(0) != null) {\r
+                       IExpression expression = variable.getExpressions().get(0);\r
                        if (expression instanceof ParameterExpression) {\r
                                Double value = ((ParameterExpression)expression).getValue();\r
                                if(value != null)\r
index a0087d4ef0dc55cdc4711bcc2bfbbf88af2b18ed..5be6073e528a436a0e6b1223fb848913a098eb38 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.mdlImport.mdlElements;\r
 \r
+import java.util.ArrayList;\r
+\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.utils.OrderedSetUtils;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -38,22 +40,21 @@ public class Subscript extends Variable {
                        if(!graph.isInstanceOf(parent, sr.Configuration))\r
                                return;\r
                        Layer0 l0 = Layer0.getInstance(graph); \r
-                       Resource enumerationIndexes = OrderedSetUtils.create(graph, sr.EnumerationIndexes);\r
-\r
+                       ArrayList<Resource> enumerationIndexes = new ArrayList<Resource>();\r
                        if(expressions != null && expressions.get(0) != null) {\r
                                String[] indexes = expressions.get(0).getExpression().split(",");\r
                                for(String s : indexes) {\r
                                        Resource ei = GraphUtils.create2(graph, \r
                                                        sr.EnumerationIndex,\r
                                                        l0.HasName, s.trim());\r
-                                       OrderedSetUtils.add(graph, enumerationIndexes, ei);\r
+                                       enumerationIndexes.add(ei);\r
                                }\r
                        }\r
 \r
                        Resource enumeration = GraphUtils.create2(graph, \r
                                        sr.Enumeration,\r
                                        l0.HasName, this.getName(),\r
-                                       sr.Enumeration_enumerationIndexes, enumerationIndexes);\r
+                                       sr.Enumeration_enumerationIndexList, ListUtils.create(graph, enumerationIndexes));\r
 \r
                        graph.claim(parent, l0.ConsistsOf, enumeration);\r
 \r
index 02c5f706ffde989c11bad4a6e4d08cba97bc979c..ad27b79b2100b0e2d1c1bfe5cfe7944a4208de2c 100644 (file)
@@ -15,6 +15,7 @@ import java.util.ArrayList;
 \r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
@@ -44,8 +45,6 @@ public abstract class Variable extends Element {
                if(diagram == null)\r
                        return;\r
                \r
-               Resource expressionList = OrderedSetUtils.create(graph, sr.Expressions);\r
-               \r
                // Make sure at least one expression exist\r
                if(getExpressions().isEmpty()) {\r
                        Expression e = new Expression();\r
@@ -53,15 +52,12 @@ public abstract class Variable extends Element {
                        getExpressions().add(e);\r
                }\r
                \r
-               Resource arrayIndexList = OrderedSetUtils.create(graph, sr.ArrayIndexes);\r
-               \r
-\r
                Resource variable = GraphUtils.create2(graph, \r
                                variableType,\r
-                               l0.HasName, ImportUtils.escapeName(name),\r
-                               sr.Variable_expressions, expressionList);\r
+                               l0.HasName, ImportUtils.escapeName(name));\r
                graph.claim(variable, mr.Mapped, variable);\r
 \r
+               ArrayList<Resource> expressions = new ArrayList<Resource>();\r
                for(Expression e : getExpressions()) {\r
 \r
                    // Get expression from the variable. They have different types\r
@@ -70,16 +66,18 @@ public abstract class Variable extends Element {
                    if(e.getRange() != null) {\r
                        graph.claimLiteral(expression, sr.Expression_arrayRange, "[" + e.getRange().trim() + "]");\r
                    }\r
-                   OrderedSetUtils.add(graph, expressionList, expression);\r
+                   expressions.add(expression);\r
                    graph.claim(variable, l0.ConsistsOf, expression);\r
                }\r
+               graph.claim(variable, sr.Variable_expressionList, ListUtils.create(graph, expressions));\r
 \r
                if(subscripts != null) {\r
+                   ArrayList<Resource> arrayIndexes = new ArrayList<Resource>();\r
                    for(Subscript sub : subscripts) {\r
                        if(sub.getResource() != null)\r
-                                       OrderedSetUtils.add(graph, arrayIndexList, sub.getResource());\r
+                           arrayIndexes.add(sub.getResource());\r
                        }\r
-                       graph.claim(variable, sr.Variable_arrayIndexes, arrayIndexList);\r
+                       graph.claim(variable, sr.Variable_arrayIndexesList, ListUtils.create(graph, arrayIndexes));\r
                }\r
                \r
                if(units != null && units.length() > 0)\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/ArrayIndexes.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/ArrayIndexes.java
deleted file mode 100644 (file)
index 869ff09..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.simantics.sysdyn.representation;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-@GraphType(SysdynResource.URIs.ArrayIndexes)\r
-public class ArrayIndexes {\r
-       \r
-    @RelatedOrderedSetElements\r
-    private ArrayList<Enumeration> enumerations = new ArrayList<Enumeration>();\r
-\r
-    public ArrayList<Enumeration> getEnumerations() {\r
-       return enumerations;\r
-    }\r
-\r
-}\r
index 51996a197f2657531652f7f46537e75944532a1f..32a73ccd6a8e8d708b5f49a45756993cc52e4c69 100644 (file)
@@ -14,8 +14,8 @@ package org.simantics.sysdyn.representation;
 import java.util.ArrayList;\r
 \r
 import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedElement;\r
 import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedListElements;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
@@ -23,8 +23,8 @@ import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;
 @GraphType(SysdynResource.URIs.Enumeration)\r
 public class Enumeration extends Variable {\r
        \r
-    @RelatedElement(SysdynResource.URIs.Enumeration_enumerationIndexes)\r
-    private EnumerationIndexes enumerationIndexes;\r
+    @RelatedListElements(SysdynResource.URIs.Enumeration_enumerationIndexList)\r
+    private ArrayList<EnumerationIndex> enumerationIndexes = new ArrayList<EnumerationIndex>();\r
     \r
     @RelatedValue(SysdynResource.URIs.Enumeration_isReplaceable)\r
     private Boolean isReplaceable;\r
@@ -53,7 +53,7 @@ public class Enumeration extends Variable {
        }\r
        \r
        public ArrayList<EnumerationIndex> getEnumerationIndexes() {\r
-       return enumerationIndexes.getEnumerationIndexes();\r
+       return enumerationIndexes;\r
        }\r
        \r
        public boolean isReplaceable() {\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/EnumerationIndexes.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/EnumerationIndexes.java
deleted file mode 100644 (file)
index fa7eca9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.simantics.sysdyn.representation;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-@GraphType(SysdynResource.URIs.EnumerationIndexes)\r
-public class EnumerationIndexes {\r
-       \r
-    @RelatedOrderedSetElements\r
-    private ArrayList<EnumerationIndex> enumerationIndexes = new ArrayList<EnumerationIndex>();\r
-\r
-    public ArrayList<EnumerationIndex> getEnumerationIndexes() {\r
-       return enumerationIndexes;\r
-    }\r
-}\r
index c2975cb7eceebc5a651c9628da86cf1f115325d1..bf4f2ad7a7dcce47de317a59e37f4b4c5584f3c2 100644 (file)
@@ -50,7 +50,7 @@ public abstract class IndependentVariable extends Variable {
         // [= expression]\r
         if(variability == Variability.PARAMETER || variability == Variability.CONSTANT) {\r
             // parameters and constants are guaranteed to have only one expression\r
-            String equation = FormatUtils.formatExpressionForModelica(this, getExpressions().getExpressions().get(0).getExpression(this));\r
+            String equation = FormatUtils.formatExpressionForModelica(this, getExpressions().get(0).getExpression(this));\r
             sb.append(" = " + equation);\r
         }\r
 \r
@@ -60,7 +60,7 @@ public abstract class IndependentVariable extends Variable {
         // Possible additions to expressions. e.g. helper classes and variables\r
         if(getExpressions() != null) {\r
             String addition;\r
-            for(IExpression e : getExpressions().getExpressions()) {\r
+            for(IExpression e : getExpressions()) {\r
                 addition = e.getDeclarationAddition(this);\r
                 if(addition != null)\r
                     sb.append(addition);\r
@@ -77,11 +77,7 @@ public abstract class IndependentVariable extends Variable {
      * @return Range of this variable, if it is an array variable. Empty string otherwise.\r
      */\r
     public String getRange() {\r
-        ArrayIndexes ai = getArrayIndexes();\r
-        ArrayList<Enumeration> enumerations = null;\r
-        if(ai != null) \r
-            enumerations = ai.getEnumerations();\r
-\r
+        ArrayList<Enumeration> enumerations = getArrayIndexes();\r
         String range = "";\r
         if(enumerations != null && enumerations.size() > 0) {\r
             StringBuilder sb = new StringBuilder();\r
@@ -106,7 +102,7 @@ public abstract class IndependentVariable extends Variable {
     public String getInitialEquation() {\r
         StringBuilder sb = new StringBuilder();                \r
 \r
-        for(IExpression expression : expressions.getExpressions()) {\r
+        for(IExpression expression : getExpressions()) {\r
             String initialEquation = expression.getInitialEquation(this);\r
             if(initialEquation != null)\r
                 sb.append(initialEquation);\r
@@ -137,11 +133,8 @@ public abstract class IndependentVariable extends Variable {
         if(this.expressions == null)\r
             return null;\r
         \r
-        ArrayList<IExpression> expressions = this.expressions.getExpressions();\r
-        ArrayIndexes ai = this.getArrayIndexes();\r
-        ArrayList<Enumeration> enumerations = null;\r
-        if(ai != null) \r
-            enumerations = ai.getEnumerations();\r
+        ArrayList<IExpression> expressions = getExpressions();\r
+        ArrayList<Enumeration> enumerations = getArrayIndexes();\r
         IExpression firstExpression = expressions.get(0);\r
         if(enumerations == null || enumerations.size() < 1) {\r
             if(firstExpression == null)\r
index f3e10ac98e785f6d33f18b95a92ea79f44c84548..97de3b0f7f9d0b4e397f709cc08c41d0dfeb2dea 100644 (file)
@@ -50,14 +50,14 @@ public class Input extends Variable {
      * @return Default input value.\r
      */\r
     public String getDefaultInputValue(String inModule) {\r
-        if( getArrayIndexes() == null || getArrayIndexes().getEnumerations().isEmpty()) {\r
+        if( getArrayIndexes() == null || getArrayIndexes().isEmpty()) {\r
             return defaultInputValue.toString();\r
         } else {\r
             StringBuilder sb = new StringBuilder();\r
             sb.append("fill(");\r
             sb.append(defaultInputValue);\r
             sb.append(", ");\r
-            Iterator<Enumeration> i = getArrayIndexes().getEnumerations().iterator();\r
+            Iterator<Enumeration> i = getArrayIndexes().iterator();\r
             while(i.hasNext()) {\r
                 Enumeration e = i.next();\r
                 sb.append((inModule != null && !inModule.isEmpty() ? inModule + "." : "") + e.getName() + ".size");\r
@@ -101,11 +101,7 @@ public class Input extends Variable {
      * @return declaration of this input variable without a default value\r
      */\r
     public String getDeclaration() {\r
-       ArrayIndexes ai = getArrayIndexes();\r
-       ArrayList<Enumeration> enumerations = null;\r
-       if(ai != null) \r
-               enumerations = ai.getEnumerations();\r
-       \r
+       ArrayList<Enumeration> enumerations = getArrayIndexes();\r
        String range = "";\r
        if(enumerations != null && enumerations.size() > 0) {\r
                StringBuilder sb = new StringBuilder();\r
index c7994cd1c565bef530aad1622aa6eb9081490f33..7b740633f4983fde71a2e0800e8ca892e8cafaa3 100644 (file)
@@ -56,22 +56,20 @@ public class Stock extends IndependentVariable {
     @Override\r
     public String getDeclaration() {\r
 \r
-        ArrayIndexes ai = getArrayIndexes();\r
-\r
         String each = "";\r
         // each is required when a single value is used for all dimensions e.g. Stock[30](each start = 0)  \r
         if (Variability.getVariability(this) == Variability.CONTINUOUS) {\r
             // start parameter is not used, everything needs to be fixed=false\r
-            if(ai != null && !ai.getEnumerations().isEmpty())\r
+            if(getArrayIndexes() != null && !getArrayIndexes().isEmpty())\r
                 each = "each";\r
             return "    " + getType() + " " + getName() + getRange() + "(" + each + " fixed=false);\n";\r
         } else {\r
             // Start parameter is used. Parameter guarantees that there is only one expression.\r
-            StockExpression e = (StockExpression)getExpressions().getExpressions().get(0);\r
+            StockExpression e = (StockExpression)getExpressions().get(0);\r
             String initialEquation = e.getExpression(this);\r
             initialEquation = SheetFormatUtils.reformatSheetReferences(this, initialEquation);\r
 \r
-            if(ai != null && !ai.getEnumerations().isEmpty())\r
+            if(getArrayIndexes() != null && !getArrayIndexes().isEmpty())\r
                 each = "each";\r
 \r
 \r
index 5b8812b04ee134dd87dcaaf8a91d8e03159771fe..9d4eab2691715597682207656edba680c265a409 100644 (file)
@@ -17,7 +17,6 @@ import org.simantics.objmap.schema.MappingSchemas;
 import org.simantics.objmap.schema.SimpleSchema;\r
 import org.simantics.sysdyn.representation.expressions.ConstantExpression;\r
 import org.simantics.sysdyn.representation.expressions.DelayExpression;\r
-import org.simantics.sysdyn.representation.expressions.Expressions;\r
 import org.simantics.sysdyn.representation.expressions.LookupExpression;\r
 import org.simantics.sysdyn.representation.expressions.NormalExpression;\r
 import org.simantics.sysdyn.representation.expressions.ParameterExpression;\r
@@ -39,11 +38,8 @@ public class SysdynSchema extends SimpleSchema {
             addLinkType(MappingSchemas.fromAnnotations(g, Input.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ModuleType.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, Model.class));\r
-            addLinkType(MappingSchemas.fromAnnotations(g, Expressions.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, Enumeration.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, EnumerationIndex.class));\r
-            addLinkType(MappingSchemas.fromAnnotations(g, EnumerationIndexes.class));\r
-            addLinkType(MappingSchemas.fromAnnotations(g, ArrayIndexes.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
index 27504514ca9a63add03213f82e7c040bedd1ea95..dda7cbd41b818d645ae95c3f4381fded08a08770 100644 (file)
@@ -187,7 +187,7 @@ public enum Variability {
         if(variable == null || variable.getExpressions() == null)\r
             return Variability.CONTINUOUS;\r
         \r
-        ArrayList<org.simantics.sysdyn.representation.expressions.IExpression> expressions = variable.getExpressions().getExpressions();\r
+        ArrayList<org.simantics.sysdyn.representation.expressions.IExpression> expressions = variable.getExpressions();\r
 \r
         if(expressions.size() != 1)\r
             return Variability.CONTINUOUS; // Cannot handle multiple expressions as parameters\r
index 1f1e1fc52a46ef158421b2f3633def0db487440a..b5109d9d276bea6cebfa379600e44197af4d4d14 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.representation;\r
 \r
+import java.util.ArrayList;\r
+\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedListElements;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.representation.expressions.Expressions;\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
 \r
 /**\r
  * Abstract class for representing a variable in system dynamics models \r
@@ -33,11 +36,11 @@ public abstract class Variable implements IElement {
     @RelatedElement(Layer0.URIs.PartOf)\r
     protected Object parent;\r
     \r
-    @RelatedElement(SysdynResource.URIs.Variable_arrayIndexes)\r
-    protected ArrayIndexes arrayIndexes;\r
+    @RelatedListElements(SysdynResource.URIs.Variable_arrayIndexesList)\r
+    protected ArrayList<Enumeration> arrayIndexes = new ArrayList<Enumeration>();\r
     \r
-    @RelatedElement(SysdynResource.URIs.Variable_expressions)\r
-    protected Expressions expressions;\r
+    @RelatedListElements(SysdynResource.URIs.Variable_expressionList)\r
+    protected ArrayList<IExpression> expressions = new ArrayList<IExpression>();\r
     \r
     @RelatedValue(SysdynResource.URIs.Variable_variability)\r
     protected String variability;\r
@@ -84,7 +87,7 @@ public abstract class Variable implements IElement {
      * \r
      * @return Array indexes for this variable\r
      */\r
-    public ArrayIndexes getArrayIndexes() {\r
+    public ArrayList<Enumeration> getArrayIndexes() {\r
        return this.arrayIndexes;\r
     }\r
     \r
@@ -92,7 +95,7 @@ public abstract class Variable implements IElement {
      * \r
      * @return Expressions of this variable\r
      */\r
-    public Expressions getExpressions() {\r
+    public ArrayList<IExpression> getExpressions() {\r
         return this.expressions;\r
     }\r
     \r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/Expressions.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/Expressions.java
deleted file mode 100644 (file)
index d05b987..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.simantics.sysdyn.representation.expressions;\r
-\r
-import java.util.ArrayList;\r
-\r
-import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.objmap.annotations.RelatedOrderedSetElements;\r
-import org.simantics.sysdyn.SysdynResource;\r
-\r
-@GraphType(SysdynResource.URIs.Expressions)\r
-public class Expressions {\r
-\r
-    @RelatedOrderedSetElements\r
-    private ArrayList<IExpression> expressions = new ArrayList<IExpression>();\r
-\r
-    public ArrayList<IExpression> getExpressions() {\r
-       return expressions;\r
-    }\r
-}\r
index 469f52fdd9e3454fcf370bdeea934051e5277f04..19f5620160745fe1a8f39086dea03b990bf75a7c 100644 (file)
@@ -20,7 +20,6 @@ import org.simantics.objmap.annotations.RelatedValue;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
 import org.simantics.sysdyn.expressionParser.ParseException;\r
-import org.simantics.sysdyn.representation.ArrayIndexes;\r
 import org.simantics.sysdyn.representation.Book;\r
 import org.simantics.sysdyn.representation.Enumeration;\r
 import org.simantics.sysdyn.representation.IElement;\r
@@ -66,12 +65,8 @@ public class StockExpression extends Expression {
         ArrayList<Valve> outgoing = ((Stock)variable).getOutgoingValves();\r
         if(incoming.isEmpty() && outgoing.isEmpty()) {\r
             // No connections, add 0 for each array index if any.\r
-            ArrayIndexes ai = variable.getArrayIndexes();\r
-            ArrayList<Enumeration> enumerations = null;\r
-            if(ai != null) \r
-                enumerations = ai.getEnumerations();\r
-            \r
-            if(ai == null || enumerations == null || enumerations.isEmpty()) {\r
+            ArrayList<Enumeration> enumerations = variable.getArrayIndexes();\r
+            if(enumerations == null || enumerations.isEmpty()) {\r
                 b.append(" 0.0");\r
             } else {\r
                 b.append(" zeros(");\r
@@ -166,7 +161,7 @@ public class StockExpression extends Expression {
      */\r
     public Double getStartValue(IndependentVariable variable) {\r
        Double value = null;\r
-       ArrayList<IExpression> expressions = variable.getExpressions().getExpressions();\r
+       ArrayList<IExpression> expressions = variable.getExpressions();\r
        if(expressions.size() == 1) {\r
                IExpression e = expressions.get(0);\r
             if(e.getInitialEquation(variable) == null) {\r
index 70d43a56cd43a1ebf974c305e5eb8c2a13bad4ac..568774bca80c87afb2cb1f0f4c88a3493884fbc9 100644 (file)
@@ -73,8 +73,8 @@ public class FormatUtils {
                                String condition;\r
                                \r
                                boolean array = reference.getArrayIndexes() != null && \r
-                                       reference.getArrayIndexes().getEnumerations() != null &&\r
-                                               !reference.getArrayIndexes().getEnumerations().isEmpty();\r
+                                       reference.getArrayIndexes() != null &&\r
+                                               !reference.getArrayIndexes().isEmpty();\r
                                \r
                                String refName = reference.getName();\r
                                if(reference.getType().equals("Boolean")) {\r
index 053d146a5a6627f22966c9cc523970fb9b4c7ebf..e2f5cf4550d0494f75febffbe61a8f5d0d1ebef2 100644 (file)
@@ -18,7 +18,6 @@ import java.util.StringTokenizer;
 import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
 import org.simantics.sysdyn.expressionParser.ExpressionParser.ForRange;\r
 import org.simantics.sysdyn.expressionParser.ParseException;\r
-import org.simantics.sysdyn.representation.ArrayIndexes;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.Enumeration;\r
 import org.simantics.sysdyn.representation.EnumerationIndex;\r
@@ -44,10 +43,9 @@ public class IndexUtils {
                if(variable == null)\r
                        return range;\r
                StringBuilder sb = new StringBuilder();\r
-               ArrayIndexes arrayIndexes = variable.getArrayIndexes();\r
-               if(arrayIndexes == null || range == null)\r
+               if(variable.getArrayIndexes() == null || range == null)\r
                        return "";\r
-               ArrayList<Enumeration> enumerations = arrayIndexes.getEnumerations();\r
+               ArrayList<Enumeration> enumerations = variable.getArrayIndexes();\r
                StringTokenizer st = new StringTokenizer(range, "[]:,", true);\r
                int index = 0;\r
                while(st.hasMoreTokens()) {\r