/*******************************************************************************
- * 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
* 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;
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;
fTraceTypes.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- validateSourceGroup();
+ updateWidgetEnablements();
}
@Override
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);
return false;
}
- String sourceDirPath;
try {
- sourceDirPath = sourceDir.getCanonicalPath();
+ sourceDir.getCanonicalPath();
} catch (IOException e) {
MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
Messages.ImportTraceWizard_InvalidTraceDirectory);
}
if (fileSystemObjects.size() > 0) {
- boolean ok = importResources(sourceDirPath, fileSystemObjects);
+ boolean ok = importResources(fileSystemObjects);
String traceBundle = null;
String traceTypeId = null;
String traceIcon = null;
String prefix = null;
for (int i = 0; i < files.size(); i++) {
File file = fileSystemObjects.get(files.get(i));
- String name = file.getAbsolutePath();
+ String name = file.getAbsolutePath() + File.separatorChar;
if (fTargetFolder != null && (prefix == null || !name.startsWith(prefix))) {
prefix = name; // new prefix
IResource resource = fTargetFolder.findMember(file.getName());
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) {
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>();
List<File> subList = new ArrayList<File>();
subList.add(resource);
if (resource.isDirectory()) {
- String prefix = resource.getAbsolutePath();
+ String prefix = resource.getAbsolutePath() + File.separatorChar;
boolean hasSamePrefix = true;
- for (int j = i; j < fileList.size() && hasSamePrefix; j++) {
+ for (int j = i + 1; j < fileList.size() && hasSamePrefix; j++) {
File res = fileList.get(j);
hasSamePrefix = res.getAbsolutePath().startsWith(prefix);
if (hasSamePrefix) {