fix bug on cancel overwrite
authorBruno Sinou <bsinou@argeo.org>
Thu, 8 Nov 2012 15:32:37 +0000 (15:32 +0000)
committerBruno Sinou <bsinou@argeo.org>
Thu, 8 Nov 2012 15:32:37 +0000 (15:32 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5749 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/model/ParentNodeFolder.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrResultTreeView.java
plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/wizards/ConfirmOverwriteWizard.java

index 93cef51cd30fa9fef36243320217a2e7c600a03e..85da2632ec2c49364d9719756e12e2444f3eb631 100644 (file)
@@ -20,8 +20,6 @@ import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.NodeType;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
 import org.argeo.slc.jcr.SlcJcrResultUtils;
 import org.argeo.slc.jcr.SlcNames;
@@ -40,8 +38,8 @@ import org.argeo.slc.jcr.SlcTypes;
  * and keeps a reference to its parent.
  */
 public class ParentNodeFolder extends ResultParent {
-       private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
-       
+       // private final static Log log = LogFactory.getLog(ParentNodeFolder.class);
+
        private Node node = null;
 
        /**
index 40b295c42258854324358cae9494149889fc2a1a..e1a5759eff3d92d3257a9998ad409893838e999d 100644 (file)
@@ -1,5 +1,6 @@
 package org.argeo.slc.client.ui.views;\r
 \r
+import java.awt.Window;\r
 import java.util.ArrayList;\r
 import java.util.Calendar;\r
 import java.util.List;\r
@@ -615,7 +616,9 @@ public class JcrResultTreeView extends ViewPart {
                                                        name, targetParentNode);\r
                                        WizardDialog dialog = new WizardDialog(Display.getDefault()\r
                                                        .getActiveShell(), wizard);\r
-                                       dialog.open();\r
+                                       \r
+                                       if (dialog.open() == WizardDialog.CANCEL)\r
+                                               return true;\r
 \r
                                        if (wizard.overwrite()) {\r
                                                targetParentNode.getNode(name).remove();\r
index 3ec3530c72fdbf6f6d13239cae9d2280e4878a67..4c812770e35cb92ee1b8918bdf814d36070d2916 100644 (file)
@@ -2,9 +2,12 @@ package org.argeo.slc.client.ui.wizards;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 
 import org.argeo.slc.SlcException;
 import org.argeo.slc.client.ui.ClientUiPlugin;
+import org.argeo.slc.client.ui.SlcUiConstants;
+import org.argeo.slc.jcr.SlcJcrResultUtils;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardPage;
@@ -34,6 +37,7 @@ public class ConfirmOverwriteWizard extends Wizard {
        private Node targetParentNode;
 
        private String newName;
+       private String parentRelPath;
        private boolean overwrite;
 
        public ConfirmOverwriteWizard(String sourceNodeName, Node targetParentNode) {
@@ -72,6 +76,7 @@ public class ConfirmOverwriteWizard extends Wizard {
                        if (overwriteBtn.getSelection())
                                doFinish = MessageDialog.openConfirm(Display.getDefault()
                                                .getActiveShell(), "CAUTION", "All data contained in ["
+                                               + (parentRelPath !=null?parentRelPath:"")
                                                + sourceNodeName
                                                + "] are about to be definitively destroyed. \n "
                                                + "Are you sure you want to proceed ?");
@@ -90,8 +95,30 @@ public class ConfirmOverwriteWizard extends Wizard {
 
                public MyPage() {
                        super("");
-                       setTitle("An object with same name (" + sourceNodeName
-                                       + ") already exists");
+                       String msg = "An object with same name (" + sourceNodeName
+                                       + ") already exists at chosen target path";
+
+                       // Add target rel path to the message
+                       Session session;
+                       String relPath;
+                       try {
+                               session = targetParentNode.getSession();
+                               relPath = targetParentNode.getPath();
+                               String basePath = SlcJcrResultUtils
+                                               .getMyResultsBasePath(session);
+                               if (relPath.startsWith(basePath))
+                                       relPath = relPath.substring(basePath.length());
+                               // FIXME currently add the default base label
+                               parentRelPath = SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL + "/"
+                                               + relPath;
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Unexpected error while defining "
+                                               + "target parent node rel path", e);
+                       }
+                       msg = msg + (parentRelPath == null ? "." : ": \n" + parentRelPath);
+
+                       // Set Title
+                       setTitle(msg);
                }
 
                public void createControl(Composite parent) {