Fix for bug 382684 (connection re-use)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / handlers / ImportHandler.java
index b3b23ef2001d85e30b35702bf6c105d1e4ae5833..eb0ce70898e6f0f06eb7888c04b8b842caf783ee 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * 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;
@@ -27,13 +27,13 @@ import org.eclipse.core.runtime.jobs.Job;
 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;
@@ -45,10 +45,11 @@ import org.eclipse.ui.IWorkbenchWindow;
 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 {
 
@@ -56,7 +57,7 @@ public class ImportHandler extends BaseControlViewHandler {
     // Attributes
     // ------------------------------------------------------------------------
     protected CommandParameter fParam;
-    
+
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
@@ -64,7 +65,7 @@ public class ImportHandler extends BaseControlViewHandler {
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
-    
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
@@ -81,7 +82,7 @@ public class ImportHandler extends BaseControlViewHandler {
         fLock.lock();
         try {
             final CommandParameter param = fParam.clone();
-            
+
             final IImportDialog dialog = TraceControlDialogFactory.getInstance().getImportDialog();
             dialog.setSession(param.getSession());
 
@@ -95,15 +96,15 @@ public class ImportHandler extends BaseControlViewHandler {
                     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;
                 }
             };
@@ -133,7 +134,7 @@ public class ImportHandler extends BaseControlViewHandler {
         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;
@@ -156,20 +157,23 @@ public class ImportHandler extends BaseControlViewHandler {
         }
         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$
@@ -193,13 +197,13 @@ public class ImportHandler extends BaseControlViewHandler {
                 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);
         }
     }
 }
This page took 0.02548 seconds and 5 git commands to generate.