ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / project / wizards / importtrace / ImportTraceWizardPage.java
index 8872f80bd2d878fb86242af4329f89878c59d87d..4abb69d572d26143acfead0c37aea320da4cb80f 100644 (file)
@@ -92,14 +92,12 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.dialogs.FileSystemElement;
 import org.eclipse.ui.dialogs.IOverwriteQuery;
 import org.eclipse.ui.dialogs.WizardResourceImportPage;
 import org.eclipse.ui.internal.ide.DialogUtil;
 import org.eclipse.ui.internal.ide.dialogs.IElementFilter;
 import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileManipulations;
-import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
 import org.eclipse.ui.internal.wizards.datatransfer.ILeveledImportStructureProvider;
 import org.eclipse.ui.internal.wizards.datatransfer.TarEntry;
 import org.eclipse.ui.internal.wizards.datatransfer.TarException;
@@ -115,17 +113,17 @@ import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
 import org.eclipse.ui.wizards.datatransfer.ImportOperation;
 
 /**
- * A variant of the standard resource import wizard for importing traces
- * to given tracing project. If no project or tracing project was selected
- * the wizard imports it to the default tracing project which is created
- * if necessary.
+ * A variant of the standard resource import wizard for importing traces to
+ * given tracing project. If no project or tracing project was selected the
+ * wizard imports it to the default tracing project which is created if
+ * necessary.
  *
  * In our case traces could be files or a directory structure. This wizard
- * supports both cases. It imports traces for a selected trace type or, if
- * no trace type is selected, it tries to detect the trace type automatically.
- * However, the automatic detection is a best-effort and cannot guarantee
- * that the detection is successful. The reason for this is that there might
- * be multiple trace types that can be assigned to a single trace.
+ * supports both cases. It imports traces for a selected trace type or, if no
+ * trace type is selected, it tries to detect the trace type automatically.
+ * However, the automatic detection is a best-effort and cannot guarantee that
+ * the detection is successful. The reason for this is that there might be
+ * multiple trace types that can be assigned to a single trace.
  *
  *
  * @author Francois Chouinard
@@ -137,19 +135,42 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     // ------------------------------------------------------------------------
     // Constants
     // ------------------------------------------------------------------------
-    private static final String IMPORT_WIZARD_PAGE = "ImportTraceWizardPage"; //$NON-NLS-1$
-    private static final String IMPORT_WIZARD_ROOT_DIRECTORY_ID = IMPORT_WIZARD_PAGE + ".import_root_directory_id"; //$NON-NLS-1$
-    private static final String IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID = IMPORT_WIZARD_PAGE + ".import_archive_file_name_id"; //$NON-NLS-1$
-    private static final String IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID = IMPORT_WIZARD_PAGE + ".import_unrecognized_traces_id"; //$NON-NLS-1$
-    private static final String IMPORT_WIZARD_PRESERVE_FOLDERS_ID = IMPORT_WIZARD_PAGE + ".import_preserve_folders_id"; //$NON-NLS-1$
-    private static final String IMPORT_WIZARD_IMPORT_FROM_DIRECTORY = IMPORT_WIZARD_PAGE + ".import_from_directory"; //$NON-NLS-1$
+    private static final String IMPORT_WIZARD_PAGE_NAME = "ImportTraceWizardPage"; //$NON-NLS-1$
+    private static final String IMPORT_WIZARD_ROOT_DIRECTORY_ID = ".import_root_directory_id"; //$NON-NLS-1$;
+    private static final String IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID = ".import_archive_file_name_id"; //$NON-NLS-1$
+    private static final String IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID = ".import_unrecognized_traces_id"; //$NON-NLS-1$
+    private static final String IMPORT_WIZARD_PRESERVE_FOLDERS_ID = ".import_preserve_folders_id"; //$NON-NLS-1$
+    private static final String IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID = ".import_from_directory"; //$NON-NLS-1$
     private static final String SEPARATOR = ":"; //$NON-NLS-1$
-    private static final String AUTO_DETECT = Messages.ImportTraceWizard_AutoDetection;
 
     // constant from WizardArchiveFileResourceImportPage1
     private static final String[] FILE_IMPORT_MASK = { "*.jar;*.zip;*.tar;*.tar.gz;*.tgz", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$
     private static final String TRACE_IMPORT_TEMP_FOLDER = ".traceImport"; //$NON-NLS-1$
 
+    /**
+     * A special trace type value to communicate that automatic trace type
+     * detection will occur instead of setting a specific trace type when
+     * importing the traces.
+     */
+    public static final String TRACE_TYPE_AUTO_DETECT = Messages.ImportTraceWizard_AutoDetection;
+
+    /**
+     * Preserve the folder structure of the import traces.
+     */
+    public static final int OPTION_PRESERVE_FOLDER_STRUCTURE = 1 << 1;
+    /**
+     * Create links to the trace files instead of copies.
+     */
+    public static final int OPTION_CREATE_LINKS_IN_WORKSPACE = 1 << 2;
+    /**
+     * Import files that were not recognized as the selected trace type.
+     */
+    public static final int OPTION_IMPORT_UNRECOGNIZED_TRACES = 1 << 3;
+    /**
+     * Overwrite existing resources without prompting.
+     */
+    public static final int OPTION_OVERWRITE_EXISTING_RESOURCES = 1 << 4;
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -178,11 +199,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     // Flag to remember the "create links" checkbox when it gets disabled by
     // the import from archive radio button
     private Boolean fPreviousCreateLinksValue = true;
+
     /** The archive name field */
-    private Combo fArchiveNameField;
+    protected Combo fArchiveNameField;
     /** The archive browse button. */
     protected Button fArchiveBrowseButton;
-
     /** The directory name field */
     protected Combo directoryNameField;
     /** The directory browse button. */
@@ -215,47 +236,6 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
      */
     protected ImportTraceWizardPage(String name, IStructuredSelection selection) {
         super(name, selection);
-    }
-
-    /**
-     *  Create the import source selection widget. (Copied from WizardResourceImportPage
-     *  but instead always uses the internal ResourceTreeAndListGroup to keep compatibility
-     *  with Kepler)
-     */
-    @Override
-    protected void createFileSelectionGroup(Composite parent) {
-
-        //Just create with a dummy root.
-        fSelectionGroup = new ResourceTreeAndListGroup(parent,
-                new FileSystemElement("Dummy", null, true),//$NON-NLS-1$
-                getFolderProvider(), new WorkbenchLabelProvider(),
-                getFileProvider(), new WorkbenchLabelProvider(), SWT.NONE,
-                DialogUtil.inRegularFontMode(parent));
-
-        ICheckStateListener listener = new ICheckStateListener() {
-            @Override
-            public void checkStateChanged(CheckStateChangedEvent event) {
-                updateWidgetEnablements();
-            }
-        };
-
-        WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
-        fSelectionGroup.setTreeComparator(comparator);
-        fSelectionGroup.setListComparator(comparator);
-        fSelectionGroup.addCheckStateListener(listener);
-
-    }
-
-    /**
-     * 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);
         setDescription(Messages.ImportTraceWizard_ImportTrace);
 
@@ -278,8 +258,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             }
         }
 
-         //  If no tracing project was selected or trace folder doesn't exist use
-         //  default tracing project
+        // If no tracing project was selected or trace folder doesn't exist use
+        // default tracing project
         if (traceFolder == null) {
             IProject project = TmfProjectRegistry.createProject(
                     TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, new NullProgressMonitor());
@@ -296,6 +276,45 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         }
     }
 
+    /**
+     * Constructor
+     *
+     * @param selection
+     *            The current selection
+     */
+    public ImportTraceWizardPage(IStructuredSelection selection) {
+        this(IMPORT_WIZARD_PAGE_NAME, selection);
+    }
+
+    /**
+     * Create the import source selection widget. (Copied from
+     * WizardResourceImportPage but instead always uses the internal
+     * ResourceTreeAndListGroup to keep compatibility with Kepler)
+     */
+    @Override
+    protected void createFileSelectionGroup(Composite parent) {
+
+        // Just create with a dummy root.
+        fSelectionGroup = new ResourceTreeAndListGroup(parent,
+                new FileSystemElement("Dummy", null, true),//$NON-NLS-1$
+                getFolderProvider(), new WorkbenchLabelProvider(),
+                getFileProvider(), new WorkbenchLabelProvider(), SWT.NONE,
+                DialogUtil.inRegularFontMode(parent));
+
+        ICheckStateListener listener = new ICheckStateListener() {
+            @Override
+            public void checkStateChanged(CheckStateChangedEvent event) {
+                updateWidgetEnablements();
+            }
+        };
+
+        WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
+        fSelectionGroup.setTreeComparator(comparator);
+        fSelectionGroup.setListComparator(comparator);
+        fSelectionGroup.addCheckStateListener(listener);
+
+    }
+
     // ------------------------------------------------------------------------
     // WizardResourceImportPage
     // ------------------------------------------------------------------------
@@ -341,7 +360,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                     if (element.isPopulated()) {
                         return getChildren(element).length > 0;
                     }
-                    //If we have not populated then wait until asked
+                    // If we have not populated then wait until asked
                     return true;
                 }
                 return false;
@@ -359,9 +378,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
      * @param parent
      *            the parent composite
      */
-    private void createSourceSelectionGroup(Composite workArea) {
+    protected void createSourceSelectionGroup(Composite parent) {
 
-        Composite sourceGroup = new Composite(workArea, SWT.NONE);
+        Composite sourceGroup = new Composite(parent, SWT.NONE);
         GridLayout layout = new GridLayout();
         layout.numColumns = 3;
         layout.makeColumnsEqualWidth = false;
@@ -375,17 +394,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 .setText(Messages.ImportTraceWizard_DirectoryLocation);
 
         // import location entry combo
-        directoryNameField = new Combo(sourceGroup, SWT.BORDER);
-
-        GridData directoryPathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
-        directoryPathData.widthHint = new PixelConverter(directoryNameField).convertWidthInCharsToPixels(25);
-        directoryNameField.setLayoutData(directoryPathData);
-
-        // browse button
-        directoryBrowseButton = new Button(sourceGroup, SWT.PUSH);
-        directoryBrowseButton
-                .setText(Messages.ImportTraceWizard_BrowseButton);
-        setButtonLayoutData(directoryBrowseButton);
+        directoryNameField = createPathSelectionCombo(sourceGroup);
+        createDirectoryBrowseButton(sourceGroup);
 
         // import from archive radio button
         fImportFromArchiveRadio = new Button(sourceGroup, SWT.RADIO);
@@ -393,33 +403,54 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 .setText(Messages.ImportTraceWizard_ArchiveLocation);
 
         // import location entry combo
-        fArchiveNameField = new Combo(sourceGroup, SWT.BORDER);
-
-        GridData archivePathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
-        archivePathData.widthHint = new PixelConverter(fArchiveNameField).convertWidthInCharsToPixels(25);
-        fArchiveNameField.setLayoutData(archivePathData); // browse button
-        fArchiveBrowseButton = new Button(sourceGroup, SWT.PUSH);
-        fArchiveBrowseButton.setText(DataTransferMessages.DataTransfer_browse);
-        setButtonLayoutData(fArchiveBrowseButton);
+        fArchiveNameField = createPathSelectionCombo(sourceGroup);
+        createArchiveBrowseButton(sourceGroup);
 
         fImportFromDirectoryRadio.setSelection(true);
         fArchiveNameField.setEnabled(false);
         fArchiveBrowseButton.setEnabled(false);
 
-        directoryBrowseButton.addSelectionListener(new SelectionAdapter() {
+        fImportFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                handleSourceDirectoryBrowseButtonPressed();
+                directoryRadioSelected();
             }
-
         });
 
-        fArchiveBrowseButton.addSelectionListener(new SelectionAdapter() {
+        fImportFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                handleArchiveBrowseButtonPressed();
+                archiveRadioSelected();
             }
         });
+    }
+
+    /**
+     * Select or deselect all files in the file selection group
+     *
+     * @param checked
+     *            whether or not the files should be checked
+     */
+    protected void setFileSelectionGroupChecked(boolean checked) {
+        if (fSelectionGroup != null) {
+            fSelectionGroup.setAllSelections(checked);
+        }
+    }
+
+    /**
+     * Create a combo that will be used to select a path to specify the source
+     * of the import. The parent is assumed to have a GridLayout.
+     *
+     * @param parent
+     *            the parent composite
+     * @return the created path selection combo
+     */
+    protected Combo createPathSelectionCombo(Composite parent) {
+        Combo pathSelectionCombo = new Combo(parent, SWT.BORDER);
+
+        GridData layoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+        layoutData.widthHint = new PixelConverter(pathSelectionCombo).convertWidthInCharsToPixels(25);
+        pathSelectionCombo.setLayoutData(layoutData);
 
         TraverseListener traverseListener = new TraverseListener() {
             @Override
@@ -458,54 +489,90 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             }
         };
 
-        directoryNameField.addModifyListener(modifyListner);
-        directoryNameField.addTraverseListener(traverseListener);
-        directoryNameField.addFocusListener(focusAdapter);
-        directoryNameField.addSelectionListener(selectionAdapter);
-        fArchiveNameField.addModifyListener(modifyListner);
-        fArchiveNameField.addTraverseListener(traverseListener);
-        fArchiveNameField.addFocusListener(focusAdapter);
-        fArchiveNameField.addSelectionListener(selectionAdapter);
+        pathSelectionCombo.addModifyListener(modifyListner);
+        pathSelectionCombo.addTraverseListener(traverseListener);
+        pathSelectionCombo.addFocusListener(focusAdapter);
+        pathSelectionCombo.addSelectionListener(selectionAdapter);
 
-        fImportFromDirectoryRadio.addSelectionListener(new SelectionAdapter() {
+        return pathSelectionCombo;
+    }
+
+    /**
+     * Create the directory browse button.
+     *
+     * @param parent
+     *            the parent composite
+     */
+    protected void createDirectoryBrowseButton(Composite parent) {
+        directoryBrowseButton = createPathSelectionBrowseButton(parent);
+        directoryBrowseButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                directoryRadioSelected();
+                handleSourceDirectoryBrowseButtonPressed();
             }
         });
+    }
 
-        fImportFromArchiveRadio.addSelectionListener(new SelectionAdapter() {
+    /**
+     * Create the archive browse button.
+     *
+     * @param parent
+     *            the parent composite
+     */
+    protected void createArchiveBrowseButton(Composite parent) {
+        fArchiveBrowseButton = createPathSelectionBrowseButton(parent);
+        fArchiveBrowseButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-                archiveRadioSelected();
+                handleArchiveBrowseButtonPressed(FILE_IMPORT_MASK);
             }
         });
     }
 
+    /**
+     * Create a browse button that will be used to browse for a path to specify
+     * the source of the import. The parent is assumed to have a GridLayout.
+     *
+     * @param parent
+     *            the parent composite
+     * @return the created path selection combo
+     */
+    protected Button createPathSelectionBrowseButton(Composite parent) {
+        Button pathSelectionBrowseButton = new Button(parent, SWT.PUSH);
+        pathSelectionBrowseButton.setText(Messages.ImportTraceWizard_BrowseButton);
+        setButtonLayoutData(pathSelectionBrowseButton);
+
+        return pathSelectionBrowseButton;
+    }
+
     private void archiveRadioSelected() {
-        if (fImportFromArchiveRadio.getSelection()) {
+        if (!isImportFromDirectory()) {
             directoryNameField.setEnabled(false);
             directoryBrowseButton.setEnabled(false);
             fArchiveNameField.setEnabled(true);
             fArchiveBrowseButton.setEnabled(true);
             updateFromSourceField();
             fArchiveNameField.setFocus();
-            fPreviousCreateLinksValue = fCreateLinksInWorkspaceButton.getSelection();
-            fCreateLinksInWorkspaceButton.setSelection(false);
-            fCreateLinksInWorkspaceButton.setEnabled(false);
+            if (fCreateLinksInWorkspaceButton != null) {
+                fPreviousCreateLinksValue = fCreateLinksInWorkspaceButton.getSelection();
+                fCreateLinksInWorkspaceButton.setSelection(false);
+                fCreateLinksInWorkspaceButton.setEnabled(false);
+            }
         }
     }
 
     private void directoryRadioSelected() {
-        if (fImportFromDirectoryRadio.getSelection()) {
+        if (isImportFromDirectory()) {
             directoryNameField.setEnabled(true);
             directoryBrowseButton.setEnabled(true);
             fArchiveNameField.setEnabled(false);
             fArchiveBrowseButton.setEnabled(false);
             updateFromSourceField();
             directoryNameField.setFocus();
-            fCreateLinksInWorkspaceButton.setSelection(fPreviousCreateLinksValue);
-            fCreateLinksInWorkspaceButton.setEnabled(true);
+            if (fCreateLinksInWorkspaceButton != null) {
+                fCreateLinksInWorkspaceButton.setSelection(fPreviousCreateLinksValue);
+                fCreateLinksInWorkspaceButton.setEnabled(true);
+            }
         }
     }
 
@@ -563,16 +630,19 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             }
             // If it is valid then proceed to populate
             setErrorMessage(null);
-            setSourceName(selectedDirectory);
+            setSourcePath(selectedDirectory);
         }
     }
 
     /**
      * Handle the button pressed event
+     *
+     * @param extensions
+     *            file extensions used to filter files shown to the user
      */
-    private void handleArchiveBrowseButtonPressed() {
+    protected void handleArchiveBrowseButtonPressed(String[] extensions) {
         FileDialog dialog = new FileDialog(fArchiveNameField.getShell(), SWT.SHEET);
-        dialog.setFilterExtensions(FILE_IMPORT_MASK);
+        dialog.setFilterExtensions(extensions);
         dialog.setText(Messages.ImportTraceWizard_SelectTraceArchiveTitle);
         String fileName = fArchiveNameField.getText().trim();
         if (!fileName.isEmpty()) {
@@ -585,21 +655,28 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         String selectedArchive = dialog.open();
         if (selectedArchive != null) {
             setErrorMessage(null);
-            setSourceName(selectedArchive);
+            setSourcePath(selectedArchive);
             updateWidgetEnablements();
         }
     }
 
     private File getSourceDirectory() {
+        if (directoryNameField == null) {
+            return null;
+        }
         return getSourceDirectory(directoryNameField.getText());
     }
 
     private File getSourceArchiveFile() {
+        if (fArchiveNameField == null) {
+            return null;
+        }
+
         return getSourceArchiveFile(fArchiveNameField.getText());
     }
 
     private String getSourceContainerPath() {
-        if (fImportFromDirectoryRadio.getSelection()) {
+        if (isImportFromDirectory()) {
             File sourceDirectory = getSourceDirectory();
             if (sourceDirectory != null) {
                 return sourceDirectory.getAbsolutePath();
@@ -641,16 +718,35 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     }
 
     private void updateFromSourceField() {
-        setSourceName(getSourceField().getText());
+        setSourcePath(getSourceField().getText());
         updateWidgetEnablements();
     }
 
     private Combo getSourceField() {
+        if (directoryNameField == null) {
+            return fArchiveNameField;
+        }
+
         return directoryNameField.isEnabled() ? directoryNameField : fArchiveNameField;
     }
 
-    private void setSourceName(String path) {
+    /**
+     * Set the source path that was selected by the user by various input
+     * methods (Browse button, typing, etc).
+     *
+     * Clients can also call this to set the path programmatically (hard-coded
+     * initial path) and this can also be overridden to be notified when the
+     * source path changes.
+     *
+     * @param path
+     *            the source path
+     */
+    protected void setSourcePath(String path) {
         Combo sourceField = getSourceField();
+        if (sourceField == null) {
+            return;
+        }
+
         if (path.length() > 0) {
             String[] currentItems = sourceField.getItems();
             int selectionIndex = -1;
@@ -696,7 +792,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         FileSystemObjectImportStructureProvider importStructureProvider = null;
 
         // Import from directory
-        if (fImportFromDirectoryRadio.getSelection()) {
+        if (isImportFromDirectory()) {
             importStructureProvider = new FileSystemObjectImportStructureProvider(FileSystemStructureProvider.INSTANCE, null);
             File sourceDirectory = getSourceDirectory();
             if (sourceDirectory == null) {
@@ -709,12 +805,14 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             String archivePath = getSourceArchiveFile() != null ? getSourceArchiveFile().getAbsolutePath() : ""; //$NON-NLS-1$
             if (ArchiveFileManipulations.isTarFile(archivePath)) {
                 if (ensureTarSourceIsValid(archivePath)) {
-                    // We close the file when we dispose the import provider, see disposeSelectionGroupRoot
+                    // We close the file when we dispose the import provider,
+                    // see disposeSelectionGroupRoot
                     TarFile tarFile = getSpecifiedTarSourceFile(archivePath);
                     leveledImportStructureProvider = new FileSystemObjectLeveledImportStructureProvider(new TarLeveledStructureProvider(tarFile), archivePath);
                 }
             } else if (ensureZipSourceIsValid(archivePath)) {
-                // We close the file when we dispose the import provider, see disposeSelectionGroupRoot
+                // We close the file when we dispose the import provider, see
+                // disposeSelectionGroupRoot
                 @SuppressWarnings("resource")
                 ZipFile zipFile = getSpecifiedZipSourceFile(archivePath);
                 leveledImportStructureProvider = new FileSystemObjectLeveledImportStructureProvider(new ZipLeveledStructureProvider(zipFile), archivePath);
@@ -741,6 +839,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         private IImportStructureProvider fImportProvider;
         private String fArchivePath;
+
         private FileSystemObjectImportStructureProvider(IImportStructureProvider importStructureProvider, String archivePath) {
             fImportProvider = importStructureProvider;
             fArchivePath = archivePath;
@@ -749,7 +848,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         @Override
         public List<IFileSystemObject> getChildren(Object element) {
             @SuppressWarnings("rawtypes")
-            List children = fImportProvider.getChildren(((IFileSystemObject)element).getRawFileSystemObject());
+            List children = fImportProvider.getChildren(((IFileSystemObject) element).getRawFileSystemObject());
             List<IFileSystemObject> adapted = new ArrayList<>(children.size());
             for (Object o : children) {
                 adapted.add(getIFileSystemObject(o));
@@ -757,9 +856,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return adapted;
         }
 
-       public IFileSystemObject getIFileSystemObject(Object o) {
+        public IFileSystemObject getIFileSystemObject(Object o) {
+            if (o == null) {
+                return null;
+            }
+
             if (o instanceof File) {
-                return new FileFileSystemObject((File)o);
+                return new FileFileSystemObject((File) o);
             } else if (o instanceof TarEntry) {
                 return new TarFileSystemObject((TarEntry) o, fArchivePath);
             } else if (o instanceof ZipEntry) {
@@ -771,22 +874,22 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         @Override
         public InputStream getContents(Object element) {
-            return fImportProvider.getContents(((IFileSystemObject)element).getRawFileSystemObject());
+            return fImportProvider.getContents(((IFileSystemObject) element).getRawFileSystemObject());
         }
 
         @Override
         public String getFullPath(Object element) {
-            return fImportProvider.getFullPath(((IFileSystemObject)element).getRawFileSystemObject());
+            return fImportProvider.getFullPath(((IFileSystemObject) element).getRawFileSystemObject());
         }
 
         @Override
         public String getLabel(Object element) {
-            return fImportProvider.getLabel(((IFileSystemObject)element).getRawFileSystemObject());
+            return fImportProvider.getLabel(((IFileSystemObject) element).getRawFileSystemObject());
         }
 
         @Override
         public boolean isFolder(Object element) {
-            return fImportProvider.isFolder(((IFileSystemObject)element).getRawFileSystemObject());
+            return fImportProvider.isFolder(((IFileSystemObject) element).getRawFileSystemObject());
         }
 
         /**
@@ -912,7 +1015,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 elementLabel, dummyParent, isContainer, provider);
         result.setFileSystemObject(element);
 
-        //Get the files for the element so as to build the first level
+        // Get the files for the element so as to build the first level
         result.getFiles();
 
         return dummyParent;
@@ -944,7 +1047,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         String[] availableTraceTypes = TmfTraceType.getAvailableTraceTypes();
         String[] traceTypeList = new String[availableTraceTypes.length + 1];
-        traceTypeList[0] = AUTO_DETECT;
+        traceTypeList[0] = TRACE_TYPE_AUTO_DETECT;
         for (int i = 0; i < availableTraceTypes.length; i++) {
             traceTypeList[i + 1] = availableTraceTypes[i];
         }
@@ -953,7 +1056,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             @Override
             public void widgetSelected(SelectionEvent e) {
                 updateWidgetEnablements();
-                boolean enabled = fTraceTypes.getText().equals(AUTO_DETECT);
+                boolean enabled = fTraceTypes.getText().equals(TRACE_TYPE_AUTO_DETECT);
                 fImportUnrecognizedButton.setEnabled(enabled);
             }
         });
@@ -1005,7 +1108,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     @Override
     public boolean validateSourceGroup() {
 
-        File source = fImportFromDirectoryRadio.getSelection() ? getSourceDirectory() : getSourceArchiveFile();
+        File source = isImportFromDirectory() ? getSourceDirectory() : getSourceArchiveFile();
         if (source == null) {
             setMessage(Messages.ImportTraceWizard_SelectTraceSourceEmpty);
             setErrorMessage(null);
@@ -1018,7 +1121,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return false;
         }
 
-        if (!fImportFromDirectoryRadio.getSelection()) {
+        if (!isImportFromDirectory()) {
             if (!ensureTarSourceIsValid(source.getAbsolutePath()) && !ensureZipSourceIsValid(source.getAbsolutePath())) {
                 setMessage(null);
                 setErrorMessage(Messages.ImportTraceWizard_BadArchiveFormat);
@@ -1050,40 +1153,58 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         return true;
     }
 
+    private boolean isImportFromDirectory() {
+        return fImportFromDirectoryRadio != null && fImportFromDirectoryRadio.getSelection();
+    }
+
     @Override
     protected void restoreWidgetValues() {
         super.restoreWidgetValues();
 
         IDialogSettings settings = getDialogSettings();
         boolean value;
-        if (settings.get(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID) == null) {
-            value = true;
-        } else {
-            value = settings.getBoolean(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID);
+        if (fImportUnrecognizedButton != null) {
+            if (settings.get(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID)) == null) {
+                value = true;
+            } else {
+                value = settings.getBoolean(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID));
+            }
+            fImportUnrecognizedButton.setSelection(value);
         }
-        fImportUnrecognizedButton.setSelection(value);
 
-        if (settings.get(IMPORT_WIZARD_PRESERVE_FOLDERS_ID) == null) {
-            value = true;
-        } else {
-            value = settings.getBoolean(IMPORT_WIZARD_PRESERVE_FOLDERS_ID);
+        if (fPreserveFolderStructureButton != null) {
+            if (settings.get(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID)) == null) {
+                value = true;
+            } else {
+                value = settings.getBoolean(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID));
+            }
+            fPreserveFolderStructureButton.setSelection(value);
         }
-        fPreserveFolderStructureButton.setSelection(value);
 
-        if (settings.get(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY) == null) {
+        if (settings.get(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID)) == null) {
             value = true;
         } else {
-            value = settings.getBoolean(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY);
+            value = settings.getBoolean(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID));
         }
-        restoreComboValues(directoryNameField, settings, IMPORT_WIZARD_ROOT_DIRECTORY_ID);
-        restoreComboValues(fArchiveNameField, settings, IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID);
 
-        fImportFromDirectoryRadio.setSelection(value);
-        fImportFromArchiveRadio.setSelection(!value);
-        if (value) {
-            directoryRadioSelected();
-        } else {
-            archiveRadioSelected();
+        if (directoryNameField != null) {
+            restoreComboValues(directoryNameField, settings, getPageStoreKey(IMPORT_WIZARD_ROOT_DIRECTORY_ID));
+        }
+        if (fArchiveNameField != null) {
+            restoreComboValues(fArchiveNameField, settings, getPageStoreKey(IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID));
+        }
+
+        if (fImportFromDirectoryRadio != null) {
+            fImportFromDirectoryRadio.setSelection(value);
+            if (value) {
+                directoryRadioSelected();
+            }
+        }
+        if (fImportFromArchiveRadio != null) {
+            fImportFromArchiveRadio.setSelection(!value);
+            if (!value) {
+                archiveRadioSelected();
+            }
         }
     }
 
@@ -1091,12 +1212,24 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     protected void saveWidgetValues() {
         // Persist dialog settings
         IDialogSettings settings = getDialogSettings();
-        settings.put(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID, fImportUnrecognizedButton.getSelection());
-        settings.put(IMPORT_WIZARD_PRESERVE_FOLDERS_ID, fPreserveFolderStructureButton.getSelection());
-        settings.put(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY, fImportFromDirectoryRadio.getSelection());
+        if (fImportUnrecognizedButton != null) {
+            settings.put(getPageStoreKey(IMPORT_WIZARD_IMPORT_UNRECOGNIZED_ID), fImportUnrecognizedButton.getSelection());
+        }
+        if (fPreserveFolderStructureButton != null) {
+            settings.put(getPageStoreKey(IMPORT_WIZARD_PRESERVE_FOLDERS_ID), fPreserveFolderStructureButton.getSelection());
+        }
+        settings.put(getPageStoreKey(IMPORT_WIZARD_IMPORT_FROM_DIRECTORY_ID), isImportFromDirectory());
+
+        if (directoryNameField != null) {
+            saveComboValues(directoryNameField, settings, getPageStoreKey(IMPORT_WIZARD_ROOT_DIRECTORY_ID));
+        }
+        if (fArchiveNameField != null) {
+            saveComboValues(fArchiveNameField, settings, getPageStoreKey(IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID));
+        }
+    }
 
-        saveComboValues(directoryNameField, settings, IMPORT_WIZARD_ROOT_DIRECTORY_ID);
-        saveComboValues(fArchiveNameField, settings, IMPORT_WIZARD_ARCHIVE_FILE_NAME_ID);
+    private String getPageStoreKey(String key) {
+        return getName() + key;
     }
 
     private static void restoreComboValues(Combo combo, IDialogSettings settings, String key) {
@@ -1132,9 +1265,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
      * @return <code>true</code> if successful else <code>false</code>
      */
     public boolean finish() {
-        String traceTypeName = fTraceTypes.getText();
+        String traceTypeName = getImportTraceTypeId();
         String traceId = null;
-        if (!AUTO_DETECT.equals(traceTypeName)) {
+        if (!TRACE_TYPE_AUTO_DETECT.equals(traceTypeName)) {
             String tokens[] = traceTypeName.split(SEPARATOR, 2);
             if (tokens.length < 2) {
                 return false;
@@ -1147,8 +1280,10 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         IPath baseSourceContainerPath = new Path(getSourceContainerPath());
         boolean importFromArchive = getSourceArchiveFile() != null;
+        int importOptionFlags = getImportOptionFlags();
+
         final TraceValidateAndImportOperation operation = new TraceValidateAndImportOperation(traceId, baseSourceContainerPath, getContainerFullPath(), importFromArchive,
-                fImportUnrecognizedButton.getSelection(), fOverwriteExistingResourcesCheckbox.getSelection(), fCreateLinksInWorkspaceButton.getSelection(), fPreserveFolderStructureButton.getSelection());
+                importOptionFlags);
 
         IStatus status = Status.OK_STATUS;
         try {
@@ -1165,25 +1300,62 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportTraceWizard_ImportProblem, e);
         } catch (InterruptedException e) {
             status = Status.CANCEL_STATUS;
-        } finally {
-            if (!status.isOK()) {
-                if (status.getSeverity() == IStatus.CANCEL) {
-                    setMessage(Messages.ImportTraceWizard_ImportOperationCancelled);
-                    setErrorMessage(null);
-                } else {
-                    if (status.getException() != null) {
-                        displayErrorDialog(status.getMessage() + ": " + status.getException()); //$NON-NLS-1$
-                    }
-                    setMessage(null);
-                    setErrorMessage(Messages.ImportTraceWizard_ImportProblem);
+        }
+        if (!status.isOK()) {
+            if (status.getSeverity() == IStatus.CANCEL) {
+                setMessage(Messages.ImportTraceWizard_ImportOperationCancelled);
+                setErrorMessage(null);
+            } else {
+                if (status.getException() != null) {
+                    displayErrorDialog(status.getMessage() + ": " + status.getException()); //$NON-NLS-1$
                 }
-                return false;
+                setMessage(null);
+                setErrorMessage(Messages.ImportTraceWizard_ImportProblem);
             }
+            return false;
         }
         setErrorMessage(null);
         return true;
     }
 
+    /**
+     * Get the trace type id to import as. This can also return
+     * {@link #TRACE_TYPE_AUTO_DETECT} to communicate that automatic trace type
+     * detection will occur instead of setting a specific trace type when
+     * importing the traces.
+     *
+     * @return the trace type id or {@link #TRACE_TYPE_AUTO_DETECT}
+     */
+    protected String getImportTraceTypeId() {
+        return fTraceTypes.getText();
+    }
+
+    /**
+     * Get import options in the form of flags (bits).
+     *
+     * @return the import flags.
+     * @see #OPTION_CREATE_LINKS_IN_WORKSPACE
+     * @see #OPTION_IMPORT_UNRECOGNIZED_TRACES
+     * @see #OPTION_OVERWRITE_EXISTING_RESOURCES
+     * @see #OPTION_PRESERVE_FOLDER_STRUCTURE
+     */
+    protected int getImportOptionFlags() {
+        int flags = 0;
+        if (fCreateLinksInWorkspaceButton != null && fCreateLinksInWorkspaceButton.getSelection()) {
+            flags |= OPTION_CREATE_LINKS_IN_WORKSPACE;
+        }
+        if (fImportUnrecognizedButton != null && fImportUnrecognizedButton.getSelection()) {
+            flags |= OPTION_IMPORT_UNRECOGNIZED_TRACES;
+        }
+        if (fOverwriteExistingResourcesCheckbox != null && fOverwriteExistingResourcesCheckbox.getSelection()) {
+            flags |= OPTION_OVERWRITE_EXISTING_RESOURCES;
+        }
+        if (fPreserveFolderStructureButton != null && fPreserveFolderStructureButton.getSelection()) {
+            flags |= OPTION_PRESERVE_FOLDER_STRUCTURE;
+        }
+        return flags;
+    }
+
     @Override
     public void dispose() {
         super.dispose();
@@ -1200,22 +1372,20 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         private IPath fDestinationContainerPath;
         private IPath fBaseSourceContainerPath;
         private boolean fImportFromArchive;
-        private boolean fImportUnrecognizedTraces;
-        private boolean fLink;
-        private boolean fPreserveFolderStructure;
+        private int fImportOptionFlags;
         private ImportConfirmation fConfirmationMode = ImportConfirmation.SKIP;
 
-        private TraceValidateAndImportOperation(String traceId, IPath baseSourceContainerPath, IPath destinationContainerPath, boolean importFromArchive, boolean doImport, boolean overwrite, boolean link, boolean preserveFolderStructure) {
+        private TraceValidateAndImportOperation(String traceId, IPath baseSourceContainerPath, IPath destinationContainerPath, boolean importFromArchive, int importOptionFlags) {
             fTraceType = traceId;
             fBaseSourceContainerPath = baseSourceContainerPath;
             fDestinationContainerPath = destinationContainerPath;
+            fImportOptionFlags = importOptionFlags;
             fImportFromArchive = importFromArchive;
-            fImportUnrecognizedTraces = doImport;
-            if (overwrite) {
+
+            boolean overwriteExistingResources = (importOptionFlags & OPTION_OVERWRITE_EXISTING_RESOURCES) != 0;
+            if (overwriteExistingResources) {
                 fConfirmationMode = ImportConfirmation.OVERWRITE_ALL;
             }
-            fLink = link;
-            fPreserveFolderStructure = preserveFolderStructure;
         }
 
         public void run(IProgressMonitor progressMonitor) {
@@ -1230,15 +1400,17 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                     public void filterElements(Collection elements, IProgressMonitor monitor) {
                         fileSystemElements.addAll(elements);
                     }
+
                     @Override
                     public void filterElements(Object[] elements, IProgressMonitor monitor) {
                         for (int i = 0; i < elements.length; i++) {
-                            fileSystemElements.add((TraceFileSystemElement)elements[i]);
+                            fileSystemElements.add((TraceFileSystemElement) elements[i]);
                         }
                     }
                 };
 
-                // List fileSystemElements will be filled using the passThroughFilter
+                // List fileSystemElements will be filled using the
+                // passThroughFilter
                 SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 1);
                 fSelectionGroup.getAllCheckedListItems(passThroughFilter, subMonitor);
 
@@ -1289,7 +1461,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                             }
                         }
                     } else {
-                        TraceFileSystemElement parentElement = (TraceFileSystemElement)element.getParent();
+                        TraceFileSystemElement parentElement = (TraceFileSystemElement) element.getParent();
                         String parentPath = parentElement.getFileSystemObject().getAbsolutePath(fBaseSourceContainerPath.toOSString());
                         parentElement.setDestinationContainerPath(computeDestinationContainerPath(new Path(parentPath)));
                         currentPath = parentPath;
@@ -1317,21 +1489,25 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 String errorMessage = Messages.ImportTraceWizard_ImportProblem + ": " + //$NON-NLS-1$
                         (currentPath != null ? currentPath : ""); //$NON-NLS-1$
                 Activator.getDefault().logError(errorMessage, e);
-                setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, errorMessage , e));
+                setStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, errorMessage, e));
             }
         }
 
         private Iterator<TraceFileSystemElement> extractSelectedFiles(Iterator<TraceFileSystemElement> fileSystemElementsIter, IFolder tempFolder, IProgressMonitor progressMonitor) throws InterruptedException,
                 InvocationTargetException {
             List<TraceFileSystemElement> subList = new ArrayList<>();
+            Map<IPath, String> sourceLocationMap = new HashMap<>();
             // Collect all the elements
             while (fileSystemElementsIter.hasNext()) {
                 ModalContext.checkCanceled(progressMonitor);
                 TraceFileSystemElement element = fileSystemElementsIter.next();
+                sourceLocationMap.put(new Path(element.getFileSystemObject().getName()).removeTrailingSeparator(), element.getSourceLocation());
+                TraceFileSystemElement parentElement = (TraceFileSystemElement) element.getParent();
+                sourceLocationMap.put(new Path(parentElement.getFileSystemObject().getName()).removeTrailingSeparator(), parentElement.getSourceLocation());
                 if (element.isDirectory()) {
                     Object[] array = element.getFiles().getChildren();
                     for (int i = 0; i < array.length; i++) {
-                        subList.add((TraceFileSystemElement)array[i]);
+                        subList.add((TraceFileSystemElement) array[i]);
                     }
                 }
                 subList.add(element);
@@ -1363,13 +1539,22 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
             operation.run(new SubProgressMonitor(progressMonitor, subList.size(), SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
 
-            // Create the new import provider and root element based on the extracted temp folder
+            // Create the new import provider and root element based on the
+            // extracted temp folder
             FileSystemObjectImportStructureProvider importStructureProvider = new FileSystemObjectImportStructureProvider(FileSystemStructureProvider.INSTANCE, null);
             IFileSystemObject rootElement = importStructureProvider.getIFileSystemObject(new File(tempFolder.getLocation().toOSString()));
             TraceFileSystemElement createRootElement = createRootElement(rootElement, importStructureProvider);
             List<TraceFileSystemElement> list = new ArrayList<>();
             getAllChildren(list, createRootElement);
             Iterator<TraceFileSystemElement> extractedElementsIter = list.iterator();
+            IPath tempPath = new Path(tempFolder.getLocation().toOSString());
+            for (TraceFileSystemElement element : list) {
+                IPath path = new Path(((File) element.getFileSystemObject().getRawFileSystemObject()).getAbsolutePath()).makeRelativeTo(tempPath);
+                element.setSourceLocation(sourceLocationMap.get(path));
+                TraceFileSystemElement parentElement = (TraceFileSystemElement) element.getParent();
+                IPath parentPath = new Path(((File) parentElement.getFileSystemObject().getRawFileSystemObject()).getAbsolutePath()).makeRelativeTo(tempPath);
+                parentElement.setSourceLocation(sourceLocationMap.get(parentPath));
+            }
             return extractedElementsIter;
         }
 
@@ -1389,20 +1574,22 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
             AdaptableList folders = rootElement.getFolders();
             for (Object folder : folders.getChildren()) {
-                getAllChildren(result, (TraceFileSystemElement)folder);
+                getAllChildren(result, (TraceFileSystemElement) folder);
             }
         }
 
         private IPath computeDestinationContainerPath(Path resourcePath) {
             IPath destinationContainerPath = fDestinationContainerPath;
 
-            // We need to figure out the new destination path relative to the selected "base" source directory.
+            // We need to figure out the new destination path relative to the
+            // selected "base" source directory.
             // Here for example, the selected source directory is /home/user
-            if (fPreserveFolderStructure) {
+            if ((fImportOptionFlags & OPTION_PRESERVE_FOLDER_STRUCTURE) != 0) {
                 // /home/user/bar/foo/trace -> /home/user/bar/foo
                 IPath sourceContainerPath = resourcePath.removeLastSegments(1);
                 if (fBaseSourceContainerPath.equals(resourcePath)) {
-                    // Use resourcePath directory if fBaseSourceContainerPath points to a directory trace
+                    // Use resourcePath directory if fBaseSourceContainerPath
+                    // points to a directory trace
                     sourceContainerPath = resourcePath;
                 }
                 // /home/user/bar/foo, /home/user -> bar/foo
@@ -1427,7 +1614,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                     // the trace did not match any trace type
                 }
                 if (traceTypeHelper == null) {
-                    if (fImportUnrecognizedTraces) {
+                    if ((fImportOptionFlags & OPTION_IMPORT_UNRECOGNIZED_TRACES) != 0) {
                         importResource(fileSystemElement, monitor);
                     }
                     return;
@@ -1503,12 +1690,13 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
             IPath containerPath = fileSystemElement.getDestinationContainerPath();
             IPath tracePath = containerPath.addTrailingSeparator().append(fileSystemElement.getLabel());
-            if (fileSystemElement.isDirectory() && (!fLink)) {
+            boolean createLinksInWorkspace = (fImportOptionFlags & OPTION_CREATE_LINKS_IN_WORKSPACE) != 0;
+            if (fileSystemElement.isDirectory() && !createLinksInWorkspace) {
                 containerPath = tracePath;
 
                 Object[] array = fileSystemElement.getFiles().getChildren();
                 for (int i = 0; i < array.length; i++) {
-                    subList.add((TraceFileSystemElement)array[i]);
+                    subList.add((TraceFileSystemElement) array[i]);
                 }
                 parentFolder = fileSystemElement;
 
@@ -1516,7 +1704,6 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 subList.add(fileSystemElement);
             }
 
-
             ImportProvider fileSystemStructureProvider = new ImportProvider();
 
             IOverwriteQuery myQueryImpl = new IOverwriteQuery() {
@@ -1532,11 +1719,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
             operation.setCreateContainerStructure(false);
             operation.setOverwriteResources(false);
-            operation.setCreateLinks(fLink);
+            operation.setCreateLinks(createLinksInWorkspace);
             operation.setVirtualFolders(false);
 
             operation.run(new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
-            String sourceLocation = fileSystemElement.getFileSystemObject().getSourceLocation();
+            String sourceLocation = fileSystemElement.getSourceLocation();
             IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(tracePath);
             if (sourceLocation != null) {
                 resource.setPersistentProperty(TmfCommonConstants.SOURCE_LOCATION, sourceLocation);
@@ -1559,8 +1746,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             // handle rename
             if (getExistingTrace(tracePath) != null) {
                 if ((fConfirmationMode == ImportConfirmation.RENAME_ALL) ||
-                    (fConfirmationMode == ImportConfirmation.OVERWRITE_ALL) ||
-                    (fConfirmationMode == ImportConfirmation.SKIP_ALL)) {
+                        (fConfirmationMode == ImportConfirmation.OVERWRITE_ALL) ||
+                        (fConfirmationMode == ImportConfirmation.SKIP_ALL)) {
                     return fConfirmationMode;
                 }
 
@@ -1579,12 +1766,12 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             final MessageDialog dialog = new MessageDialog(getContainer()
                     .getShell(), null, null, NLS.bind(Messages.ImportTraceWizard_TraceAlreadyExists, tracePath.makeRelativeTo(fTraceFolderElement.getProject().getPath())),
                     MessageDialog.QUESTION, new String[] {
-                        ImportConfirmation.RENAME.getInName(),
-                        ImportConfirmation.RENAME_ALL.getInName(),
-                        ImportConfirmation.OVERWRITE.getInName(),
-                        ImportConfirmation.OVERWRITE_ALL.getInName(),
-                        ImportConfirmation.SKIP.getInName(),
-                        ImportConfirmation.SKIP_ALL.getInName(),
+                            ImportConfirmation.RENAME.getInName(),
+                            ImportConfirmation.RENAME_ALL.getInName(),
+                            ImportConfirmation.OVERWRITE.getInName(),
+                            ImportConfirmation.OVERWRITE_ALL.getInName(),
+                            ImportConfirmation.SKIP.getInName(),
+                            ImportConfirmation.SKIP_ALL.getInName(),
                     }, 4) {
                 @Override
                 protected int getShellStyle() {
@@ -1618,7 +1805,8 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
                 return;
             }
 
-            // Not using IFolder on purpose to leave the door open to import directly into an IProject
+            // Not using IFolder on purpose to leave the door open to import
+            // directly into an IProject
             IContainer folder = (IContainer) trace.getParent().getResource();
             int i = 2;
             while (true) {
@@ -1667,8 +1855,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
     }
 
     /**
-     * The <code>TraceFileSystemElement</code> is a <code>FileSystemElement</code> that knows
-     * if it has been populated or not.
+     * The <code>TraceFileSystemElement</code> is a
+     * <code>FileSystemElement</code> that knows if it has been populated or
+     * not.
      */
     private static class TraceFileSystemElement extends FileSystemElement {
 
@@ -1676,6 +1865,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         private String fLabel = null;
         private IPath fDestinationContainerPath;
         private FileSystemObjectImportStructureProvider fProvider;
+        private String fSourceLocation;
 
         public TraceFileSystemElement(String name, FileSystemElement parent, boolean isDirectory, FileSystemObjectImportStructureProvider provider) {
             super(name, parent, isDirectory);
@@ -1696,7 +1886,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         @Override
         public AdaptableList getFiles() {
-            if(!fIsPopulated) {
+            if (!fIsPopulated) {
                 populateElementChildren();
             }
             return super.getFiles();
@@ -1704,7 +1894,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         @Override
         public AdaptableList getFolders() {
-            if(!fIsPopulated) {
+            if (!fIsPopulated) {
                 populateElementChildren();
             }
             return super.getFolders();
@@ -1712,6 +1902,7 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         /**
          * Sets the label for the trace to be used when importing at trace.
+         *
          * @param name
          *            the label for the trace
          */
@@ -1741,14 +1932,15 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
         }
 
         /**
-         * Populates the children of the specified parent <code>FileSystemElement</code>
+         * Populates the children of the specified parent
+         * <code>FileSystemElement</code>
          */
         private void populateElementChildren() {
             List<IFileSystemObject> allchildren = fProvider.getChildren(this.getFileSystemObject());
             Object child = null;
             TraceFileSystemElement newelement = null;
             Iterator<IFileSystemObject> iter = allchildren.iterator();
-            while(iter.hasNext()) {
+            while (iter.hasNext()) {
                 child = iter.next();
                 newelement = new TraceFileSystemElement(fProvider.getLabel(child), this, fProvider.isFolder(child), fProvider);
                 newelement.setFileSystemObject(child);
@@ -1765,6 +1957,17 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             Object fileSystemObject = super.getFileSystemObject();
             return (IFileSystemObject) fileSystemObject;
         }
+
+        public String getSourceLocation() {
+            if (fSourceLocation == null) {
+                fSourceLocation = getFileSystemObject().getSourceLocation();
+            }
+            return fSourceLocation;
+        }
+
+        public void setSourceLocation(String sourceLocation) {
+            fSourceLocation = sourceLocation;
+        }
     }
 
     /**
@@ -1775,9 +1978,15 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
      */
     private interface IFileSystemObject {
         String getLabel();
+
+        String getName();
+
         String getAbsolutePath(String parentContainerPath);
+
         String getSourceLocation();
+
         Object getRawFileSystemObject();
+
         boolean exists();
     }
 
@@ -1801,6 +2010,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return name;
         }
 
+        @Override
+        public String getName() {
+            return fFileSystemObject.getName();
+        }
+
         @Override
         public String getAbsolutePath(String parentContainerPath) {
             return fFileSystemObject.getAbsolutePath();
@@ -1858,6 +2072,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return new Path(fFileSystemObject.getName()).lastSegment();
         }
 
+        @Override
+        public String getName() {
+            return fFileSystemObject.getName();
+        }
+
         @Override
         public String getAbsolutePath(String parentContainerPath) {
             return new Path(parentContainerPath).append(fFileSystemObject.getName()).toOSString();
@@ -1899,6 +2118,11 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
             return new Path(fFileSystemObject.getName()).lastSegment();
         }
 
+        @Override
+        public String getName() {
+            return fFileSystemObject.getName();
+        }
+
         @Override
         public String getAbsolutePath(String parentContainerPath) {
             return new Path(parentContainerPath).append(fFileSystemObject.getName()).toOSString();
@@ -1929,36 +2153,36 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         @Override
         public String getLabel(Object element) {
-            TraceFileSystemElement resource = (TraceFileSystemElement)element;
+            TraceFileSystemElement resource = (TraceFileSystemElement) element;
             return resource.getLabel();
         }
 
         @Override
         public List getChildren(Object element) {
-            TraceFileSystemElement resource = (TraceFileSystemElement)element;
+            TraceFileSystemElement resource = (TraceFileSystemElement) element;
             Object[] array = resource.getFiles().getChildren();
-                    List<Object> list = new ArrayList<>();
-                    for (int i = 0; i < array.length; i++) {
-                        list.add(array[i]);
-                    }
+            List<Object> list = new ArrayList<>();
+            for (int i = 0; i < array.length; i++) {
+                list.add(array[i]);
+            }
             return list;
         }
 
         @Override
         public InputStream getContents(Object element) {
-            TraceFileSystemElement resource = (TraceFileSystemElement)element;
+            TraceFileSystemElement resource = (TraceFileSystemElement) element;
             return resource.getProvider().getContents(resource.getFileSystemObject());
         }
 
         @Override
         public String getFullPath(Object element) {
-            TraceFileSystemElement resource = (TraceFileSystemElement)element;
+            TraceFileSystemElement resource = (TraceFileSystemElement) element;
             return resource.getProvider().getFullPath(resource.getFileSystemObject());
         }
 
         @Override
         public boolean isFolder(Object element) {
-            TraceFileSystemElement resource = (TraceFileSystemElement)element;
+            TraceFileSystemElement resource = (TraceFileSystemElement) element;
             return resource.isDirectory();
         }
     }
@@ -1989,7 +2213,9 @@ public class ImportTraceWizardPage extends WizardResourceImportPage {
 
         /**
          * Private constructor
-         * @param name the name of state
+         *
+         * @param name
+         *            the name of state
          */
         private ImportConfirmation(String name) {
             fInName = name;
This page took 0.072355 seconds and 5 git commands to generate.