1 package org.simantics.sysdyn.ui.wizards.functions;
\r
3 import org.simantics.browsing.ui.common.node.DeleteException;
\r
4 import org.simantics.browsing.ui.common.node.IDropTargetNode;
\r
5 import org.simantics.db.Resource;
\r
6 import org.simantics.db.WriteGraph;
\r
7 import org.simantics.db.common.request.WriteRequest;
\r
8 import org.simantics.db.exception.DatabaseException;
\r
9 import org.simantics.layer0.Layer0;
\r
10 import org.simantics.sysdyn.SysdynResource;
\r
11 import org.simantics.sysdyn.ui.browser.nodes.FunctionLibraryNode;
\r
12 import org.simantics.ui.SimanticsUI;
\r
13 import org.simantics.ui.utils.ResourceAdaptionUtils;
\r
15 public class SharedFunctionsFolderNode extends FunctionLibraryNode<Resource> implements IDropTargetNode {
\r
17 public SharedFunctionsFolderNode(Resource resource) {
\r
22 public void delete() throws DeleteException {
\r
23 SimanticsUI.getSession().asyncRequest(new WriteRequest() {
\r
26 public void perform(WriteGraph graph) throws DatabaseException {
\r
27 Layer0 l0 = Layer0.getInstance(graph);
\r
29 graph.deny(data, l0.PartOf);
\r
30 graph.deny(data, l0.IsLinkedTo_Inverse);
\r
32 // TODO: remove file
\r
38 public void drop(Object data) {
\r
39 final Resource[] resources = ResourceAdaptionUtils.toResources(data);
\r
40 final Resource library = this.data;
\r
41 if(resources.length > 0) {
\r
42 SimanticsUI.getSession().asyncRequest(new WriteRequest() {
\r
45 public void perform(WriteGraph graph) throws DatabaseException {
\r
46 SysdynResource sr = SysdynResource.getInstance(graph);
\r
47 Layer0 l0 = Layer0.getInstance(graph);
\r
48 for(Resource tobeMoved : resources) {
\r
49 if(graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunction) ||
\r
50 graph.isInstanceOf(tobeMoved, sr.SysdynModelicaFunctionLibrary)) {
\r
51 graph.deny(tobeMoved, l0.PartOf);
\r
52 graph.claim(tobeMoved, l0.PartOf, library);
\r