Drag and drop enhancements
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / handlers / SelectTraceTypeHandler.java
index d7a86e928d395ba5dcd84f395ea14afd2d5524e5..e434c081befad413d2b755bccf45dd5a1b0f36f2 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011 Ericsson
+ * Copyright (c) 2011, 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
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Patrick Tasse - Fix propagation to experiment traces
  *******************************************************************************/
 
 package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
@@ -47,9 +48,9 @@ public class SelectTraceTypeHandler extends AbstractHandler {
     // Constants
     // ------------------------------------------------------------------------
 
-    private static final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.bundle"; //$NON-NLS-1$
-    private static final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.type"; //$NON-NLS-1$
-    private static final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.project.trace.select_trace_type.icon"; //$NON-NLS-1$
+    private static final String BUNDLE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.select_trace_type.bundle"; //$NON-NLS-1$
+    private static final String TYPE_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.select_trace_type.type"; //$NON-NLS-1$
+    private static final String ICON_PARAMETER = "org.eclipse.linuxtools.tmf.ui.commandparameter.select_trace_type.icon"; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -73,6 +74,9 @@ public class SelectTraceTypeHandler 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;
@@ -83,7 +87,6 @@ public class SelectTraceTypeHandler extends AbstractHandler {
         fSelection = null;
         if (selection instanceof TreeSelection) {
             fSelection = (TreeSelection) selection;
-            @SuppressWarnings("unchecked")
             Iterator<Object> iterator = fSelection.iterator();
             while (iterator.hasNext()) {
                 Object element = iterator.next();
@@ -164,7 +167,7 @@ public class SelectTraceTypeHandler extends AbstractHandler {
                 for (final ITmfProjectModelElement child : experiment.getChildren()) {
                     if (child instanceof TmfTraceElement) {
                         TmfTraceElement linkedTrace = (TmfTraceElement) child;
-                        if (linkedTrace.equals(trace)) {
+                        if (linkedTrace.getName().equals(trace.getName())) {
                             IResource resource = linkedTrace.getResource();
                             setProperties(resource, bundleName, traceType, iconUrl);
                             linkedTrace.refreshTraceType();
This page took 0.038791 seconds and 5 git commands to generate.