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" />
</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
--- /dev/null
+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
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
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
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
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.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
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
}\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
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
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
*******************************************************************************/\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
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
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
\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
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
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
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
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
\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
\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
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
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
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
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
\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
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
@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
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
*/\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
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
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
\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
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
\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
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
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
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
\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
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
\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
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
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
\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
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
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
\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
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
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
\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
\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
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
\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
\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
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
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
\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
\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
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
\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
l0.PartOf, jfreechart,\r
l0.ConsistsOf, dataset\r
);\r
+ Layer0Utils.addCommentMetadata(g, "Created new Pie Chart " + label + " " + jfreechart);\r
+ \r
}\r
\r
});\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.diagram.stubs.G2DResource;\r
import org.simantics.jfreechart.chart.ChartUtils;\r
import org.simantics.layer0.Layer0;\r
\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
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
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
\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
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
\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
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
}\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
GridDataFactory.fillDefaults().span(1, 1).applyTo(lineThicknessGroup);\r
GridLayoutFactory.fillDefaults().applyTo(lineThicknessGroup);\r
}\r
-\r
}\r
\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
return (int)Math.round(FlowConnectionStyle.DEFAULT_LINE_WIDTH * 3);\r
}\r
}\r
-\r
}\r
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
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
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
List<Resource> enumerationResources;\r
\r
@Override\r
- public void beforeApply() {\r
+ public void beforeApply() { \r
enumerationResources = getSelectedResources(availableEnumerationsExplorer);\r
}\r
\r
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
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
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
}\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
}\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
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
});\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
}\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
}\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
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
*/\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
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
*/\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
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
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
*/\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
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
@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
@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
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
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
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
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
);\r
}\r
});\r
+ Layer0Utils.addCommentMetadata(graph, "Deleted Expression " + activeExpression + " from " + graph.getPossibleRelatedValue2(input, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
}\r
});\r
\r
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
\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
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
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
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
*/\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
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
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
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
@Override\r
public void setInput(ISessionContext context, Object input) {\r
externalFilesExplorer.setInput(context, input);\r
+ updateButtons(externalFilesExplorer);\r
}\r
\r
/**\r
*/\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
}\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
\r
public class FlowTab extends LabelPropertyTabContributor {\r
\r
+ public FlowTab(Object id) {\r
+ super(id);\r
+ }\r
+\r
Scale lineThicknessScale;\r
\r
@Override\r
\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
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
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
*/\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
*/\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
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
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
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
*/\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
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
return true;\r
}\r
}\r
-\r
}\r
\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
\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
\r
public class ModuleParameterTab extends LabelPropertyTabContributor {\r
\r
+ public ModuleParameterTab(Object id) {\r
+ super(id);\r
+ }\r
+\r
GraphExplorerComposite explorer;\r
\r
@Override\r
\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
\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
\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
\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
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
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
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
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
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
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
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
// 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
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
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
// 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
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
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
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
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
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
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
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
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
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
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
// 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
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
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
\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
\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
*/\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
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
\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
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
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
usedSharedFunctionLibraries.setInput(context, input);\r
this.model = AdaptionUtils.adaptToSingle(input, Resource.class);\r
}\r
-\r
}\r
\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.db.procedure.Listener;\r
import org.simantics.db.request.Read;\r
*\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
\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
GridDataFactory.fillDefaults().applyTo(fontComposite);\r
GridLayoutFactory.fillDefaults().numColumns(2).applyTo(fontComposite);\r
}\r
-\r
}\r
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
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
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
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
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
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
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
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
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
\r
}\r
\r
+ @Override\r
+ public IUndoManager getUndoManager() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
}\r
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
public void addVerifyKeyListener(VerifyKeyListener listener);\r
\r
public void addFocusListener(FocusListener listener);\r
+ \r
+ public IUndoManager getUndoManager();\r
}\r
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
\r
}\r
\r
+ @Override\r
+ public IUndoManager getUndoManager() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
}\r
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
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
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
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
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
}\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
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
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
\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
} 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
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
}\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
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
this.integralExpression.getSourceViewer().getTextWidget().addVerifyKeyListener(listener);\r
}\r
\r
+ @Override\r
+ public IUndoManager getUndoManager() {\r
+ return undoManager;\r
+ }\r
+\r
}\r
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
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
@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
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
});\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
}\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
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
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
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
--- /dev/null
+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