ctf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.gdbtrace.ui / src / org / eclipse / linuxtools / internal / gdbtrace / ui / views / project / handlers / SelectTraceExecutableHandler.java
index 3f85857e5badc41fc1db558e9a8001894336c0d4..51e63f1ab9289d7b5c2b69047600614f524d296f 100644 (file)
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Patrick Tasse - Initial API and implementation
+ *   Bernd Hufmann - Improved trace selection
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.gdbtrace.ui.views.project.handlers;
@@ -21,7 +22,7 @@ import org.eclipse.core.runtime.IPath;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.window.Window;
-import org.eclipse.linuxtools.internal.gdbtrace.trace.GdbTrace;
+import org.eclipse.linuxtools.internal.gdbtrace.core.trace.GdbTrace;
 import org.eclipse.linuxtools.internal.gdbtrace.ui.views.project.dialogs.SelectTraceExecutableDialog;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.swt.widgets.MessageBox;
@@ -30,7 +31,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 /**
- * Handler for the Select Trace Excecutable command
+ * Handler for the Select Trace Executable command
  * @author Patrick Tasse
  */
 public class SelectTraceExecutableHandler extends AbstractHandler {
@@ -38,6 +39,11 @@ public class SelectTraceExecutableHandler extends AbstractHandler {
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
         Shell shell = HandlerUtil.getActiveShell(event);
+
+        // Get the selection before opening the dialog because otherwise the
+        // getCurrentSelection() call will always return null
+        ISelection selection = HandlerUtil.getCurrentSelection(event);
+
         SelectTraceExecutableDialog dialog = new SelectTraceExecutableDialog(shell);
         dialog.open();
         if (dialog.getReturnCode() != Window.OK) {
@@ -45,7 +51,6 @@ public class SelectTraceExecutableHandler extends AbstractHandler {
         }
         IPath tracedExecutable = dialog.getExecutablePath();
 
-        ISelection selection = HandlerUtil.getCurrentSelection(event);
         if (selection instanceof IStructuredSelection) {
             for (Object o : ((IStructuredSelection) selection).toList()) {
                 TmfTraceElement traceElement = (TmfTraceElement) o;
This page took 0.030649 seconds and 5 git commands to generate.