args="org.simantics.sysdyn.ui.browser.nodes.BarChartNode"\r
property="org.simantics.sysdyn.ui.nodeClass">\r
</test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.VariableNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.EnumerationNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
+ <test\r
+ args="org.simantics.sysdyn.ui.browser.nodes.ModuleNode"\r
+ property="org.simantics.sysdyn.ui.nodeClass">\r
+ </test>\r
<!--\r
<test\r
args="org.simantics.document.workbench.browser_old.DocumentationNode"\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.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\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.ObjectsWithType;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.utils.VariableNameValidator;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.ui.ExceptionUtils;\r
\r
-public class EnumerationNode extends VariableNode<Resource> implements /*IModifiableNode,*/ IDeletableNode {\r
+public class EnumerationNode extends VariableNode<Resource> implements IModifiableNode, IDeletableNode {\r
\r
public EnumerationNode(Resource resource) {\r
super(resource);\r
public EnumerationNode(Variable variable, Resource represents) {\r
super(variable, represents);\r
}\r
- /*\r
+ \r
@Override\r
public Modifier getModifier(String columnId) {\r
\r
- Session session = SimanticsUI.getSession();\r
+ final Session session = SimanticsUI.getSession();\r
LabelModifier modifier = new LabelModifier(session, data, session.getService(Layer0.class).HasName) {\r
@Override\r
public String isValid(String label) {\r
else\r
return null;\r
}\r
+ \r
+ @Override\r
+ public void modify(final String label) {\r
+ try {\r
+ session.syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph)\r
+ throws DatabaseException {\r
+\r
+ String originalName = graph.getRelatedValue(data, Layer0.getInstance(graph).HasName);\r
+ if(!originalName.equals(label)) {\r
+ Resource configuration = graph.getPossibleObject(data, Layer0.getInstance(graph).PartOf);\r
+ new VariableNameValidator().renameInAllEquations(graph, configuration, originalName, label);\r
+ graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label);\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ super.modify(label);\r
+ }\r
};\r
return modifier;\r
- }*/\r
+ }\r
\r
@Override\r
public void delete() throws DeleteException {\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.browser.nodes;\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.db.ReadGraph;\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.ReadRequest;\r
+import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.PasteHandler;\r
import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
import org.simantics.db.layer0.variable.Variable;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.sysdyn.ui.utils.VariableNameValidator;\r
import org.simantics.ui.SimanticsUI;\r
\r
-public class ModuleNode extends ConfigurationNode<Resource>/* implements IModifiableNode*/ {\r
+public class ModuleNode extends ConfigurationNode<Resource> implements IModifiableNode {\r
\r
Resource configuration;\r
\r
return super.getAdapter(adapter);\r
}\r
\r
- /*@Override\r
+ @Override\r
public Modifier getModifier(String columnId) {\r
try {\r
- Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
- LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+ final Session session = SimanticsUI.getSession();\r
+ Resource hasName = Layer0.getInstance(session).HasName;\r
+ LabelModifier modifier = new LabelModifier(session, data, hasName) {\r
@Override\r
public String isValid(String label) {\r
if (!new VariableNameValidator().isValid(data, label))\r
else\r
return null;\r
}\r
+ \r
+ @Override\r
+ public void modify(final String label) {\r
+ try {\r
+ session.syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph)\r
+ throws DatabaseException {\r
+\r
+ String originalName = graph.getRelatedValue(data, Layer0.getInstance(graph).HasName);\r
+ if(!originalName.equals(label)) {\r
+ Resource configuration = graph.getPossibleObject(data, Layer0.getInstance(graph).PartOf);\r
+ new VariableNameValidator().renameInAllEquations(graph, configuration, originalName, label);\r
+ graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label);\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ super.modify(label);\r
+ }\r
};\r
return modifier;\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
}\r
return null;\r
- }*/\r
+ }\r
}\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
import org.simantics.browsing.ui.common.node.AbstractNode;\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.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.DatabaseException;\r
import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.ui.utils.VariableNameValidator;\r
+import org.simantics.ui.SimanticsUI;\r
\r
-public class VariableNode<T> extends AbstractNode<Resource>/* implements IModifiableNode*/ {\r
+public class VariableNode<T> extends AbstractNode<Resource> implements IModifiableNode {\r
\r
Variable variable;\r
\r
return variable;\r
}\r
\r
- /*@Override\r
+ @Override\r
public Modifier getModifier(String columnId) {\r
try {\r
- Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
- LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+ final Session session = SimanticsUI.getSession();\r
+ Resource hasName = Layer0.getInstance(session).HasName;\r
+ LabelModifier modifier = new LabelModifier(session, data, hasName) {\r
@Override\r
public String isValid(String label) {\r
if (!new VariableNameValidator().isValid(data, label))\r
else\r
return null;\r
}\r
+ \r
+ @Override\r
+ public void modify(final String label) {\r
+ try {\r
+ session.syncRequest(new WriteRequest() {\r
+ @Override\r
+ public void perform(WriteGraph graph)\r
+ throws DatabaseException {\r
+\r
+ String originalName = graph.getRelatedValue(data, Layer0.getInstance(graph).HasName);\r
+ if(!originalName.equals(label)) {\r
+ Resource configuration = graph.getPossibleObject(data, Layer0.getInstance(graph).PartOf);\r
+ new VariableNameValidator().renameInAllEquations(graph, configuration, originalName, label);\r
+ graph.claimLiteral(data, Layer0.getInstance(graph).HasName, label);\r
+ }\r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+\r
+ super.modify(label);\r
+ }\r
};\r
return modifier;\r
} catch (DatabaseException e) {\r
e.printStackTrace();\r
}\r
return null;\r
- }*/\r
+ }\r
}\r
\r
@Override\r
public void run() {\r
- if(result != null)\r
+ if(result != null && !showAll.getWidget().isDisposed())\r
showAll.getWidget().setSelection(result.booleanValue());\r
}\r
});\r