--- /dev/null
+/*******************************************************************************\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
--- /dev/null
+/*******************************************************************************\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
--- /dev/null
+/*******************************************************************************\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
MIGRATION.Ontologies\r
MIGRATION.Spreadsheets\r
MIGRATION.SysdynChanges\r
+ MIGRATION.OrderedSetsToLists\r
\r
MIGRATION.Ontologies : L0.NamespaceMigrationStep\r
@L0.list\r
@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
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
>-- 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"
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
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
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
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
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
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
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
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
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
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
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
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
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
"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
*******************************************************************************/\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
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
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
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
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
\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
*******************************************************************************/\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
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
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
}\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
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
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
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
}\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
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
}\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
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
}\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
*******************************************************************************/\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
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
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
\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
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
\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
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
@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
\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
@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
*******************************************************************************/\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
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
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
@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
\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
\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
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
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
@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
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
// 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
*/\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
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
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
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
\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
\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
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
\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
\r
@Override\r
public String getViewpointId() {\r
- return "Used enumerations";\r
+ return "Available enumerations";\r
}\r
\r
\r
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
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
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
\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
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
*/\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
\r
@Override\r
public String getViewpointId() {\r
- return "Available enumerations";\r
+ return "Used enumerations";\r
}\r
}\r
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
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
\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
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
\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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
\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
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
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
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
}\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
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
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
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
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
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
*/\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
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
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
\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
} 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
*******************************************************************************/\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
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
\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
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
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
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
+++ /dev/null
-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
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
@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
}\r
\r
public ArrayList<EnumerationIndex> getEnumerationIndexes() {\r
- return enumerationIndexes.getEnumerationIndexes();\r
+ return enumerationIndexes;\r
}\r
\r
public boolean isReplaceable() {\r
+++ /dev/null
-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
// [= 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
// 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
* @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
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
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
* @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
* @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
@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
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
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
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
*******************************************************************************/\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
@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
* \r
* @return Array indexes for this variable\r
*/\r
- public ArrayIndexes getArrayIndexes() {\r
+ public ArrayList<Enumeration> getArrayIndexes() {\r
return this.arrayIndexes;\r
}\r
\r
* \r
* @return Expressions of this variable\r
*/\r
- public Expressions getExpressions() {\r
+ public ArrayList<IExpression> getExpressions() {\r
return this.expressions;\r
}\r
\r
+++ /dev/null
-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
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
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
*/\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
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
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
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