/*******************************************************************************
* Copyright (c) 2009, 2010, 2011 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
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
-import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.ui.project.model.ITmfProjectModelElement;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfExperimentFolder;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return false;
+ }
// Get the selection
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IWorkbenchPart part = page.getActivePart();
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
- if (selectionProvider == null)
+ if (selectionProvider == null) {
return false;
+ }
ISelection selection = selectionProvider.getSelection();
// Make sure selection contains only traces
// Check if we are closing down
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
+ if (window == null) {
return null;
+ }
// Confirm the operation
Shell shell = window.getShell();
MessageBox confirmOperation = new MessageBox(shell, SWT.ICON_QUESTION | SWT.CANCEL | SWT.OK);
confirmOperation.setText(Messages.DeleteDialog_Title);
confirmOperation.setMessage(Messages.DeleteTraceHandler_Message);
- if (confirmOperation.open() != SWT.OK)
+ if (confirmOperation.open() != SWT.OK) {
return null;
+ }
@SuppressWarnings("unchecked")
Iterator<Object> iterator = fSelection.iterator();
try {
IPath path = resource.getLocation();
if (path != null && (trace.getParent() instanceof TmfTraceFolder)) {
- String location = path.toFile().getCanonicalPath();
+ String location = path.toString();
TmfExperimentFolder experimentFolder = trace.getProject().getExperimentsFolder();
// Propagate the removal to traces
resource.delete(true, new NullProgressMonitor());
// Delete supplementary files
- trace.deleteSupplementaryFiles();
+ trace.deleteSupplementaryFolder();
// Refresh the project
trace.getProject().refresh();
- } catch (IOException e1) {
- e1.printStackTrace();
} catch (CoreException e) {
- e.printStackTrace();
+ Activator.getDefault().logError("Error deleting trace: " + trace.getName(), e); //$NON-NLS-1$
}
}
}