tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / ImportTraceWizardPage.java
index 5c11c66203097e9cd598a5d83cb15d56ca5528f3..697417aedcf804ca7faa29db66956bd4ec0c832d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2011, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson and others.
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -10,6 +10,7 @@
  *   Francois Chouinard - Initial API and implementation
  *   Francois Chouinard - Got rid of dependency on internal platform class
  *   Francois Chouinard - Complete re-design
+ *   Anna Dushistova(Montavista) - [383047] NPE while importing a CFT trace
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.project.wizards;
@@ -53,6 +54,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefin
 import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
@@ -587,7 +589,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         fTraceTypes.addSelectionListener(new SelectionListener() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                validateSourceGroup();
+                updateWidgetEnablements();
             }
 
             @Override
@@ -738,10 +740,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
             List<File> traces = isolateTraces();
             for (File trace : traces) {
-                ITmfTrace<?> tmfTrace = null;
+                ITmfTrace tmfTrace = null;
                 try {
                     IConfigurationElement ce = fTraceAttributes.get(traceTypeName);
-                    tmfTrace = (ITmfTrace<?>) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
+                    tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
                     if (tmfTrace != null && !tmfTrace.validate(fProject, trace.getAbsolutePath())) {
                         setMessage(null);
                         setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
@@ -809,9 +811,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return false;
         }
 
-        String sourceDirPath;
         try {
-            sourceDirPath = sourceDir.getCanonicalPath();
+            sourceDir.getCanonicalPath();
         } catch (IOException e) {
             MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
                     Messages.ImportTraceWizard_InvalidTraceDirectory);
@@ -833,7 +834,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         }
 
         if (fileSystemObjects.size() > 0) {
-            boolean ok = importResources(sourceDirPath, fileSystemObjects);
+            boolean ok = importResources(fileSystemObjects);
             String traceBundle = null;
             String traceTypeId = null;
             String traceIcon = null;
@@ -893,10 +894,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                                 resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, traceBundle);
                                 resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceTypeId);
                                 resource.setPersistentProperty(TmfCommonConstants.TRACEICON, traceIcon);
-                                for (TmfTraceElement traceElement : TmfProjectRegistry.getProject(resource.getProject()).getTracesFolder().getTraces()) {
-                                    if (traceElement.getName().equals(resource.getName())) {
-                                        traceElement.refreshTraceType();
-                                        break;
+                                TmfProjectElement tmfProject = TmfProjectRegistry.getProject(resource.getProject());
+                                if (tmfProject != null) {
+                                    for (TmfTraceElement traceElement : tmfProject.getTracesFolder().getTraces()) {
+                                        if (traceElement.getName().equals(resource.getName())) {
+                                            traceElement.refreshTraceType();
+                                            break;
+                                        }
                                     }
                                 }
                             } catch (CoreException e) {
@@ -914,7 +918,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         return false;
     }
 
-    private boolean importResources(String rootDirectory, Map<String, File> fileSystemObjects) {
+    private boolean importResources(Map<String, File> fileSystemObjects) {
 
         // Determine the sorted canonical list of items to import
         List<File> fileList = new ArrayList<File>();
This page took 0.024809 seconds and 5 git commands to generate.