]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merged trunk @29712, 29717, 29863, 29865, 29867, 29869, 29870, 29871, 29878, 29887...
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 13:24:34 +0000 (13:24 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 16 Jul 2014 13:24:34 +0000 (13:24 +0000)
refs #4950
refs #5005
refs #5091
refs #5093
refs #5096
refs #5097
refs #5106

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

71 files changed:
1.8/org.simantics.sysdyn.ontology/graph.tg
1.8/org.simantics.sysdyn.ontology/graph/svg/loop.svg
1.8/org.simantics.sysdyn.ui/plugin.xml
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/PropertyViewUndoHandler.java [new file with mode: 0644]
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Project.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/AbstractChartNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/EnumerationNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ExperimentNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModelNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleTypeNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SCLModule.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedFunctionLibraryNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SharedOntologyNode.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/participant/SysdynConnectionBuilder.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/LoopFactory.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynElementFactory.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/SysdynTextElementNoBounds.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewBarChartHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewEnumerationNodeHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewExperimentNodeHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewFunctionLibraryHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewModuleNodeHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewPieChartHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityChartHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSpreadSheetHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewXYLineChartHandler.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayDependencyTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayFlowTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ArrayIndexesTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ConfigurationTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/DependencyTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EnumerationTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExperimentTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FlowTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionLibraryTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/GameExperimentTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LookupTableTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LoopTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleInputTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleOutputTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleParameterTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTypeTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/PlaybackExperimentTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResultTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SharedFunctionLibrariesTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/DelayMarkWidget.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/DelayExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/EmptyExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/IExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/LookupExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/StockExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/ComboStringPropertyModifier.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/functions/FunctionCodeWidget.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivityChartAxisAndVariablesTab.java
1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/SensitivitySeriesPropertyComposite.java
1.8/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java [new file with mode: 0644]

index 98d3e2d9d3c08048e17df94d6c693b6727ff0474..cde7423cbcea2477c7c58042b99fff81ce0618bd 100644 (file)
Binary files a/1.8/org.simantics.sysdyn.ontology/graph.tg and b/1.8/org.simantics.sysdyn.ontology/graph.tg differ
index aaa11b1f0dbf176caae0f76d2d422a7e1c3fc629..39433ba256c5e11c507ae6bea89586ca31edacee 100644 (file)
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="32"
-     inkscape:cx="-1.9642866"
-     inkscape:cy="-2.7672376"
+     inkscape:cx="3.4526228"
+     inkscape:cy="8.6397355"
      inkscape:document-units="px"
      inkscape:current-layer="layer1"
      inkscape:window-width="1006"
      inkscape:window-height="739"
-     inkscape:window-x="1428"
-     inkscape:window-y="52"
+     inkscape:window-x="510"
+     inkscape:window-y="43"
      showgrid="false"
      inkscape:window-maximized="0"
      fit-margin-top="0"
        inkscape:randomized="0"
        d="m 148.57144,345.21932 230.49908,-204.50728 61.85896,301.8717 z"
        inkscape:transform-center-y="-0.37884722"
-       transform="matrix(0.00747689,-0.00472065,0.00249533,0.01414476,2.177026,1048.1856)" />
+       transform="matrix(0.00747689,-0.00472065,0.00249533,0.01414476,8.177026,1038.1856)" />
     <path
        sodipodi:type="arc"
        style="fill:none;stroke:#000000;stroke-width:0.88339353;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:none;marker-mid:none;marker-end:none"
        sodipodi:rx="21.785715"
        sodipodi:ry="13.121153"
        d="m 59.821428,1014.4158 a 21.785715,13.121153 0 1 1 -22.182754,-13.119"
-       transform="matrix(0.23486318,0,0,0.36599586,-8.614148,680.86439)"
+       transform="matrix(0.23486318,0,0,0.36599586,-2.614148,670.86439)"
        sodipodi:start="0"
        sodipodi:end="4.6941632"
        sodipodi:open="true" />
index ee0afef0f083552eb0e557341bfd5ecafee3a695..7b06dd5bb14c4e834bb7da0f042c1a8d94648638 100644 (file)
                </or>\r
             </with>\r
          </activeWhen>\r
-      </handler>      \r
+      </handler>\r
+            <handler\r
+            class="org.simantics.sysdyn.ui.PropertyViewUndoHandler"\r
+            commandId="org.eclipse.ui.edit.undo">\r
+         <activeWhen>\r
+            <reference\r
+                  definitionId="org.simantics.sysdyn.ui.inExpressionField">\r
+            </reference>\r
+         </activeWhen>\r
+      </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.PropertyViewUndoHandler"\r
+            commandId="org.eclipse.ui.edit.redo">\r
+         <activeWhen>\r
+            <reference\r
+                  definitionId="org.simantics.sysdyn.ui.inExpressionField">\r
+            </reference>\r
+         </activeWhen>\r
+      </handler>\r
+      \r
    </extension>\r
    \r
    <extension\r
             class="org.simantics.sysdyn.ui.preferences.SysdynDiagramPreferencesInitializer">\r
       </initializer>      \r
    </extension>\r
+   \r
+   <extension point="org.eclipse.core.expressions.definitions">\r
+      <definition\r
+            id="org.simantics.sysdyn.ui.inExpressionField">\r
+         <with variable="activePartId">\r
+            <equals\r
+                  value="org.simantics.browsing.ui.graph.propertyView">\r
+            </equals>\r
+         </with>\r
+      </definition>\r
+   </extension>\r
+   \r
 </plugin>\r
diff --git a/1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/PropertyViewUndoHandler.java b/1.8/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/PropertyViewUndoHandler.java
new file mode 100644 (file)
index 0000000..9fc3a96
--- /dev/null
@@ -0,0 +1,51 @@
+package org.simantics.sysdyn.ui;\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.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
+import org.simantics.ui.workbench.handler.SessionUndoHandler;\r
+\r
+public class PropertyViewUndoHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        String id = event.getCommand().getId();\r
+        \r
+        Event e = (Event)event.getTrigger();\r
+        Widget w = e.widget;\r
+        Object data = w.getData(TrackedText.ID);\r
+        if (data != null) {\r
+            TrackedText text = (TrackedText) data;\r
+            if (id.equals("org.eclipse.ui.edit.undo"))\r
+                text.undo();\r
+            else\r
+                text.redo();\r
+            return null;\r
+        }\r
+        \r
+        \r
+        Composite c = ((Control)((Event)event.getTrigger()).widget).getParent();\r
+        if (c instanceof ExpressionField) {\r
+            ExpressionField f = (ExpressionField)c;\r
+            if (id.equals("org.eclipse.ui.edit.undo")) {\r
+                f.getSourceViewer().getUndoManager().undo();\r
+            }\r
+            else {\r
+                f.getSourceViewer().getUndoManager().redo();\r
+            }\r
+        } else {\r
+                SessionUndoHandler suh = new SessionUndoHandler();\r
+                suh.execute(event);\r
+                //Layer0Utils.undo();\r
+            \r
+        }\r
+        return null;\r
+    }\r
+\r
+}\r
index 73725ccb3ca2949de236e4f28e484687e72c2152..0d381be52c645e1e20c8eeacf896c88367996018 100644 (file)
@@ -48,7 +48,10 @@ public class Project extends ViewpointContributor<Resource> {
         ProjectResource PROJ = ProjectResource.getInstance(graph);\r
         if(!graph.isInstanceOf(project, PROJ.Project)) return Collections.emptyList();\r
         Collection<Resource> ontologies = Simantics.applySCL("Simantics/SharedOntologies", "traverseSharedOntologies", graph, graph.getRootLibrary());\r
-        for(Resource o : ontologies) result.add(new SharedOntologyNode(o));\r
+        for(Resource o : ontologies) {\r
+               if(!graph.isImmutable(o))\r
+                       result.add(new SharedOntologyNode(o));\r
+        }\r
 \r
         return result;\r
 \r
index 61eb18506df1b89b88cb3e24727940c9f17c31bb..0d17007c6574bb27be30efff6c1ec68e9eb40362 100644 (file)
@@ -19,13 +19,16 @@ import org.simantics.browsing.ui.common.node.AbstractNode;
 import org.simantics.browsing.ui.common.node.DeleteException;\r
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
 import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
+import org.simantics.databoard.Bindings;\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.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\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.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
@@ -67,7 +70,10 @@ public abstract class AbstractChartNode<T> extends AbstractNode<Resource> implem
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    graph.markUndoPoint();\r
+                    String chartName = graph.getRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed chart '" + chartName +"' " + data);\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 7d7ee9dcb7f29ac2d45f83d58c21184858e3412a..bfa2943d6f2332794e53daedf9c6f27b301c086b 100644 (file)
@@ -5,6 +5,7 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
@@ -13,6 +14,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.layer0.Layer0;\r
@@ -76,6 +78,7 @@ public class EnumerationNode extends VariableNode<Resource> implements IModifiab
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    graph.markUndoPoint();\r
                     SysdynResource sr = SysdynResource.getInstance(graph);\r
                     for(Resource redeclaration : graph.getObjects(data, sr.Redeclaration_replacedEnumeration_Inverse)) {\r
                        graph.deny(redeclaration, sr.Module_redeclaration_Inverse);\r
@@ -96,8 +99,9 @@ public class EnumerationNode extends VariableNode<Resource> implements IModifiab
                         }\r
                     }\r
                     \r
+                    String enumerationName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
-                    \r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Enumeration " + enumerationName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index deeb8dd7082e0fbfedcdfc9bc91818477baf6cd7..e059b644b23223fc0e0646f840ad2738131b7f5e 100644 (file)
@@ -20,12 +20,15 @@ import org.simantics.browsing.ui.common.node.IDoubleClickableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\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.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.project.IProject;\r
 import org.simantics.simulation.project.IExperimentManager;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -81,7 +84,9 @@ public class ExperimentNode extends AbstractNode<Resource> implements IDoubleCli
                     if(resultSets != null)\r
                         for(Resource resultSet : resultSets) \r
                             SimulationResultSetNode.unlinkResultSet(graph, resultSet);\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed experiment " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 660fe185108c48855429b56772caf8a948886266..13971866e315e2a9e6594920019bcc259784c648 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
+import org.simantics.Simantics;\r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.common.node.DeleteException;\r
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
@@ -18,6 +19,7 @@ import org.simantics.browsing.ui.common.node.IDoubleClickableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
@@ -25,6 +27,7 @@ import org.simantics.db.common.request.WriteRequest;
 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.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -49,14 +52,22 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
 \r
                @Override\r
                        public void execute(final String result) {\r
-                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                   if (result == null)\r
+                       return;\r
+                               Simantics.getSession().asyncRequest(new WriteRequest() {\r
                                        \r
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
                                                Layer0 l0 = Layer0.getInstance(graph);\r
                                                SimulationResource sim = SimulationResource.getInstance(graph);\r
                                                Resource configuration = graph.getPossibleObject(data, sim.HasConfiguration);\r
+                                               \r
+                                               String label = graph.getPossibleRelatedValue2(configuration, l0.HasLabel, Bindings.STRING);\r
+                                               if (label != null)\r
+                                                   return;\r
+                                               \r
                                                graph.claimLiteral(configuration, l0.HasLabel, result);\r
+                                               Layer0Utils.addCommentMetadata(graph, "Created ModelNode to model browser for model " + result);\r
                                        }\r
                                });\r
                        }\r
@@ -98,10 +109,13 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
                 return new WriteRequest() {\r
                     @Override\r
                     public void perform(WriteGraph g) throws DatabaseException {\r
+                        g.markUndoPoint();\r
                        Layer0 l0 = Layer0.getInstance(g);\r
+                       String oldName = g.getPossibleRelatedValue2(data, l0.HasLabel, Bindings.STRING);\r
                         g.claimLiteral(data, l0.HasLabel, label);\r
                         String safeName = NameUtils.findFreshName(g, label, g.getSingleObject(data, l0.PartOf), l0.ConsistsOf, "%s%d");\r
                         g.claimLiteral(data, l0.HasName, safeName);\r
+                        Layer0Utils.addCommentMetadata(g, "Renamed model " + oldName + " to " + label + " " + data.toString());\r
                     }\r
                 };\r
             }\r
@@ -116,13 +130,20 @@ public class ModelNode extends AbstractNode<Resource> implements IDoubleClickabl
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    \r
+                    graph.markUndoPoint();\r
+                    \r
                        Layer0 l0 = Layer0.getInstance(graph);\r
                        \r
                     for(Resource r : graph.getObjects(data, l0.ConsistsOf))\r
                         if(graph.isInstanceOf(r, SysdynResource.getInstance(graph).Result))\r
                             SimulationResultNode.deleteResultFiles(graph, r);\r
 \r
+                    String modelName = graph.getPossibleRelatedValue2(data, l0.HasName, Bindings.STRING);\r
+                    String modelResource = data.toString();\r
                     RemoverUtil.remove(graph, data);\r
+                    \r
+                    Layer0Utils.addCommentMetadata(graph, "Removed model '" + modelName +"' " + modelResource);\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 6d7734460b06799a8a4fe90163c93e29b18592c4..06e93bd0b22b7d5c5f04e5f7b434afcf0978230a 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
@@ -34,6 +35,7 @@ import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;
 import org.simantics.db.exception.ServiceException;\r
 import org.simantics.db.layer0.adapter.PasteHandler;\r
 import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -78,8 +80,12 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
                                        \r
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
-                                               if(configuration != null)\r
-                                                       graph.claimLiteral(configuration, Layer0.getInstance(graph).HasLabel, result);\r
+                                               if(configuration != null) {\r
+                                                   Layer0 L0 = Layer0.getInstance(graph);\r
+                                                   String currentLabel = graph.getRelatedValue2(configuration, L0.HasLabel, Bindings.STRING);\r
+                                                   if (!currentLabel.equals(result))\r
+                                                       graph.claimLiteral(configuration, L0.HasLabel, result);\r
+                                               }\r
                                        }\r
                                });\r
                        }\r
@@ -150,6 +156,7 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
 \r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException{\r
+                    graph.markUndoPoint();\r
                        Layer0 l0 = Layer0.getInstance(graph);\r
                     StructuralResource2 st = StructuralResource2.getInstance(graph);\r
                     ModelingResources mr = ModelingResources.getInstance(graph);\r
@@ -175,6 +182,7 @@ public class ModuleTypeNode extends AbstractNode<Resource> implements IDeletable
                             RemoverUtil.remove(graph, issue);\r
                         }\r
                     }\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Module Type " + graph.getRelatedValue2(type, l0.HasName, Bindings.STRING) + " " + type.toString());\r
                     RemoverUtil.remove(graph, type);\r
                 }\r
             });\r
index 70815ee471a1201b004dd4e31c91f74462f6079b..9307287ea630a3888b389a94a6d2b25a0428bce6 100644 (file)
@@ -17,12 +17,14 @@ import org.simantics.browsing.ui.common.node.IDeletableNode;
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -40,7 +42,9 @@ public class SCLModule extends AbstractNode<Resource> implements IDeletableNode,
             SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed SCL Module " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index e2269ebaa27f445fd4bb687553cd786115e5c62f..b508227732e4818dc2c11314bf989653314e2c65 100644 (file)
@@ -15,10 +15,13 @@ import org.simantics.browsing.ui.common.node.DeleteException;
 import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
 import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\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.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.utils.SharedFunctionLibraryNameValidator;\r
@@ -37,12 +40,9 @@ public class SharedFunctionLibraryNode extends FunctionLibraryNode<Resource> imp
 \r
                        @Override\r
                        public void perform(WriteGraph graph) throws DatabaseException {\r
-                               Layer0 l0 = Layer0.getInstance(graph);\r
-                               \r
-                               graph.deny(data, l0.PartOf);\r
-                               graph.deny(data, l0.IsLinkedTo_Inverse);\r
-\r
-                               // TODO: remove file\r
+                String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
+                RemoverUtil.remove(graph, data);\r
+                Layer0Utils.addCommentMetadata(graph, "Removed Shared Function Library " + ontologyName + " "+ data.toString());\r
                        }\r
                });\r
        }\r
index 6e6d5951bdb4f1b7b2fd83276ff842cf119e10fb..678a4c05256834b00accbb5c1fe304cbec81241d 100644 (file)
@@ -1,17 +1,20 @@
 package org.simantics.sysdyn.ui.browser.nodes;\r
 \r
+import org.simantics.Simantics;\r
 import org.simantics.browsing.ui.common.node.AbstractNode;\r
 import org.simantics.browsing.ui.common.node.DeleteException;\r
 import org.simantics.browsing.ui.common.node.IDeletableNode;\r
 import org.simantics.browsing.ui.common.node.IModifiableNode;\r
 import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.databoard.Bindings;\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.exception.CancelTransactionException;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
-import org.simantics.ui.SimanticsUI;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
 public class SharedOntologyNode extends AbstractNode<Resource> implements IDeletableNode, IModifiableNode {\r
@@ -23,10 +26,13 @@ public class SharedOntologyNode extends AbstractNode<Resource> implements IDelet
     @Override\r
     public void delete() throws DeleteException {\r
         try {\r
-            SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+            Simantics.getSession().syncRequest(new WriteRequest() {\r
                 @Override\r
                 public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    graph.markUndoPoint();\r
+                    String ontologyName = graph.getPossibleRelatedValue2(data, Layer0.getInstance(graph).HasName, Bindings.STRING);\r
                     RemoverUtil.remove(graph, data);\r
+                    Layer0Utils.addCommentMetadata(graph, "Removed Shared Ontology " + ontologyName + " "+ data.toString());\r
                 }\r
             });\r
         } catch (DatabaseException e) {\r
index 159abc54e33267ad5da55dffa8acc3ae243a3957..5f3c32594ab5b90e1d2fe96bbab8bf7a7171b566 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.content.ConnectionUtil;\r
 import org.simantics.diagram.participant.ConnectionBuilder;\r
 import org.simantics.diagram.participant.ControlPoint;\r
@@ -65,6 +66,9 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{
      */\r
     public void create(WriteGraph graph, ConnectionJudgement judgment, Deque<ControlPoint> controlPoints,\r
             TerminalInfo startTerminal, TerminalInfo endTerminal) throws DatabaseException {\r
+        \r
+        graph.markUndoPoint();\r
+        \r
        // If needs a valve, we will create two separate connections\r
         if(needsValve(startTerminal, endTerminal)) {\r
                createValveAndConnections(graph, judgment, controlPoints, startTerminal, endTerminal);\r
@@ -73,6 +77,14 @@ public class SysdynConnectionBuilder extends ConnectionBuilder{
         else {\r
                createConnection(graph, judgment, controlPoints, startTerminal, endTerminal, false);\r
         }\r
+        \r
+        String startElementName = startTerminal.e.getHint(ElementHints.KEY_TEXT);\r
+        String endElementName = endTerminal.e.getHint(ElementHints.KEY_TEXT);\r
+        \r
+        String startElementResource = startTerminal.e.getHint(ElementHints.KEY_OBJECT).toString();\r
+        String endElementResource = endTerminal.e.getHint(ElementHints.KEY_OBJECT).toString();\r
+        \r
+        Layer0Utils.addCommentMetadata(graph, "Created dependency starting from " + startElementName + " " + startElementResource + " and ending to " + endElementName + " " + endElementResource);\r
     }\r
     /**\r
      * @param graph\r
index 473ee7a17b769b1867a521335245630e13bdae90..2498e4a487f49de12f24ab61dea204fbfea9cd87 100644 (file)
@@ -62,10 +62,14 @@ import org.simantics.g2d.svg.SVGImage;
 import org.simantics.g2d.utils.Alignment;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseEnterEvent;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseExitEvent;\r
 import org.simantics.scenegraph.g2d.nodes.SVGNode;\r
 import org.simantics.scenegraph.g2d.nodes.ShapeNode;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.properties.LoopTab;\r
+import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
 import org.simantics.sysdyn.utils.LoopUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.Callback;\r
@@ -116,13 +120,14 @@ public class LoopFactory extends SysdynElementFactory {
 \r
        static Shape getLoopShape() {\r
                // Used in shortcut.\r
+               double x0 = 5, y0 = 2;\r
                Path2D loop = new Path2D.Double();\r
-               loop.moveTo(1, 2);\r
-               loop.lineTo(0, 0);\r
-               loop.lineTo(-1, 2);\r
+               loop.moveTo(x0 + 1, y0 + 2);\r
+               loop.lineTo(x0 + 0, y0 + 0);\r
+               loop.lineTo(x0  -1, y0 + 2);\r
                loop.closePath();\r
 \r
-               loop.append(new Arc2D.Double(-10, -3, 10, 10, 0, -270, Arc2D.OPEN), false);\r
+               loop.append(new Arc2D.Double(x0 -10, y0 -3, 10, 10, 0, -270, Arc2D.OPEN), false);\r
                return loop;\r
        }\r
 \r
@@ -201,7 +206,7 @@ public class LoopFactory extends SysdynElementFactory {
                        SVGNode image = e.getHint(getNodeKey());\r
                        if (clockwise != null && clockwise) {\r
                Point2D imageParent = (Point2D) image.localToParent(new Point2D.Double(0.0,0.0)).clone();\r
-               AffineTransform at = new AffineTransform(-1.0, 0.0, 0.0, 1.0, imageParent.getX(), imageParent.getY());\r
+               AffineTransform at = new AffineTransform(-1.0, 0.0, 0.0, 1.0, imageParent.getX()+12.34, imageParent.getY());\r
                image.setTransform(at);\r
                        }\r
                        \r
@@ -292,12 +297,12 @@ public class LoopFactory extends SysdynElementFactory {
 \r
                private static double getXCoordShift(IElement e) {\r
                        //String location = e.getHint(SysdynElementHints.KEY_LOCATION);\r
-                       return 0;\r
+                       return 6.3;\r
                }\r
 \r
                private static double getYCoordShift(IElement e) {\r
                        //String location = e.getHint(SysdynElementHints.KEY_LOCATION);\r
-                       return 9.7;\r
+                       return -0.3;\r
                }\r
 \r
                @Override\r
index 174ae5748fab4c4b33f19e501283bb0fe0fdc2ec..a3c3be2ca81993b3ae882be4213018b41f10556f 100644 (file)
@@ -157,7 +157,7 @@ public abstract class SysdynElementFactory extends SyncElementFactory {
         Resource component = graph.getPossibleObject(element, mr.ElementToComponent);\r
         if (component != null && graph.hasStatement(component, SysdynResource.getInstance(graph).IsOutput)) {\r
             Font font = ElementUtils.getTextFont(e);\r
-            font = font.deriveFont(Font.BOLD);\r
+            font = font.deriveFont(font.isItalic() ? Font.ITALIC | Font.BOLD : Font.BOLD);\r
             ElementUtils.setTextFont(e, font);\r
         }\r
         \r
index 3d6eda9e2463bb98c326ec522c91820af18cd89e..3e2f4f52896f1f10aeaed4d55c2d3aa48fb9f33e 100644 (file)
@@ -41,6 +41,7 @@ import org.simantics.modeling.ModelingResources;
 import org.simantics.modeling.ui.diagramEditor.DiagramEditor;\r
 import org.simantics.modeling.ui.diagramEditor.DiagramViewer;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.scenegraph.g2d.events.MouseEvent;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.utils.SysdynWorkbenchUtils;\r
 import org.simantics.sysdyn.ui.utils.VariableNameValidator;\r
@@ -145,6 +146,7 @@ public class SysdynTextElementNoBounds extends TextElementNoBounds {
                         String text = node.getText();\r
                         if(!new VariableNameValidator().isValid(component, text, false)) {\r
                             text = textBeforeEdit;\r
+                            node.setEditMode(false);\r
                             node.setText(text);\r
                             if(new VariableNameValidator().isValid(component, text, false))\r
                                 node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
@@ -304,5 +306,13 @@ public class SysdynTextElementNoBounds extends TextElementNoBounds {
         \r
         unflipText(e);\r
     }\r
+    \r
+    @Override\r
+    public boolean handleMouseEvent(IElement e, final ICanvasContext ctx, MouseEvent me) {\r
+       //if (!(me instanceof MouseEnterEvent) && !(me instanceof MouseMovedEvent) && !(me instanceof MouseExitEvent))\r
+               //System.out.println(me instanceof MouseDragBegin ? "drag begin" : "no drag begin");\r
+       //SysdynWorkbenchUtils.setHoveringHint(ctx, me, SysdynTextElementNoBounds.this);\r
+        return super.handleMouseEvent(e, ctx, me);\r
+    }\r
 \r
 }\r
index 88aa7eb72e68837fd5c5c2db8fde7b8784d538d6..1e3421421dd517bf8d00549c964d9d66b420b6af 100644 (file)
@@ -25,6 +25,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -55,13 +56,16 @@ public class NewBarChartHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
                 G2DResource g2d = G2DResource.getInstance(g);\r
 \r
+                String label = NameUtils.findFreshLabel(g, "Bar Chart", model);\r
+                \r
                 Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
                         l0.HasName, "BarChart" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, NameUtils.findFreshLabel(g, "Bar Chart", model),\r
+                        l0.HasLabel, label,\r
                         l0.PartOf, model,\r
                         jfree.Chart_visibleBorder, true,\r
                         jfree.Chart_borderWidth, 3,\r
@@ -100,6 +104,7 @@ public class NewBarChartHandler extends AbstractHandler {
                         l0.ConsistsOf, dataset,\r
                         l0.ConsistsOf, domainAxis,\r
                         l0.ConsistsOf, rangeAxis);\r
+                Layer0Utils.addCommentMetadata(g, "Created new Bar Chart " +  label + " " + jfreechart);\r
             }\r
 \r
         });\r
index 6801225c1d069a66cfd542c12e046bfb2a83312f..81128020d790d378897b92cfc81c8a6ae49f0f55 100644 (file)
@@ -18,12 +18,14 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;\r
 import org.eclipse.jface.viewers.ISelection;\r
 import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\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.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.modeling.ModelingResources;\r
@@ -51,6 +53,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                SysdynResource sr = SysdynResource.getInstance(g);\r
                Layer0 l0 = Layer0.getInstance(g);\r
                \r
@@ -79,6 +82,7 @@ public class NewEnumerationNodeHandler extends AbstractHandler {
                                l0.HasName, name,\r
                                sr.Enumeration_enumerationIndexList, ListUtils.create(g, new ArrayList<Resource>()),\r
                                l0.PartOf, configuration);\r
+               Layer0Utils.addCommentMetadata(g, "Created new Enumeration " + name + " to " + g.getRelatedValue2(configuration, l0.HasLabel, Bindings.STRING));\r
             }\r
         });\r
                return null;\r
index 0ddf1a3b8ea2295c99bc7f38acdbadd73bc0934a..ddfc2b1d58ef4e052d02b2eae9388f79d2b051c3 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -56,6 +57,7 @@ public class NewExperimentNodeHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 String label = NameUtils.findFreshName(g, getNameSuggestion(), model, l0.ConsistsOf, l0.HasLabel, "%s%d");\r
                 Resource experiment = GraphUtils.create2(g, getExperimentType(g),\r
@@ -63,6 +65,7 @@ public class NewExperimentNodeHandler extends AbstractHandler {
                         l0.HasLabel, label,\r
                         l0.PartOf, model);\r
                 configureExperiment(g, experiment);\r
+                Layer0Utils.addCommentMetadata(g, "Created new experiment " + label + " " + experiment.toString());\r
             }\r
         });\r
         return null;\r
index 7acab21ed23d06b97e2f3693b2e9cedd7f441ba3..e048657cf762ae801d725503c2bce2807558cfcb 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -55,6 +56,7 @@ public class NewFunctionHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                Layer0 l0 = Layer0.getInstance(g);\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
 \r
@@ -71,11 +73,13 @@ public class NewFunctionHandler extends AbstractHandler {
                 \r
                 String name = NameUtils.findFreshName(g, "Function", library, l0.ConsistsOf, "%s%d");\r
 \r
-                GraphUtils.create2(g, sr.SysdynModelicaFunction,\r
+                Resource func = GraphUtils.create2(g, sr.SysdynModelicaFunction,\r
                         l0.HasName, name,\r
                         l0.HasDescription, "",\r
                         sr.SysdynModelicaFunction_modelicaFunctionCode, "",\r
                         l0.PartOf, library);\r
+                \r
+                Layer0Utils.addCommentMetadata(g, "Created new Function " + name + " " + func.toString());\r
             }\r
         });\r
         \r
index bf62f3efdf04d739becd531ae55e2af1c4fdf0c9..62d88a4ad474287d704bb3ab476d3f94830ff630 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ResourceNotFoundException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
@@ -63,6 +64,7 @@ public class NewFunctionLibraryHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                Layer0 l0 = Layer0.getInstance(g);\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
 \r
@@ -100,6 +102,8 @@ public class NewFunctionLibraryHandler extends AbstractHandler {
                 \r
                 if(shared)\r
                        g.claim(model, l0.IsLinkedTo, functionLibrary);\r
+                \r
+                Layer0Utils.addCommentMetadata(g, "Created new Function Library " + name + " " + functionLibrary.toString());\r
             }\r
         });\r
        }\r
index 60170f7eccc9fd459d52038d5cbc47bde51aae0f..b5939cb726d4ea9a92a1080a4cff87ca821af6cf 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.adapter.Template;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.synchronization.graph.DiagramGraphUtil;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -33,8 +34,8 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.ui.browser.actions.newActions.NewModuleTypeAction;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.ui.AdaptionUtils;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 \r
 /**\r
  * Creates a new module node for a model.\r
@@ -62,6 +63,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
             \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 SysdynResource sr = SysdynResource.getInstance(g);\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 Layer0X L0X = Layer0X.getInstance(g);\r
@@ -122,7 +124,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
                                 \r
                 g.claim(moduleSymbol, sr2.IsDefinedBy, OrderedSetUtils.create(g, sr2.Composite, terminal, terminal2));\r
             \r
-                \r
+                Layer0Utils.addCommentMetadata(g, "Created new Module Type " + name + " " + moduleType.toString());\r
             }\r
         });\r
         return null;\r
index 3f17f995c7bbaf5e9457bec76e12c6845988a069..0d386c7bd8aecf6ee0842500414790c524598a2c 100644 (file)
@@ -25,6 +25,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -55,13 +56,16 @@ public class NewPieChartHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
                 G2DResource g2d = G2DResource.getInstance(g);\r
 \r
+                String label = NameUtils.findFreshLabel(g, "Pie Chart", model);\r
+                \r
                 Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
                         l0.HasName, "PieChart" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, NameUtils.findFreshLabel(g, "Pie Chart", model),\r
+                        l0.HasLabel, label,\r
                         l0.PartOf, model,\r
                         jfree.Chart_visibleBorder, true,\r
                         jfree.Chart_borderWidth, 3);\r
@@ -83,6 +87,8 @@ public class NewPieChartHandler extends AbstractHandler {
                         l0.PartOf, jfreechart,\r
                         l0.ConsistsOf, dataset\r
                         );\r
+                Layer0Utils.addCommentMetadata(g, "Created new Pie Chart " +  label + " " + jfreechart);\r
+                \r
             }\r
 \r
         });\r
index 013c56023179ebf46d8da60b6ed0354ee7f2eb7b..7bc7a370a57fd0699ffbf4d4630c55c88e7c2d2d 100644 (file)
@@ -27,6 +27,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.jfreechart.chart.ChartUtils;\r
 import org.simantics.layer0.Layer0;\r
@@ -54,14 +55,17 @@ public class NewSensitivityChartHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
                 G2DResource g2d = G2DResource.getInstance(g);\r
                 SysdynResource SR = SysdynResource.getInstance(g);\r
 \r
+                String label = NameUtils.findFreshLabel(g, "SensitivityChart", model);\r
+                \r
                 Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
                         l0.HasName, "SensitivityChart" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, NameUtils.findFreshLabel(g, "SensitivityChart", model),\r
+                        l0.HasLabel, label,\r
                         l0.PartOf, model,\r
                         jfree.Chart_visibleBorder, true,\r
                         jfree.Chart_borderWidth, 3);\r
@@ -143,6 +147,7 @@ public class NewSensitivityChartHandler extends AbstractHandler {
                         l0.ConsistsOf, dataset,\r
                         l0.ConsistsOf, domainAxis,\r
                         l0.ConsistsOf, rangeAxis);\r
+                Layer0Utils.addCommentMetadata(g, "Created new Sensitivity Chart " +  label + " " + jfreechart);\r
             }\r
 \r
         });\r
index 3a64607af182da73b28fbbcb20279ac3f7ab70cc..5a612a496de050c3e64317efc6f4449c49281beb 100644 (file)
@@ -19,7 +19,9 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.sysdyn.utils.SheetUtils;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.utils.ResourceAdaptionUtils;\r
@@ -44,7 +46,9 @@ public class NewSpreadSheetHandler extends AbstractHandler {
             \r
             @Override\r
             public void perform(WriteGraph graph) throws DatabaseException {\r
-                SheetUtils.createSheet(graph, book, null, new String[] {}, new int[] {50});\r
+                graph.markUndoPoint();\r
+                Resource sheet = SheetUtils.createSheet(graph, book, null, new String[] {}, new int[] {50});\r
+                Layer0Utils.addCommentMetadata(graph, "Created new Spreadsheet " + NameUtils.getSafeName(graph, sheet) + " " + sheet.toString());\r
             }\r
         });      \r
         return null;\r
index 2f06ce812f6c41d9929a27a512e9f3f5d95aa453..9c2e675e98a53dc42b48129c44cc2d3606b5ab9f 100644 (file)
@@ -26,6 +26,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.diagram.stubs.G2DResource;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.layer0.utils.direct.GraphUtils;\r
@@ -58,13 +59,16 @@ public class NewXYLineChartHandler extends AbstractHandler {
 \r
             @Override\r
             public void perform(WriteGraph g) throws DatabaseException {\r
+                g.markUndoPoint();\r
                 Layer0 l0 = Layer0.getInstance(g);\r
                 JFreeChartResource jfree = JFreeChartResource.getInstance(g);\r
                 G2DResource g2d = G2DResource.getInstance(g);\r
-\r
+                \r
+                String label = NameUtils.findFreshLabel(g, "Chart", model);\r
+                \r
                 Resource jfreechart = GraphUtils.create2(g, jfree.Chart,\r
                         l0.HasName, "Chart" + UUID.randomUUID().toString(),\r
-                        l0.HasLabel, NameUtils.findFreshLabel(g, "Chart", model),\r
+                        l0.HasLabel, label,\r
                         l0.PartOf, model,\r
                         jfree.Chart_visibleBorder, true,\r
                         jfree.Chart_borderWidth, 3);\r
@@ -102,6 +106,7 @@ public class NewXYLineChartHandler extends AbstractHandler {
                         l0.ConsistsOf, dataset,\r
                         l0.ConsistsOf, domainAxis,\r
                         l0.ConsistsOf, rangeAxis);\r
+                Layer0Utils.addCommentMetadata(g, "Created new Line Chart " +  label + " " + jfreechart);\r
             }\r
 \r
         });\r
index bd1c1bfd910f63936894de89f1c89a5a5add6c85..1e7808846c7567f00acdbc916196c123e27a3b86 100644 (file)
@@ -268,7 +268,11 @@ public class ArrayDependencyTab  extends AdjustableTab {
         }\r
     }\r
 \r
-       @Override\r
+       public ArrayDependencyTab(Object dependencies) {\r
+           super(dependencies);\r
+       }\r
+\r
+    @Override\r
        protected void createAndAddControls(Composite body, IWorkbenchSite site,\r
                        ISessionContext context, WidgetSupport support) {\r
                composite = new Composite(body, SWT.NONE);\r
@@ -387,5 +391,4 @@ public class ArrayDependencyTab  extends AdjustableTab {
         GridDataFactory.fillDefaults().span(1, 1).applyTo(lineThicknessGroup);\r
         GridLayoutFactory.fillDefaults().applyTo(lineThicknessGroup);\r
        }\r
-\r
 }\r
index ad02e9ada9b3d66a38b70f4aba0f22838eef8e55..47238fb4d5602b7b8d2c3fa1456f24c4491cf635 100644 (file)
@@ -42,6 +42,10 @@ public class ArrayFlowTab  extends LabelPropertyTabContributor {
 \r
        private Scale lineThicknessScale;\r
     \r
+    public ArrayFlowTab(Object input) {\r
+        super(input);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         Composite composite = new Composite(body, SWT.NONE);\r
@@ -102,5 +106,4 @@ public class ArrayFlowTab  extends LabelPropertyTabContributor {
             return (int)Math.round(FlowConnectionStyle.DEFAULT_LINE_WIDTH * 3);\r
         }\r
     }\r
-\r
 }\r
index e97de85e745d48ba8d08cd6985d5289478897208..741cfcc20a92ea7311409075a37a6e3090f2d767 100644 (file)
@@ -29,13 +29,16 @@ import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\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.request.ReadRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
 import org.simantics.layer0.Layer0;\r
@@ -43,6 +46,7 @@ import org.simantics.sysdyn.SysdynResource;
 import org.simantics.sysdyn.ui.properties.widgets.ColumnKeys;\r
 import org.simantics.utils.RunnableWithObject;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.threads.SWTThread;\r
 \r
 public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widget{\r
 \r
@@ -50,8 +54,16 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
        GraphExplorerComposite usedEnumerationsExplorer;\r
        private WidgetSupportImpl buttonSupport;\r
        private org.simantics.browsing.ui.swt.widgets.Label usedEnumerationsLabel;\r
+    private Button down;\r
+    private Button up;\r
+    private Button remove;\r
        \r
-       @Override\r
+       public ArrayIndexesTab(Object variables) {\r
+        super(variables);\r
+    }\r
+\r
+\r
+    @Override\r
        public void createControls(Composite body, IWorkbenchSite site,\r
                        ISessionContext context, WidgetSupport support) {\r
                support.register(this);\r
@@ -93,7 +105,7 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
             List<Resource> enumerationResources;\r
 \r
             @Override\r
-            public void beforeApply() {\r
+            public void beforeApply() { \r
                 enumerationResources = getSelectedResources(availableEnumerationsExplorer);\r
             }\r
 \r
@@ -103,16 +115,27 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                                SysdynResource sr = SysdynResource.getInstance(graph);\r
                                for(Resource r : input.resources) {\r
                                    Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList);\r
+                                   StringBuilder sb = new StringBuilder();\r
+                                   sb.append("Added new enumeration(s) ");\r
                                    if(arrayIndexes == null) {\r
-                                       graph.claim(r, sr.Variable_arrayIndexesList, ListUtils.create(graph, enumerationResources));\r
+                                       arrayIndexes = ListUtils.create(graph, enumerationResources);\r
+                                       graph.claim(r, sr.Variable_arrayIndexesList, arrayIndexes);\r
+                                       sb.append(enumerationResources.toString() + " ");\r
                                    } else {\r
                                        ArrayList<Resource> filtered = new ArrayList<Resource>();\r
                                        for(Resource enumeration : enumerationResources) {\r
-                                           if(ListUtils.getNode(graph, arrayIndexes, enumeration) == null)\r
+                                           if(ListUtils.getNode(graph, arrayIndexes, enumeration) == null) {\r
                                                filtered.add(enumeration);\r
+                                               sb.append(graph.getPossibleRelatedValue2(enumeration, Layer0.getInstance(graph).HasName, Bindings.STRING) + " ");\r
+                                           }\r
                                        }\r
+                                       if (filtered.isEmpty())\r
+                                           return;\r
                                        ListUtils.insertBack(graph, arrayIndexes, filtered);\r
                                    }\r
+                    sb.append("to " + graph.getPossibleRelatedValue2(r, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
+                    Layer0Utils.addCommentMetadata(graph, sb.toString());\r
+                    updateUsedButtons(graph, arrayIndexes);\r
                                }\r
                        }\r
                });\r
@@ -166,7 +189,7 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                Composite buttons = new Composite(body, SWT.None);\r
                GridLayoutFactory.fillDefaults().applyTo(buttons);\r
                \r
-               Button up = new Button(buttons, buttonSupport, SWT.NONE);\r
+               up = new Button(buttons, buttonSupport, SWT.NONE);\r
                up.setText("Up");\r
                up.addSelectionListener(new SelectionListenerImpl<ResourceArray>(context) {\r
 \r
@@ -189,6 +212,8 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                     if(arrayIndexes != null) {\r
                         List<Resource> enumerations = ListUtils.toList(graph, arrayIndexes);\r
                         List<Resource> toBeMoved = new ArrayList<Resource>();\r
+                        StringBuilder sb = new StringBuilder();\r
+                        sb.append("Moved enumeration(s) ");\r
                         for(Integer index : selectedIndexes) {\r
                             if(index < enumerations.size()) {\r
                                 Resource enumeration = enumerations.get(index);\r
@@ -196,14 +221,20 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                             }\r
 \r
                         }\r
-\r
+                        boolean moved = false;\r
                         for(Resource enumeration : toBeMoved) {\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
+                                sb.append(graph.getPossibleRelatedValue2(enumeration, Layer0.getInstance(graph).HasName, Bindings.STRING) + " ");\r
+                                moved = ListUtils.swapWithPrevious(graph, arrayIndexes, enumeration);\r
                             }\r
                         }\r
+                        if (moved) {\r
+                            sb.append("up");\r
+                            Layer0Utils.addCommentMetadata(graph, sb.toString());\r
+                        }\r
+\r
                     }\r
                 }\r
                 \r
@@ -235,7 +266,7 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                    }\r
                });\r
 \r
-               Button down = new Button(buttons, buttonSupport, SWT.NONE);\r
+               down = new Button(buttons, buttonSupport, SWT.NONE);\r
                down.setText("Down");\r
                down.addSelectionListener(new SelectionListenerImpl<ResourceArray>(context) {\r
 \r
@@ -259,21 +290,28 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                            if(arrayIndexes != null) {\r
                                List<Resource> enumerations = ListUtils.toList(graph, arrayIndexes);\r
                                List<Resource> toBeMoved = new ArrayList<Resource>();\r
+                               StringBuilder sb = new StringBuilder();\r
+                               sb.append("Moved enumeration(s) ");\r
                                for(Integer index : selectedIndexes) {\r
                                    if(index < enumerations.size()) {\r
                                        Resource enumeration = enumerations.get(index);\r
                                        toBeMoved.add(0, enumeration); // Make an inverted list. \r
                                    }\r
-\r
                                }\r
-\r
+                               boolean moved = false;\r
                                for(Resource enumeration : toBeMoved) {\r
                             Resource node = ListUtils.getNode(graph, arrayIndexes, enumeration);\r
                             Resource next = graph.getSingleObject(node, L0.List_Next);\r
+                            \r
                             if(!arrayIndexes.equals(next) && !toBeMoved.contains(graph.getPossibleObject(next, L0.List_Element))) {\r
-                                ListUtils.swapWithNext(graph, arrayIndexes, enumeration);\r
+                                sb.append(graph.getPossibleRelatedValue2(enumeration, Layer0.getInstance(graph).HasName, Bindings.STRING) + " ");\r
+                                moved = ListUtils.swapWithNext(graph, arrayIndexes, enumeration);\r
                                    }\r
                                }\r
+                        if (moved) {\r
+                            sb.append("down");\r
+                            Layer0Utils.addCommentMetadata(graph, sb.toString());\r
+                        }\r
                            }\r
                        }\r
                        \r
@@ -307,7 +345,7 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                });\r
 \r
                \r
-               Button remove = new Button(buttons, buttonSupport, SWT.NONE);\r
+               remove = new Button(buttons, buttonSupport, SWT.NONE);\r
                remove.setText("Remove");\r
                remove.addSelectionListener(new SelectionListenerImpl<ResourceArray>(context) {\r
                    \r
@@ -335,9 +373,15 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                                }\r
 \r
                                }\r
-                               \r
-                               for(Resource enumeration : toBeRemoved)\r
+                               StringBuilder sb = new StringBuilder();\r
+                               sb.append("Removed enumeration(s) ");\r
+                               for(Resource enumeration : toBeRemoved) {\r
                                    ListUtils.removeElement(graph, arrayIndexes, enumeration);\r
+                                   sb.append(graph.getPossibleRelatedValue2(enumeration, Layer0.getInstance(graph).HasName, Bindings.STRING) + " ");\r
+                               }\r
+                               sb.append("from " + graph.getPossibleRelatedValue2(variable, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
+                               Layer0Utils.addCommentMetadata(graph, sb.toString());\r
+                               updateUsedButtons(graph, arrayIndexes);\r
                            }\r
                        }\r
                    }\r
@@ -345,6 +389,33 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
        }\r
 \r
        \r
+    protected void updateUsedButtons(ReadGraph graph, Resource arrayIndexes) {\r
+        boolean enabled = false;\r
+        if (arrayIndexes == null)\r
+            enabled = false;\r
+        else {\r
+            try {\r
+                List<Resource> currEnumerations = ListUtils.toList(graph, arrayIndexes);\r
+                if (!currEnumerations.isEmpty()) {\r
+                    enabled = true;\r
+                }\r
+            } catch (DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        final boolean finalEnabled = enabled;\r
+        SWTThread.getThreadAccess().asyncExec(new Runnable() {\r
+            \r
+            @Override\r
+            public void run() {\r
+                up.getControl().setEnabled(finalEnabled);\r
+                down.getControl().setEnabled(finalEnabled);\r
+                remove.getControl().setEnabled(finalEnabled);     \r
+            }\r
+        });\r
+    }\r
+\r
+\r
        private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
                List<Resource> result = new ArrayList<Resource>();\r
                \r
@@ -395,16 +466,27 @@ public class ArrayIndexesTab extends LabelPropertyTabContributor implements Widg
                 resourceArray = new ResourceArray((Resource)first);\r
             else if( first instanceof Collection<?>)\r
                 resourceArray = new ResourceArray(((Collection<?>)first).toArray(new Resource[((Collection<?>)first).size()]));\r
-            \r
+            final ResourceArray finalResourceArray = resourceArray;\r
             if(resourceArray != null) {\r
-                StructuredSelection selection = new StructuredSelection(resourceArray);\r
+                StructuredSelection selection = new StructuredSelection(finalResourceArray);\r
                 availableEnumerationsExplorer.setInput(context, selection);\r
                 usedEnumerationsExplorer.setInput(context, selection);    \r
                 buttonSupport.fireInput(context, selection);\r
+                \r
+                try {\r
+                    context.getSession().syncRequest(new ReadRequest() {\r
+                        \r
+                        @Override\r
+                        public void run(ReadGraph graph) throws DatabaseException {\r
+                            Resource r = finalResourceArray.resources[0];\r
+                            Resource arrayIndexes = graph.getPossibleObject(r, SysdynResource.getInstance(graph).Variable_arrayIndexesList);\r
+                            updateUsedButtons(graph, arrayIndexes);\r
+                        }\r
+                    });\r
+                } catch (DatabaseException e) {\r
+                    e.printStackTrace();\r
+                }\r
             }\r
         }\r
-        \r
-\r
        }\r
-\r
 }\r
index 0b6c00c10031eed1bb4fa0a49f88d3e0c3bacaea..cc4838c7291d45e65066b475a476eab566e43e76 100644 (file)
@@ -34,7 +34,11 @@ import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;
  */\r
 public class CommentTab extends LabelPropertyTabContributor {\r
 \r
-       @Override\r
+       public CommentTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    @Override\r
        public String getPartName(ISelection forSelection) {\r
                return "Comment";\r
        }\r
index 33ad0ea6310db36e136a65d172974a9b67275bfb..36e3fa14e3aa2d91e25ba839bb44fcbfbf736ed7 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.db.WriteGraph;
 import org.simantics.db.common.request.PossibleObjectWithType;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.issues.ontology.IssueResource;\r
 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
@@ -59,7 +60,11 @@ import org.simantics.sysdyn.ui.properties.widgets.factories.ModelNameInputValida
  */\r
 public class ConfigurationTab extends AdjustableTab {\r
 \r
-       private ScrolledComposite sc;\r
+       public ConfigurationTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    private ScrolledComposite sc;\r
        private Label nameLabel, startTimeLabel, stopTimeLabel, stepLengthLabel, \r
                outputIntervalLabel, methodLabel, toleranceLabel, variableFilterLabel;\r
        private TrackedText name, startTime, stopTime, stepLength, outputInterval, tolerance, variableFilter;\r
@@ -259,6 +264,7 @@ public class ConfigurationTab extends AdjustableTab {
             public void applyText(WriteGraph graph, Resource input, String text)\r
                     throws DatabaseException {\r
                 graph.claimLiteral(input, SysdynResource.getInstance(graph).SysdynModel_timeUnit, text);\r
+                Layer0Utils.addCommentMetadata(graph, "Modified " + graph.getRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " time unit to " + text);\r
             }\r
         });\r
         \r
index 1acc02126ddd35cfa09d5c89f74f663c267d0c4a..666d10088a5a2c8253d6b5249743e704808722af 100644 (file)
@@ -31,8 +31,10 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.elements.connections.DependencyEdgeClass;\r
 import org.simantics.sysdyn.ui.elements.connections.DependencyNode;\r
@@ -50,6 +52,10 @@ import org.simantics.utils.datastructures.Triple;
  */\r
 public class DependencyTab  extends AdjustableTab {\r
 \r
+    public DependencyTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     Button none, plus, minus, other, inside, outside;\r
     TrackedText polarityText, polarityLocationText;\r
     Scale lineThicknessScale;\r
@@ -79,6 +85,7 @@ public class DependencyTab  extends AdjustableTab {
             SysdynResource sr = SysdynResource.getInstance(graph);\r
             float width = ((float)selection) / 10.0f;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_strokeWidth, width);\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Line thickness for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + width);\r
         }\r
         \r
     }\r
@@ -110,9 +117,12 @@ public class DependencyTab  extends AdjustableTab {
         @Override\r
         public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
+            String currentLocation = graph.getPossibleRelatedValue2(connectionElement, sr.DependencyConnection_polarityLocation, Bindings.STRING);\r
+            if (currentLocation != null && currentLocation.equals(location))\r
+                return;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_polarityLocation, location);\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Location for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + location);\r
         }\r
-        \r
     }\r
     \r
     class PolarityLocationRadioSelectionFactory extends ReadFactoryImpl<Resource, Boolean> {\r
@@ -153,7 +163,11 @@ public class DependencyTab  extends AdjustableTab {
         @Override\r
         public void apply(WriteGraph graph, Resource connectionElement) throws DatabaseException {\r
             SysdynResource sr = SysdynResource.getInstance(graph);\r
+            String currentPolarity = graph.getPossibleRelatedValue2(connectionElement, sr.DependencyConnection_polarity, Bindings.STRING);\r
+            if (currentPolarity != null && currentPolarity.equals(polarity))\r
+                return;\r
             graph.claimLiteral(connectionElement, sr.DependencyConnection_polarity, polarity.trim());\r
+            Layer0Utils.addCommentMetadata(graph, "Modified Polarity for connection " + graph.getPossibleRelatedValue2(connectionElement, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to " + polarity.trim());\r
         }\r
         \r
     }\r
index 833a62610a814884d0dd739c622436615afdc374..7514f47c6184dc6e4b8d9366667db965c77b169d 100644 (file)
@@ -60,15 +60,19 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.ui.properties.widgets.arrays.EnumerationIndexNode;\r
 import org.simantics.sysdyn.ui.properties.widgets.arrays.ReplaceableIndexesWidget;\r
-import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameInputValidator;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.ui.SimanticsUI;\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
-       GraphExplorerComposite indexExplorer;\r
+       public EnumerationTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    GraphExplorerComposite indexExplorer;\r
        \r
        Button showAll;\r
        Variable variable;\r
index 633cdfa3df877678dd47127b35af3b4ebf285bdf..4d45a5cbad577d80891f6d51d3b3f8b674d1c4ba 100644 (file)
@@ -46,6 +46,7 @@ import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -56,6 +57,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.request.WriteResultRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.AsyncListener;\r
@@ -104,7 +106,11 @@ public class EquationTab extends AdjustableTab implements Widget {
        private Label unitLabel;\r
        private IsOutputWidget isOutput;\r
 \r
-       @Override\r
+       public EquationTab(Object input) {\r
+           super(input);\r
+    }\r
+\r
+    @Override\r
        public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport _support) {\r
                _support.register(this);\r
                setSupport();\r
@@ -468,6 +474,7 @@ public class EquationTab extends AdjustableTab implements Widget {
                                                );\r
                                        }\r
                                });\r
+                               Layer0Utils.addCommentMetadata(graph, "Deleted Expression " + activeExpression + " from " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                        }\r
                });\r
 \r
@@ -492,10 +499,12 @@ public class EquationTab extends AdjustableTab implements Widget {
                                        graph.claim(newExpression, l0.InstanceOf, graph.getSingleObject(activeExpression, l0.InstanceOf));\r
                                        if(graph.isInstanceOf(newExpression, sr.StockExpression)) {\r
                                                graph.claimLiteral(newExpression, sr.StockExpression_initialEquation, "");\r
+                                               Layer0Utils.addCommentMetadata(graph, "Created new Stock Expression " + newExpression + " for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                                        }\r
                                } else {\r
                                    // If there was no active expression, create a normal expression\r
                                        graph.claim(newExpression, l0.InstanceOf, sr.NormalExpression);\r
+                                       Layer0Utils.addCommentMetadata(graph, "Created new Normal Expression " + newExpression + " for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
                                }\r
                                ArrayList<Resource> addition = new ArrayList<Resource>(1);\r
                                addition.add(newExpression);\r
index 0c291db7a828d0720b22c9ceae117cc5ec699f16..d1bb32f5cb848ba8a1bd47e285a163c434e649d8 100644 (file)
@@ -19,6 +19,10 @@ import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;
 \r
 public class ExperimentTab extends LabelPropertyTabContributor {\r
 \r
+    public ExperimentTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         \r
index a4a91c9f02f29639b955484568f283e5c7661f25..fb32aa51533e46c0bb0a2aa52bb3bfe2ba1e1609 100644 (file)
@@ -12,6 +12,7 @@
 package org.simantics.sysdyn.ui.properties;\r
 \r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.List;\r
 \r
 import org.eclipse.jface.dialogs.MessageDialog;\r
@@ -23,6 +24,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.swt.widgets.Tree;\r
 import org.eclipse.ui.IWorkbenchSite;\r
@@ -35,17 +38,18 @@ import org.simantics.browsing.ui.swt.widgets.impl.Widget;
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\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.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.handlers.RemoveNodeHandler;\r
 import org.simantics.sysdyn.ui.handlers.exports.ExportExternalFunctionFilesHandler;\r
 import org.simantics.sysdyn.ui.handlers.imports.ImportExternalFunctionFilesHandler;\r
-import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.ArrayMap;\r
 import org.simantics.utils.datastructures.Pair;\r
+import org.simantics.utils.threads.SWTThread;\r
 \r
 /**\r
  * Tab for properties of a SysdynModelicaFunction containing all external files added to that function \r
@@ -55,7 +59,11 @@ import org.simantics.utils.datastructures.Pair;
  */\r
 public class ExternalFilesTab extends LabelPropertyTabContributor implements Widget {\r
 \r
-       GraphExplorerComposite externalFilesExplorer;\r
+       public ExternalFilesTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    GraphExplorerComposite externalFilesExplorer;\r
        Button importButton, exportButton, removeButton; \r
        \r
        @Override\r
@@ -77,8 +85,17 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                                Resource.class));\r
 \r
                externalFilesExplorer.setContextMenuId("#ExternalFunctionFileBrowser");\r
+               \r
+               externalFilesExplorer.addListenerToControl(SWT.Selection, new Listener() {\r
+            \r
+            @Override\r
+            public void handleEvent(Event event) {\r
+                updateButtons(externalFilesExplorer);\r
+            }\r
+        });\r
+               \r
                externalFilesExplorer.finish();\r
-\r
+               \r
                GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
                                externalFilesExplorer);\r
                \r
@@ -96,34 +113,26 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                importButton.setText("Import");\r
                importButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
 \r
+                   private Pair<String, String[]> importedFiles; \r
+                   \r
+                   @Override\r
+                   public void beforeApply() {\r
+                Shell shell = importButton.getWidget().getShell();\r
+                importedFiles = ImportExternalFunctionFilesHandler.importFiles(shell, "Import files", ImportExternalFunctionFilesHandler.C_EXTENSIONS);                        \r
+                   }\r
+                   \r
                        @Override\r
-                       public void apply(WriteGraph graph, final Resource input)\r
-                                       throws DatabaseException {\r
-                               \r
-                               importButton.getWidget().getDisplay().asyncExec(new Runnable() {\r
-                                       \r
-                                       @Override\r
-                                       public void run() {\r
-                                               Shell shell = importButton.getWidget().getShell();\r
-                                               \r
-                                               final Pair<String, String[]> importedFiles = ImportExternalFunctionFilesHandler.importFiles(shell, "Import files", ImportExternalFunctionFilesHandler.C_EXTENSIONS);\r
-                                               \r
-                                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
-\r
-                                                       @Override\r
-                                                       public void perform(WriteGraph graph) throws DatabaseException {\r
-                                                               ImportExternalFunctionFilesHandler.addFilesToFunction(graph, input, importedFiles);\r
-                                                       }\r
-                                               });\r
-                                       }\r
-                               });\r
-\r
-\r
+                       public void apply(WriteGraph graph, final Resource input) throws DatabaseException {\r
+                           graph.markUndoPoint();\r
+                ImportExternalFunctionFilesHandler.addFilesToFunction(graph, input, importedFiles);\r
+                Layer0Utils.addCommentMetadata(graph, "Imported External File(s) " + Arrays.toString(importedFiles.second) + " to " + NameUtils.getSafeName(graph, input));\r
+                updateButtons(externalFilesExplorer);\r
                        }\r
                });\r
 \r
                exportButton = new Button(buttonRow, support, SWT.NONE);\r
                exportButton.setText("Export");\r
+               exportButton.getControl().setEnabled(false);\r
                exportButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
 \r
                        @Override\r
@@ -141,39 +150,46 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                                                        ExportExternalFunctionFilesHandler.exportFiles(shell, resources);\r
                                        }\r
                                });\r
-\r
-\r
                        }\r
                });\r
 \r
                removeButton = new Button(buttonRow, support, SWT.NONE);\r
                removeButton.setText("Remove");\r
+               removeButton.getControl().setEnabled(false);\r
                removeButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
 \r
+                   private int delete;\r
+                   private List<Resource> resourceList;\r
+                   \r
+                   @Override\r
+                   public void beforeApply() {\r
+                Shell shell = removeButton.getWidget().getShell();\r
+\r
+                resourceList = getSelectedResources(externalFilesExplorer);\r
+                Resource[] resources = resourceList.toArray(new Resource[resourceList.size()]);\r
+                if(resources.length > 0) {\r
+                    MessageDialog dialog = new MessageDialog(shell, resources.length > 1 ? "Remove selected items" : "Remove selected item" , null, "Are you sure?", 0,\r
+                            new String[] { "OK", "Cancel" }, 0);\r
+                    dialog.create();\r
+                    delete = dialog.open();\r
+                }\r
+                   }\r
+                   \r
                        @Override\r
-                       public void apply(WriteGraph graph, final Resource input)\r
-                       throws DatabaseException {\r
-\r
-                               removeButton.getWidget().getDisplay().asyncExec(new Runnable() {\r
-\r
-                                       @Override\r
-                                       public void run() {\r
-                                               Shell shell = removeButton.getWidget().getShell();\r
-\r
-                                               List<Resource> resourceList = getSelectedResources(externalFilesExplorer);\r
-                                               Resource[] resources = resourceList.toArray(new Resource[resourceList.size()]);\r
-                                               if(resources.length > 0) {\r
-                                                       MessageDialog dialog = new MessageDialog(shell, resources.length > 1 ? "Remove selected items" : "Remove selected item" , null, "Are you sure?", 0,\r
-                                                                       new String[] { "OK", "Cancel" }, 0);\r
-                                                       dialog.create();\r
-                                                       if (dialog.open() == 0) {\r
-                                                               RemoveNodeHandler.deleteItem(resources);\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               });\r
-\r
-\r
+                       public void apply(WriteGraph graph, final Resource input) throws DatabaseException {\r
+                           if (delete == 0) {\r
+                    Resource[] resources = resourceList.toArray(new Resource[resourceList.size()]);\r
+                    StringBuilder sb = new StringBuilder();\r
+                    sb.append("Removed External File(s) ");\r
+                    for (Resource resource : resources) {\r
+                        RemoverUtil.remove(graph, resource);\r
+                        sb.append(NameUtils.getSafeName(graph, resource) + " ");\r
+                    }\r
+                    sb.append("from " + NameUtils.getSafeName(graph, input));\r
+                    Layer0Utils.addCommentMetadata(graph, sb.toString());\r
+                    \r
+                    updateButtons(externalFilesExplorer);\r
+                           }\r
                        }\r
                });\r
        }\r
@@ -181,6 +197,7 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
        @Override\r
        public void setInput(ISessionContext context, Object input) {\r
                externalFilesExplorer.setInput(context, input);\r
+               updateButtons(externalFilesExplorer);\r
        }\r
 \r
        /**\r
@@ -190,7 +207,6 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
         */\r
        private List<Resource> getSelectedResources(GraphExplorerComposite explorer) {\r
                List<Resource> result = new ArrayList<Resource>();\r
-               \r
                ISelection selection = ((ISelectionProvider) explorer\r
                                .getAdapter(ISelectionProvider.class)).getSelection();\r
                if (selection == null)\r
@@ -204,5 +220,30 @@ public class ExternalFilesTab extends LabelPropertyTabContributor implements Wid
                }\r
                return result;\r
        }\r
-\r
+       \r
+       protected void updateButtons(final GraphExplorerComposite explorer) {\r
+           if (SWTThread.getThreadAccess().currentThreadAccess()) {\r
+               runnable.run();\r
+           } else {\r
+               SWTThread.getThreadAccess().asyncExec(runnable);\r
+           }\r
+       }\r
+       \r
+       Runnable runnable = new Runnable() {\r
+        \r
+        @Override\r
+        public void run() {\r
+            ISelection selection = ((ISelectionProvider) externalFilesExplorer.getAdapter(ISelectionProvider.class)).getSelection();\r
+            \r
+            IStructuredSelection iss = (IStructuredSelection) selection;\r
+            @SuppressWarnings("unchecked")\r
+            List<AdaptableHintContext> selections = iss.toList();\r
+            \r
+            boolean enabled = false;\r
+            if (!selections.isEmpty()) \r
+                enabled = true;\r
+            removeButton.getControl().setEnabled(enabled);\r
+            exportButton.getControl().setEnabled(enabled);\r
+        }\r
+    };\r
 }\r
index 885d4ab9acba53fd4be90a538e3e922254372aeb..1eee34ca7c963d1c28c27a49fb1279393712c21b 100644 (file)
@@ -33,6 +33,10 @@ import org.simantics.sysdyn.ui.elements.connections.FlowConnectionStyle;
 \r
 public class FlowTab  extends LabelPropertyTabContributor {\r
 \r
+    public FlowTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     Scale lineThicknessScale;\r
     \r
     @Override\r
index 9704d07480cbdca5ade31ec5865eb13b37033fbc..567d57bb30edc4b7330574ae58be3bed7948e661 100644 (file)
@@ -27,7 +27,11 @@ import org.simantics.sysdyn.ui.properties.widgets.factories.FunctionLibraryNameI
 \r
 public class FunctionLibraryTab extends LabelPropertyTabContributor {\r
 \r
-       @Override\r
+       public FunctionLibraryTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    @Override\r
        public void createControls(Composite body, IWorkbenchSite site,\r
                        ISessionContext context, WidgetSupport support) {\r
                Composite composite = new Composite(body, SWT.NONE);\r
index c20ede211a543439d3f5ec07e20ebe3d9a189c2d..c4564eaf2bfb3f03738da6a10054244eb9f44841 100644 (file)
@@ -22,17 +22,26 @@ import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;
 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
 import org.simantics.browsing.ui.swt.widgets.TrackedText;\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.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.db.request.Read;\r
 import org.simantics.jfreechart.chart.properties.AdjustableTab;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionField;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.FunctionNameInputValidator;\r
 import org.simantics.sysdyn.ui.properties.widgets.functions.FunctionCodeWidget;\r
+import org.simantics.sysdyn.utils.SelectionUtils;\r
 \r
 public class FunctionTab extends AdjustableTab {\r
        \r
-       ExpressionField modelicaCode;\r
+       public FunctionTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    ExpressionField modelicaCode;\r
        private TrackedText nameText;\r
        private Group modelicaGroup;\r
        private Label startLabel;\r
@@ -81,6 +90,23 @@ public class FunctionTab extends AdjustableTab {
         information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);\r
         information.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasDescription));\r
         information.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasDescription));\r
+        \r
+        if (id instanceof Resource) {\r
+            final Resource r = (Resource) id;\r
+            try {\r
+                boolean editable = context.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+                    @Override\r
+                    public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+                        return SelectionUtils.canEdit(graph, r);\r
+                    }\r
+                });\r
+                information.setEditable(editable);\r
+                nameText.setEditable(editable);\r
+            } catch (DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
        }\r
 \r
        @Override\r
index 8e26cc3fd28aee2b56263f536cac5a7e1e2fe66a..ea4941fefba7f6b3b4cb25dff57942fd4ae44282 100644 (file)
@@ -29,7 +29,11 @@ import org.simantics.utils.ui.validators.DoubleValidator;
  */\r
 public class GameExperimentTab extends LabelPropertyTabContributor {\r
 \r
-       @Override\r
+       public GameExperimentTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    @Override\r
        public void createControls(Composite body, IWorkbenchSite site,\r
                ISessionContext context, WidgetSupport support) {\r
                \r
index ceed5ad2b8d3614dfd9c789e90e0d00db77abe87..2b4883eaa9dbd7fddd047d2d20bd4113d6d039e8 100644 (file)
@@ -63,6 +63,10 @@ import org.simantics.utils.ui.ISelectionUtils;
  */\r
 public class HistoryDataTab  extends LabelPropertyTabContributor {\r
 \r
+    public HistoryDataTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         \r
index fd5480ee1a85067ae3217526ca70aed6f13211a1..5da056d0197e1cbcd8f63659bfd37c349a8f0b57 100644 (file)
@@ -41,8 +41,8 @@ import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;
 import org.simantics.sysdyn.ui.properties.widgets.UnitComboWidget;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
-import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNameInputValidator;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.VariableNamePropertyModifier;\r
 import org.simantics.utils.datastructures.Pair;\r
 import org.simantics.utils.ui.validators.DoubleValidator;\r
 \r
@@ -55,6 +55,10 @@ import org.simantics.utils.ui.validators.DoubleValidator;
 public class InputVariableTab  extends LabelPropertyTabContributor {\r
 \r
     \r
+    public InputVariableTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         Composite composite = new Composite(body, SWT.NONE);\r
index 25de7c92510661e9319fd70ecde046426acc52fb..ec059e69ede6e62c92229268dd4519b146cfa686 100644 (file)
@@ -28,7 +28,11 @@ import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactor
 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
 \r
 public class LookupTableTab extends LabelPropertyTabContributor {\r
-    \r
+\r
+    public LookupTableTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
 \r
index ee43cbb41ce1bf911988fb94fd8236a95be24a9a..ffec528decaa477402c6786ffc26e13b374b13c0 100644 (file)
@@ -56,7 +56,11 @@ import org.simantics.utils.datastructures.Triple;
  */\r
 public class LoopTab extends AdjustableTab {\r
 \r
-       private Label loopItemsLabel;\r
+       public LoopTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    private Label loopItemsLabel;\r
        private TrackedCombo loopItemsDropdown;\r
        Button auto, balancing, reinforcing, other, inside, outside;\r
     TrackedText loopComment, polarityLocationText;\r
@@ -64,8 +68,8 @@ public class LoopTab extends AdjustableTab {
     Group commentGroup, rotationGroup;\r
        protected Resource resource;\r
        public static final String AUTO = "$$AUTO$$";\r
-       \r
-       @Override\r
+\r
+    @Override\r
        protected void createAndAddControls(Composite body, IWorkbenchSite site,\r
                        ISessionContext context, WidgetSupport support) {\r
                composite = new Composite(body, SWT.NONE);\r
@@ -402,5 +406,4 @@ public class LoopTab extends AdjustableTab {
             return true;\r
         }\r
     }\r
-\r
 }\r
index 320fb9075610b76598d337930e24734e2a2555b5..0455d0e35207885f9474850c5f70b73d24d651b8 100644 (file)
@@ -36,6 +36,10 @@ import org.simantics.sysdyn.ui.properties.widgets.modules.RowProvider;
 \r
 public class ModuleInputTab extends LabelPropertyTabContributor {\r
 \r
+    public ModuleInputTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     public static final String FIRSTCOLUMN = "Input in Module";\r
     public static final String SECONDCOLUMN = "Refers to output";\r
     \r
index 9691f7e7c6c49cf8418eee27a980d555efa031cb..d35bc40675dfa073f0b9abc705ce1ba322484a64 100644 (file)
@@ -36,6 +36,10 @@ import org.simantics.sysdyn.ui.properties.widgets.modules.RowProvider;
 \r
 public class ModuleOutputTab extends LabelPropertyTabContributor {\r
 \r
+    public ModuleOutputTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     public static final String FIRSTCOLUMN = "Output in module";\r
     public static final String SECONDCOLUMN = "Referes to input";\r
     \r
index 5e3f1246c656f6d88fd10289c510dcbf0ac2237a..e80cf2059479bec174a04df21f9bd5473da1f673 100644 (file)
@@ -30,6 +30,10 @@ import org.simantics.utils.datastructures.ArrayMap;
 \r
 public class ModuleParameterTab extends LabelPropertyTabContributor {\r
 \r
+    public ModuleParameterTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     GraphExplorerComposite explorer;\r
     \r
     @Override\r
index 64a558bf07e2b83408d77a3c091c9f0be48db390..0a6ed5360766868e025ce7a6557d0ef933b9614a 100644 (file)
@@ -37,7 +37,12 @@ import org.simantics.utils.datastructures.ArrayMap;
 \r
 public class ModuleTab extends LabelPropertyTabContributor implements Widget {\r
 \r
-       GraphExplorerComposite enumerationRedeclarationExplorer;\r
+       public ModuleTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+\r
+    GraphExplorerComposite enumerationRedeclarationExplorer;\r
        \r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
index 918dafd21d33749134b27bec6018e17eb11c0077..69976cc3362a32ea9cf174c2dcf3335d087a4a8a 100644 (file)
@@ -27,6 +27,10 @@ import org.simantics.sysdyn.ui.properties.widgets.factories.ModuleTypeNameInputV
 \r
 public class ModuleTypeTab extends LabelPropertyTabContributor {\r
 \r
+    public ModuleTypeTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         Composite composite = new Composite(body, SWT.NONE);\r
index a1038bc5050275f6e9329736f4bdb96ec74f9a32..0c595db958a88e6f034b9f1f8b6967825658891b 100644 (file)
@@ -43,6 +43,10 @@ import org.simantics.utils.ui.color.ColorValue;
 \r
 public class PlaybackExperimentTab extends LabelPropertyTabContributor {\r
 \r
+    public PlaybackExperimentTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     private static int gradientWidth = 250;\r
     private static int gradientHeight = 20;\r
 \r
index 55c4ce956db5632e86670bc04946af75cd70f686..369a8da42be1f2d91b73048201930de15f958297 100644 (file)
@@ -19,6 +19,10 @@ import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;
 \r
 public class ReferenceDependencyTab extends LabelPropertyTabContributor {\r
 \r
+    public ReferenceDependencyTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
     }\r
index 49407d6bbd459f0590427f117e4d0207f17a8632..ab129cfb2a160126fb4d5fdefb20720215460fca 100644 (file)
@@ -44,6 +44,7 @@ import org.simantics.sysdyn.JFreeChartResource;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.SharedFunctionsFolder;\r
 import org.simantics.sysdyn.ui.trend.SensitivityChartAxisAndVariablesTab;\r
+import org.simantics.sysdyn.utils.SelectionUtils;\r
 import org.simantics.ui.selection.AnyVariable;\r
 import org.simantics.ui.selection.WorkbenchSelectionElement;\r
 import org.simantics.utils.ui.AdaptionUtils;\r
@@ -114,14 +115,14 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 if (!variables.isEmpty())\r
                        // Do we have at least one variable\r
                        tabs.add(new ComparableTabContributor(\r
-                               new ArrayIndexesTab(),\r
+                               new ArrayIndexesTab(variables),\r
                                1,\r
                                variables,\r
                                "Indexes"));\r
                 else if (!dependencies.isEmpty()) {\r
                     // Dependencies only\r
                        tabs.add(new ComparableTabContributor(\r
-                            new ArrayDependencyTab(),\r
+                            new ArrayDependencyTab(dependencies),\r
                             1,\r
                             dependencies,\r
                             "Dependency Properties"));\r
@@ -129,7 +130,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 else if (!flows.isEmpty()) {\r
                     // Flows only\r
                        tabs.add(new ComparableTabContributor(\r
-                            new ArrayFlowTab(),\r
+                            new ArrayFlowTab(flows),\r
                             1,\r
                             flows,\r
                             "Flow Properties"));\r
@@ -165,7 +166,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 SharedFunctionsFolder sff = AdaptionUtils.adaptToSingle(selection, SharedFunctionsFolder.class);\r
                 if (sff != null) {\r
                     return Collections.singleton(new ComparableTabContributor(\r
-                            new SharedFunctionLibrariesTab(),\r
+                            new SharedFunctionLibrariesTab(sff.data),\r
                             2,\r
                             sff.data,\r
                             "Shared Functions"));\r
@@ -179,7 +180,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 NodeType type = nc.getConstant(NodeType.TYPE);\r
                 if(type != null && type.equals(sharedFunctionsTestNode)) {\r
                     return Collections.singleton(new ComparableTabContributor(\r
-                            new SharedFunctionLibrariesTab(),\r
+                            new SharedFunctionLibrariesTab(r),\r
                             2,\r
                             r,\r
                             "Shared Functions"));\r
@@ -225,7 +226,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if(backend.isInstanceOf(r, sr.Loop)) {\r
                return Collections.singleton(\r
                                (new ComparableTabContributor(\r
-                               new LoopTab(),\r
+                               new LoopTab(r),\r
                                1,\r
                                r,\r
                                "Loop")));\r
@@ -249,27 +250,27 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                     expression = expressionList.get(0);\r
                 }\r
                 tabs.add(new ComparableTabContributor(\r
-                        new EquationTab(),\r
+                        new EquationTab(var != null ? var : r),\r
                         3,\r
                         var != null ? var : r,\r
                         "Equation"));\r
                 if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
                     // WithLookupExpression has its own extra tab for visual configuration\r
                     tabs.add(new ComparableTabContributor(\r
-                            new LookupTableTab(),\r
+                            new LookupTableTab(expression),\r
                             2,\r
                             expression,\r
                             "Lookup Table"));\r
                 }\r
 \r
                 tabs.add(new ComparableTabContributor(\r
-                        new ArrayIndexesTab(),\r
+                        new ArrayIndexesTab(r),\r
                         1,\r
                         r,\r
                         "Indexes"));\r
 \r
                 tabs.add(new ComparableTabContributor(\r
-                        new VariableInformationTab(),\r
+                        new VariableInformationTab(r),\r
                         0,\r
                         r,\r
                         "Additional Information"));\r
@@ -279,19 +280,19 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             // Input variable\r
             if (backend.isInstanceOf(r, sr.Input)) {\r
                 tabs.add(new ComparableTabContributor(\r
-                        new InputVariableTab(),\r
+                        new InputVariableTab(r),\r
                         2,\r
                         r,\r
                         "Input"));\r
 \r
                 tabs.add(new ComparableTabContributor(\r
-                        new ArrayIndexesTab(),\r
+                        new ArrayIndexesTab(r),\r
                         1,\r
                         r,\r
                         "Indexes"));\r
 \r
                 tabs.add(new ComparableTabContributor(\r
-                        new VariableInformationTab(),\r
+                        new VariableInformationTab(r),\r
                         0,\r
                         r,\r
                         "Additional Information"));\r
@@ -305,7 +306,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                     s = r;\r
                 // give either variable or the actual resource\r
                 return Collections.singleton(new ComparableTabContributor(\r
-                        new EnumerationTab(),\r
+                        new EnumerationTab(s),\r
                         2,\r
                         s,\r
                         "Enumeration"));\r
@@ -318,7 +319,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 if (r != null)\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
-                                    new ConfigurationTab(),\r
+                                    new ConfigurationTab(r),\r
                                     0,\r
                                     r,\r
                                     "Model Properties"));\r
@@ -327,22 +328,22 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             // Module\r
             if (backend.isInstanceOf(r, sr.Module)){\r
                 tabs.add(new ComparableTabContributor(\r
-                        new ModuleTab(),\r
+                        new ModuleTab(r),\r
                         10,\r
                         r,\r
                         "Module Properties"));\r
                 tabs.add(new ComparableTabContributor(\r
-                        new ModuleParameterTab(),\r
+                        new ModuleParameterTab(r),\r
                         9,\r
                         r,\r
                         "Parameters"));\r
                 tabs.add(new ComparableTabContributor(\r
-                        new ModuleInputTab(),\r
+                        new ModuleInputTab(r),\r
                         2,\r
                         r,\r
                         "Inputs"));\r
                 tabs.add(new ComparableTabContributor(\r
-                        new ModuleOutputTab(),\r
+                        new ModuleOutputTab(r),\r
                         1,\r
                         r,\r
                         "Outputs"));\r
@@ -353,7 +354,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.PlaybackExperiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new PlaybackExperimentTab(),\r
+                                new PlaybackExperimentTab(r),\r
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
@@ -362,7 +363,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.GameExperiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new GameExperimentTab(),\r
+                                new GameExperimentTab(r),\r
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
@@ -371,7 +372,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.SensitivityAnalysisExperiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new SensitivityAnalysisExperimentTab(),\r
+                                new SensitivityAnalysisExperimentTab(r),\r
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
@@ -380,7 +381,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, simu.Experiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new ExperimentTab(),\r
+                                new ExperimentTab(r),\r
                                 0,\r
                                 r,\r
                                 "Experiment Properties"));\r
@@ -389,7 +390,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.HistoryDataset))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new HistoryDataTab(),\r
+                                new HistoryDataTab(r),\r
                                 0,\r
                                 r,\r
                                 "History Data Properties"));\r
@@ -398,7 +399,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.Result))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new ResultTab(),\r
+                                new ResultTab(r),\r
                                 0,\r
                                 r,\r
                                 "Result Properties"));\r
@@ -409,7 +410,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                     Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
-                                    new DependencyTab(),\r
+                                    new DependencyTab(diaConnection),\r
                                     0,\r
                                     diaConnection,\r
                                     "Reference Properties"));\r
@@ -417,7 +418,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                     Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
-                                    new DependencyTab(),\r
+                                    new DependencyTab(diaConnection),\r
                                     0,\r
                                     diaConnection,\r
                                     "Dependency Properties"));\r
@@ -428,7 +429,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                Resource diaConnection = backend.getPossibleObject(r, ModelingResources.getInstance(backend).ConnectionToDiagramConnection);\r
                return Collections.singleton(\r
                        new ComparableTabContributor(\r
-                                       new FlowTab(),\r
+                                       new FlowTab(diaConnection),\r
                                        0,\r
                                        diaConnection,\r
                                        "Flow Properties"));\r
@@ -441,7 +442,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                 if(r != null)\r
                     return Collections.singleton(\r
                             new ComparableTabContributor(\r
-                                    new ModuleTypeTab(),\r
+                                    new ModuleTypeTab(r),\r
                                     0,\r
                                     r,\r
                                     "Module Type Properties"));\r
@@ -450,15 +451,17 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             // Function\r
             if (backend.isInstanceOf(r, sr.SysdynModelicaFunction)) {\r
                 tabs.add(new ComparableTabContributor(\r
-                        new FunctionTab(),\r
+                        new FunctionTab(r),\r
                         2,\r
                         r,\r
                         "Function"));\r
-                tabs.add(new ComparableTabContributor(\r
-                        new ExternalFilesTab(),\r
+                if (SelectionUtils.canEdit(backend, r)) {\r
+                    tabs.add(new ComparableTabContributor(\r
+                        new ExternalFilesTab(r),\r
                         1,\r
                         r,\r
                         "External files"));\r
+                }\r
                 return tabs;\r
             }\r
 \r
@@ -469,7 +472,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                     s = r;\r
                 // give either variable or the actual resource\r
                 return Collections.singleton(new ComparableTabContributor(\r
-                        new FunctionLibraryTab(),\r
+                        new FunctionLibraryTab(s),\r
                         2,\r
                         s,\r
                         "Function library"));\r
@@ -489,7 +492,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
             if (backend.isInstanceOf(r, sr.AdditionalSymbols_MultilineText))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
-                                new CommentTab(),\r
+                                new CommentTab(r),\r
                                 0,\r
                                 r,\r
                                 "Comment"));\r
@@ -519,17 +522,17 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
 \r
                 if(backend.isInstanceOf(plot, SysdynResource.getInstance(backend).Charts_SensitivityPlot)) {\r
                     tabs.add(new ComparableTabContributor(\r
-                            new XYLineGeneralPropertiesTab(),\r
+                            new XYLineGeneralPropertiesTab(r),\r
                             10,\r
                             r,\r
                             "General"));\r
                     tabs.add(new ComparableTabContributor(\r
-                            new SensitivityChartAxisAndVariablesTab(),\r
+                            new SensitivityChartAxisAndVariablesTab(r),\r
                             9,\r
                             r,\r
                             "Axis and Variables"));\r
                     tabs.add(new ComparableTabContributor(\r
-                            new ChartTab(),\r
+                            new ChartTab(r),\r
                             1,\r
                             r,\r
                             "Chart"));\r
index fee1f4c97a33e36e1b546f22bbd0b8aae3149992..0fff894541ee342775be7f4de37ecf7a83136a12 100644 (file)
@@ -19,6 +19,10 @@ import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;
 \r
 public class ResultTab extends LabelPropertyTabContributor {\r
 \r
+    public ResultTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     @Override\r
     public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
         \r
index ee1a45557a907e69313ceeb08fc284ef106804ef..60b3fdc200ce8c2342dad4e1513f429b50f7b9a2 100644 (file)
@@ -95,6 +95,10 @@ import org.simantics.utils.ui.validators.IntegerValidator;
  */\r
 public class SensitivityAnalysisExperimentTab extends AdjustableTab implements Widget {\r
 \r
+    public SensitivityAnalysisExperimentTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     private GraphExplorerComposite explorer;\r
     private WidgetSupportImpl parameterSupport = new WidgetSupportImpl();\r
     private ScrolledComposite propertyContainer;\r
index ac3d2e74d738b9a6dde7490362c12678c2df8b81..a130a91c2e0f21f642c3a9d0fc88481600bd4e5a 100644 (file)
@@ -36,7 +36,9 @@ import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
 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.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
 import org.simantics.layer0.Layer0;\r
@@ -48,7 +50,11 @@ import org.simantics.utils.ui.AdaptionUtils;
 \r
 public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor implements Widget {\r
        \r
-       GraphExplorerComposite availableSharedFunctionLibraries;\r
+       public SharedFunctionLibrariesTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
+    GraphExplorerComposite availableSharedFunctionLibraries;\r
        GraphExplorerComposite usedSharedFunctionLibraries;\r
        Resource model;\r
 \r
@@ -126,9 +132,14 @@ public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor impl
                            throws DatabaseException {\r
                        if(selectedLibraries != null) {\r
                            Layer0 l0 = Layer0.getInstance(graph);\r
-                           for(Resource library : selectedLibraries) {\r
-                               graph.claim(input, l0.IsLinkedTo, library);\r
-                           }\r
+                    StringBuilder sb = new StringBuilder();\r
+                    sb.append("Added Shared Function Library ");\r
+                    for(Resource library : selectedLibraries) {\r
+                        graph.claim(input, l0.IsLinkedTo, library);\r
+                        sb.append(NameUtils.getSafeName(graph, library) + " ");\r
+                    }\r
+                    sb.append("to " + NameUtils.getSafeName(graph, input));\r
+                    Layer0Utils.addCommentMetadata(graph,  sb.toString());\r
                        }\r
                    }\r
                });\r
@@ -149,9 +160,14 @@ public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor impl
                                throws DatabaseException {\r
                            if(selectedLibraries != null) {\r
                                Layer0 l0 = Layer0.getInstance(graph);\r
+                               StringBuilder sb = new StringBuilder();\r
+                               sb.append("Removed Shared Function Library ");\r
                                for(Resource library : selectedLibraries) {\r
                                    graph.deny(input, l0.IsLinkedTo, library);\r
+                                   sb.append(NameUtils.getSafeName(graph, library) + " ");\r
                                }\r
+                               sb.append("from " + NameUtils.getSafeName(graph, input));\r
+                               Layer0Utils.addCommentMetadata(graph,  sb.toString());\r
                            }\r
                        }\r
                });\r
@@ -234,6 +250,5 @@ public class SharedFunctionLibrariesTab extends LabelPropertyTabContributor impl
                usedSharedFunctionLibraries.setInput(context, input);\r
                this.model = AdaptionUtils.adaptToSingle(input, Resource.class);\r
        }\r
-\r
 }\r
 \r
index 2e4fc80143161a57c5e6d248f80b9e2242886e37..bb66b6e4f031d938f2c697840b66bcfebeab1d78 100644 (file)
@@ -40,6 +40,7 @@ import org.simantics.db.Resource;
 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.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
@@ -68,6 +69,11 @@ import org.simantics.utils.ui.validators.DoubleValidator;
  *\r
  */\r
 public class VariableInformationTab extends AdjustableTab implements Widget {\r
+    \r
+    public VariableInformationTab(Object id) {\r
+        super(id);\r
+    }\r
+\r
     private Composite orientationComposite;\r
     private WidgetSupport support;\r
     private Resource component;\r
@@ -349,15 +355,23 @@ public class VariableInformationTab extends AdjustableTab implements Widget {
 \r
             @Override\r
             public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                graph.markUndoPoint();\r
                 Resource element = graph.getPossibleObject(input, ModelingResources.getInstance(graph).ComponentToElement);\r
                 if(element != null) {\r
                     G2DResource g2d = G2DResource.getInstance(graph);\r
                     graph.deny(element, g2d.HasFont);\r
-                    if(f != null)\r
+                    StringBuilder sb = new StringBuilder();\r
+                    if(f != null) {\r
                         graph.claim(element, g2d.HasFont, G2DUtils.createFont(graph, f));\r
+                        sb.append(" font to " + f.getName());\r
+                    }\r
                     graph.deny(element, g2d.HasColor);\r
-                    if(color != null)\r
+                    if(color != null) {\r
                         graph.claim(element,  g2d.HasColor, G2DUtils.createColor(graph, color));\r
+                        sb.append(" color to " + color.getRGB());\r
+                    }\r
+                    sb.insert(0, "Modified");\r
+                    Layer0Utils.addCommentMetadata(graph, sb.toString());\r
                 }\r
             }\r
 \r
@@ -428,5 +442,4 @@ public class VariableInformationTab extends AdjustableTab implements Widget {
         GridDataFactory.fillDefaults().applyTo(fontComposite);\r
         GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fontComposite);\r
        }\r
-\r
 }\r
index e5d4e0eca7cb2beccd440ead451844e8d236a6cb..d13f3e6ba68c5f2307f9ae75520dde184b8adb93 100644 (file)
@@ -22,12 +22,15 @@ import org.eclipse.swt.widgets.Composite;
 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 \r
@@ -155,8 +158,10 @@ public class DelayMarkWidget implements Widget{
                 final SysdynResource sr =  SysdynResource.getInstance(graph);\r
                 if(graph.hasStatement(input, sr.DependencyConnection_delayMark)) {\r
                            graph.deny(input, sr.DependencyConnection_delayMark);\r
+                           Layer0Utils.addCommentMetadata(graph, "Modified Delay mark for connection " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to False");\r
                        } else {\r
                            graph.claim(input, SysdynResource.getInstance(graph).DependencyConnection_delayMark, null, input);\r
+                           Layer0Utils.addCommentMetadata(graph, "Modified Delay mark for connection " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to True");\r
                        }\r
             }  \r
         });\r
index 5297182de0526ce2a9452f5d4241e066dd4f76dc..db9a513fde029e4b89e5ee308ca9374a56a05931 100644 (file)
@@ -19,12 +19,15 @@ import org.eclipse.swt.widgets.Composite;
 import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
 import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 \r
@@ -88,8 +91,10 @@ public class IsOutputWidget implements Widget{
                 SysdynResource sr =  SysdynResource.getInstance(graph);\r
                 if(graph.hasStatement(input, sr.IsOutput)) {\r
                     graph.deny(input, sr.IsOutput);\r
+                    Layer0Utils.addCommentMetadata(graph, "Modified Is Output for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to False");\r
                 } else {\r
                     graph.claim(input, SysdynResource.getInstance(graph).IsOutput, null, input);\r
+                    Layer0Utils.addCommentMetadata(graph, "Modified Is Output for " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING) + " to True");\r
                 }\r
             }\r
         });\r
index 12ad3c80a5a20901cbb3bdf9c8d992de6941d0d9..a1c654953e8056e6951790ebf254a8797e3b9869 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.text.BadLocationException;\r
 import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusListener;\r
@@ -236,4 +237,10 @@ public class BasicExpression implements IExpression {
        public void addVerifyKeyListener(VerifyKeyListener listener) {\r
                this.expression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
        }\r
+\r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
 }\r
index e6b1962641bb1f6efa6979dfd0359f66b435568a..5e778c926986ca0c95076deb0f9061335813117a 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.text.BadLocationException;\r
 import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusAdapter;\r
@@ -382,4 +383,10 @@ public class DelayExpression implements IExpression {
         this.initialValue.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
     }\r
 \r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+\r
 }\r
index f36fac969ddd6c15999b7127893636b6e7924e39..8a382746ad91d2b02873da773e80aaabefb2ab2b 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.sysdyn.ui.properties.widgets.expressions;
 import java.util.List;\r
 import java.util.Map;\r
 \r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.KeyListener;\r
@@ -90,4 +91,10 @@ public class EmptyExpression implements IExpression {
                \r
        }\r
 \r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+\r
 }\r
index c2c6eff032a4d4dfc3d850477ed88e62dea368cc..bd0b0b71d0c67c7e6e0f68cef76cc6f67c01dddd 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.sysdyn.ui.properties.widgets.expressions;
 import java.util.List;\r
 import java.util.Map;\r
 \r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.KeyListener;\r
@@ -45,4 +46,6 @@ public interface IExpression {
     public void addVerifyKeyListener(VerifyKeyListener listener);\r
 \r
     public void addFocusListener(FocusListener listener);\r
+    \r
+    public IUndoManager getUndoManager();\r
 }\r
index cf0f2304215d8cd5d00e198aacda42812ca2bc2a..db7311b382f86c7a8072c9c48fb6240eff03ad9e 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.sysdyn.ui.properties.widgets.expressions;
 import java.util.List;\r
 import java.util.Map;\r
 \r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.KeyListener;\r
@@ -90,4 +91,10 @@ public class LookupExpression implements IExpression {
                \r
        }\r
 \r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+\r
 }\r
index d92c9a1a96ebb6fe7ae2ca8a6ecca3b74f6e9dfa..14f87e966c5bbb535a650126c394ea38df230d1e 100644 (file)
@@ -19,6 +19,8 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.text.BadLocationException;\r
 import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.IUndoManager;\r
+import org.eclipse.jface.text.TextViewerUndoManager;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
 import org.eclipse.swt.events.FocusAdapter;\r
@@ -33,6 +35,7 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;\r
 import org.eclipse.swt.widgets.Listener;\r
 import org.eclipse.swt.widgets.Table;\r
+import org.simantics.Simantics;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
@@ -42,6 +45,7 @@ import org.simantics.db.common.request.ReadRequest;
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
@@ -50,7 +54,6 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Valve;\r
-import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
 public class StockExpression implements IExpression {\r
@@ -58,6 +61,7 @@ public class StockExpression implements IExpression {
     private final ExpressionWidgetInput input;\r
     private ExpressionField integralExpression, initialExpression;\r
     private ExpressionField lastSelectedText;\r
+    private TextViewerUndoManager undoManager;\r
     \r
     public StockExpression(ExpressionWidgetInput input) {\r
         this.input = input;\r
@@ -88,6 +92,10 @@ public class StockExpression implements IExpression {
             }\r
         });\r
         \r
+        undoManager = new TextViewerUndoManager(100);\r
+        integralExpression.getSourceViewer().setUndoManager(undoManager);\r
+        undoManager.connect(integralExpression.getSourceViewer());\r
+        \r
         Button defaultButton = new Button(integralComposite, SWT.PUSH);\r
         defaultButton.setText("Use default");\r
         defaultButton.addListener(SWT.Selection, new Listener() {\r
@@ -97,7 +105,7 @@ public class StockExpression implements IExpression {
                        switch (event.type) {\r
                        case SWT.Selection:\r
                                StockExpression.this.integralExpression.setExpression(getDefaultIntegral(input.expression));\r
-                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                               Simantics.getSession().asyncRequest(new WriteRequest() {\r
 \r
                                        @Override\r
                                        public void perform(WriteGraph graph)\r
@@ -152,7 +160,7 @@ public class StockExpression implements IExpression {
         Pair<String, String> equations = null;\r
         if (expression != null && data.get("initialEquation") == null) {\r
                try {\r
-                   equations = SimanticsUI.getSession().syncRequest(new Read<Pair<String, String>>() {\r
+                   equations = Simantics.getSession().syncRequest(new Read<Pair<String, String>>() {\r
        \r
                        @Override\r
                        public Pair<String, String> perform(ReadGraph graph) throws DatabaseException {\r
@@ -176,7 +184,7 @@ public class StockExpression implements IExpression {
 \r
         if (equations.first == null) {\r
                try {\r
-                               SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+                               Simantics.getSession().syncRequest(new WriteRequest() {\r
 \r
                                        @Override\r
                                        public void perform(WriteGraph graph) throws DatabaseException {\r
@@ -197,7 +205,7 @@ public class StockExpression implements IExpression {
         } else {\r
                try {\r
                        final String integral = equations.first;\r
-                               SimanticsUI.getSession().syncRequest(new ReadRequest() {\r
+                               Simantics.getSession().syncRequest(new ReadRequest() {\r
 \r
                                        @Override\r
                                        public void run(ReadGraph graph) throws DatabaseException {\r
@@ -242,7 +250,7 @@ public class StockExpression implements IExpression {
         if(!currentInitial.equals(data.get("initialEquation"))\r
                        || currentIntegral == null\r
                        || !currentIntegral.equals(data.get("integral"))) {\r
-            SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+            Simantics.getSession().asyncRequest(new WriteRequest() {\r
 \r
                 @Override\r
                 public void perform(WriteGraph g)\r
@@ -275,10 +283,11 @@ public class StockExpression implements IExpression {
                     }\r
                     g.claimLiteral(expression, sr.StockExpression_integralEquation, currentIntegral);\r
                     \r
+                    updateData(data);\r
+                    \r
                     g.markUndoPoint();\r
-                               CommentMetadata cm = g.getMetadata(CommentMetadata.class);\r
-                               g.addMetadata(cm.add("Save"));\r
-\r
+                    \r
+                    Layer0Utils.addCommentMetadata(g, "Saved Stock Expression " + currentIntegral + " " + expression.toString() + " with Initial Value " + currentInitial);\r
                 }\r
 \r
             });\r
@@ -336,7 +345,7 @@ public class StockExpression implements IExpression {
         if(expression == null)\r
                return integral;\r
         try {\r
-            integral = SimanticsUI.getSession().syncRequest(new Read<String>() {\r
+            integral = Simantics.getSession().syncRequest(new Read<String>() {\r
 \r
                 @Override\r
                 public String perform(ReadGraph graph) throws DatabaseException {\r
@@ -376,4 +385,9 @@ public class StockExpression implements IExpression {
                this.integralExpression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
        }\r
 \r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        return undoManager;\r
+    }\r
+\r
 }\r
index 66132ab91a2088480ca0eb9d5ef86519d5d6fc76..5051f5c1d72456829a2f3d21e034fd73745d22ee 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.layout.GridLayoutFactory;\r
 import org.eclipse.jface.text.BadLocationException;\r
 import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.IUndoManager;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.awt.SWT_AWT;\r
 import org.eclipse.swt.custom.VerifyKeyListener;\r
@@ -459,4 +460,10 @@ public class WithLookupExpression implements IExpression {
         smallPanel.getChart().getXYPlot().setDataset(dataset);\r
     }\r
 \r
+    @Override\r
+    public IUndoManager getUndoManager() {\r
+        // TODO Auto-generated method stub\r
+        return null;\r
+    }\r
+\r
 }\r
index a029acd377b6b1c556fbe5818fd2d7d7d817ce24..27b49076b190b1cc3475597a4e6ee7b59baa7155 100644 (file)
@@ -52,10 +52,9 @@ abstract public class ComboStringPropertyModifier<T> implements TextModifyListen
                                @SuppressWarnings("unchecked")\r
                 @Override\r
                                public void perform(WriteGraph graph) throws DatabaseException {\r
-\r
+                                   graph.markUndoPoint();\r
                                        T single = (T) ISelectionUtils.filterSingleSelection((ISelection)input, clazz);\r
                                        applyText(graph, single, textValue);\r
-                                       \r
                                }\r
                                \r
                        });\r
index 696f4815d6dd67eb882b9095b7d6d83bfa53a003..18294955d201a52be16b7685d20cd15b5d4c13cd 100644 (file)
@@ -34,6 +34,7 @@ import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.IsParent;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
@@ -152,6 +153,16 @@ public class FunctionCodeWidget implements Widget {
                        });\r
                        if(code != null) {\r
                                modelicaCode.setExpression(code);\r
+                               \r
+                               boolean editable = context.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+                    @Override\r
+                    public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+                        boolean asd = new IsParent(SysdynResource.getInstance(graph).Built$in_Functions, function).perform(graph);\r
+                        return !asd;\r
+                    }\r
+                               });\r
+                           modelicaCode.getSourceViewer().setEditable(editable);\r
                                validate();\r
                        }\r
                } catch (DatabaseException e) {\r
@@ -206,6 +217,10 @@ public class FunctionCodeWidget implements Widget {
        }\r
     \r
     private void save() {\r
+        \r
+        if (!modelicaCode.getSourceViewer().isEditable())\r
+            return;\r
+        \r
        final String code = modelicaCode.getExpression();\r
        \r
        // Update input and output lists.\r
index ab53b0f848129ba6137d01b212db63bb16006818..c414bf94bfbeaa01fb5fa421480b20ba191e1a79 100644 (file)
@@ -48,7 +48,8 @@ public class SensitivityChartAxisAndVariablesTab extends AdjustableTab {
     private ScrolledComposite propertyContainer;\r
     private WidgetSupportImpl additionalSupport;\r
 \r
-    public SensitivityChartAxisAndVariablesTab() {\r
+    public SensitivityChartAxisAndVariablesTab(Object id) {\r
+        super(id);\r
         additionalSupport = new WidgetSupportImpl();\r
     }\r
 \r
index 4be6de7fb3c84a4bea89544775ce618f56e2d9bc..b6c5aed98c451193c622fc0430e9c04524fb536a 100644 (file)
@@ -23,7 +23,9 @@ import org.simantics.databoard.Bindings;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.jfreechart.chart.properties.xyline.SeriesPropertyComposite;\r
 import org.simantics.layer0.Layer0;\r
@@ -81,9 +83,10 @@ public class SensitivitySeriesPropertyComposite extends SeriesPropertyComposite
                 Boolean result = graph.getPossibleRelatedValue(dataset, SR.Charts_SensitivityDataset_median, Bindings.BOOLEAN);\r
                 if(result == null)\r
                     result = false;\r
-                graph.claimLiteral(dataset, SR.Charts_SensitivityDataset_median, Boolean.FALSE.equals(result));\r
+                boolean newValue = Boolean.FALSE.equals(result);\r
+                graph.claimLiteral(dataset, SR.Charts_SensitivityDataset_median, newValue);\r
+                Layer0Utils.addCommentMetadata(graph, "Display Median for " + NameUtils.getSafeName(graph, series) + " to " + newValue);\r
             }\r
-            \r
         });\r
         \r
         Composite c = new Composite(this, SWT.NONE);\r
diff --git a/1.8/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java b/1.8/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/SelectionUtils.java
new file mode 100644 (file)
index 0000000..bb9272c
--- /dev/null
@@ -0,0 +1,24 @@
+package org.simantics.sysdyn.utils;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+/**\r
+ * @author Jani Simomaa\r
+ *\r
+ */\r
+public class SelectionUtils {\r
+\r
+    /**\r
+     * Checks whether <strong>resource</strong> can be edited\r
+     * \r
+     * @param graph\r
+     * @param resource\r
+     * @return\r
+     * @throws DatabaseException\r
+     */\r
+    public static boolean canEdit(ReadGraph graph, Resource resource) throws DatabaseException {\r
+        return !graph.isImmutable(resource);\r
+    }\r
+}\r