Remove bookmarks file on drag&drop trace copy.
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 3 May 2012 18:07:22 +0000 (14:07 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 3 May 2012 18:43:27 +0000 (14:43 -0400)
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/DropAdapterAssistant.java

index 34a5f2fbd1209171bddb81d16e9985113281d973..8139af18a0322ff338041c594d7ffbaeba8f0c5f 100644 (file)
@@ -32,6 +32,7 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
 import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
@@ -212,6 +213,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant {
                 try {
                     IPath destination = targetExperiment.getProject().getTracesFolder().getResource().getFullPath().addTrailingSeparator().append(sourceResource.getName());
                     sourceResource.copy(destination, false, null);
+                    cleanupBookmarks(destination);
                     // use the copied resource for the experiment
                     if (sourceResource.getType() == IResource.FILE) {
                         sourceResource = targetExperiment.getProject().getTracesFolder().getResource().getFile(sourceResource.getName());
@@ -252,6 +254,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant {
             try {
                 IPath destination = traceFolder.getResource().getFullPath().addTrailingSeparator().append(sourceResource.getName());
                 sourceResource.copy(destination, false, null);
+                cleanupBookmarks(destination);
                 return true;
             } catch (CoreException e) {
                 displayException(e);
@@ -359,6 +362,7 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant {
             displayException(e);
         }
     } 
+
     /**
      * Create a link to the actual trace and set the trace type
      * 
@@ -397,6 +401,24 @@ public class DropAdapterAssistant extends CommonDropAdapterAssistant {
         }
     }
 
+    /**
+     * Cleanup bookmarks file in copied trace
+     */
+    private void cleanupBookmarks(IPath path) {
+        IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+        if (folder.exists()) {
+            try {
+                for (IResource member : folder.members()) {
+                    if (TmfTrace.class.getCanonicalName().equals(member.getPersistentProperty(TmfTraceElement.TRACETYPE))) {
+                        member.delete(true, null);
+                    }
+                }
+            } catch (CoreException e) {
+                displayException(e);
+            }
+        }
+    }
+
     /**
      * Set the trace persistent properties
      * 
This page took 0.025313 seconds and 5 git commands to generate.