tmf: Remove legacy import wizard
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 20 Nov 2013 23:00:01 +0000 (18:00 -0500)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Wed, 27 Nov 2013 22:26:07 +0000 (17:26 -0500)
Change-Id: I5915c26efd4f076959ea791d8b7d33b2cec1ce56
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/18694
Tested-by: Hudson CI
org.eclipse.linuxtools.tmf.ui/plugin.properties
org.eclipse.linuxtools.tmf.ui/plugin.xml
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/BatchImportTraceHandler.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ImportTraceHandler.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/Messages.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/BatchImportTraceWizard.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizard.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/messages.properties

index 53c46b9550fe9763f07977800a2054229fa7ed05..ef4aea26d13f9b6ca0a3fb588bbf2c1750c1fa77 100644 (file)
@@ -107,10 +107,6 @@ command.synchronize_traces.description = Synchronize 2 or more traces
 ## Trace folder menu
 #  Import, Refresh
 
-command.import = Import...
-command.import.mnemonic = I
-command.import.description = Import traces into project
-
 command.batch_import = Batch Import...
 command.batch_import.mnemonic = A
 command.batch_import.description = Batch Import traces into project
index 32f7e06ef5b74702c3ed060109ab419f85af41d6..9403911c8a005b13729db0e696faf68f15a532a1 100644 (file)
             id="org.eclipse.linuxtools.tmf.import.category"
             name="%project.new.category.name">
       </category>
-      <wizard
-            category="org.eclipse.linuxtools.tmf.import.category"
-            class="org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.ImportTraceWizard"
-            icon="icons/etool16/import.gif"
-            id="org.eclipse.linuxtools.tmf.ui.trace.import.wizard"
-            name="%project.import.wizard.name">
-      </wizard>
       <wizard
             category="org.eclipse.linuxtools.tmf.import.category"
             class="org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard"
          point="org.eclipse.ui.menus">
       <menuContribution
             locationURI="popup:org.eclipse.ui.popup.any?after=additions">
-         <command
-               commandId="org.eclipse.ui.file.import"
-               label="%command.import"
-               mnemonic="%command.import.mnemonic"
-               style="push">
-            <visibleWhen
-                  checkEnabled="false">
-               <with
-                     variable="selection">
-                  <count
-                        value="1">
-                  </count>
-                  <iterate
-                        operator="and">
-                     <instanceof
-                           value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
-                     </instanceof>
-                  </iterate>
-               </with>
-            </visibleWhen>
-         </command>
          <command
                commandId="org.eclipse.linuxtools.tmf.ui.batch_import"
                label="%command.batch_import"
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
-      <handler
-            class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.ImportTraceHandler"
-            commandId="org.eclipse.ui.file.import">
-         <activeWhen>
-            <and>
-               <count
-                     value="1">
-               </count>
-               <iterate
-                     ifEmpty="false"
-                     operator="and">
-                  <instanceof
-                        value="org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder">
-                  </instanceof>
-               </iterate>
-            </and>
-         </activeWhen>
-      </handler>
       <handler
             class="org.eclipse.linuxtools.internal.tmf.ui.project.handlers.RefreshHandler"
             commandId="org.eclipse.ui.file.refresh">
index ec7c8a5c7f42870675b8ae63f7f6a4efc2ef76ec..93d54fbf0d4130948e6ea8ae850052dd84513281 100644 (file)
 
 package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
 
+import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
 import org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.BatchImportTraceWizard;
 import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.handlers.HandlerUtil;
@@ -30,7 +36,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
  * @author Matthew Khouzam
  * @since 2.0
  */
-public class BatchImportTraceHandler extends ImportTraceHandler {
+public class BatchImportTraceHandler extends AbstractHandler {
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -63,4 +69,38 @@ public class BatchImportTraceHandler extends ImportTraceHandler {
         return null;
     }
 
+    /**
+     * @return the trace folder or null
+     */
+    private static TmfTraceFolder getTraceFolder() {
+        // Check if we are closing down
+        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        if (window == null) {
+            return null;
+        }
+
+        // Get the selection
+        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+        IWorkbenchPart part = page.getActivePart();
+        if (part == null) {
+            return null;
+        }
+        ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
+        if (selectionProvider == null) {
+            return null;
+        }
+        ISelection selection = selectionProvider.getSelection();
+
+        TmfTraceFolder traceFolder = null;
+        if (selection instanceof TreeSelection) {
+            TreeSelection sel = (TreeSelection) selection;
+            // There should be only one item selected as per the plugin.xml
+            Object element = sel.getFirstElement();
+            if (element instanceof TmfTraceFolder) {
+                traceFolder = (TmfTraceFolder) element;
+            }
+        }
+        return traceFolder;
+    }
+
 }
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ImportTraceHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/handlers/ImportTraceHandler.java
deleted file mode 100644 (file)
index bfa8bc5..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.tmf.ui.project.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
-import org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <b><u>ImportTraceHandler</u></b>
- * <p>
- * Starts an ImportTraceWizard that will handle the lowly details.
- */
-public class ImportTraceHandler extends AbstractHandler {
-
-    // ------------------------------------------------------------------------
-    // Execution
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-
-        TmfTraceFolder traceFolder = getTraceFolder();
-        if (traceFolder == null) {
-            return null;
-        }
-        // Fire the Import Trace Wizard
-        IWorkbench workbench = PlatformUI.getWorkbench();
-        Shell shell = workbench.getActiveWorkbenchWindow().getShell();
-
-        ImportTraceWizard wizard = new ImportTraceWizard();
-        wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder));
-        WizardDialog dialog = new WizardDialog(shell, wizard);
-        dialog.open();
-
-        traceFolder.refresh();
-
-        return null;
-    }
-
-    /**
-     * @return the trace folder or null
-     */
-    protected TmfTraceFolder getTraceFolder() {
-        // Check if we are closing down
-        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-        if (window == null) {
-            return null;
-        }
-
-        // Get the selection
-        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
-        IWorkbenchPart part = page.getActivePart();
-        if (part == null) {
-            return null;
-        }
-        ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
-        if (selectionProvider == null) {
-            return null;
-        }
-        ISelection selection = selectionProvider.getSelection();
-
-        TmfTraceFolder traceFolder = null;
-        if (selection instanceof TreeSelection) {
-            TreeSelection sel = (TreeSelection) selection;
-            // There should be only one item selected as per the plugin.xml
-            Object element = sel.getFirstElement();
-            if (element instanceof TmfTraceFolder) {
-                traceFolder = (TmfTraceFolder) element;
-            }
-        }
-        return traceFolder;
-    }
-
-}
index bea988e72d4bae8a1b9178ac875e58b6757b9a28..579232771ced8c1c0484cd124dc66538ca084262 100644 (file)
@@ -33,96 +33,25 @@ public class Messages extends NLS {
      */
     public static String NewProjectWizard_DialogMessage;
     /**
-     * The dialog title of the import trace wizard
-     */
-    public static String ImportTraceWizard_DialogTitle;
-    /**
-     * The title of the file system within the import trace wizard
-     */
-    public static String ImportTraceWizard_FileSystemTitle;
-    /**
-     * The title of the the import trace wizard page.
-     */
-    public static String ImportTraceWizard_ImportTrace;
-    /**
-     * The label of the directory location (import trace wizard)
-     */
-    public static String ImportTraceWizard_DirectoryLocation;
-    /**
-     * The title of the select trace directory dialog (import trace wizard)
-     */
-    public static String ImportTraceWizard_SelectTraceDirectoryTitle;
-    /**
-     * The message of the select trace directory dialog (import trace wizard)
-     */
-    public static String ImportTraceWizard_SelectTraceDirectoryMessage;
-    /**
-     * The title of the trace type label (import trace wizard)
-     */
-    public static String ImportTraceWizard_TraceType;
-    /**
-     * The label of the overwrite checkbox (import trace wizard)
-     */
-    public static String ImportTraceWizard_OverwriteExistingTrace;
-    /**
-     * The label of the checkbox to create a link to the trace in workspace (import trace wizard)
-     */
-    public static String ImportTraceWizard_CreateLinksInWorkspace;
-    /**
-     * The error message for invalid trace directory (import trace wizard)
-     */
-    public static String ImportTraceWizard_InvalidTraceDirectory;
-    /**
-     * The error message when a trace validation failed (import trace wizard).
-     */
-    public static String ImportTraceWizard_TraceValidationFailed;
-    /**
-     * The error message when trace source is empty (import trace wizard).
-     */
-    public static String ImportTraceWizard_SelectTraceSourceEmpty;
-    /**
-     * The error message when no trace is selected (import trace wizard).
-     */
-    public static String ImportTraceWizard_SelectTraceNoneSelected;
-    /**
-     * The error message when an error occurred during import operation.
-     */
-    public static String ImportTraceWizard_ImportProblem;
-    /**
-     * The error message if destination directory is a virtual folder.
-     */
-    public static String ImportTraceWizard_CannotImportFilesUnderAVirtualFolder;
-    /**
-     * The error message if destination directory is a virtual folder (for a link).
+     *  The title of the select traces wizard.
      */
-    public static String ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder;
+    public static String SelectTracesWizard_WindowTitle;
     /**
-     * The label string of the browse button.
+     * The column header for the traces (select traces wizard page).
      */
-    public static String ImportTraceWizard_BrowseButton;
+    public static String SelectTracesWizardPage_TraceColumnHeader;
     /**
-     * The information label string.
+     * The title of select traces wizard page.
      */
-    public static String ImportTraceWizard_Information;
+    public static String SelectTracesWizardPage_WindowTitle;
     /**
-     *  The title of the select traces wizard.
+     * The description of the select traces wizard page.
      */
-    public static String SelectTracesWizard_WindowTitle;
+    public static String SelectTracesWizardPage_Description;
     /**
-     * The column header for the traces (select traces wizard page).
+     * The error message when no name was entered in a dialog box (new trace or
+     * experiment dialog)
      */
-       public static String SelectTracesWizardPage_TraceColumnHeader;
-       /**
-        * The title of select traces wizard page.
-        */
-       public static String SelectTracesWizardPage_WindowTitle;
-       /**
-        * The description of the select traces wizard page.
-        */
-       public static String SelectTracesWizardPage_Description;
-       /**
-        * The error message when no name was entered in a dialog box (new trace or experiment dialog)
-        */
     public static String Dialog_EmptyNameError;
     /**
      * The error message when name of trace or experiment already exists
index d5d98cfdf02822832061bf99837f4d69c90975da..b1074d65c004748c6fb5c741564bf7eea7361f4e 100644 (file)
@@ -45,6 +45,7 @@ import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper;
@@ -56,6 +57,7 @@ import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;
 import org.eclipse.linuxtools.tmf.ui.project.model.TraceTypeHelper;
 import org.eclipse.linuxtools.tmf.ui.project.model.TraceValidationHelper;
+import org.eclipse.ui.IImportWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.dialogs.IOverwriteQuery;
 import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
@@ -67,7 +69,7 @@ import org.eclipse.ui.wizards.datatransfer.ImportOperation;
  * @author Matthew Khouzam
  * @since 2.0
  */
-public class BatchImportTraceWizard extends ImportTraceWizard {
+public class BatchImportTraceWizard extends Wizard implements IImportWizard {
 
     private static final int WIN_HEIGHT = 400;
     private static final int WIN_WIDTH = 800;
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizard.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizard.java
deleted file mode 100644 (file)
index b56a2dd..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace;
-
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.tmf.ui.project.wizards.Messages;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * The import trace wizard implementation.
- * <p>
- * @version 1.0
- * @author Francois Chouinard
- * @since 2.0
- */
-public class ImportTraceWizard extends Wizard implements IImportWizard {
-
-    // ------------------------------------------------------------------------
-    // Constants
-    // ------------------------------------------------------------------------
-
-    static private final String PLUGIN_ID = Activator.PLUGIN_ID;
-    static private final String IMPORT_WIZARD = "ImportTraceWizard"; //$NON-NLS-1$
-    static private final String ICON_PATH = "icons/wizban/trace_import_wiz.png"; //$NON-NLS-1$
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    private IWorkbench fWorkbench;
-    private IStructuredSelection fSelection;
-    private ImportTraceWizardPage fTraceImportWizardPage;
-
-    // ------------------------------------------------------------------------
-    // Constructor
-    // ------------------------------------------------------------------------
-    /**
-     * Default constructor
-     */
-    public ImportTraceWizard() {
-        IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings();
-        IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
-        if (section == null) {
-            section = workbenchSettings.addNewSection(IMPORT_WIZARD);
-        }
-        setDialogSettings(section);
-    }
-
-    // ------------------------------------------------------------------------
-    // Wizard
-    // ------------------------------------------------------------------------
-
-    @Override
-    public void init(IWorkbench workbench, IStructuredSelection selection) {
-        fWorkbench = workbench;
-        fSelection = selection;
-
-        List<?> selectedResources = IDE.computeSelectedResources(selection);
-        if (!selectedResources.isEmpty()) {
-            fSelection = new StructuredSelection(selectedResources);
-        }
-
-        setWindowTitle(Messages.ImportTraceWizard_DialogTitle);
-        setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
-        setNeedsProgressMonitor(true);
-    }
-
-    @Override
-    public void addPages() {
-        super.addPages();
-        fTraceImportWizardPage = new ImportTraceWizardPage(fWorkbench, fSelection);
-        addPage(fTraceImportWizardPage);
-    }
-
-    @Override
-    public boolean performFinish() {
-        return fTraceImportWizardPage.finish();
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/wizards/importtrace/ImportTraceWizardPage.java
deleted file mode 100644 (file)
index 41e7af6..0000000
+++ /dev/null
@@ -1,881 +0,0 @@
-/*******************************************************************************
- * 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
- *   Matthew Khouzam - Moved out some common functions
- *   Patrick Tasse - Add sorting of file system elements
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.project.wizards.importtrace;
-
-import java.io.File;
-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;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-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.tmf.core.TmfProjectNature;
-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.linuxtools.tmf.ui.project.model.TraceTypeHelper;
-import org.eclipse.linuxtools.tmf.ui.project.wizards.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-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.ui.IWorkbench;
-import org.eclipse.ui.dialogs.FileSystemElement;
-import org.eclipse.ui.dialogs.WizardResourceImportPage;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
-import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-
-/**
- * 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>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.
- * <p>
- *
- * @version 1.0
- * @author Francois Chouinard
- * @since 2.0
- */
-public class ImportTraceWizardPage extends WizardResourceImportPage {
-
-    // ------------------------------------------------------------------------
-    // Classes
-    // ------------------------------------------------------------------------
-
-    private static class FileSystemElementComparator implements Comparator<Object> {
-
-        FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE;
-
-        @Override
-        public int compare(Object o1, Object o2) {
-            String label1 = provider.getLabel(o1);
-            String label2 = provider.getLabel(o2);
-            return label1.compareTo(label2);
-        }
-
-    }
-
-    // ------------------------------------------------------------------------
-    // Constants
-    // ------------------------------------------------------------------------
-
-    private static final String IMPORT_WIZARD_PAGE = "ImportTraceWizardPage"; //$NON-NLS-1$
-    private static final FileSystemElementComparator FILE_SYSTEM_ELEMENT_COMPARATOR = new FileSystemElementComparator();
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    // Folder navigation start point (saved between invocations)
-    private static String fRootDirectory = null;
-
-    // Navigation folder content viewer and selector
-    private CheckboxTreeViewer fFolderViewer;
-
-    // Target import directory ('Traces' folder)
-    private IFolder fTargetFolder;
-    private static final String SEPARATOR = ":"; //$NON-NLS-1$
-
-    // ------------------------------------------------------------------------
-    // 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);
-        setDescription(Messages.ImportTraceWizard_ImportTrace);
-
-        // Locate the target trace folder
-        IFolder traceFolder = null;
-        Object element = selection.getFirstElement();
-
-        if (element instanceof TmfTraceFolder) {
-            TmfTraceFolder tmfTraceFolder = (TmfTraceFolder) element;
-            tmfTraceFolder.getProject().getResource();
-            traceFolder = tmfTraceFolder.getResource();
-        } else if (element instanceof IProject) {
-            IProject project = (IProject) element;
-            try {
-                if (project.hasNature(TmfProjectNature.ID)) {
-                    traceFolder = (IFolder) project.findMember(TmfTraceFolder.TRACE_FOLDER_NAME);
-                }
-            } catch (CoreException e) {
-            }
-        }
-
-        // Set the target trace folder
-        if (traceFolder != null) {
-            fTargetFolder = traceFolder;
-            String path = traceFolder.getFullPath().toOSString();
-            setContainerFieldValue(path);
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // WizardResourceImportPage
-    // ------------------------------------------------------------------------
-
-    @Override
-    public void createControl(Composite parent) {
-        super.createControl(parent);
-        // Restore last directory if applicable
-        if (fRootDirectory != null) {
-            directoryNameField.setText(fRootDirectory);
-            updateFromSourceField();
-        }
-    }
-
-    @Override
-    protected void createSourceGroup(Composite parent) {
-        createDirectorySelectionGroup(parent);
-        createFileSelectionGroup(parent);
-        createTraceTypeGroup(parent);
-        validateSourceGroup();
-    }
-
-    @Override
-    protected void createFileSelectionGroup(Composite parent) {
-
-        // This Composite is only used for widget alignment purposes
-        Composite composite = new Composite(parent, SWT.NONE);
-        composite.setFont(parent.getFont());
-        GridLayout layout = new GridLayout();
-        composite.setLayout(layout);
-        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        final int PREFERRED_LIST_HEIGHT = 150;
-
-        fFolderViewer = new CheckboxTreeViewer(composite, SWT.BORDER);
-        GridData data = new GridData(GridData.FILL_BOTH);
-        data.heightHint = PREFERRED_LIST_HEIGHT;
-        fFolderViewer.getTree().setLayoutData(data);
-        fFolderViewer.getTree().setFont(parent.getFont());
-
-        fFolderViewer.setContentProvider(getFileProvider());
-        fFolderViewer.setLabelProvider(new WorkbenchLabelProvider());
-        fFolderViewer.addCheckStateListener(new ICheckStateListener() {
-            @Override
-            public void checkStateChanged(CheckStateChangedEvent event) {
-                Object elem = event.getElement();
-                if (elem instanceof FileSystemElement) {
-                    FileSystemElement element = (FileSystemElement) elem;
-                    if (fFolderViewer.getGrayed(element)) {
-                        fFolderViewer.setSubtreeChecked(element, false);
-                        fFolderViewer.setGrayed(element, false);
-                    } else if (event.getChecked()) {
-                        fFolderViewer.setSubtreeChecked(event.getElement(), true);
-                    } else {
-                        fFolderViewer.setParentsGrayed(element, true);
-                        if (!element.isDirectory()) {
-                            fFolderViewer.setGrayed(element, false);
-                        }
-                    }
-                    updateWidgetEnablements();
-                }
-            }
-        });
-    }
-
-    @Override
-    protected ITreeContentProvider getFolderProvider() {
-        return null;
-    }
-
-    @Override
-    protected ITreeContentProvider getFileProvider() {
-        return new WorkbenchContentProvider() {
-            @Override
-            public Object[] getChildren(Object o) {
-                if (o instanceof FileSystemElement) {
-                    FileSystemElement element = (FileSystemElement) o;
-                    populateChildren(element);
-                    // For our purpose, we need folders + files
-                    Object[] folders = element.getFolders().getChildren();
-                    Object[] files = element.getFiles().getChildren();
-
-                    List<Object> result = new LinkedList<Object>();
-                    for (Object folder : folders) {
-                        result.add(folder);
-                    }
-                    for (Object file : files) {
-                        result.add(file);
-                    }
-
-                    return result.toArray();
-                }
-                return new Object[0];
-            }
-        };
-    }
-
-    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) {
-            Object fileSystemObject = parent.getFileSystemObject();
-            List<?> children = provider.getChildren(fileSystemObject);
-            if (children != null) {
-                Collections.sort(children, FILE_SYSTEM_ELEMENT_COMPARATOR);
-                Iterator<?> iterator = children.iterator();
-                while (iterator.hasNext()) {
-                    Object child = iterator.next();
-                    String label = provider.getLabel(child);
-                    FileSystemElement element = new FileSystemElement(label, parent, provider.isFolder(child));
-                    element.setFileSystemObject(child);
-                }
-            }
-        }
-    }
-
-    @Override
-    protected List<FileSystemElement> getSelectedResources() {
-        List<FileSystemElement> resources = new ArrayList<FileSystemElement>();
-        Object[] checkedItems = fFolderViewer.getCheckedElements();
-        for (Object item : checkedItems) {
-            if (item instanceof FileSystemElement && !fFolderViewer.getGrayed(item)) {
-                resources.add((FileSystemElement) item);
-            }
-        }
-        return resources;
-    }
-
-    // ------------------------------------------------------------------------
-    // 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);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 3;
-        directoryContainerGroup.setLayout(layout);
-        directoryContainerGroup.setFont(parent.getFont());
-        directoryContainerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-        // Label ("Trace directory:")
-        Label groupLabel = new Label(directoryContainerGroup, SWT.NONE);
-        groupLabel.setText(Messages.ImportTraceWizard_DirectoryLocation);
-        groupLabel.setFont(parent.getFont());
-
-        // Directory name entry field
-        directoryNameField = new Combo(directoryContainerGroup, SWT.BORDER);
-        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
-        data.widthHint = SIZING_TEXT_FIELD_WIDTH;
-        directoryNameField.setLayoutData(data);
-        directoryNameField.setFont(parent.getFont());
-
-        directoryNameField.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                updateFromSourceField();
-            }
-        });
-
-        directoryNameField.addKeyListener(new KeyListener() {
-            @Override
-            public void keyPressed(KeyEvent e) {
-                // If there has been a key pressed then mark as dirty
-                entryChanged = true;
-                if (e.character == SWT.CR) { // Windows...
-                    entryChanged = false;
-                    updateFromSourceField();
-                }
-            }
-
-            @Override
-            public void keyReleased(KeyEvent e) {
-            }
-        });
-
-        directoryNameField.addFocusListener(new FocusListener() {
-            @Override
-            public void focusGained(FocusEvent e) {
-                // Do nothing when getting focus
-            }
-
-            @Override
-            public void focusLost(FocusEvent e) {
-                // Clear the flag to prevent constant update
-                if (entryChanged) {
-                    entryChanged = false;
-                    updateFromSourceField();
-                }
-            }
-        });
-
-        // Browse button
-        directoryBrowseButton = new Button(directoryContainerGroup, SWT.PUSH);
-        directoryBrowseButton.setText(Messages.ImportTraceWizard_BrowseButton);
-        directoryBrowseButton.addListener(SWT.Selection, this);
-        directoryBrowseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-        directoryBrowseButton.setFont(parent.getFont());
-        setButtonLayoutData(directoryBrowseButton);
-    }
-
-    // ------------------------------------------------------------------------
-    // Browse for the source directory
-    // ------------------------------------------------------------------------
-
-    @Override
-    public void handleEvent(Event event) {
-        if (event.widget == directoryBrowseButton) {
-            handleSourceDirectoryBrowseButtonPressed();
-        }
-        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);
-        dialog.setText(Messages.ImportTraceWizard_SelectTraceDirectoryTitle);
-        dialog.setMessage(Messages.ImportTraceWizard_SelectTraceDirectoryMessage);
-        dialog.setFilterPath(getSourceDirectoryName(currentSource));
-
-        String selectedDirectory = dialog.open();
-        if (selectedDirectory != null) {
-            // Just quit if the directory is not valid
-            if ((getSourceDirectory(selectedDirectory) == null) || selectedDirectory.equals(currentSource)) {
-                return;
-            }
-            // If it is valid then proceed to populate
-            setErrorMessage(null);
-            setSourceName(selectedDirectory);
-        }
-    }
-
-    private File getSourceDirectory() {
-        return getSourceDirectory(directoryNameField.getText());
-    }
-
-    private static File getSourceDirectory(String path) {
-        File sourceDirectory = new File(getSourceDirectoryName(path));
-        if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
-            return null;
-        }
-
-        return sourceDirectory;
-    }
-
-    private static String getSourceDirectoryName(String sourceName) {
-        IPath result = new Path(sourceName.trim());
-        if (result.getDevice() != null && result.segmentCount() == 0) {
-            result = result.addTrailingSeparator();
-        } else {
-            result = result.removeTrailingSeparator();
-        }
-        return result.toOSString();
-    }
-
-    private String getSourceDirectoryName() {
-        return getSourceDirectoryName(directoryNameField.getText());
-    }
-
-    private void updateFromSourceField() {
-        setSourceName(directoryNameField.getText());
-        updateWidgetEnablements();
-    }
-
-    private void setSourceName(String path) {
-        if (path.length() > 0) {
-            String[] currentItems = directoryNameField.getItems();
-            int selectionIndex = -1;
-            for (int i = 0; i < currentItems.length; i++) {
-                if (currentItems[i].equals(path)) {
-                    selectionIndex = i;
-                }
-            }
-            if (selectionIndex < 0) {
-                int oldLength = currentItems.length;
-                String[] newItems = new String[oldLength + 1];
-                System.arraycopy(currentItems, 0, newItems, 0, oldLength);
-                newItems[oldLength] = path;
-                directoryNameField.setItems(newItems);
-                selectionIndex = oldLength;
-            }
-            directoryNameField.select(selectionIndex);
-        }
-        resetSelection();
-    }
-
-    // ------------------------------------------------------------------------
-    // File Selection Group (forked WizardFileSystemResourceImportPage1)
-    // ------------------------------------------------------------------------
-
-    private void resetSelection() {
-        FileSystemElement root = getFileSystemTree();
-        populateListViewer(root);
-    }
-
-    private void populateListViewer(final Object treeElement) {
-        fFolderViewer.setInput(treeElement);
-    }
-
-    private FileSystemElement getFileSystemTree() {
-        File sourceDirectory = getSourceDirectory();
-        if (sourceDirectory == null) {
-            return null;
-        }
-        return selectFiles(sourceDirectory, FileSystemStructureProvider.INSTANCE);
-    }
-
-    private FileSystemElement selectFiles(final Object rootFileSystemObject, final IImportStructureProvider structureProvider) {
-        final FileSystemElement[] results = new FileSystemElement[1];
-        BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
-            @Override
-            public void run() {
-                // Create the root element from the supplied file system object
-                results[0] = createRootElement(rootFileSystemObject, structureProvider);
-            }
-        });
-        return results[0];
-    }
-
-    private static FileSystemElement createRootElement(Object fileSystemObject,
-            IImportStructureProvider provider) {
-
-        boolean isContainer = provider.isFolder(fileSystemObject);
-        String elementLabel = provider.getLabel(fileSystemObject);
-
-        FileSystemElement dummyParent = new FileSystemElement("", null, true); //$NON-NLS-1$
-        FileSystemElement element = new FileSystemElement(elementLabel, dummyParent, isContainer);
-        element.setFileSystemObject(fileSystemObject);
-
-        // Get the first level
-        populateChildren(element);
-
-        return dummyParent;
-    }
-
-    // ------------------------------------------------------------------------
-    // Trace Type Group
-    // ------------------------------------------------------------------------
-
-    private Combo fTraceTypes;
-
-    private final void createTraceTypeGroup(Composite parent) {
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 3;
-        layout.makeColumnsEqualWidth = false;
-        composite.setLayout(layout);
-        composite.setFont(parent.getFont());
-        GridData buttonData = new GridData(SWT.FILL, SWT.FILL, true, false);
-        composite.setLayoutData(buttonData);
-
-        // Trace type label ("Trace Type:")
-        Label typeLabel = new Label(composite, SWT.NONE);
-        typeLabel.setText(Messages.ImportTraceWizard_TraceType);
-        typeLabel.setFont(parent.getFont());
-
-        // Trace type combo
-        fTraceTypes = new Combo(composite, SWT.BORDER);
-        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
-        fTraceTypes.setLayoutData(data);
-        fTraceTypes.setFont(parent.getFont());
-
-        String[] availableTraceTypes = TmfTraceType.getInstance().getAvailableTraceTypes();
-        fTraceTypes.setItems(availableTraceTypes);
-
-        fTraceTypes.addSelectionListener(new SelectionListener() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                updateWidgetEnablements();
-            }
-
-            @Override
-            public void widgetDefaultSelected(SelectionEvent e) {
-            }
-        });
-    }
-
-    // ------------------------------------------------------------------------
-    // Options
-    // ------------------------------------------------------------------------
-
-    private Button overwriteExistingResourcesCheckbox;
-    private Button createLinksInWorkspaceButton;
-
-    @Override
-    protected void createOptionsGroupButtons(Group optionsGroup) {
-
-        // Overwrite checkbox
-        overwriteExistingResourcesCheckbox = new Button(optionsGroup, SWT.CHECK);
-        overwriteExistingResourcesCheckbox.setFont(optionsGroup.getFont());
-        overwriteExistingResourcesCheckbox.setText(Messages.ImportTraceWizard_OverwriteExistingTrace);
-        overwriteExistingResourcesCheckbox.setSelection(false);
-
-        // Create links checkbox
-        createLinksInWorkspaceButton = new Button(optionsGroup, SWT.CHECK);
-        createLinksInWorkspaceButton.setFont(optionsGroup.getFont());
-        createLinksInWorkspaceButton.setText(Messages.ImportTraceWizard_CreateLinksInWorkspace);
-        createLinksInWorkspaceButton.setSelection(true);
-
-        createLinksInWorkspaceButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                updateWidgetEnablements();
-            }
-        });
-
-        updateWidgetEnablements();
-    }
-
-    // ------------------------------------------------------------------------
-    // Determine if the finish button can be enabled
-    // ------------------------------------------------------------------------
-
-    @Override
-    public boolean validateSourceGroup() {
-
-        File sourceDirectory = getSourceDirectory();
-        if (sourceDirectory == null) {
-            setMessage(Messages.ImportTraceWizard_SelectTraceSourceEmpty);
-            return false;
-        }
-
-        if (sourceConflictsWithDestination(new Path(sourceDirectory.getPath()))) {
-            setMessage(null);
-            setErrorMessage(getSourceConflictMessage());
-            return false;
-        }
-
-        List<FileSystemElement> resourcesToImport = getSelectedResources();
-        if (resourcesToImport.size() == 0) {
-            setMessage(null);
-            setErrorMessage(Messages.ImportTraceWizard_SelectTraceNoneSelected);
-            return false;
-        }
-
-        IContainer container = getSpecifiedContainer();
-        if (container != null && container.isVirtual()) {
-            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()) {
-                setMessage(null);
-                setErrorMessage(Messages.ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder);
-                return false;
-            }
-        }
-
-        // Perform trace validation
-        String traceTypeName = fTraceTypes.getText();
-        String tokens[] = traceTypeName.split(SEPARATOR, 2);
-        if (tokens.length >= 2) {
-            String id = TmfTraceType.getInstance().getTraceTypeId(tokens[0], tokens[1]);
-            if (!TmfTraceType.getInstance().validateTrace(id, getSelectedResources())) {
-                setMessage(null);
-                setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
-                return false;
-            }
-        }
-        setErrorMessage(null);
-        return true;
-    }
-
-    // ------------------------------------------------------------------------
-    // 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());
-        if (!sourceDir.isDirectory()) {
-            setErrorMessage(Messages.ImportTraceWizard_InvalidTraceDirectory);
-            return false;
-        }
-
-        try {
-            sourceDir.getCanonicalPath();
-        } catch (IOException e) {
-            MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
-                    Messages.ImportTraceWizard_InvalidTraceDirectory);
-            return false;
-        }
-
-        // Save directory for next import operation
-        fRootDirectory = getSourceDirectoryName();
-
-        List<FileSystemElement> selectedResources = getSelectedResources();
-        Iterator<FileSystemElement> resources = selectedResources.iterator();
-
-        // 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();
-            String key = file.getAbsolutePath();
-            fileSystemObjects.put(key, file);
-        }
-
-        if (fileSystemObjects.size() > 0) {
-            boolean ok = importResources(fileSystemObjects);
-            String traceTypeName = fTraceTypes.getText();
-            boolean traceTypeOK = false;
-            TraceTypeHelper traceTypeHelper = null;
-
-            if (!traceTypeName.isEmpty()) {
-                // Trace type was selected
-                String temp[] = traceTypeName.split(SEPARATOR, 2);
-                if (temp.length < 2) {
-                    Activator.getDefault().logError("Error with trace type " + traceTypeName); //$NON-NLS-1$
-                    return false;
-                }
-                final String traceId = TmfTraceType.getInstance().getTraceTypeId(temp[0], temp[1]);
-                if (traceId != null) {
-                    traceTypeHelper = TmfTraceType.getInstance().getTraceType(traceId);
-                    if (traceTypeHelper == null || !TmfTraceType.getInstance().validateTrace(traceId, getSelectedResources())) {
-                        setMessage(null);
-                        setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
-                        return false;
-                    }
-
-                    traceTypeOK = true;
-                } else {
-                    setMessage(null);
-                    setErrorMessage(Messages.ImportTraceWizard_TraceValidationFailed);
-                    return false;
-                }
-            }
-
-            if (ok && traceTypeOK) {
-                // Tag the selected traces with their type
-                List<String> files = new ArrayList<String>(fileSystemObjects.keySet());
-                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() + File.separatorChar;
-                    if (fTargetFolder != null && (prefix == null || !name.startsWith(prefix))) {
-                        prefix = name; // new prefix
-                        IResource resource = fTargetFolder.findMember(file.getName());
-                        if (resource != null) {
-                            try {
-                                TmfTraceType.setTraceType(resource.getFullPath(), traceTypeHelper);
-
-                                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) {
-                                Activator.getDefault().logError("Error importing trace resource " + resource.getName(), e); //$NON-NLS-1$
-                            }
-                        }
-                    }
-                }
-            }
-            return ok;
-        }
-
-        MessageDialog.openInformation(getContainer().getShell(), Messages.ImportTraceWizard_Information,
-                Messages.ImportTraceWizard_SelectTraceNoneSelected);
-        return false;
-    }
-
-    private boolean importResources(Map<String, File> fileSystemObjects) {
-
-        // Determine the sorted canonical list of items to import
-        List<File> fileList = new ArrayList<File>();
-        for (Entry<String, File> entry : fileSystemObjects.entrySet()) {
-            fileList.add(entry.getValue());
-        }
-        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)
-        boolean ok = true;
-        boolean isLinked = createLinksInWorkspaceButton.getSelection();
-        for (int i = 0; i < fileList.size(); i++) {
-            File resource = fileList.get(i);
-            File parentFolder = new File(resource.getParent());
-
-            List<File> subList = new ArrayList<File>();
-            subList.add(resource);
-            if (resource.isDirectory()) {
-                String prefix = resource.getAbsolutePath() + File.separatorChar;
-                boolean hasSamePrefix = true;
-                for (int j = i + 1; j < fileList.size() && hasSamePrefix; j++) {
-                    File res = fileList.get(j);
-                    hasSamePrefix = res.getAbsolutePath().startsWith(prefix);
-                    if (hasSamePrefix) {
-                        // Import children individually if not linked
-                        if (!isLinked) {
-                            subList.add(res);
-                        }
-                        i = j;
-                    }
-                }
-            }
-
-            // Perform the import operation for this subset
-            FileSystemStructureProvider fileSystemStructureProvider = FileSystemStructureProvider.INSTANCE;
-            ImportOperation operation = new ImportOperation(getContainerFullPath(), parentFolder, fileSystemStructureProvider, this,
-                    subList);
-            operation.setContext(getShell());
-            ok = executeImportOperation(operation);
-        }
-
-        return ok;
-    }
-
-    private boolean executeImportOperation(ImportOperation op) {
-        initializeOperation(op);
-
-        try {
-            getContainer().run(true, true, op);
-        } catch (InterruptedException e) {
-            return false;
-        } catch (InvocationTargetException e) {
-            displayErrorDialog(e.getTargetException());
-            return false;
-        }
-
-        IStatus status = op.getStatus();
-        if (!status.isOK()) {
-            ErrorDialog.openError(getContainer().getShell(), Messages.ImportTraceWizard_ImportProblem, null, status);
-            return false;
-        }
-
-        return true;
-    }
-
-    private void initializeOperation(ImportOperation op) {
-        op.setCreateContainerStructure(false);
-        op.setOverwriteResources(overwriteExistingResourcesCheckbox.getSelection());
-        op.setCreateLinks(createLinksInWorkspaceButton.getSelection());
-        op.setVirtualFolders(false);
-    }
-
-}
index 64841195cff2f500021ec3e16041d9beed7100b4..fb1e87131a7095a26efe298bdf0b1dc48c44ee36 100644 (file)
 NewProjectWizard_DialogHeader = Tracing Project
 NewProjectWizard_DialogMessage = Create a Tracing Project
 
-# ImportTraceWizard
-ImportTraceWizard_DialogTitle=Trace Import
-ImportTraceWizard_FileSystemTitle=File system
-ImportTraceWizard_ImportTrace=Import a trace from the local file system
-ImportTraceWizard_DirectoryLocation=Source directory:
-ImportTraceWizard_BrowseButton=B&rowse...
-ImportTraceWizard_TraceType=Trace Type:
-ImportTraceWizard_SelectTraceDirectoryTitle=Select trace directory
-ImportTraceWizard_SelectTraceDirectoryMessage=Select directory to import trace from
-ImportTraceWizard_OverwriteExistingTrace=Overwrite existing trace without warning
-ImportTraceWizard_CreateLinksInWorkspace=Create lin&ks in workspace
-ImportTraceWizard_TraceValidationFailed=Validation failed
-ImportTraceWizard_InvalidTraceDirectory=Invalid trace directory
-ImportTraceWizard_SelectTraceSourceEmpty=Source must not be empty
-ImportTraceWizard_SelectTraceNoneSelected=No trace selected
-ImportTraceWizard_ImportProblem=Import problem
-ImportTraceWizard_CannotImportFilesUnderAVirtualFolder=Can not import trace under a virtual folder
-ImportTraceWizard_HaveToCreateLinksUnderAVirtualFolder=Have to create link under a virtual folder
-ImportTraceWizard_Information=Information
-
 # SelectTracesWizard
 SelectTracesWizard_WindowTitle=Select Traces
 SelectTracesWizardPage_TraceColumnHeader=Trace
This page took 0.044047 seconds and 5 git commands to generate.