[[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 ===
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,
+++ /dev/null
-/**********************************************************************
- * 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();
-}
+++ /dev/null
-/**********************************************************************
- * 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();
-}
+++ /dev/null
-/**********************************************************************
- * 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();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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();
- }
-}
+++ /dev/null
-/**********************************************************************
- * 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;
- }
-}
-
*/
private IAddContextDialog fAddContextDialog;
- /**
- * The import dialog implementation.
- */
- private IImportDialog fImportDialog;
-
- /**
- * The import confirmation dialog.
- */
- private IImportConfirmationDialog fImportConfirmationDialog;
-
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
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;
- }
}
**********************************************************************/
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;
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;
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;
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;
*/
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$
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;
}
// 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
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;
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
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
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;
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...
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;
private RemoteFetchLogWizardPage fFetchLogWizardPage;
private RemoteFetchLogWizardRemotePage fFetchLogRemotePage;
+ private @Nullable RemoteImportProfileElement fRemoteProfile = null;
+
// ------------------------------------------------------------------------
// Constructor(s)
// ------------------------------------------------------------------------
setDialogSettings(section);
}
+ /**
+ * Create wizard with pre-defined remote profile
+ * @param profile
+ * a remote profile
+ */
+ public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile) {
+ this();
+ fRemoteProfile = profile;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@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);
}
@Override
public boolean canFinish() {
- return fFetchLogWizardPage.canFlipToNextPage();
+ if (fFetchLogWizardPage != null) {
+ return fFetchLogWizardPage.canFlipToNextPage();
+ }
+ return super.canFinish();
}
-
}
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;
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;
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)
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
* 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));
}
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);
}
createButtonsGroup(composite);
+ createProjectGroup(composite);
+
restoreWidgetValues();
updatePageCompletion();
});
}
+ 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) {
*/
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);
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;
+ }
+
}
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",