tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / handlers / DeleteExperimentSupplementaryFilesHandler.java
index d22ca3bf3f704fbc5b37d63d160e1233944433ad..0086e5adb195ebe5c82896686efe7ba00e05d643 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2011 Ericsson
- * 
+ * Copyright (c) 2009, 2013 Ericsson
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
  *******************************************************************************/
@@ -21,14 +21,12 @@ import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.ui.project.dialogs.SelectSupplementaryResourcesDialog;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
@@ -60,6 +58,9 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler {
         // Get the selection
         IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
         IWorkbenchPart part = page.getActivePart();
+        if (part == null) {
+            return false;
+        }
         ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
         if (selectionProvider == null) {
             return false;
@@ -73,23 +74,26 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler {
             // There should be only one item selected as per the plugin.xml
             Object element = sel.getFirstElement();
             List<IResource> resourcesList = new ArrayList<IResource>();
-            
+
             if (element instanceof TmfExperimentElement) {
 
                 TmfExperimentElement trace = (TmfExperimentElement) element;
 
+                IResource[] resources = trace.getSupplementaryResources();
+                resourcesList.addAll(Arrays.asList(resources));
+
                 for (TmfTraceElement aTrace : trace.getTraces()) {
 
                     // If trace is under an experiment, use the original trace from the traces folder
                     aTrace = aTrace.getElementUnderTraceFolder();
 
                     // Delete the selected resources
-                    IResource[] resources = aTrace.getSupplementaryResources();
+                    resources = aTrace.getSupplementaryResources();
                     resourcesList.addAll(Arrays.asList(resources));
                 }
 
                 SelectSupplementaryResourcesDialog dialog = new SelectSupplementaryResourcesDialog(window.getShell(), resourcesList.toArray(new IResource[resourcesList.size()]));
-                
+
                 if (dialog.open() != Window.OK) {
                     return null;
                 }
@@ -100,18 +104,16 @@ public class DeleteExperimentSupplementaryFilesHandler extends AbstractHandler {
                     try {
                         resourcesToDelete[i].delete(true, new NullProgressMonitor());
                     } catch (CoreException e) {
-                        TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error deleting supplementary resource " + resourcesToDelete[i], e)); //$NON-NLS-1$
+                        Activator.getDefault().logError("Error deleting supplementary resource " + resourcesToDelete[i], e); //$NON-NLS-1$
                     }
                 }
 
                 IResource resource = trace.getProject().getResource();
                 if (resource != null) {
                     try {
-                        if (resource != null) {
-                            resource.refreshLocal(IResource.DEPTH_INFINITE, null);
-                        }
+                        resource.refreshLocal(IResource.DEPTH_INFINITE, null);
                     } catch (CoreException e) {
-                        TmfUiPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TmfUiPlugin.PLUGIN_ID, "Error refreshing resource " + resource, e)); //$NON-NLS-1$
+                        Activator.getDefault().logError("Error refreshing resource " + resource, e); //$NON-NLS-1$
                     }
                 }
             }
This page took 0.024968 seconds and 5 git commands to generate.