]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
* The sorting of variables in shortcut tab lost the data field. Now the data field...
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Feb 2013 06:19:24 +0000 (06:19 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Feb 2013 06:19:24 +0000 (06:19 +0000)
* Added polarity signs for dependencies whose one end is connected to a module, similarly to those that were connected to variables (refs #3940).
* Validating names of variables and module instances now checks also that there are no similarly named modules within the current model (or current module instance). Such invalid names are not accepted (#refs #3040).
* Validating names of variables and module instances now checks also that there are no similarly named module types defined in the model. Such invalid names are not accepted (#refs #680).

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26737 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ShortcutTabWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/VariableNameUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/imports/SysdynImportFormatHandler.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Model.java

index 5581db47a3ef8b4765bf7b81074467dad5f9c670..ab4c39b58de5ea522cd008c9ffccfe26f4a17f59 100644 (file)
@@ -22,7 +22,6 @@ import org.simantics.browsing.ui.model.nodetypes.NodeType;
 import org.simantics.browsing.ui.model.nodetypes.SpecialNodeType;\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.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
@@ -31,21 +30,12 @@ import org.simantics.db.layer0.request.PossibleActiveVariableFromVariable;
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.diagram.stubs.DiagramResource;\r
 import org.simantics.jfreechart.ChartSelectionTabContributor;\r
-import org.simantics.jfreechart.chart.properties.ChartTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarAxisTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarGeneralPropertiesTab;\r
-import org.simantics.jfreechart.chart.properties.bar.BarSeriesTab;\r
-import org.simantics.jfreechart.chart.properties.pie.PieGeneralPropertiesTab;\r
-import org.simantics.jfreechart.chart.properties.pie.PieSeriesTab;\r
-import org.simantics.jfreechart.chart.properties.xyline.XYLineAxisAndVariablesTab;\r
-import org.simantics.jfreechart.chart.properties.xyline.XYLineGeneralPropertiesTab;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.modeling.ui.property.svg.SVGElementComposite;\r
 import org.simantics.selectionview.ComparableTabContributor;\r
 import org.simantics.selectionview.SelectionProcessor;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
-import org.simantics.sysdyn.JFreeChartResource;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
 import org.simantics.ui.selection.AnyVariable;\r
@@ -57,6 +47,7 @@ import org.simantics.utils.ui.ISelectionUtils;
  * SelectionProcessor for processing selections for property view in system dynamics\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 public class ResourceSelectionProcessor implements SelectionProcessor<Object, ReadGraph>  {\r
@@ -342,14 +333,15 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
 \r
             // Dependency\r
             if (backend.isInstanceOf(r, sr.Dependency))\r
-                if (backend.hasStatement(r, sr.Dependency_refersTo))\r
+                if (backend.hasStatement(r, sr.Dependency_refersTo)) {\r
+                    Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
-                                    new ReferenceDependencyTab(),\r
+                                    new DependencyTab(),\r
                                     0,\r
-                                    r,\r
+                                    diaConnection,\r
                                     "Reference Properties"));\r
-                else {\r
+                else {\r
                     Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
index 6b7d45956a11e923db548f159b721d4ff062af59..70879febb66ed1e804e67d32069c069c6cd2cc88 100644 (file)
@@ -237,6 +237,7 @@ public class ShortcutTabWidget implements Widget {
                                                        connectedVariables[i].dispose();\r
                                                        TableItem item2 = new TableItem(variableTable, SWT.NONE, j);\r
                                                        item2.setText(values);\r
+                                                       item2.setData(values);\r
                                                        connectedVariables = variableTable.getItems();\r
                                                        break;\r
                                                    }\r
index 344a096335d1d80331450c6346434fcc72ce3fa9..f3b37044b615665b3fbc913e8d8621b9e8766cf4 100644 (file)
@@ -29,6 +29,9 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.manager.SysdynModel;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Model;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.ModuleType;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
@@ -110,6 +113,8 @@ public class VariableNameUtils {
                Configuration configuration = model.getConfiguration();\r
                if(configuration == null)\r
                    return true;\r
+               \r
+               // Browse through variables and modules within the current module\r
                IElement current = model.getElement(variable);\r
                for(IElement e : configuration.getElements()) {\r
                        if(e instanceof Variable) {\r
@@ -117,8 +122,29 @@ public class VariableNameUtils {
                                if(!v.equals(current) && v.getName() != null && v.getName().equals(name)) {\r
                                        return true;\r
                                }\r
-                       }\r
+                       } else if (e instanceof Module) {\r
+                Module m = (Module)e;\r
+                if(!m.equals(current) && m.getName() != null && m.getName().equals(name)) {\r
+                    return true;\r
+                }\r
+            }\r
                }\r
+               \r
+               // Browse through all ModuleTypes within the whole model\r
+               Model rootModel = null;\r
+               ModuleType moduleType = configuration.getModuleType();\r
+               if (moduleType != null) {\r
+                   Object o = moduleType.getParent();\r
+                   if (o instanceof Model) {\r
+                       rootModel = (Model)o;\r
+                   }\r
+               } else {\r
+                   rootModel = configuration.getModel();\r
+               }\r
+               if (rootModel != null)\r
+                   return rootModel.containsModuleType(name);\r
+               \r
+               // We should not go here I think\r
                return false;\r
        }\r
 \r
index 713041e298356057954b47093b7465814a759679..f7712f23225d8c7757d18d4654d57adaab3d7538 100644 (file)
@@ -36,10 +36,10 @@ import org.simantics.sysdyn.ui.Activator;
  */\r
 public class SysdynImportFormatHandler implements FormatHandler<Object> {\r
     \r
-    private Resource parent;\r
-    private IProgressMonitor monitor;\r
-    private String migrationURI;\r
-    private DefaultPasteImportAdvisor importAdvisor;\r
+    private final Resource parent;\r
+    private final IProgressMonitor monitor;\r
+    private final String migrationURI;\r
+    private final DefaultPasteImportAdvisor importAdvisor;\r
     \r
     /**\r
      * Works 2 (2 * 1) in the monitor\r
@@ -87,7 +87,7 @@ public class SysdynImportFormatHandler implements FormatHandler<Object> {
             MigrationStep step = MigrationUtils.getStep(session, migrationURI);\r
             MigrationState state = MigrationUtils.newState();\r
             state.setProperty(MigrationStateKeys.CURRENT_TG, tg);\r
-            step.applyTo(session, state);\r
+            step.applyTo(monitor, session, state);\r
 //            tg = state.getProperty(MigrationStateKeys.CURRENT_TG);\r
 \r
             worked(1);\r
index 6e22190f2d3cf0d8a2d75bf60cdc48130a3e2cab..bb4e3f66fd4a476af0cfce38e94c9f39753ec396 100644 (file)
@@ -26,16 +26,17 @@ import org.simantics.sysdyn.representation.annotations.BuiltinFunctions;
 /**\r
  * Representation of a system dynamics model\r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 @GraphType(SysdynResource.URIs.SysdynModel)\r
 public class Model {\r
 \r
     @RelatedValue(SysdynResource.URIs.SysdynModel_startTime)\r
-    private Double startTime = 0.0;\r
+    private final Double startTime = 0.0;\r
 \r
     @RelatedValue(SysdynResource.URIs.SysdynModel_stopTime)\r
-    private Double stopTime = 10.0;\r
+    private final Double stopTime = 10.0;\r
 \r
     @RelatedValue(SysdynResource.URIs.SysdynModel_outputInterval)\r
     private Double outputInterval;\r
@@ -58,12 +59,12 @@ public class Model {
     @RelatedElements(\r
             value = Layer0.URIs.ConsistsOf,\r
             composition = true)\r
-    private ArrayList<Object> consistsOf = new ArrayList<Object>();\r
+    private final ArrayList<Object> consistsOf = new ArrayList<Object>();\r
     \r
     @RelatedElements(\r
             value = Layer0.URIs.IsLinkedTo,\r
             composition = true)\r
-    private ArrayList<Object> linkedTo = new ArrayList<Object>();\r
+    private final ArrayList<Object> linkedTo = new ArrayList<Object>();\r
     \r
     \r
     @BuiltinFunctions\r
@@ -159,6 +160,24 @@ public class Model {
         return functions;\r
     }\r
     \r
+    /**\r
+     * Determine if this Model consists of a certain ModuleType.\r
+     * @param moduleType The name of the ModuleType that is sought \r
+     * @return true iff this consists of moduleType\r
+     */\r
+    public boolean containsModuleType(String moduleType) {\r
+        if(consistsOf != null ) {\r
+            for(Object o : consistsOf) {\r
+                if(o instanceof ModuleType) {\r
+                    ModuleType mt = (ModuleType)o;\r
+                    if (mt.getName().equals(moduleType)) \r
+                        return true;\r
+                }\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+    \r
     /**\r
      * Add built-in functions to functions map. Built-in functions do not have any library path.\r
      * @param library Built-in function library\r