-package org.simantics.document.ui.actions;\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.WriteRequest;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class NewDocumentFolder implements ActionFactory {\r
- Resource folderType;\r
- Resource relation;\r
- \r
- public NewDocumentFolder(ReadGraph graph, String folderTypeUri, String relationUri) throws DatabaseException {\r
- folderType = graph.getResource(folderTypeUri);\r
- relation = graph.getResource(relationUri);\r
- }\r
- \r
- @Override\r
- public Runnable create(Object target) {\r
-\r
- if(!(target instanceof Resource))\r
- return null;\r
-\r
- final Resource resource = (Resource)target;\r
-\r
- return new Runnable() {\r
- @Override\r
- public void run() {\r
- SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
- \r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- graph.markUndoPoint();\r
- \r
- Layer0 l0 = Layer0.getInstance(graph);\r
-\r
- String name = NameUtils.findFreshName(graph, "Folder", resource, relation);\r
- Resource folder = graph.newResource();\r
- graph.claim(folder, l0.InstanceOf, folderType);\r
- graph.claimLiteral(folder, l0.HasName, name);\r
- graph.claim(resource, relation, folder);\r
- }\r
- \r
- });\r
- }\r
- };\r
- }\r
-}\r
+package org.simantics.document.ui.actions;
+
+import org.simantics.Simantics;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.layer0.Layer0;
+
+public class NewDocumentFolder implements ActionFactory {
+ Resource folderType;
+ Resource relation;
+
+ public NewDocumentFolder(ReadGraph graph, String folderTypeUri, String relationUri) throws DatabaseException {
+ folderType = graph.getResource(folderTypeUri);
+ relation = graph.getResource(relationUri);
+ }
+
+ @Override
+ public Runnable create(Object target) {
+
+ if(!(target instanceof Resource))
+ return null;
+
+ final Resource resource = (Resource)target;
+
+ return new Runnable() {
+ @Override
+ public void run() {
+ Simantics.getSession().asyncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ graph.markUndoPoint();
+
+ Layer0 l0 = Layer0.getInstance(graph);
+
+ String name = NameUtils.findFreshName(graph, Messages.NewDocumentFolder_Folder, resource, relation);
+ Resource folder = graph.newResource();
+ graph.claim(folder, l0.InstanceOf, folderType);
+ graph.claimLiteral(folder, l0.HasName, name);
+ graph.claim(resource, relation, folder);
+ }
+
+ });
+ }
+ };
+ }
+}