]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - plugins/org.argeo.slc.akb.ui/src/main/java/org/argeo/slc/akb/ui/commands/DeleteAkbNodes.java
work on active environments
[gpl/argeo-slc.git] / plugins / org.argeo.slc.akb.ui / src / main / java / org / argeo / slc / akb / ui / commands / DeleteAkbNodes.java
index 2faafa38b7ba88937d1ff8893058afffd5950437..3a3e9a0a9e0804ba112e284f07467775bf93f2f5 100644 (file)
@@ -7,6 +7,7 @@ import javax.jcr.Session;
 
 import org.argeo.jcr.JcrUtils;
 import org.argeo.slc.akb.AkbException;
+import org.argeo.slc.akb.AkbTypes;
 import org.argeo.slc.akb.ui.AkbUiPlugin;
 import org.argeo.slc.akb.ui.editors.AkbNodeEditorInput;
 import org.argeo.slc.akb.utils.AkbJcrUtils;
@@ -48,14 +49,10 @@ public class DeleteAkbNodes extends AbstractHandler {
                        if (nodeJcrId != null)
                                node = session.getNodeByIdentifier(nodeJcrId);
 
-                       // We must be in a template to delete nodes...
-                       Node template = AkbJcrUtils.getCurrentTemplate(node);
-
-                       IEditorPart currPart = currentPage
-                                       .findEditor(new AkbNodeEditorInput(
-                                                       template.getIdentifier(), nodeJcrId));
-                       if (currPart != null)
-                               currPart.dispose();
+                       // We must be in a template or on the root of an env instance to
+                       // delete nodes.
+                       Node template = node.isNodeType(AkbTypes.AKB_ENV) ? node
+                                       : AkbJcrUtils.getCurrentTemplate(node);
 
                        if (node != null) {
                                Boolean ok = MessageDialog.openConfirm(
@@ -63,6 +60,12 @@ public class DeleteAkbNodes extends AbstractHandler {
                                                "Do you want to delete this item?");
 
                                if (ok) {
+                                       IEditorPart currPart = currentPage
+                                                       .findEditor(new AkbNodeEditorInput(template
+                                                                       .getIdentifier(), nodeJcrId));
+                                       if (currPart != null)
+                                               currentPage.closeEditor(currPart, false);
+
                                        node.remove();
                                        session.save();
                                }