control: replace ImportDialog with TMF remote fetch wizard
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Tue, 11 Aug 2015 17:51:27 +0000 (13:51 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Fri, 28 Aug 2015 12:44:43 +0000 (08:44 -0400)
Change-Id: I14ad7587e0e278f511d83c586b4cfd65306877f6
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/53604
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
20 files changed:
doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportDialog.png
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportOverwriteConfirmationDialog.png
doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportRenameDialog.png [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/META-INF/MANIFEST.MF
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportConfirmationDialog.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportDialog.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportConfirmationDialog.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportDialog.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportFileInfo.java [deleted file]
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/ImportHandler.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/messages/Messages.java
lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/messages/messages.properties
tmf/org.eclipse.tracecompass.tmf.remote.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/messages/RemoteMessages.java
tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/messages/messages.properties
tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizard.java
tmf/org.eclipse.tracecompass.tmf.remote.ui/src/org/eclipse/tracecompass/internal/tmf/remote/ui/wizards/fetch/RemoteFetchLogWizardRemotePage.java
tmf/org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF

index 5711240c222e44418bca01c5398cc30697f9fb64..c17680f401d0b32a1de09048a4f3145e8bae2967 100644 (file)
@@ -1449,17 +1449,14 @@ A new display will open for selecting the traces to import.
 
 [[Image:images/LTTng2ImportDialog.png]]
 
-By default all traces are selected. A default project with the name '''Remote''' is selected which will be created if necessary. Update the list of traces to be imported, if necessary, by selecting and deselecting the relevant traces in the tree viewer. Use buttons '''Select All''' or '''Deselect All''' to select or deselect all traces. Also if needed, change the tracing project from the '''Available Projects''' combo box. Select the Overwrite button ('''Overwrite existing trace without warning''') if required. Then press button '''Ok'''. Upon successful import operation the selected traces will be stored in the '''Traces''' directory of the specified tracing project. The session directory structure as well as the trace names will be preserved in the destination tracing project. For '''Kernel''' traces the trace type '''Linux Kernel Trace''' and for '''UST''' traces the trace type '''LTTng UST Trace''' will be set. From the '''Project Explorer''' view, the trace can be analyzed further.
+By default all traces are selected. A default project with the name '''Remote''' is selected which will be created if necessary. Update the list of traces to be imported, if necessary, by selecting and deselecting the relevant traces in the tree viewer. Use buttons '''Select All''' or '''Deselect All''' to select or deselect all traces. Also if needed, change the tracing project from the '''Available Projects''' combo box. Then press button '''Finish'''. Upon successful import operation the selected traces will be stored in the '''Traces''' directory of the specified tracing project. A directory with the connection name will be created under the '''Traces'''  directory. Underneath that, the session directory structure as well as the trace names will be preserved in the destination tracing project. For '''Kernel''' traces the trace type '''Linux Kernel Trace''' and for '''UST''' traces the trace type '''LTTng UST Trace''' will be set. From the '''Project Explorer''' view, the trace can be analyzed further.
 
-'''Note''': If the overwrite button ('''Overwrite existing trace without warning''') was not selected and a trace with the same name of a trace to be imported already exists in the destination directory of the project, then a new confirmation dialog box will open.
+'''Note''': If a trace already exists with the same name in the destination directory, the user can choose to rename the imported trace, overwrite the original trace or skip the trace. When rename is chosen, a number is appended to the trace name, for example kernel becomes kernel(2).
 
 [[Image:images/LTTng2ImportOverwriteConfirmationDialog.png]]
 
-To Overwrite select the '''Overwrite''' Button and press '''Ok'''.
-
-If the existing trace should not be overwritten select, then select the '''Rename''' option of the confirmation dialog box above, enter a new name and then press '''Ok'''.
+If one selects '''Rename All''', '''Overwrite All''' or '''Skip All''' the choice will be applied for all traces with a name conflict.
 
-[[Image:images/LTTng2ImportRenameDialog.png]]
 
 === Importing Network Traces to a Tracing Project ===
 
index 09b3520ea67fd4fee3227e26297337f1fe459014..ec1abe3b919ee42c40319227922f88302566a3cc 100644 (file)
Binary files a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportDialog.png and b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportDialog.png differ
index 5688ac3e107dd003c25ca4b66b212e4df84a8406..51bc7cb6fd02bca5a90eb0d7a13d160f626f3fae 100644 (file)
Binary files a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportOverwriteConfirmationDialog.png and b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportOverwriteConfirmationDialog.png differ
diff --git a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportRenameDialog.png b/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportRenameDialog.png
deleted file mode 100644 (file)
index 10e39de..0000000
Binary files a/doc/org.eclipse.tracecompass.doc.user/doc/images/LTTng2ImportRenameDialog.png and /dev/null differ
index cbbf7aafd366493cda143bb3502904f647d43ead..36220c989ce813719af86bc3e807c9513258b592 100644 (file)
@@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.remote.core;bundle-version="2.0.0",
  org.eclipse.remote.ui;bundle-version="2.0.0",
  org.eclipse.tracecompass.tmf.remote.core,
+ org.eclipse.tracecompass.tmf.remote.ui,
  org.eclipse.core.filesystem
 Export-Package: org.eclipse.tracecompass.internal.lttng2.control.ui;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
  org.eclipse.tracecompass.internal.lttng2.control.ui.relayd;x-internal:=true,
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportConfirmationDialog.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportConfirmationDialog.java
deleted file mode 100644 (file)
index 1ed0847..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2014 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:
- *   Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-/**
- * <p>
- * Interface for dialog box for updating file import information.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public interface IImportConfirmationDialog {
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-    /**
-     * @param name old trace name.
-     */
-    void setTraceName(String name);
-
-    /**
-     * @return the new trace name if not overwrite.
-     */
-    String getNewTraceName();
-
-    /**
-     *
-     * @return true to overwrite existing trace.
-     */
-    boolean isOverwrite();
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    /**
-     * @return the open return value
-     */
-    int open();
-}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportDialog.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/IImportDialog.java
deleted file mode 100644 (file)
index 8b92a40..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2014 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:
- *   Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
-
-/**
- * <p>
- * Interface for import traces dialog.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public interface IImportDialog {
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-    /**
-     * @return a list of trace paths to import.
-     */
-    List<ImportFileInfo> getTracePathes();
-
-    /**
-     * @return the project to import the traces to
-     */
-    IProject getProject();
-
-    /**
-     * Sets the session containing the traces to import
-     * @param session The trace session
-     */
-    void setSession(TraceSessionComponent session);
-
-    /**
-     * Sets the default project name to use
-     *
-     * @param defaultProject
-     *            the name of the default project to use
-     */
-    void setDefaultProject(String defaultProject);
-
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-    /**
-     * @return the open return value
-     */
-    int open();
-}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportConfirmationDialog.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportConfirmationDialog.java
deleted file mode 100644 (file)
index d3125ce..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2014 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:
- *   Bernd Hufmann - Initial API and implementation
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-
-/**
- * <p>
- * Dialog box for collecting session creation information.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public class ImportConfirmationDialog extends Dialog implements IImportConfirmationDialog {
-
-    // ------------------------------------------------------------------------
-    // Constants
-    // ------------------------------------------------------------------------
-    /**
-     * The icon file for this dialog box.
-     */
-    public static final String IMPORT_ICON_FILE = "icons/elcl16/import_trace.gif"; //$NON-NLS-1$
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    /**
-     * The radio button for selecting the overwrite action
-     */
-    private Button fOverwriteButton = null;
-    /**
-     * The radio button for selecting the renaming action
-     */
-    private Button fRenameButton = null;
-    /**
-     * The text widget for the session name
-     */
-    private Text fNewTraceNameText = null;
-    /**
-     * The trace name which already exists in the project
-     */
-    private String fTraceName = null;
-    /**
-     * The session name string.
-     */
-    private String fNewTraceName = null;
-    /**
-     * Flag whether default location (path) shall be used or not
-     */
-    private boolean fIsOverride = true;
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
-     * @param shell - a shell for the display of the dialog
-     */
-    public ImportConfirmationDialog(Shell shell) {
-        super(shell);
-        setShellStyle(SWT.RESIZE | getShellStyle());
-    }
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-
-    @Override
-    public void setTraceName(String name) {
-        fTraceName = name;
-    }
-
-    @Override
-    public String getNewTraceName() {
-        return fNewTraceName;
-    }
-
-    @Override
-    public boolean isOverwrite() {
-        return fIsOverride;
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-
-    @Override
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        newShell.setText(Messages.TraceControl_ImportDialogConfirmationTitle);
-        newShell.setImage(Activator.getDefault().loadIcon(IMPORT_ICON_FILE));
-    }
-
-    @Override
-    protected Control createDialogArea(Composite parent) {
-
-        // Main dialog panel
-       Composite dialogComposite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout(1, true);
-        dialogComposite.setLayout(layout);
-        dialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        Label sessionNameLabel = new Label(dialogComposite, SWT.RIGHT);
-        sessionNameLabel.setText(Messages.TraceControl_ImportDialogTraceAlreadyExistError + ": " + fTraceName); //$NON-NLS-1$
-
-        fOverwriteButton = new Button(dialogComposite, SWT.RADIO);
-        fOverwriteButton.setText(Messages.TraceControl_ImportDialogConfirmationOverwriteLabel);
-
-        fOverwriteButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                fNewTraceNameText.setEnabled(false);
-                fNewTraceNameText.setText(fTraceName);
-            }
-        });
-
-        fRenameButton = new Button(dialogComposite, SWT.RADIO);
-        fRenameButton.setText(Messages.TraceControl_ImportDialogConfirmationRenameLabel);
-
-        fRenameButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                fNewTraceNameText.setEnabled(true);
-            }
-        });
-
-        fNewTraceNameText = new Text(dialogComposite, SWT.NONE);
-        fNewTraceNameText.setToolTipText(Messages.TraceControl_ImportDialogConfirmationNewNameLabel);
-        fNewTraceNameText.setText(fTraceName);
-
-        // Default
-        fOverwriteButton.setSelection(true);
-        fNewTraceNameText.setEnabled(false);
-
-
-        // layout widgets
-        GridData data = new GridData(GridData.FILL_HORIZONTAL);
-
-        fNewTraceNameText.setLayoutData(data);
-
-        getShell().setMinimumSize(new Point(300, 150));
-
-        return dialogComposite;
-    }
-
-    @Override
-    protected void createButtonsForButtonBar(Composite parent) {
-        createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
-        createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
-    }
-
-    @Override
-    protected void okPressed() {
-
-        fIsOverride = fOverwriteButton.getSelection();
-
-        if (fIsOverride) {
-            // new name is old name
-            fNewTraceName = fTraceName;
-        } else {
-            fNewTraceName = fNewTraceNameText.getText();
-        }
-
-        // Check for invalid names
-        if (!fNewTraceName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$
-            MessageDialog.openError(getShell(),
-                    Messages.TraceControl_ImportDialogConfirmationTitle,
-                    Messages.TraceControl_InvalidTraceNameError + " (" + fNewTraceName + ") \n");  //$NON-NLS-1$ //$NON-NLS-2$
-            return;
-        }
-
-        // validation successful -> call super.okPressed()
-        super.okPressed();
-    }
-}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportDialog.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportDialog.java
deleted file mode 100644 (file)
index 9562d06..0000000
+++ /dev/null
@@ -1,509 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2015 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:
- *   Bernd Hufmann - Initial API and implementation
- *   Bernd Hufmann - Added handling of streamed traces
- *   Marc-Andre Laperle - Use common method to get opened tmf projects
- *   Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.remote.core.IRemoteFileService;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
-import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
-import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
-import org.eclipse.tracecompass.tmf.ui.project.model.TraceUtils;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * <p>
- * Dialog box for collecting trace import information.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public class ImportDialog extends Dialog implements IImportDialog {
-
-    // ------------------------------------------------------------------------
-    // Constants
-    // ------------------------------------------------------------------------
-    /** The icon file for this dialog box. */
-    public static final String IMPORT_ICON_FILE = "icons/elcl16/import_trace.gif"; //$NON-NLS-1$
-
-    /** Parent directory for UST traces */
-    public static final String UST_PARENT_DIRECTORY = "ust"; //$NON-NLS-1$
-
-    /** Name of metadata file of trace */
-    public static final String METADATA_FILE_NAME = "metadata"; //$NON-NLS-1$
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    /**
-     * The dialog composite.
-     */
-    private Composite fDialogComposite = null;
-    /**
-     * The checkbox tree viewer for selecting available traces
-     */
-    private CheckboxTreeViewer fFolderViewer;
-    /**
-     * The combo box for selecting a project.
-     */
-    private CCombo fCombo;
-    /**
-     * The overwrite button
-     */
-    private Button fOverwriteButton;
-    /**
-     * List of available LTTng 2.0 projects
-     */
-    private List<IProject> fProjects;
-    /**
-     * The parent where the new node should be added.
-     */
-    private TraceSessionComponent fSession = null;
-    /**
-     * The name of the default project name
-     */
-    private String fDefaultProjectName = null;
-    /**
-     * List of traces to import
-     */
-    private final List<ImportFileInfo> fTraces = new ArrayList<>();
-    /**
-     * Selection index in project combo box.
-     */
-    private int fProjectIndex;
-    /**
-     * Flag to indicate that something went wrong when creating the dialog box.
-     */
-    private boolean fIsError = false;
-    /**
-     * Children of the remote folder (can be null)
-     */
-    private Object[] fFolderChildren = null;
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Constructor
-     *
-     * @param shell
-     *            - a shell for the display of the dialog
-     */
-    public ImportDialog(Shell shell) {
-        super(shell);
-        setShellStyle(SWT.RESIZE | getShellStyle());
-    }
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-
-    @Override
-    public List<ImportFileInfo> getTracePathes() {
-        List<ImportFileInfo> retList = new ArrayList<>();
-        retList.addAll(fTraces);
-        return retList;
-    }
-
-    @Override
-    public IProject getProject() {
-        return fProjects.get(fProjectIndex);
-    }
-
-    @Override
-    public void setSession(TraceSessionComponent session) {
-        fSession = session;
-    }
-
-    @Override
-    public void setDefaultProject(String defaultProject) {
-        fDefaultProjectName = defaultProject;
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-
-    @Override
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        newShell.setText(Messages.TraceControl_ImportDialogTitle);
-        newShell.setImage(Activator.getDefault().loadIcon(IMPORT_ICON_FILE));
-    }
-
-    @Override
-    protected Control createDialogArea(Composite parent) {
-
-        // Main dialog panel
-        fDialogComposite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout(1, true);
-        fDialogComposite.setLayout(layout);
-        fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        try {
-            createRemoteComposite();
-        } catch (CoreException e) {
-            createErrorComposite(parent, e.fillInStackTrace());
-            return fDialogComposite;
-        }
-        return fDialogComposite;
-    }
-
-    @Override
-    protected void createButtonsForButtonBar(Composite parent) {
-        Button selectAllButton = createButton(parent, IDialogConstants.SELECT_ALL_ID, Messages.TraceControl_ImportDialog_SelectAll, true);
-        selectAllButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                setFolderChildrenChecked(true);
-            }
-        });
-
-        Button deselectAllButton = createButton(parent, IDialogConstants.DESELECT_ALL_ID, Messages.TraceControl_ImportDialog_DeselectAll, true);
-        deselectAllButton.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                setFolderChildrenChecked(false);
-            }
-        });
-        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
-        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
-        updateOKButtonEnablement();
-    }
-
-    @Override
-    protected void okPressed() {
-        if (!fIsError) {
-
-            // Validate input data
-            fTraces.clear();
-
-            fProjectIndex = fCombo.getSelectionIndex();
-
-            if (fProjectIndex < 0) {
-                MessageDialog.openError(getShell(),
-                        Messages.TraceControl_ImportDialogTitle,
-                        Messages.TraceControl_ImportDialogNoProjectSelectedError);
-                return;
-            }
-
-            IProject project = fProjects.get(fProjectIndex);
-            IFolder traceFolder = project.getFolder(TmfTracesFolder.TRACES_FOLDER_NAME);
-
-            if (!traceFolder.exists()) {
-                // Invalid LTTng 2.0 project
-                MessageDialog.openError(getShell(),
-                        Messages.TraceControl_ImportDialogTitle,
-                        Messages.TraceControl_ImportDialogInvalidTracingProject + " (" + TmfTracesFolder.TRACES_FOLDER_NAME + ")"); //$NON-NLS-1$//$NON-NLS-2$
-                return;
-            }
-
-            boolean overwriteAll = fOverwriteButton.getSelection();
-
-            Object[] checked = fFolderViewer.getCheckedElements();
-            for (int i = 0; i < checked.length; i++) {
-                IFileStore file = (IFileStore) checked[i];
-                if (!file.fetchInfo().isDirectory() && file.getName().equals(METADATA_FILE_NAME)) {
-                    IFileStore trace = file.getParent();
-                    IFileStore parent = trace.getParent();
-
-                    String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
-                    path = getUnifiedPath(path);
-                    IPath sessionParentPath = new Path(path).removeLastSegments(1);
-                    IPath traceParentPath = new Path(parent.toURI().getPath());
-
-                    IPath relativeTracePath = traceParentPath.makeRelativeTo(sessionParentPath);
-
-                    IFolder destinationFolder = traceFolder.getFolder(new Path(relativeTracePath.toOSString()));
-
-                    ImportFileInfo info = new ImportFileInfo(trace, trace.getName(), destinationFolder, overwriteAll);
-                    IFolder folder = destinationFolder.getFolder(trace.getName());
-
-                    // Verify if trace directory already exists (and not
-                    // overwrite)
-                    if (folder.exists() && !overwriteAll) {
-
-                        // Ask user for overwrite or new name
-                        IImportConfirmationDialog conf = TraceControlDialogFactory.getInstance().getImportConfirmationDialog();
-                        conf.setTraceName(trace.getName());
-
-                        // Don't add trace to list if dialog was cancelled.
-                        if (conf.open() == Window.OK) {
-                            info.setOverwrite(conf.isOverwrite());
-                            if (!conf.isOverwrite()) {
-                                info.setLocalTraceName(conf.getNewTraceName());
-                            }
-                            fTraces.add(info);
-                        }
-                    } else {
-                        fTraces.add(info);
-                    }
-                }
-            }
-
-            if (fTraces.isEmpty()) {
-                MessageDialog.openError(getShell(),
-                        Messages.TraceControl_ImportDialogTitle,
-                        Messages.TraceControl_ImportDialogNoTraceSelectedError);
-                return;
-            }
-        }
-
-        // validation successful -> call super.okPressed()
-        super.okPressed();
-    }
-
-    // ------------------------------------------------------------------------
-    // Helper methods and classes
-    // ------------------------------------------------------------------------
-
-    private final class FolderCheckStateListener implements ICheckStateListener {
-        @Override
-        public void checkStateChanged(CheckStateChangedEvent event) {
-            Object elem = event.getElement();
-            if (elem instanceof IFileStore) {
-                IFileStore element = (IFileStore) elem;
-                IFileInfo info = element.fetchInfo();
-                if (!info.isDirectory()) {
-                    // A trick to keep selection of a file in sync with the
-                    // directory
-                    boolean p = fFolderViewer.getChecked((element.getParent()));
-                    fFolderViewer.setChecked(element, p);
-                } else {
-                    fFolderViewer.setSubtreeChecked(event.getElement(), event.getChecked());
-                    if (!event.getChecked()) {
-                        fFolderViewer.setChecked(element.getParent(), false);
-                    }
-                }
-                updateOKButtonEnablement();
-            }
-        }
-    }
-
-    /**
-     * Helper class for the contents of a folder in a tracing project
-     *
-     * @author Bernd Hufmann
-     */
-    public static class FolderContentProvider implements ITreeContentProvider {
-        @Override
-        public Object[] getChildren(Object o) {
-            try {
-                IFileStore store = (IFileStore) o;
-                if (store.fetchInfo().isDirectory()) {
-                    return store.childStores(EFS.NONE, new NullProgressMonitor());
-                }
-            } catch (CoreException e) {
-                Activator.getDefault().logError(e.getMessage(), e);
-            }
-            return new Object[0];
-        }
-
-        @Override
-        public Object getParent(Object element) {
-            return ((IFileStore) element).getParent();
-        }
-
-        @Override
-        public void dispose() {
-        }
-
-        @Override
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-        }
-
-        @Override
-        public Object[] getElements(Object inputElement) {
-            return getChildren(inputElement);
-        }
-
-        @Override
-        public boolean hasChildren(Object element) {
-            return ((IFileStore) element).fetchInfo().isDirectory();
-        }
-    }
-
-    /**
-     * Creates a dialog composite with an error message which can be used when
-     * an exception occurred during creation time of the dialog box.
-     *
-     * @param parent
-     *            - a parent composite
-     * @param e
-     *            - a error causing exception
-     */
-    private void createErrorComposite(Composite parent, Throwable e) {
-        fIsError = true;
-        fDialogComposite.dispose();
-
-        fDialogComposite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout(1, true);
-        fDialogComposite.setLayout(layout);
-        fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        Text errorText = new Text(fDialogComposite, SWT.MULTI);
-        StringBuffer error = new StringBuffer();
-        error.append(Messages.TraceControl_ImportDialogCreationError);
-        error.append(System.getProperty("line.separator")); //$NON-NLS-1$
-        error.append(System.getProperty("line.separator")); //$NON-NLS-1$
-        error.append(e.toString());
-        errorText.setText(error.toString());
-        errorText.setLayoutData(new GridData(GridData.FILL_BOTH));
-    }
-
-    private void createRemoteComposite() throws CoreException {
-        Group contextGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
-        contextGroup.setText(Messages.TraceControl_ImportDialogTracesGroupName);
-        GridLayout layout = new GridLayout(1, true);
-        contextGroup.setLayout(layout);
-        contextGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-        RemoteSystemProxy proxy = fSession.getTargetNode().getRemoteSystemProxy();
-
-        IRemoteFileService fsss = proxy.getRemoteConnection().getService(IRemoteFileService.class);
-
-        if (fsss == null) {
-            return;
-        }
-
-        final String path = fSession.isSnapshotSession() ? fSession.getSnapshotInfo().getSnapshotPath() : fSession.getSessionPath();
-        final IFileStore remoteFolder = fsss.getResource(path);
-
-        fFolderViewer = new CheckboxTreeViewer(contextGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
-        GridData data = new GridData(GridData.FILL_BOTH);
-        Tree tree = fFolderViewer.getTree();
-        tree.setLayoutData(data);
-        tree.setFont(fDialogComposite.getFont());
-        tree.setToolTipText(Messages.TraceControl_ImportDialogTracesTooltip);
-
-        fFolderViewer.setContentProvider(new FolderContentProvider());
-        fFolderViewer.setLabelProvider(new LabelProvider() {
-            @Override
-            public String getText(Object element) {
-                return ((IFileStore) element).getName();
-            }
-
-            @Override
-            public Image getImage(Object element) {
-                if (((IFileStore) element).fetchInfo().isDirectory()) {
-                    return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
-                }
-                return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
-            }
-        });
-
-        fFolderViewer.addCheckStateListener(new FolderCheckStateListener());
-        fFolderViewer.setInput(remoteFolder);
-
-        fFolderChildren = remoteFolder.childStores(EFS.NONE, new NullProgressMonitor());
-        // children can be null if there the path doesn't exist. This happens
-        // when a trace
-        // session hadn't been started and no output was created.
-        setFolderChildrenChecked(true);
-
-        Group projectGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
-        projectGroup.setText(Messages.TraceControl_ImportDialogProjectsGroupName);
-        layout = new GridLayout(1, true);
-        projectGroup.setLayout(layout);
-        projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-        fProjects = new ArrayList<>();
-        List<String> projectNames = new ArrayList<>();
-
-        for (IProject project : TraceUtils.getOpenedTmfProjects()) {
-            fProjects.add(project);
-            projectNames.add(project.getName());
-        }
-
-        fCombo = new CCombo(projectGroup, SWT.READ_ONLY);
-        fCombo.setToolTipText(Messages.TraceControl_ImportDialogProjectsTooltip);
-        fCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
-        fCombo.setItems(projectNames.toArray(new String[projectNames.size()]));
-
-        if (fDefaultProjectName != null) {
-            int select = projectNames.indexOf(fDefaultProjectName);
-            fCombo.select(select);
-        }
-
-        Group overrideGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
-        layout = new GridLayout(1, true);
-        overrideGroup.setLayout(layout);
-        overrideGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-        fOverwriteButton = new Button(overrideGroup, SWT.CHECK);
-        fOverwriteButton.setText(Messages.TraceControl_ImportDialogOverwriteButtonText);
-        getShell().setMinimumSize(new Point(500, 400));
-    }
-
-    private void setFolderChildrenChecked(boolean isChecked) {
-        if (fFolderChildren != null) {
-            for (Object child : fFolderChildren) {
-                fFolderViewer.setSubtreeChecked(child, isChecked);
-            }
-        }
-        updateOKButtonEnablement();
-    }
-
-    private void updateOKButtonEnablement() {
-        Object[] checked = fFolderViewer.getCheckedElements();
-        Button okButton = getButton(IDialogConstants.OK_ID);
-        if (okButton != null) {
-            okButton.setEnabled(checked.length > 0);
-        }
-    }
-
-    private static String getUnifiedPath(String path) {
-        // Use Path class to remove unnecessary slashes
-        return new Path(path).removeTrailingSeparator().toString();
-    }
-}
diff --git a/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportFileInfo.java b/lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/dialogs/ImportFileInfo.java
deleted file mode 100644 (file)
index 5e586d1..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2014 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:
- *   Bernd Hufmann - Initial API and implementation
- *   Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IFolder;
-
-/**
- * <p>
- * Helper class for storing information about a remote file to import.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public class ImportFileInfo {
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-    /**
-     * Remote file reference
-     */
-    private IFileStore fRemoteFile;
-    /**
-     * Local Trace Name
-     */
-    private String fLocalTraceName;
-    /**
-     * Global overwrite flag
-     */
-    private boolean fIsOverwrite;
-    /**
-     * Destination folder to import the trace to (full workspace path)
-     */
-    private IFolder fDestinationFolder;
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-    /**
-     * Standard constructor
-     *
-     * @param file
-     *            A remote file reference
-     * @param traceName
-     *            A trace name
-     * @param destinationFolder
-     *            The destination folder (full workspace path)
-     * @param isOverwrite
-     *            global overwrite flag
-     */
-    public ImportFileInfo(IFileStore file, String traceName, IFolder destinationFolder, boolean isOverwrite) {
-        fRemoteFile = file;
-        fLocalTraceName = traceName;
-        fDestinationFolder = destinationFolder;
-        fIsOverwrite = isOverwrite;
-    }
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-    /**
-     * @return name of traces after importing
-     */
-    public String getLocalTraceName() {
-        return fLocalTraceName;
-    }
-
-    /**
-     * Sets the local trace name
-     *
-     * @param importTraceName
-     *            - local name of trace to set (name after importing)
-     */
-    public void setLocalTraceName(String importTraceName) {
-        this.fLocalTraceName = importTraceName;
-    }
-    /**
-     * @return true if local trace should be overwritten if a trace with the same name already exists.
-     */
-    public boolean isOverwrite() {
-        return fIsOverwrite;
-    }
-    /**
-     * Sets the overwrite flag.
-     * @param isOverwrite If the Overwrite checkbox is checked or not
-     */
-    public void setOverwrite(boolean isOverwrite) {
-        this.fIsOverwrite = isOverwrite;
-    }
-
-    /**
-     * @return the remote file implementation.
-     */
-    public IFileStore getImportFile() {
-        return fRemoteFile;
-    }
-
-    /**
-     * Sets the remote file implementation
-     *
-     * @param remoteFile
-     *            The remote file implementation.
-     */
-    public void setRemoteFile(IFileStore remoteFile) {
-        fRemoteFile = remoteFile;
-    }
-
-    /**
-     * Returns the destination folder to import the trace to (full workspace path).
-     *
-     * @return destination folder
-     */
-    public IFolder getDestinationFolder() {
-        return fDestinationFolder;
-    }
-}
-
index 78ec9989642af54ffa9f82e47ba0845c403cfeac..65073548c5a3f09aa3812bf32dc2ea93744068b6 100644 (file)
@@ -73,16 +73,6 @@ public final class TraceControlDialogFactory {
      */
     private IAddContextDialog fAddContextDialog;
 
-    /**
-     * The import dialog implementation.
-     */
-    private IImportDialog fImportDialog;
-
-    /**
-     * The import confirmation dialog.
-     */
-    private IImportConfirmationDialog fImportConfirmationDialog;
-
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -243,40 +233,5 @@ public final class TraceControlDialogFactory {
         fAddContextDialog = addContextDialog;
     }
 
-    /**
-     * @return the import dialog implementation
-     */
-    public IImportDialog getImportDialog() {
-        if (fImportDialog == null) {
-            fImportDialog = new ImportDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
-        }
-        return fImportDialog;
-    }
-
-    /**
-     * Sets the import dialog implementation.
-     * @param importDialog - a import dialog implementation
-     */
-    public void setImportDialog(IImportDialog importDialog) {
-        fImportDialog = importDialog;
-    }
-
-    /**
-     * @return the import confirmation dialog implementation.
-     */
-    public IImportConfirmationDialog getImportConfirmationDialog() {
-        if (fImportConfirmationDialog == null) {
-            fImportConfirmationDialog = new ImportConfirmationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
-        }
-        return fImportConfirmationDialog;
-    }
-
-    /**
-     * Sets the import confirmation dialog implementation.
-     * @param confirmDialog - a import confirmation dialog implementation.
-     */
-    public void setImportConfirmationDialog(IImportConfirmationDialog confirmDialog) {
-        fImportConfirmationDialog = confirmDialog;
-    }
 }
 
index 2673c438ed750569b9fcd732d54a286116701d02..b7a536f240d70284c8a88ef8e8f9fc5370b00414 100644 (file)
  **********************************************************************/
 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
 
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.Iterator;
 import java.util.List;
 
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -35,19 +29,17 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.core.runtime.URIUtil;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionHostService;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
@@ -55,16 +47,21 @@ import org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydCon
 import org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConnectionManager;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.LttngRelaydConsumer;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.IImportDialog;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ImportFileInfo;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.RemoteFetchLogWizard;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.RemoteFetchLogWizardRemotePage;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportConnectionNodeElement;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportTraceGroupElement;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.importtrace.ImportTraceWizard;
-import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
+import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
+import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement;
+import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceImportException;
 import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.tracecompass.tmf.ctf.core.CtfConstants;
+import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfOpenTraceHelper;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
@@ -72,7 +69,6 @@ import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceTypeUIUtils;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
-import org.eclipse.tracecompass.tmf.ui.project.model.TraceUtils;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
@@ -87,16 +83,9 @@ import org.eclipse.ui.PlatformUI;
  */
 public class ImportHandler extends BaseControlViewHandler {
 
-    private static final int BUFFER_IN_KB = 16;
-
-    private static final int BYTES_PER_KB = 1024;
-
     // ------------------------------------------------------------------------
     // Constants
     // ------------------------------------------------------------------------
-    /** Name of default project to import traces to */
-    public static final String DEFAULT_REMOTE_PROJECT_NAME = "Remote"; //$NON-NLS-1$
-
     /** The preference key to remeber whether or not the user wants the notification shown next time **/
     private static final String NOTIFY_IMPORT_STREAMED_PREF_KEY = "NOTIFY_IMPORT_STREAMED"; //$NON-NLS-1$
 
@@ -122,99 +111,74 @@ public class ImportHandler extends BaseControlViewHandler {
             return false;
         }
 
+        CommandParameter param;
         fLock.lock();
         try {
-            final CommandParameter param = fParam.clone();
-
-            // create default project
-            IProject project = TmfProjectRegistry.createProject(DEFAULT_REMOTE_PROJECT_NAME, null, null);
-
-            if (param.getSession().isLiveTrace()) {
-                importLiveTrace(new LttngRelaydConnectionInfo(param.getSession().getLiveUrl(), param.getSession().getLivePort(), param.getSession().getName()), project);
-                return null;
-            } else if (param.getSession().isStreamedTrace()) {
-
-                IPreferenceStore store = Activator.getDefault().getPreferenceStore();
-                String notify = store.getString(NOTIFY_IMPORT_STREAMED_PREF_KEY);
-                if (!MessageDialogWithToggle.ALWAYS.equals(notify)) {
-                    MessageDialogWithToggle.openInformation(window.getShell(), null, Messages.TraceControl_ImportDialogStreamedTraceNotification, Messages.TraceControl_ImportDialogStreamedTraceNotificationToggle, false, store, NOTIFY_IMPORT_STREAMED_PREF_KEY);
-                }
-
-                // Streamed trace
-                TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
-                TmfTraceFolder traceFolder = projectElement.getTracesFolder();
-
-                ImportTraceWizard wizard = new ImportTraceWizard();
-                wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder));
-                WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
-                dialog.open();
-                return null;
-            }
-
-            // Remote trace
-            final IImportDialog dialog = TraceControlDialogFactory.getInstance().getImportDialog();
-            dialog.setSession(param.getSession());
-            dialog.setDefaultProject(DEFAULT_REMOTE_PROJECT_NAME);
-
-            if (dialog.open() != Window.OK) {
-                return null;
+            param = fParam.clone();
+        } finally {
+            fLock.unlock();
+        }
+        // create default project
+        IProject project = TmfProjectRegistry.createProject(RemoteFetchLogWizardRemotePage.DEFAULT_REMOTE_PROJECT_NAME, null, null);
+
+        if (param.getSession().isLiveTrace()) {
+            importLiveTrace(new LttngRelaydConnectionInfo(param.getSession().getLiveUrl(), param.getSession().getLivePort(), param.getSession().getName()), project);
+            return null;
+        } else if (param.getSession().isStreamedTrace()) {
+
+            IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+            String notify = store.getString(NOTIFY_IMPORT_STREAMED_PREF_KEY);
+            if (!MessageDialogWithToggle.ALWAYS.equals(notify)) {
+                MessageDialogWithToggle.openInformation(window.getShell(), null, Messages.TraceControl_ImportDialogStreamedTraceNotification, Messages.TraceControl_ImportDialogStreamedTraceNotificationToggle, false, store, NOTIFY_IMPORT_STREAMED_PREF_KEY);
             }
 
-            Job job = new Job(Messages.TraceControl_ImportJob) {
-                @Override
-                protected IStatus run(IProgressMonitor monitor) {
-
-                    MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, Messages.TraceControl_ImportFailure, null);
-                    List<ImportFileInfo> traces = dialog.getTracePathes();
-                    IProject selectedProject = dialog.getProject();
-                    for (Iterator<ImportFileInfo> iterator = traces.iterator(); iterator.hasNext();) {
-                        try {
-
-                            if (monitor.isCanceled()) {
-                                status.add(Status.CANCEL_STATUS);
-                                break;
-                            }
-
-                            ImportFileInfo remoteFile = iterator.next();
-
-                            downloadTrace(remoteFile, selectedProject, monitor);
-
-                            // Set trace type
-                            IFolder traceFolder = remoteFile.getDestinationFolder();
+            // Streamed trace
+            TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
+            TmfTraceFolder traceFolder = projectElement.getTracesFolder();
 
-                            IResource file = traceFolder.findMember(remoteFile.getLocalTraceName());
+            ImportTraceWizard wizard = new ImportTraceWizard();
+            wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(traceFolder));
+            WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
+            dialog.open();
+            return null;
+        }
 
-                            if (file != null) {
-                                TraceTypeHelper helper = null;
+        // Generate the profile
+        RemoteImportProfileElement profile = new RemoteImportProfileElement(null, "LTTng Remote Traces"); //$NON-NLS-1$
+        TraceSessionComponent session = param.getSession();
+        RemoteSystemProxy proxy = session.getTargetNode().getRemoteSystemProxy();
+        IRemoteConnection rc = proxy.getRemoteConnection();
+        String name = rc.getName();
 
-                                try {
-                                    helper = TmfTraceTypeUIUtils.selectTraceType(file.getLocation().toOSString(), null, null);
-                                } catch (TmfTraceImportException e) {
-                                    // the trace did not match any trace type
-                                }
+        if (!rc.hasService(IRemoteConnectionHostService.class)) {
+            return null;
+        }
 
-                                if (helper != null) {
-                                    status.add(TmfTraceTypeUIUtils.setTraceType(file, helper));
-                                }
+        String scheme = rc.getConnectionType().getScheme();
+        IRemoteConnectionHostService hostService = rc.getService(IRemoteConnectionHostService.class);
+        String address = hostService.getHostname();
+        String user = hostService.getUsername();
+        int port =  hostService.getPort();
 
-                                URI uri = remoteFile.getImportFile().toURI();
-                                String sourceLocation = URIUtil.toUnencodedString(uri);
-                                file.setPersistentProperty(TmfCommonConstants.SOURCE_LOCATION, sourceLocation);
-                            }
-                        } catch (ExecutionException e) {
-                            status.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ImportFailure, e));
-                        } catch (CoreException e) {
-                            status.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_ImportFailure, e));
-                        }
-                    }
-                    return status;
-                }
-            };
-            job.setUser(true);
-            job.schedule();
-        } finally {
-            fLock.unlock();
+        URI remoteUri;
+        try {
+            remoteUri = new URI(scheme, user, address, port, null, null, null);
+        } catch (URISyntaxException e) {
+            return false;
         }
+        RemoteImportConnectionNodeElement connection = new RemoteImportConnectionNodeElement(profile, name, remoteUri.toString());
+        String pathString = session.isSnapshotSession() ? session.getSnapshotInfo().getSnapshotPath() : session.getSessionPath();
+        IPath path = new Path(pathString);
+        RemoteImportTraceGroupElement group = new RemoteImportTraceGroupElement(connection, path.removeLastSegments(1).toString());
+        group.setRecursive(true);
+        TracePackageElement element = new TracePackageTraceElement(group, "", "");  //$NON-NLS-1$//$NON-NLS-2$
+        new TracePackageFilesElement(element, path.lastSegment() + "/.*"); //$NON-NLS-1$
+
+        RemoteFetchLogWizard wizard = new RemoteFetchLogWizard(profile);
+        wizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
+        WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
+        dialog.open();
+
         return null;
     }
 
@@ -261,84 +225,7 @@ public class ImportHandler extends BaseControlViewHandler {
     // Helper methods
     // ------------------------------------------------------------------------
 
-    /**
-     * Downloads a trace from the remote host to the given project.
-     *
-     * @param trace
-     *            - trace information of trace to import
-     * @param project
-     *            - project to import to
-     * @param monitor
-     *            - a progress monitor
-     * @throws ExecutionException
-     */
-    private static void downloadTrace(ImportFileInfo trace, IProject project, IProgressMonitor monitor)
-            throws ExecutionException {
-        try {
-            IFileStore importRoot = trace.getImportFile();
-
-            IFolder traceFolder = project.getFolder(TmfTracesFolder.TRACES_FOLDER_NAME);
-            if (!traceFolder.exists()) {
-                throw new ExecutionException(Messages.TraceControl_ImportDialogInvalidTracingProject + " (" + TmfTracesFolder.TRACES_FOLDER_NAME + ")"); //$NON-NLS-1$//$NON-NLS-2$
-            }
-
-            IFolder destinationFolder = trace.getDestinationFolder();
-            TraceUtils.createFolder(destinationFolder, monitor);
-
-            String traceName = trace.getLocalTraceName();
-            IFolder folder = destinationFolder.getFolder(traceName);
-            if (folder.exists()) {
-                if (!trace.isOverwrite()) {
-                    throw new ExecutionException(Messages.TraceControl_ImportDialogTraceAlreadyExistError + ": " + traceName); //$NON-NLS-1$
-                }
-            } else {
-                folder.create(true, true, null);
-            }
-
-            IFileStore[] sources = importRoot.childStores(EFS.NONE, new NullProgressMonitor());
-            SubMonitor subMonitor = SubMonitor.convert(monitor, sources.length);
-            subMonitor.beginTask(Messages.TraceControl_DownloadTask, sources.length);
-
-            for (IFileStore source : sources) {
-                if (subMonitor.isCanceled()) {
-                    monitor.setCanceled(true);
-                    return;
-                }
-                SubMonitor childMonitor = subMonitor.newChild(1);
-                IFileInfo info = source.fetchInfo();
-                if (!info.isDirectory()) {
-                    IPath destination = folder.getLocation().addTrailingSeparator().append(source.getName());
-                    subMonitor.setTaskName(Messages.TraceControl_DownloadTask + ' ' + traceName + '/' + source.getName());
-                    try (InputStream in = source.openInputStream(EFS.NONE, new NullProgressMonitor())) {
-                        copy(in, destination, childMonitor, info.getLength());
-                    }
-                }
-            }
-        } catch (IOException e) {
-            throw new ExecutionException(e.toString(), e);
-        } catch (CoreException e) {
-            throw new ExecutionException(e.toString(), e);
-        }
-    }
-
-    private static void copy(InputStream in, IPath destination, SubMonitor monitor, long length) throws IOException {
-        try (OutputStream out = new FileOutputStream(destination.toFile())) {
-            monitor.setWorkRemaining((int) (length / BYTES_PER_KB));
-            byte[] buf = new byte[BYTES_PER_KB * BUFFER_IN_KB];
-            int counter = 0;
-            for (;;) {
-                int n = in.read(buf);
-                if (n <= 0) {
-                    return;
-                }
-                out.write(buf, 0, n);
-                counter = (counter % BYTES_PER_KB) + n;
-                monitor.worked(counter / BYTES_PER_KB);
-            }
-        }
-    }
-
-    private static void importLiveTrace(final LttngRelaydConnectionInfo connectionInfo, final IProject project) {
+   private static void importLiveTrace(final LttngRelaydConnectionInfo connectionInfo, final IProject project) {
         Job job = new Job(Messages.TraceControl_ImportJob) {
 
             @Override
index 5944aba3b894bd9bae6e346fd240bf9e4adc8d60..a935d19a53c246db06fe9465c5bbfea172810566 100644 (file)
@@ -238,25 +238,6 @@ public final class Messages extends NLS {
 
     public static String TraceControl_ImportDialogStreamedTraceNotification;
     public static String TraceControl_ImportDialogStreamedTraceNotificationToggle;
-    public static String TraceControl_ImportDialogTitle;
-    public static String TraceControl_ImportDialogTracesGroupName;
-    public static String TraceControl_ImportDialogTracesTooltip;
-    public static String TraceControl_ImportDialogProjectsGroupName;
-    public static String TraceControl_ImportDialogProjectsTooltip;
-    public static String TraceControl_ImportDialogOverwriteButtonText;
-    public static String TraceControl_ImportDialogCreationError;
-    public static String TraceControl_ImportDialogNoProjectSelectedError;
-    public static String TraceControl_ImportDialogInvalidTracingProject;
-    public static String TraceControl_ImportDialogNoTraceSelectedError;
-    public static String TraceControl_ImportDialog_SelectAll;
-    public static String TraceControl_ImportDialog_DeselectAll;
-
-    public static String TraceControl_ImportDialogConfirmationTitle;
-    public static String TraceControl_ImportDialogConfirmationOverwriteLabel;
-    public static String TraceControl_ImportDialogConfirmationRenameLabel;
-    public static String TraceControl_ImportDialogConfirmationNewNameLabel;
-    public static String TraceControl_InvalidTraceNameError;
-    public static String TraceControl_ImportDialogTraceAlreadyExistError;
 
     // Tree structure strings
     public static String TraceControl_KernelDomainDisplayName;
index 7ac5155160868ddb2ec1a90d479947d6c18fc8f1..099c66b8296f5138ebe821313ce0f054ff7be868 100644 (file)
@@ -224,26 +224,6 @@ TraceControl_AddContextAllLabel=All Contexts
 
 TraceControl_ImportDialogStreamedTraceNotification=You are importing a trace generated by a streamed session. By default the traces will be outputed to ~/lttng-traces/hostname/sessionname but the location can vary.
 TraceControl_ImportDialogStreamedTraceNotificationToggle=Do not warn me again
-TraceControl_ImportDialogTitle=Import Traces
-TraceControl_ImportDialogTracesGroupName=Available Traces
-TraceControl_ImportDialogTracesTooltip=The available traces of current session to import
-TraceControl_ImportDialogProjectsGroupName=Available Projects
-TraceControl_ImportDialogProjectsTooltip=The available projects to select from
-TraceControl_ImportDialogOverwriteButtonText=Overwrite existing trace without warning
-TraceControl_ImportDialogCreationError=Dialog box cannot be created
-TraceControl_ImportDialogNoProjectSelectedError=No tracing project selected or available
-TraceControl_ImportDialogInvalidTracingProject=Invalid tracing project. Missing directory
-TraceControl_ImportDialogNoTraceSelectedError=No trace selected or available
-
-TraceControl_ImportDialogConfirmationTitle=Import Confirmation Dialog
-TraceControl_ImportDialogConfirmationOverwriteLabel=Overwrite
-TraceControl_ImportDialogConfirmationRenameLabel=Rename
-TraceControl_ImportDialogConfirmationNewNameLabel=New Trace Name
-TraceControl_InvalidTraceNameError=Invalid trace name
-TraceControl_ImportDialogTraceAlreadyExistError=Trace already exists in project
-TraceControl_ImportDialog_SelectAll=Select All
-TraceControl_ImportDialog_DeselectAll=Deselect All
-
 
 # Tree structure strings
 TraceControl_KernelDomainDisplayName=Kernel
index aa0c4890bc360c87d8777e6418515eeeb167a981..57ef66ba32b53bad17069a9304fce8214156f9de 100644 (file)
@@ -23,6 +23,6 @@ Require-Bundle: org.eclipse.core.runtime,
 Export-Package: org.eclipse.tracecompass.internal.tmf.remote.ui;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.remote.ui.messages;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.remote.ui.preferences;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model;x-friends:="org.eclipse.tracecompass.tmf.remote.ui.tests",
+ org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch;x-friends:="org.eclipse.tracecompass.lttng2.control.ui",
+ org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model;x-friends:="org.eclipse.tracecompass.tmf.remote.ui.tests,org.eclipse.tracecompass.lttng2.control.ui",
  org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.preferences;x-internal:=true
index 84676e7e35dc6756ce47833df1939dacd21b6c4e..658852b9b38c04fe5f3197031203000a93a44179 100644 (file)
@@ -44,6 +44,12 @@ public class RemoteMessages extends NLS {
     public static String RemoteFetchLogWizardRemotePage_OpeningConnectionTo;
     /** Title of remote fetch wizard remote page*/
     public static String RemoteFetchLogWizardRemotePage_Title;
+    /** Project group label */
+    public static String RemoteFetchLogWizardRemotePage_ImportDialogProjectsGroupName;
+    /** Error String for no project selected*/
+    public static String RemoteFetchLogWizardRemotePage_NoProjectSelectedError;
+    /** Error string for invalid tracing project */
+    public static String RemoteFetchLogWizardRemotePage_InvalidTracingProject;
 
     /** Label of add button in remote preference page */
     public static String RemoteProfilesPreferencePage_AddButton;
index 05ae64c68ade98e68e343a54ceefea6fe4daa861..2076169b5205164a4a379f36b9e2152a5d61706a 100644 (file)
@@ -21,6 +21,9 @@ RemoteFetchLogWizardRemotePage_ExpandAll=Expand All
 RemoteFetchLogWizardRemotePage_MissingConnectionInformation=Missing remote connection information in profile
 RemoteFetchLogWizardRemotePage_OpeningConnectionTo=Opening connection to ''{0}''
 RemoteFetchLogWizardRemotePage_Title=Remote Traces
+RemoteFetchLogWizardRemotePage_ImportDialogProjectsGroupName=Available Projects
+RemoteFetchLogWizardRemotePage_NoProjectSelectedError=No tracing project selected or available
+RemoteFetchLogWizardRemotePage_InvalidTracingProject=Invalid tracing project. Missing directory
 
 RemoteProfilesPreferencePage_AddButton=Add
 RemoteProfilesPreferencePage_BrowseButton=Browse...
index 96ae9e5f108507e0d4ec5142414dab56724bb7ff..13dc2b2f9850f9466e75220a6c25f63befaa11cb 100644 (file)
@@ -13,12 +13,15 @@ package org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch;
 
 import java.util.List;
 
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 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.tracecompass.internal.tmf.remote.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.remote.ui.messages.RemoteMessages;
+import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement;
 import org.eclipse.ui.IImportWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.ide.IDE;
@@ -43,6 +46,8 @@ public class RemoteFetchLogWizard extends Wizard implements IImportWizard {
     private RemoteFetchLogWizardPage fFetchLogWizardPage;
     private RemoteFetchLogWizardRemotePage fFetchLogRemotePage;
 
+    private @Nullable RemoteImportProfileElement fRemoteProfile = null;
+
     // ------------------------------------------------------------------------
     // Constructor(s)
     // ------------------------------------------------------------------------
@@ -59,6 +64,16 @@ public class RemoteFetchLogWizard extends Wizard implements IImportWizard {
         setDialogSettings(section);
     }
 
+    /**
+     * Create wizard with pre-defined remote profile
+     * @param profile
+     *              a remote profile
+     */
+    public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile) {
+        this();
+        fRemoteProfile = profile;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -79,9 +94,11 @@ public class RemoteFetchLogWizard extends Wizard implements IImportWizard {
     @Override
     public void addPages() {
         super.addPages();
-        fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection);
-        addPage(fFetchLogWizardPage);
-        fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection);
+        if (fRemoteProfile == null) {
+            fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection);
+            addPage(fFetchLogWizardPage);
+        }
+        fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection, fRemoteProfile);
         addPage(fFetchLogRemotePage);
     }
 
@@ -98,7 +115,9 @@ public class RemoteFetchLogWizard extends Wizard implements IImportWizard {
 
     @Override
     public boolean canFinish() {
-        return fFetchLogWizardPage.canFlipToNextPage();
+        if (fFetchLogWizardPage != null) {
+            return fFetchLogWizardPage.canFlipToNextPage();
+        }
+        return super.canFinish();
     }
-
 }
index d02ea1e33c47e3df854fbc4f1d45cf3186d10ece..1bf8797095cf4ae466c2010181b5a8a3e6a55e7c 100644 (file)
@@ -16,25 +16,32 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.lang.reflect.InvocationTargetException;
 import java.text.MessageFormat;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.viewers.CheckboxTreeViewer;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ViewerSorter;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
 import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator;
@@ -50,7 +57,12 @@ import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePa
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement;
 import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.importexport.Messages;
+import org.eclipse.tracecompass.tmf.core.TmfProjectNature;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceFolder;
+import org.eclipse.tracecompass.tmf.ui.project.model.TmfTracesFolder;
+import org.eclipse.tracecompass.tmf.ui.project.model.TraceUtils;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -72,6 +84,8 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
     private static final String ICON_PATH = "icons/elcl16/fetch_log_wiz.gif"; //$NON-NLS-1$
     private static final Image COLLAPSE_ALL_IMAGE = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_COLLAPSEALL);
     private static final Image EXPAND_ALL_IMAGE = Activator.getDefault().getImageFromPath("icons/elcl16/expandall.png"); //$NON-NLS-1$
+    /** Name of default project to import traces to */
+    public static final String DEFAULT_REMOTE_PROJECT_NAME = "Remote"; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
     // Attributes(s)
@@ -82,6 +96,9 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
     private final Set<RemoteImportConnectionNodeElement> fRemoteHosts = new HashSet<>();
     private boolean fOverwriteAll;
     private boolean fIsVisible = false;
+    private String fDefaultProjectName = null;
+    private CCombo fCombo;
+    private List<IProject> fProjects;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -93,8 +110,10 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
      *          The Wizard title
      * @param selection
      *          The current selection (trace folder element)
+     * @param profile
+     *          A profile to use or null
      */
-    protected RemoteFetchLogWizardRemotePage(String title, IStructuredSelection selection) {
+    protected RemoteFetchLogWizardRemotePage(String title, IStructuredSelection selection, @Nullable RemoteImportProfileElement profile) {
         super(PAGE_NAME, title, null, selection);
         setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, ICON_PATH));
 
@@ -103,8 +122,12 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
         }
 
         if (fTmfTraceFolder == null) {
-            throw new IllegalArgumentException();
+            // create default project
+            TmfProjectRegistry.createProject(DEFAULT_REMOTE_PROJECT_NAME, null, null);
+            fDefaultProjectName = DEFAULT_REMOTE_PROJECT_NAME;
         }
+
+        fProfile = profile;
         setDescription(RemoteMessages.RemoteFetchLogWizardRemotePage_Description);
     }
 
@@ -126,6 +149,8 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
 
         createButtonsGroup(composite);
 
+        createProjectGroup(composite);
+
         restoreWidgetValues();
         updatePageCompletion();
 
@@ -222,6 +247,31 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
         });
     }
 
+    private void createProjectGroup(Composite parent) {
+        if (fDefaultProjectName != null) {
+            Group projectGroup = new Group(parent, SWT.SHADOW_NONE);
+            projectGroup.setText(RemoteMessages.RemoteFetchLogWizardRemotePage_ImportDialogProjectsGroupName);
+            GridLayout layout = new GridLayout(1, true);
+            projectGroup.setLayout(layout);
+            projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+            fProjects = new ArrayList<>();
+            List<String> projectNames = new ArrayList<>();
+
+            for (IProject project : TraceUtils.getOpenedTmfProjects()) {
+                fProjects.add(project);
+                projectNames.add(project.getName());
+            }
+
+            fCombo = new CCombo(projectGroup, SWT.READ_ONLY);
+            fCombo.setToolTipText(RemoteMessages.RemoteFetchLogWizardRemotePage_ImportDialogProjectsGroupName);
+            fCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
+            fCombo.setItems(projectNames.toArray(new String[projectNames.size()]));
+            int select = projectNames.indexOf(fDefaultProjectName);
+            fCombo.select(select);
+        }
+    }
+
     @Override
     protected Object createElementViewerInput() {
         if (fProfile == null) {
@@ -319,13 +369,19 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
      */
     public boolean finish() {
 
+        boolean result;
         if (!fIsVisible) {
-            boolean result = updateViewer();
+            result = updateViewer();
             if (!result) {
                 return false;
             }
         }
 
+        result = validateProject();
+        if (!result) {
+            return false;
+        }
+
         Object[] elements = getElementViewer().getCheckedElements();
         final RemoteImportTracesOperation importOperation = new RemoteImportTracesOperation(getContainer().getShell(), fTmfTraceFolder, elements, fOverwriteAll);
 
@@ -388,4 +444,33 @@ public class RemoteFetchLogWizardRemotePage extends AbstractTracePackageWizardPa
         return true;
     }
 
+    private boolean validateProject() {
+        if (fCombo != null) {
+            int fProjectIndex = fCombo.getSelectionIndex();
+            if (fProjectIndex < 0) {
+                handleError(RemoteMessages.RemoteFetchLogWizardRemotePage_NoProjectSelectedError, null);
+                return false;
+            }
+
+            IProject project = fProjects.get(fProjectIndex);
+            IFolder traceFolder = project.getFolder(TmfTracesFolder.TRACES_FOLDER_NAME);
+
+            if (!traceFolder.exists()) {
+                handleError(RemoteMessages.RemoteFetchLogWizardRemotePage_InvalidTracingProject, null);
+                return false;
+            }
+
+            try {
+                if (project.hasNature(TmfProjectNature.ID)) {
+                    TmfProjectElement projectElement = TmfProjectRegistry.getProject(project, true);
+                    fTmfTraceFolder = projectElement.getTracesFolder();
+                }
+            } catch (CoreException ex) {
+                handleError(RemoteMessages.RemoteFetchLogWizardRemotePage_InvalidTracingProject, ex);
+                return false;
+            }
+        }
+        return true;
+    }
+
 }
index 5841e8b89e47ca38bd81fcc9a6368dd430003439..b231c5c0cc5884202dbb4cf39be6dff23b551405 100644 (file)
@@ -40,7 +40,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.ui;x-friends:="org.eclipse
    org.eclipse.tracecompass.lttng2.control.ui,
    org.eclipse.tracecompass.tmf.remote.ui,
    org.eclipse.tracecompass.tmf.ui.swtbot.tests",
- org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg;x-friends:="org.eclipse.tracecompass.tmf.remote.ui,org.eclipse.tracecompass.tmf.remote.ui.tests",
+ org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg;x-friends:="org.eclipse.tracecompass.tmf.remote.ui,org.eclipse.tracecompass.tmf.remote.ui.tests,org.eclipse.tracecompass.lttng2.control.ui",
  org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.importexport;x-friends:="org.eclipse.tracecompass.tmf.remote.ui",
  org.eclipse.tracecompass.internal.tmf.ui.viewers.piecharts;x-friends:="org.eclipse.tracecompass.tmf.ui.tests",
  org.eclipse.tracecompass.internal.tmf.ui.viewers.piecharts.model;x-friends:="org.eclipse.tracecompass.tmf.ui.tests",
This page took 0.048679 seconds and 5 git commands to generate.