*******************************************************************************/\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.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.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
+ graph.markUndoPoint();\r
+ Layer0Utils.addCommentMetadata(graph, "Removed " + NameUtils.getSafeName(graph, data));\r
RemoverUtil.remove(graph, data);\r
}\r
});\r
final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
final Resource library = this.data;\r
if(resources.length > 0) {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ Simantics.getSession().asyncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
Layer0 l0 = Layer0.getInstance(graph);\r
+ \r
+ // Fixing #5196\r
+ // Prevent dropping functions to immutable function libraries such as Built-in Functions, Modelica Array Functions etc.\r
+ if (graph.isImmutable(library))\r
+ return;\r
+ \r
for(Resource tobeMoved : resources) {\r
if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||\r
graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
+import org.simantics.Simantics;\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.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.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.utils.FunctionNameValidator;\r
-import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
public class FunctionNode extends VariableNode<Resource> implements IDeletableNode, IModifiableNode, IDropTargetNode {\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
+ Resource hasName = Layer0.getInstance(Simantics.getSession()).HasName;\r
+ LabelModifier modifier = new LabelModifier(Simantics.getSession(), data, hasName) {\r
@Override\r
public String isValid(String label) {\r
if (!new FunctionNameValidator().isValid(data, label))\r
\r
@Override\r
public void delete() throws DeleteException {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ Simantics.getSession().asyncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
+ graph.markUndoPoint();\r
+ Layer0Utils.addCommentMetadata(graph, "Removed " + NameUtils.getSafeName(graph, data));\r
RemoverUtil.remove(graph, data);\r
}\r
});\r
final Resource thisFunction = this.data;\r
\r
if(resources.length > 0) {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ Simantics.getSession().asyncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
*******************************************************************************/\r
package org.simantics.sysdyn.ui.browser.nodes;\r
\r
+import org.simantics.Simantics;\r
import org.simantics.browsing.ui.common.node.DeleteException;\r
import org.simantics.browsing.ui.common.node.IDropTargetNode;\r
import org.simantics.browsing.ui.content.Labeler.Modifier;\r
import org.simantics.layer0.Layer0;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.utils.SharedFunctionLibraryNameValidator;\r
-import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.utils.ResourceAdaptionUtils;\r
\r
public class SharedFunctionLibraryNode extends FunctionLibraryNode<Resource> implements IDropTargetNode {\r
\r
@Override\r
public void delete() throws DeleteException {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ Simantics.getSession().asyncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\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
+ Resource hasName = Layer0.getInstance(Simantics.getSession()).HasName;\r
+ LabelModifier modifier = new LabelModifier(Simantics.getSession(), data, hasName) {\r
@Override\r
public String isValid(String label) {\r
if (!new SharedFunctionLibraryNameValidator().isValid(data, label))\r
final Resource[] resources = ResourceAdaptionUtils.toResources(data);\r
final Resource library = this.data;\r
if(resources.length > 0) {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+ Simantics.getSession().asyncRequest(new WriteRequest() {\r
\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r