/**********************************************************************
* Copyright (c) 2012 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:
+ *
+ * Contributors:
* Bernd Hufmann - Initial API and implementation
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IImportDialog;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ImportFileInfo;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.ui.PlatformUI;
/**
- * <b><u>ImportHandler</u></b>
* <p>
* Command handler implementation to import traces from a (remote) session to a tracing project.
* </p>
+ *
+ * @author Bernd Hufmann
*/
public class ImportHandler extends BaseControlViewHandler {
// Attributes
// ------------------------------------------------------------------------
protected CommandParameter fParam;
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
-
+
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
fLock.lock();
try {
final CommandParameter param = fParam.clone();
-
+
final IImportDialog dialog = TraceControlDialogFactory.getInstance().getImportDialog();
dialog.setSession(param.getSession());
try {
List<ImportFileInfo> traces = dialog.getTracePathes();
IProject project = dialog.getProject();
-
+
for (Iterator<ImportFileInfo> iterator = traces.iterator(); iterator.hasNext();) {
- ImportFileInfo remoteFile = (ImportFileInfo) iterator.next();
+ ImportFileInfo remoteFile = iterator.next();
downloadTrace(remoteFile, project);
}
} catch (ExecutionException e) {
- return new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ImportFailure, e);
- }
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ImportFailure, e);
+ }
return Status.OK_STATUS;
}
};
if (selection instanceof StructuredSelection) {
StructuredSelection structered = ((StructuredSelection) selection);
for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
- Object element = (Object) iterator.next();
+ Object element = iterator.next();
if (element instanceof TraceSessionComponent) {
// Add only TraceSessionComponents that are inactive and not destroyed
TraceSessionComponent tmpSession = (TraceSessionComponent) element;
}
return isEnabled;
}
-
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
/**
* Downloads a trace from the remote host to the given project.
- * @param trace - trace information of trace to import
- * @param project - project to import to
+ *
+ * @param trace
+ * - trace information of trace to import
+ * @param project
+ * - project to import to
* @throws ExecutionException
*/
private void downloadTrace(ImportFileInfo trace, IProject project) throws ExecutionException {
try {
IRemoteFileSubSystem fsss = trace.getImportFile().getParentRemoteFileSubSystem();
-
+
IFolder traceFolder = project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME);
if (!traceFolder.exists()) {
throw new ExecutionException(Messages.TraceControl_ImportDialogInvalidTracingProject + " (" + TmfTraceFolder.TRACE_FOLDER_NAME + ")"); //$NON-NLS-1$//$NON-NLS-2$
destinations[i] = folder.getLocation().addTrailingSeparator().append(sources[i].getName()).toString();
encodings[i] = null;
}
-
+
fsss.downloadMultiple(sources, destinations, encodings, new NullProgressMonitor());
-
+
} catch (SystemMessageException e) {
- throw new ExecutionException(e.fillInStackTrace().toString());
+ throw new ExecutionException(e.toString(), e);
} catch (CoreException e) {
- throw new ExecutionException(e.fillInStackTrace().toString());
+ throw new ExecutionException(e.toString(), e);
}
}
}