[Tmf][Ctf] Add descriptive fail to import messages.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / ImportTraceWizardPage.java
index aa5a5081697e45ea51319822546280fbdb912a7d..91b720a42c596a537a538d2d85247d7fa7b843e0 100644 (file)
@@ -1,15 +1,16 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010, 2011 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
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *   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;
@@ -19,11 +20,13 @@ import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFolder;
@@ -43,17 +46,19 @@ import org.eclipse.jface.viewers.CheckboxTreeViewer;
 import org.eclipse.jface.viewers.ICheckStateListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+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.core.util.TmfTraceType;
-import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
-import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTrace;
-import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
-import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTrace;
-import org.eclipse.linuxtools.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+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;
+import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.BusyIndicator;
 import org.eclipse.swt.events.FocusEvent;
@@ -72,7 +77,6 @@ import org.eclipse.swt.widgets.DirectoryDialog;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.dialogs.FileSystemElement;
 import org.eclipse.ui.dialogs.WizardResourceImportPage;
@@ -83,20 +87,21 @@ import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
 import org.eclipse.ui.wizards.datatransfer.ImportOperation;
 
 /**
- * <b><u>ImportTraceWizardPage</u></b>
- * <p>
  * A variant of the standard resource import wizard with the following changes:
  * <ul>
  * <li>A folder/file combined checkbox tree viewer to select traces
- * <li>Cherry-picking of traces in the file structure without re-creating the file hierarchy
+ * <li>Cherry-picking of traces in the file structure without re-creating the
+ * file hierarchy
  * <li>A trace types dropbox for optional characterization
  * </ul>
- * For our purpose, a trace can either be a single file or a whole directory sub-tree, whichever is reached first from
- * the root directory.
+ * For our purpose, a trace can either be a single file or a whole directory
+ * sub-tree, whichever is reached first from the root directory.
  * <p>
- * TODO: Consider adding Filter/Select/Deselect buttons
+ *
+ * @version 1.0
+ * @author Francois Chouinard
  */
-public class ImportTraceWizardPage extends WizardResourceImportPage implements Listener {
+public class ImportTraceWizardPage extends WizardResourceImportPage {
 
     // ------------------------------------------------------------------------
     // Constants
@@ -127,10 +132,26 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // Constructors
     // ------------------------------------------------------------------------
 
+    /**
+     * Constructor. Creates the trace wizard page.
+     *
+     * @param name
+     *            The name of the page.
+     * @param selection
+     *            The current selection
+     */
     protected ImportTraceWizardPage(String name, IStructuredSelection selection) {
         super(name, selection);
     }
 
+    /**
+     * Constructor
+     *
+     * @param workbench
+     *            The workbench reference.
+     * @param selection
+     *            The current selection
+     */
     public ImportTraceWizardPage(IWorkbench workbench, IStructuredSelection selection) {
         this(IMPORT_WIZARD_PAGE, selection);
         setTitle(Messages.ImportTraceWizard_FileSystemTitle);
@@ -165,7 +186,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // ------------------------------------------------------------------------
     // WizardResourceImportPage
     // ------------------------------------------------------------------------
-
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardResourceImportPage#createControl(org.eclipse
+     * .swt.widgets.Composite)
+     */
     @Override
     public void createControl(Composite parent) {
         super.createControl(parent);
@@ -176,6 +203,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         }
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardResourceImportPage#createSourceGroup(org
+     * .eclipse.swt.widgets.Composite)
+     */
     @Override
     protected void createSourceGroup(Composite parent) {
         createDirectorySelectionGroup(parent);
@@ -184,6 +218,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         validateSourceGroup();
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardResourceImportPage#createFileSelectionGroup
+     * (org.eclipse.swt.widgets.Composite)
+     */
     @Override
     protected void createFileSelectionGroup(Composite parent) {
 
@@ -227,11 +268,21 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         });
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFolderProvider()
+     */
     @Override
     protected ITreeContentProvider getFolderProvider() {
         return null;
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.ui.dialogs.WizardResourceImportPage#getFileProvider()
+     */
     @Override
     protected ITreeContentProvider getFileProvider() {
         return new WorkbenchContentProvider() {
@@ -245,10 +296,12 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
                     Object[] files = element.getFiles().getChildren();
 
                     List<Object> result = new LinkedList<Object>();
-                    for (Object folder : folders)
+                    for (Object folder : folders) {
                         result.add(folder);
-                    for (Object file : files)
+                    }
+                    for (Object file : files) {
                         result.add(file);
+                    }
 
                     return result.toArray();
                 }
@@ -257,7 +310,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         };
     }
 
-    private void populateChildren(FileSystemElement parent) {
+    private static void populateChildren(FileSystemElement parent) {
         // Do not re-populate if the job was done already...
         FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
         if (parent.getFolders().size() == 0 && parent.getFiles().size() == 0) {
@@ -275,6 +328,12 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         }
     }
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardResourceImportPage#getSelectedResources()
+     */
     @Override
     protected List<FileSystemElement> getSelectedResources() {
         List<FileSystemElement> resources = new ArrayList<FileSystemElement>();
@@ -291,10 +350,22 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // Directory Selection Group (forked WizardFileSystemResourceImportPage1)
     // ------------------------------------------------------------------------
 
+    /**
+     * The directory name field
+     */
     protected Combo directoryNameField;
+    /**
+     * The directory browse button.
+     */
     protected Button directoryBrowseButton;
     private boolean entryChanged = false;
 
+    /**
+     * creates the directory selection group.
+     *
+     * @param parent
+     *            the parent composite
+     */
     protected void createDirectorySelectionGroup(Composite parent) {
 
         Composite directoryContainerGroup = new Composite(parent, SWT.NONE);
@@ -368,6 +439,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // Browse for the source directory
     // ------------------------------------------------------------------------
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardResourceImportPage#handleEvent(org.eclipse
+     * .swt.widgets.Event)
+     */
     @Override
     public void handleEvent(Event event) {
         if (event.widget == directoryBrowseButton) {
@@ -376,6 +454,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         super.handleEvent(event);
     }
 
+    /**
+     * Handle the button pressed event
+     */
     protected void handleSourceDirectoryBrowseButtonPressed() {
         String currentSource = directoryNameField.getText();
         DirectoryDialog dialog = new DirectoryDialog(directoryNameField.getShell(), SWT.SAVE | SWT.SHEET);
@@ -399,7 +480,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         return getSourceDirectory(directoryNameField.getText());
     }
 
-    private File getSourceDirectory(String path) {
+    private static File getSourceDirectory(String path) {
         File sourceDirectory = new File(getSourceDirectoryName(path));
         if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
             return null;
@@ -408,7 +489,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         return sourceDirectory;
     }
 
-    private String getSourceDirectoryName(String sourceName) {
+    private static String getSourceDirectoryName(String sourceName) {
         IPath result = new Path(sourceName.trim());
         if (result.getDevice() != null && result.segmentCount() == 0) {
             result = result.addTrailingSeparator();
@@ -482,7 +563,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         return results[0];
     }
 
-    private FileSystemElement createRootElement(Object fileSystemObject, IImportStructureProvider provider) {
+    private static FileSystemElement createRootElement(Object fileSystemObject,
+            IImportStructureProvider provider) {
 
         boolean isContainer = provider.isFolder(fileSystemObject);
         String elementLabel = provider.getLabel(fileSystemObject);
@@ -530,7 +612,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         fTraceTypes.addSelectionListener(new SelectionListener() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                validateSourceGroup();
+                updateWidgetEnablements();
             }
 
             @Override
@@ -539,9 +621,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         });
     }
 
-    // The mapping of available trace type IDs to their corresponding configuration element
-    private Map<String, IConfigurationElement> fTraceTypeAttributes = new HashMap<String, IConfigurationElement>();
-    private Map<String, IConfigurationElement> fTraceCategories = new HashMap<String, IConfigurationElement>();
+    // The mapping of available trace type IDs to their corresponding
+    // configuration element
+    private final Map<String, IConfigurationElement> fTraceTypeAttributes = new HashMap<String, IConfigurationElement>();
+    private final Map<String, IConfigurationElement> fTraceCategories = new HashMap<String, IConfigurationElement>();
     private final Map<String, IConfigurationElement> fTraceAttributes = new HashMap<String, IConfigurationElement>();
 
     private String[] getAvailableTraceTypes() {
@@ -601,6 +684,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     private Button overwriteExistingResourcesCheckbox;
     private Button createLinksInWorkspaceButton;
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see
+     * org.eclipse.ui.dialogs.WizardDataTransferPage#createOptionsGroupButtons
+     * (org.eclipse.swt.widgets.Group)
+     */
     @Override
     protected void createOptionsGroupButtons(Group optionsGroup) {
 
@@ -630,6 +720,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // Determine if the finish button can be enabled
     // ------------------------------------------------------------------------
 
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.ui.dialogs.WizardDataTransferPage#validateSourceGroup()
+     */
     @Override
     public boolean validateSourceGroup() {
 
@@ -654,12 +749,12 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
 
         IContainer container = getSpecifiedContainer();
         if (container != null && container.isVirtual()) {
-            if (Platform.getPreferencesService().getBoolean(TmfUiPlugin.PLUGIN_ID, ResourcesPlugin.PREF_DISABLE_LINKING, false, null)) {
+            if (Platform.getPreferencesService().getBoolean(Activator.PLUGIN_ID, ResourcesPlugin.PREF_DISABLE_LINKING, false, null)) {
                 setMessage(null);
                 setErrorMessage(Messages.ImportTraceWizard_CannotImportFilesUnderAVirtualFolder);
                 return false;
             }
-            if (createLinksInWorkspaceButton == null || createLinksInWorkspaceButton.getSelection() == false) {
+            if (createLinksInWorkspaceButton == null || !createLinksInWorkspaceButton.getSelection()) {
                 setMessage(null);
                 setErrorMessage(Messages.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder);
                 return false;
@@ -669,24 +764,29 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         // Perform trace validation
         String traceTypeName = fTraceTypes.getText();
         if (traceTypeName != null && !"".equals(traceTypeName) && //$NON-NLS-1$
-            !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) {
+                !traceTypeName.startsWith(CUSTOM_TXT_CATEGORY) && !traceTypeName.startsWith(CUSTOM_XML_CATEGORY)) {
 
             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);
-                    if (tmfTrace != null && !tmfTrace.validate(fProject, trace.getAbsolutePath())) {
-                        setMessage(null);
-                        setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
-                        tmfTrace.dispose();
-                        return false;
+                    tmfTrace = (ITmfTrace) ce.createExecutableExtension(TmfTraceType.TRACE_TYPE_ATTR);
+                    if (tmfTrace != null) {
+                        IStatus status = tmfTrace.validate(fProject, trace.getAbsolutePath());
+                        if (!status.isOK()) {
+                            setMessage(null);
+                            setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
+                            tmfTrace.dispose();
+                            return false;
+                        }
                     }
                 } catch (CoreException e) {
                 } finally {
-                    if (tmfTrace != null)
+                    if (tmfTrace != null) {
                         tmfTrace.dispose();
+                    }
                 }
             }
         }
@@ -731,6 +831,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
     // Import the trace(s)
     // ------------------------------------------------------------------------
 
+    /**
+     * Finish the import.
+     *
+     * @return <code>true</code> if successful else false
+     */
     public boolean finish() {
         // Ensure source is valid
         File sourceDir = new File(getSourceDirectoryName());
@@ -739,9 +844,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
             return false;
         }
 
-        String sourceDirPath;
         try {
-            sourceDirPath = sourceDir.getCanonicalPath();
+            sourceDir.getCanonicalPath();
         } catch (IOException e) {
             MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
                     Messages.ImportTraceWizard_InvalidTraceDirectory);
@@ -754,7 +858,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         List<FileSystemElement> selectedResources = getSelectedResources();
         Iterator<FileSystemElement> resources = selectedResources.iterator();
 
-        // Use a map to end up with unique resources (getSelectedResources() can return duplicates)
+        // Use a map to end up with unique resources (getSelectedResources() can
+        // return duplicates)
         Map<String, File> fileSystemObjects = new HashMap<String, File>();
         while (resources.hasNext()) {
             File file = (File) resources.next().getFileSystemObject();
@@ -763,7 +868,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         }
 
         if (fileSystemObjects.size() > 0) {
-            boolean ok = importResources(sourceDirPath, fileSystemObjects);
+            boolean ok = importResources(fileSystemObjects);
             String traceBundle = null;
             String traceTypeId = null;
             String traceIcon = null;
@@ -773,7 +878,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
                 for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
                     if (traceType.equals(CUSTOM_TXT_CATEGORY + " : " + def.definitionName)) { //$NON-NLS-1$
                         traceTypeOK = true;
-                        traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName();
+                        traceBundle = Activator.getDefault().getBundle().getSymbolicName();
                         traceTypeId = CustomTxtTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
                         traceIcon = DEFAULT_TRACE_ICON_PATH;
                         break;
@@ -783,7 +888,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
                 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
                     if (traceType.equals(CUSTOM_XML_CATEGORY + " : " + def.definitionName)) { //$NON-NLS-1$
                         traceTypeOK = true;
-                        traceBundle = TmfUiPlugin.getDefault().getBundle().getSymbolicName();
+                        traceBundle = Activator.getDefault().getBundle().getSymbolicName();
                         traceTypeId = CustomXmlTrace.class.getCanonicalName() + ":" + def.definitionName; //$NON-NLS-1$
                         traceIcon = DEFAULT_TRACE_ICON_PATH;
                         break;
@@ -801,29 +906,39 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
             if (ok && traceTypeOK && !traceType.equals("")) { //$NON-NLS-1$
                 // Tag the selected traces with their type
                 List<String> files = new ArrayList<String>(fileSystemObjects.keySet());
-                Collections.sort(files);
+                Collections.sort(files, new Comparator<String>() {
+                    @Override
+                    public int compare(String o1, String o2) {
+                        String v1 = o1 + File.separatorChar;
+                        String v2 = o2 + File.separatorChar;
+                        return v1.compareTo(v2);
+                    }
+                });
                 // After sorting, traces correspond to the unique prefixes
                 String prefix = null;
                 for (int i = 0; i < files.size(); i++) {
                     File file = fileSystemObjects.get(files.get(i));
-                    String name = file.getAbsolutePath();
-                    if (prefix == null || !name.startsWith(prefix)) {
+                    String name = file.getAbsolutePath() + File.separatorChar;
+                    if (fTargetFolder != null && (prefix == null || !name.startsWith(prefix))) {
                         prefix = name; // new prefix
                         IResource resource = fTargetFolder.findMember(file.getName());
                         if (resource != null) {
                             try {
                                 // Set the trace properties for this resource
-                                resource.setPersistentProperty(TmfTraceElement.TRACEBUNDLE, traceBundle);
-                                resource.setPersistentProperty(TmfTraceElement.TRACETYPE, traceTypeId);
-                                resource.setPersistentProperty(TmfTraceElement.TRACEICON, traceIcon);
-                                for (TmfTraceElement traceElement : TmfProjectRegistry.getProject(resource.getProject()).getTracesFolder().getTraces()) {
-                                    if (traceElement.getName().equals(resource.getName())) {
-                                        traceElement.refreshTraceType();
-                                        break;
+                                resource.setPersistentProperty(TmfCommonConstants.TRACEBUNDLE, traceBundle);
+                                resource.setPersistentProperty(TmfCommonConstants.TRACETYPE, traceTypeId);
+                                resource.setPersistentProperty(TmfCommonConstants.TRACEICON, traceIcon);
+                                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) {
-                                e.printStackTrace();
+                                Activator.getDefault().logError("Error importing trace resource " + resource.getName(), e); //$NON-NLS-1$
                             }
                         }
                     }
@@ -837,17 +952,26 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
         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>();
-        for (String key : fileSystemObjects.keySet()) {
-            fileList.add(fileSystemObjects.get(key));
+        for (Entry<String, File> entry : fileSystemObjects.entrySet()) {
+            fileList.add(entry.getValue());
         }
-        Collections.sort(fileList);
+        Collections.sort(fileList, new Comparator<File>() {
+            @Override
+            public int compare(File o1, File o2) {
+                String v1 = o1.getAbsolutePath() + File.separatorChar;
+                String v2 = o2.getAbsolutePath() + File.separatorChar;
+                return v1.compareTo(v2);
+            }
+        });
 
-        // Perform a distinct import operation for everything that has the same prefix
-        // (distinct prefixes correspond to traces - we don't want to re-create parent structures)
+        // Perform a distinct import operation for everything that has the same
+        // prefix
+        // (distinct prefixes correspond to traces - we don't want to re-create
+        // parent structures)
         boolean ok = true;
         boolean isLinked = createLinksInWorkspaceButton.getSelection();
         for (int i = 0; i < fileList.size(); i++) {
@@ -857,9 +981,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage implements L
             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) {
This page took 0.03138 seconds and 5 git commands to generate.