org.eclipse.tracecompass.ctf.core,
org.eclipse.tracecompass.tmf.core,
org.eclipse.tracecompass.tmf.ctf.core
-Export-Package: org.eclipse.tracecompass.internal.lttng2.control.core;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests",
+Export-Package: org.eclipse.tracecompass.internal.lttng2.control.core;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui",
org.eclipse.tracecompass.internal.lttng2.control.core.model;x-friends:="org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.core.tests",
org.eclipse.tracecompass.internal.lttng2.control.core.model.impl;x-friends:="org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.core.tests",
org.eclipse.tracecompass.internal.lttng2.control.core.relayd;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests",
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 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
+ **********************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.core;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Class to manage LTTng profiles files in workspace.
+ *
+ * @author Bernd Hufmann
+ */
+public class LttngProfileManager {
+
+ private static final String FOLDER = "sessions"; //$NON-NLS-1$
+
+ private static final IPath SAVED_PROFILE_PATH =
+ Activator.getDefault().getStateLocation().append(FOLDER);
+
+ static {
+ File dir = SAVED_PROFILE_PATH.toFile();
+ /* Check if directory exists, otherwise create it */
+ if (!dir.exists() || !dir.isDirectory()) {
+ dir.mkdirs();
+ }
+ }
+
+ /**
+ * Returns all LTTng profile files available in workspace.
+ *
+ * @return array with LTTng profiles
+ */
+ public static File[] getProfiles() {
+ return SAVED_PROFILE_PATH.toFile().listFiles();
+ }
+}
commands.control.wizard=Record...
commands.control.wizard.description=Create automated tracing session
+commands.control.load=Load...
+commands.control.load.description=Load session(s)
+
preference.page.control.name=LTTng Tracer Control Preferences
commandParameter.remoteServicesId.name = Remote Services ID
id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.snapshot"
name="%commands.control.snapshot">
</command>
+
<command
- defaultHandler="org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.ProfileHandler"
- description="%commands.control.wizard.description"
- id="org.eclipse.tracecompass.lttng2.control.ui.wizard"
- name="%commands.control.wizard">
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.load.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.load"
+ name="%commands.control.load">
</command>
</extension>
label="%commands.control.import"
style="push">
</command>
- <command
- commandId="org.eclipse.tracecompass.lttng2.control.ui.wizard"
- icon="icons/elcl16/add_button.gif"
- label="%commands.control.record"
- style="push">
- </command>
</menuContribution>
<menuContribution
label="%commands.control.create.session"
style="push">
<visibleWhen
- checkEnabled="false">
+ checkEnabled="true">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.load"
+ icon="icons/elcl16/import_button.png"
+ label="%commands.control.load"
+ style="push">
+ <visibleWhen
+ checkEnabled="true">
</visibleWhen>
</command>
<command
</with>
</visibleWhen>
</command>
- <command
- commandId="org.eclipse.tracecompass.lttng2.control.ui.wizard"
- icon="icons/obj16/channel_disabled.gif"
- label="Record..."
- style="push"
- >
- <visibleWhen
- checkEnabled="true">
- </visibleWhen>
- </command>
</menuContribution>
</with>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.LoadHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.load">
+ <activeWhen>
+ <with
+ variable="selection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </activeWhen>
+ </handler>
<handler
class="org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers.ExecuteCommandScriptHandler"
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.executeScript">
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
- **********************************************************************/
--->
-<sessions>
- <session>
- <name>baseCPUtrace</name>
- <domains>
- <domain>
- <type>KERNEL</type>
- <buffer_type>GLOBAL</buffer_type>
- <channels>
- <channel>
- <name>channel0</name>
- <enabled>false</enabled>
- <overwrite_mode>DISCARD</overwrite_mode>
- <subbuffer_size>8388608</subbuffer_size>
- <subbuffer_count>4</subbuffer_count>
- <switch_timer_interval>0</switch_timer_interval>
- <read_timer_interval>200000</read_timer_interval>
- <output_type>SPLICE</output_type>
- <tracefile_size>0</tracefile_size>
- <tracefile_count>0</tracefile_count>
- <live_timer_interval>0</live_timer_interval>
- <events>
- <event>
- <name>kmem_cache_free</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kfree</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_cache_alloc_node</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kmalloc_node</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_cache_alloc</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kmalloc</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- </events>
- </channel>
- </channels>
- </domain>
- </domains>
- <started>false</started>
- </session>
-</sessions>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
- **********************************************************************/
--->
-<sessions>
- <session>
- <name>baseCPUtrace</name>
- <domains>
- <domain>
- <type>KERNEL</type>
- <buffer_type>GLOBAL</buffer_type>
- <channels>
- <channel>
- <name>channel0</name>
- <enabled>false</enabled>
- <overwrite_mode>DISCARD</overwrite_mode>
- <subbuffer_size>8388608</subbuffer_size>
- <subbuffer_count>4</subbuffer_count>
- <switch_timer_interval>0</switch_timer_interval>
- <read_timer_interval>200000</read_timer_interval>
- <output_type>SPLICE</output_type>
- <tracefile_size>0</tracefile_size>
- <tracefile_count>0</tracefile_count>
- <live_timer_interval>0</live_timer_interval>
- <events>
- <event>
- <name>kmem_cache_free</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kfree</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_cache_alloc_node</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kmalloc_node</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_cache_alloc</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- <event>
- <name>kmem_kmalloc</name>
- <enabled>true</enabled>
- <type>TRACEPOINT</type>
- </event>
- </events>
- </channel>
- </channels>
- </domain>
- </domains>
- <started>false</started>
- </session>
-</sessions>
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert, William Enright,
- * William Tri-Khiem Truong - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionType;
-
-/**
- * TODO document
- *
- */
-public final class ConnectionContentProvider implements ITreeContentProvider {
- private static final Object[] NO_CHILDREN = {};
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- List<Object> children = new ArrayList<>();
- if (inputElement instanceof IRemoteConnectionType) {
- IRemoteConnectionType irc = (IRemoteConnectionType) inputElement;
- children.addAll(irc.getRemoteServicesManager().getAllRemoteConnections());
- }
- return children.toArray();
- }
-
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IRemoteConnectionType) {
- return getConnections((IRemoteConnectionType) parentElement);
- }
- return NO_CHILDREN;
- }
-
- static IRemoteConnection[] getConnections(IRemoteConnectionType parentElement) {
- List<IRemoteConnection> connectionList = parentElement.getConnections();
- IRemoteConnection[] result = connectionList.toArray(new IRemoteConnection[connectionList.size()]);
- Arrays.sort(result);
- return result;
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof IRemoteConnection) {
- return ((IRemoteConnection) element).getConnectionType();
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert, William Enright,
- * William Tri-Khiem Truong - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionType;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-
-/**
- * TODO
- *
- */
-public final class ConnectionTreeLabelProvider extends LabelProvider {
- @Override
- public String getText(Object element) {
- if (element instanceof IRemoteConnection) {
- IRemoteConnection rc = (IRemoteConnection) element;
- return rc.getName();
- } else if (element instanceof IRemoteConnectionType) {
- IRemoteConnectionType rs = (IRemoteConnectionType) element;
- return rs.getName();
- }
- return Messages.TraceControl_UnknownNode;
- }
-
- @Override
- public Image getImage(Object element) {
-// if (element instanceof IRemoteConnection) {
-// return Activator.getDefault().loadIcon(NewConnectionDialog.CONNECTION_ICON_FILE);
-// }
-// return Activator.getDefault().loadIcon(NewConnectionDialog.PROVIDERS_ICON_FILE);
- return null;
- }
-}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 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
+ **********************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
+
+import java.util.List;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * Interface for a dialog box for collecting parameter for loading a session.
+ *
+ * @author Bernd Hufmann
+ */
+public interface ILoadDialog {
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * Returns a list of file resources to load
+ * @return a list of remote resources or null if local resources to upload
+ */
+ List<IFileStore> getRemoteResources();
+
+ /**
+ * Returns a list of file resources to load
+ * @return a list of local resources to upload and load or null in remote case
+ */
+ List<IFileStore> getLocalResources();
+
+
+ /**
+ * Returns flag to overwrite existing session or not
+ * @return flag to overwrite existing session or not
+ */
+ boolean isForce();
+
+ /**
+ * Sets the remote connection reference
+ * @param connection
+ * a remote connection
+ */
+ void initialize(IRemoteConnection connection);
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Open method
+ * @return the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal, 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:
+ * Contributors:
+ * Patrick-Jeffrey Pollo Guilbert, William Enright,
+ * William Tri-Khiem Truong - Initial API and implementation
+ * Bernd Hufmann - Renamed from ProfileHandler and redesign
+ **********************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.ui.widgets.RemoteResourceBrowserWidget;
+import org.eclipse.swt.SWT;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.tracecompass.internal.lttng2.control.core.LttngProfileManager;
+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.service.LTTngControlServiceConstants;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Dialog box for collecting parameter for loading a session.
+ *
+ * @author Bernd Hufmann
+ * @author Patrick-Jeffrey Pollo Guilbert
+ * @author William Enright
+ * @author William Tri-Khiem Truong
+ *
+ */
+public class LoadDialog extends TitleAreaDialog implements ILoadDialog {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /** The icon file for this dialog box. */
+ public static final String IMPORT_ICON_FILE = "icons/elcl16/import_button.png"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ private Button fLocalButton = null;
+ private Button fRemoteButton = null;
+
+ private Composite fLocalComposite = null;
+ private CheckboxTreeViewer fFolderViewer;
+
+ private Button fForceButton = null;
+
+ private RemoteResourceBrowserWidget fFileWidget;
+ private IRemoteConnection fConnection = null;
+
+ private List<IFileStore> fLocalFiles = null;
+ private List<IFileStore> fRemoteFiles = null;
+
+ private boolean fIsForce = true;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param shell
+ * - a shell for the display of the dialog
+ */
+ public LoadDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE | getShellStyle());
+ }
+
+ @Override
+ public List<IFileStore> getRemoteResources() {
+ return fRemoteFiles;
+ }
+
+ @Override
+ public List<IFileStore> getLocalResources() {
+ return fLocalFiles;
+ }
+
+ @Override
+ public boolean isForce() {
+ return fIsForce;
+ }
+
+ @Override
+ public void initialize (IRemoteConnection connection) {
+ fConnection = connection;
+ fIsForce = true;
+ fRemoteFiles = null;
+ fLocalFiles = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_LoadDialogTitle);
+ 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);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.heightHint = 300;
+ fDialogComposite.setLayoutData(data);
+
+ createSelectionGroup();
+ createOptionComposite();
+ fLocalComposite = null;
+ fFileWidget = null;
+ createLocalComposite();
+ setMessage(Messages.TraceControl_SelectProfileText);
+ return fDialogComposite;
+ }
+
+ private void createSelectionGroup() {
+ Composite group = new Composite(fDialogComposite, SWT.BORDER);
+ group.setLayout(new GridLayout(2, true));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ fLocalButton = new Button(group, SWT.RADIO);
+ fLocalButton.setText(Messages.TraceControl_LocalButtonText);
+ fLocalButton.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fLocalButton.setSelection(true);
+
+ fRemoteButton = new Button(group, SWT.RADIO);
+ fRemoteButton.setText(Messages.TraceControl_RemoteButtonText);
+ fRemoteButton.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fLocalButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fLocalButton.getSelection()) {
+ disposeRemoteComposite();
+ createLocalComposite();
+ fRemoteFiles = null;
+ fDialogComposite.layout();
+ enableLocalButtons();
+ }
+ }
+ });
+
+ fRemoteButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (fRemoteButton.getSelection()) {
+ disposeLocalComposite();
+ createRemoteComposite();
+ fLocalFiles = null;
+ fDialogComposite.layout();
+ enableRemoteButtons();
+ }
+ }
+ });
+ }
+
+ private void createLocalComposite() {
+ if (fLocalComposite == null) {
+ fLocalComposite = new Composite(fDialogComposite, SWT.BORDER);
+ fLocalComposite.setLayout(new GridLayout(2, false));
+ fLocalComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Composite viewerComposite = new Composite(fLocalComposite, SWT.NONE);
+ viewerComposite.setLayout(new GridLayout(1, false));
+ viewerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fFolderViewer = new CheckboxTreeViewer(viewerComposite);
+ fFolderViewer.setContentProvider(new ProfileContentProvider());
+ fFolderViewer.setLabelProvider(new ProfileLabelProvider());
+ fFolderViewer.setInput(LttngProfileManager.getProfiles());
+
+ GridData data = new GridData(GridData.FILL_BOTH);
+ Tree tree = fFolderViewer.getTree();
+ tree.setLayoutData(data);
+
+ fFolderViewer.addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ enableLocalButtons();
+ }
+ });
+ }
+ }
+
+ /**
+ * Disposes the remote composite (if existing)
+ */
+ private void disposeLocalComposite() {
+ if (fLocalComposite != null) {
+ fLocalComposite.dispose();
+ fLocalComposite = null;
+ }
+ }
+
+ private void createRemoteComposite() {
+ if (fFileWidget == null) {
+ fFileWidget = new RemoteResourceBrowserWidget(fDialogComposite, SWT.BORDER, RemoteResourceBrowserWidget.SHOW_HIDDEN_CHECKBOX);
+ fFileWidget.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fFileWidget.setInitialPath(LTTngControlServiceConstants.DEFAULT_PATH);
+ fFileWidget.setConnection(fConnection);
+ fFileWidget.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ enableRemoteButtons();
+ }
+ });
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
+ }
+
+ /**
+ * Disposes the remote composite (if existing)
+ */
+ private void disposeRemoteComposite() {
+ if (fFileWidget != null) {
+ fFileWidget.dispose();
+ fFileWidget = null;
+ }
+ }
+
+ private void createOptionComposite() {
+ Composite group = new Composite(fDialogComposite, SWT.BORDER);
+ group.setLayout(new GridLayout(1, true));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ fForceButton = new Button(group, SWT.CHECK);
+ fForceButton.setText(Messages.TraceControl_ForceButtonText);
+ fForceButton.setSelection(true);
+ }
+
+ private void enableLocalButtons() {
+ Object[] checked = fFolderViewer.getCheckedElements();
+ boolean enabled = (checked != null) && (checked.length > 0);
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null) {
+ okButton.setEnabled(enabled);
+ }
+ }
+
+ private void enableRemoteButtons() {
+ List<IFileStore> resources = fFileWidget.getResources();
+ boolean enabled = (resources != null) && (resources.size() > 0);
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null) {
+ okButton.setEnabled(enabled);
+ }
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ Button button = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
+ button.setEnabled(false);
+ }
+
+ @Override
+ protected void okPressed() {
+ fIsForce = fForceButton.getSelection();
+ if (fFileWidget != null) {
+ fRemoteFiles = fFileWidget.getResources();
+ if (fRemoteFiles.size() > 0) {
+ super.okPressed();
+ }
+ return;
+ }
+
+ Object[] files = fFolderViewer.getCheckedElements();
+ List<IFileStore> stores = new ArrayList<>();
+ for (Object file : files) {
+ if (file instanceof File) {
+ stores.add(EFS.getLocalFileSystem().fromLocalFile((File) file));
+ }
+ }
+ if (stores.size() != 0) {
+ fLocalFiles = stores;
+ super.okPressed();
+ }
+ }
+
+ /**
+ * Helper class for the contents of a folder in a tracing project
+ *
+ * @author Bernd Hufmann
+ */
+ public static class ProfileContentProvider implements ITreeContentProvider {
+ @Override
+ public Object[] getChildren(Object o) {
+
+ if (o instanceof File[]) {
+ return (File[]) o;
+ }
+ File store = (File) o;
+ if (store.isDirectory()) {
+ return store.listFiles();
+ }
+ return new Object[0];
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return ((File) 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 ((File) element).isDirectory();
+ }
+ }
+
+ static class ProfileLabelProvider extends LabelProvider {
+ @Override
+ public String getText(Object element) {
+ return ((File) element).getName();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (((File) element).isDirectory()) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
+ }
+ }
+}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert, William Enright,
- * William Tri-Khiem Truong - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.HelpEvent;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- *
- * <p>
- * Dialog box using profiles
- * </p>
- *
- * @author William Enright, Patrick-Jeffrey Pollo Guilbert, William Tri-Khiem
- * Truong
- *
- *
- */
-public class ProfileDialog extends TitleAreaDialog {
-
- private Composite fBase;
- private Composite fLabel;
- private CheckboxTreeViewer fCbtv;
- private Text descriptionText;
- private ArrayList<File> fSessionFiles = new ArrayList<>();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Constructor
- *
- * @param parentShell
- * - a shell for the display of the dialog
- */
- public ProfileDialog(Shell parentShell) {
- super(parentShell);
-
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- setTitle(Messages.TraceControl_BasicMode);
- setMessage(Messages.TraceControl_SelectBasicProfile);
-
- Composite parentComp = (Composite) super.createDialogArea(parent);
-
- fBase = new Composite(parentComp, SWT.NONE);
-
- // Creating composite for label group
- fLabel = new Composite(parentComp, SWT.NONE);
- fLabel.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).create());
- fLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- descriptionText = new Text(fLabel, SWT.READ_ONLY | SWT.BORDER | SWT.MULTI);
- descriptionText.setText(Messages.TraceControl_NoProfileSelected + "\n\n\n\n\n"); //$NON-NLS-1$
- descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- descriptionText.setBackground(new Color(null, 255, 255, 255));
- fBase.addHelpListener(new HelpListener() {
-
- @Override
- public void helpRequested(HelpEvent e) {
- try {
- PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL("http://archive.eclipse.org/tracecompass/doc/org.eclipse.tracecompass.doc.user/LTTng-Tracer-Control.html#Control_View")); //$NON-NLS-1$
- } catch (PartInitException e1) {
-
- } catch (MalformedURLException e1) {
-
- }
-
- }
- });
-
- fBase.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).create());
- fBase.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- FilteredTree ft = new FilteredTree(fBase, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) {
- @Override
- protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
- fCbtv = new CheckboxTreeViewer(fBase);
- fCbtv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- fCbtv.setContentProvider(new BasicContentProvider());
- try {
- fCbtv.setInput(initialize());
- } catch (IOException e) {
-
- }
- fCbtv.expandAll();
- return fCbtv;
- }
- };
-
- ft.setBounds(0, 0, 500, 500);
- fCbtv.addSelectionChangedListener(new ProfileSelectionChangedListener());
-
- return fBase;
- }
-
- // Updates text to be displayed in the textbox for profile description
- private void updateSelectionText(IStructuredSelection sel, boolean uncheck)
- {
- Object[] obj = fCbtv.getCheckedElements();
- obj.getClass();
-
- if (fCbtv.getCheckedElements().length == 0)
- {
- descriptionText.setText(Messages.NoSelectionDescription);
- }
- else if (fCbtv.getCheckedElements().length != 1 && fCbtv.getCheckedElements().length != 0)
- {
- descriptionText.setText(Messages.TraceControl_MultipleSelectionDescription);
- } else {
-
- TreeParent checkedElement;
- boolean commentFound = false;
- if (uncheck) {
- checkedElement = (TreeParent) obj[0];
- } else {
- checkedElement = (TreeParent) sel.getFirstElement();
- }
-
- TreeParent currentParent = checkedElement.getParent();
- String parentPath = currentParent.getName();
-
- if (fCbtv.getChecked(checkedElement))
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- factory.setIgnoringComments(false);
- String fullPath = parentPath + checkedElement.getName();
- Document document = builder.parse(new File(fullPath));
- document.getDocumentElement().normalize();
- NodeList nl = document.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- if (nl.item(i).getNodeType() == Node.COMMENT_NODE) {
- commentFound = true;
- Comment comment = (Comment) nl.item(i);
- descriptionText.setText(comment.getData());
- }
- }
-
- if (!commentFound) {
- descriptionText.setText(Messages.TraceControl_SingleSelectionDescription);
- }
- } catch (ParserConfigurationException e) {
-
- } catch (SAXException e) {
-
- } catch (IOException e) {
-
- }
-
- }
-
- }
- }
-
- private List<TreeParent> addCustomFolders() throws IOException
- {
- String basicPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
- basicPath = basicPath + "resources/folders.txt"; //$NON-NLS-1$
- String thisLine = ""; //$NON-NLS-1$
- List<TreeParent> folderList = new ArrayList<>();
-
- try (BufferedReader reader = new BufferedReader(new FileReader(basicPath))) {
- while ((thisLine = reader.readLine()) != null) {
-
- for (String retval : thisLine.split("\n")) { //$NON-NLS-1$
- if (!retval.equals("")) { //$NON-NLS-1$
- List<TreeParent> filesList = new ArrayList<>();
- TreeParent newParent = new TreeParent(thisLine);
- filesList = addFilesFromFolder(thisLine);
-
- for (int i = 0; i < filesList.size(); i++)
- {
- newParent.addChild(new TreeParent(filesList.get(i).getName()));
- }
- folderList.add(newParent);
- }
- }
- }
- } catch (FileNotFoundException e) {
- System.out.printf(Messages.TraceControl_ReadingPathError, basicPath);
- }
- return folderList;
- }
-
- private List<TreeParent> addFilesFromFolder(String folderPath)
- {
- List<TreeParent> fileList = new ArrayList<>();
- File dir = new File(folderPath);
- File[] files = dir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir1, String name) {
- return name.toLowerCase().endsWith(Messages.TraceControl_LttngSuffix);
- }
- });
- if (files == null) {
- files = new File[0];
- }
- for (File f : files)
- {
- fSessionFiles.add(f);
- fileList.add(new TreeParent(f.getName()));
- }
-
- return fileList;
-
- }
-
- private TreeParent initialize() throws IOException {
-
- String absolutePath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
- String defaultPath = absolutePath + "resources/"; //$NON-NLS-1$
-
- TreeParent root = new TreeParent("Root"); //$NON-NLS-1$
-
- List<TreeParent> sessionFilesList = new ArrayList<>();
- sessionFilesList = addFilesFromFolder(defaultPath);
-
- TreeParent defaultTP = new TreeParent(defaultPath);
-
- for (int i = 0; i < sessionFilesList.size(); i++)
- {
- defaultTP.addChild(sessionFilesList.get(i));
- }
-
- root.addChild(defaultTP);
-
- List<TreeParent> customList = new ArrayList<>();
- customList = addCustomFolders();
-
- for (TreeParent tp : customList)
- {
- root.addChild(tp);
- }
-
- return root;
- }
-
- private final class ProfileSelectionChangedListener implements ISelectionChangedListener {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
-
- if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection)
- {
- IStructuredSelection sel = (IStructuredSelection) event.getSelection();
-
- updateSelectionText(sel, false);
- Object selectedObject = sel.getFirstElement();
- updateCheckedProfiles(sel, selectedObject);
- }
- }
-
- private void updateCheckedProfiles(IStructuredSelection sel, Object selectedObject) {
- // Check if all the other brothers are checked, if so, check parent
- // TreeObject is checked
- if (fCbtv.getChecked(selectedObject)) {
- ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
- for (TreeObject parentAbove : allParents) {
- Boolean brothersChecked = true;
- ArrayList<TreeObject> allChildren = ((TreeParent) parentAbove).getAllChildren();
- for (TreeObject child : allChildren) {
- // TreeParent is checked
- if (!fCbtv.getChecked(child)) {
- brothersChecked = false;
- }
- }
- if (brothersChecked) {
- fCbtv.setChecked(parentAbove, true);
- }
- }
- }
-
- if (selectedObject.getClass() == TreeParent.class)
- {
- // TreeParent is checked, must check all children
- if (fCbtv.getChecked(selectedObject)) {
- ArrayList<TreeObject> allChildren = ((TreeParent) selectedObject).getAllChildren();
- for (TreeObject child : allChildren) {
- fCbtv.setChecked(child, true);
- }
- fCbtv.expandToLevel(selectedObject, AbstractTreeViewer.ALL_LEVELS);
- }
- // TreeParent is unchecked, must uncheck children and parent,
- // but not brothers
- else {
- ArrayList<TreeObject> allChildren = ((TreeParent) selectedObject).getAllChildren();
- for (TreeObject child : allChildren) {
- fCbtv.setChecked(child, false);
- updateSelectionText(sel, true);
- }
- ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
- for (TreeObject parentAbove : allParents) {
- fCbtv.setChecked(parentAbove, false);
- updateSelectionText(sel, true);
- }
-
- }
- } else if (selectedObject.getClass() == TreeObject.class) {
- // TreeObject is checked
- if (fCbtv.getChecked(selectedObject)) {
-
- }
- // TreeObject is unchecked
- else {
- ArrayList<TreeObject> allParents = ((TreeObject) selectedObject).getAllParents();
- for (TreeObject parentAbove : allParents) {
- fCbtv.setChecked(parentAbove, false);
- }
- }
- }
- }
- }
-
- class TreeObject extends PlatformObject {
- private String name;
- private TreeParent parent;
-
- public TreeObject(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setParent(TreeParent parent) {
- this.parent = parent;
- }
-
- public TreeParent getParent() {
- return parent;
- }
-
- public ArrayList<TreeObject> getAllParents() {
- ArrayList<TreeObject> both = new ArrayList<>();
- TreeObject parentTemp = getParent();
- if (parentTemp != null) { // is not root, has more parents
- both.add(parentTemp);
- both.addAll(parentTemp.getAllParents());
- }
-
- return both;
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- }
-
- class TreeParent extends TreeObject {
- private ArrayList<TreeObject> children;
-
- public TreeParent(String name) {
- super(name);
- children = new ArrayList<>();
- }
-
- public void addChild(TreeObject child) {
- children.add(child);
- child.setParent(this);
- }
-
- public void removeChild(TreeObject child) {
- children.remove(child);
- child.setParent(null);
- }
-
- public TreeObject[] getChildren() {
- return children.toArray(new TreeObject[children.size()]);
- }
-
- public ArrayList<TreeObject> getAllChildren()
- {
- ArrayList<TreeObject> both = new ArrayList<>();
- for (Object child : getChildren()) {
- if (child.getClass() == TreeParent.class) { // is a parent
- both.add((TreeObject) child);
- both.addAll(((TreeParent) child).getAllChildren());
- } else {
- both.add((TreeObject) child);
- }
- }
- return both;
- }
-
- public boolean hasChildren() {
- return children.size() > 0;
- }
- }
-
- class BasicContentProvider implements ITreeContentProvider {
- private TreeParent invisibleRoot;
-
- @Override
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public Object[] getElements(Object parent) {
- if (parent.equals(null)) {
- if (invisibleRoot == null) {
- try {
- invisibleRoot = initialize();
- } catch (IOException e) {
-
- }
- }
- return getChildren(invisibleRoot);
- }
- return getChildren(parent);
- }
-
- @Override
- public Object getParent(Object child) {
- if (child instanceof TreeObject) {
- return ((TreeObject) child).getParent();
- }
- return null;
- }
-
- @Override
- public Object[] getChildren(Object parent) {
- if (parent instanceof TreeParent) {
- return ((TreeParent) parent).getChildren();
- }
- return new Object[0];
- }
-
- @Override
- public boolean hasChildren(Object parent) {
- if (parent instanceof TreeParent) {
- return ((TreeParent) parent).hasChildren();
- }
- return false;
- }
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- @Override
- protected void okPressed()
- {
- Object[] checkedElements = fCbtv.getCheckedElements();
-
- if (checkedElements.length != 0) {
- ArrayList<File> temp = new ArrayList<>();
- for (Object checked : checkedElements) {
- String sessionName = ((TreeParent) checked).toString();
- if (sessionName.endsWith(Messages.ProfileDialog_LTTNG_Suffix)) {
-
- for (File f : fSessionFiles) {
- if (f.getAbsolutePath().endsWith(sessionName)) {
- temp.add(f);
- }
- }
- }
- }
- fSessionFiles = temp;
- }
-
- super.okPressed();
- }
-
- /**
- * @return the list of checked files
- */
- public ArrayList<File> getCheckedFiles() {
- return fSessionFiles;
- }
-
-}
*/
private ISelectCommandScriptDialog fCommandScriptDialog;
+ /**
+ * The command script selection dialog.
+ */
+ private ILoadDialog fLoadDialog;
+
/**
* The enable events dialog.
*/
return fCommandScriptDialog;
}
+ /**
+ * @return command script selection dialog implementation
+ */
+ public ILoadDialog getLoadDialog() {
+ if (fLoadDialog == null) {
+ fLoadDialog = new LoadDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fLoadDialog;
+ }
+
+ /**
+ * Sets a load dialog implementation
+ * @param loadDialog
+ * a load dialog implementation
+ */
+ public void setLoadDialog(ILoadDialog loadDialog) {
+ fLoadDialog = loadDialog;
+ }
+
/**
* Sets a create session dialog implementation.
* @param createSessionDialog - a create session implementation.
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal and others
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Patrick-Jeffrey Pollo Guilbert - Extracted from NewConnectionDialog
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
-
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionType;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.ui.IRemoteUIConnectionService;
-import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.Label;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ConnectionContentProvider;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ConnectionTreeLabelProvider;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-
-final class ConnectionPage extends WizardPage {
- /**
- *
- *
- *
- */
-
- private static final int BUTTONS_NUMBER_OF_COLUMNS = 3;
- private Button fNewButton;
- private Button fEditButton;
- private IRemoteConnection fConnection;
- private TreeViewer fConnectionTree = null;
-
- ConnectionPage(String pageName) {
- super(pageName);
- }
-
- @Override
- public void createControl(Composite parent) {
- GridData gd;
- Composite dialogComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- dialogComposite.setLayout(layout);
- dialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label = new Label(dialogComposite, SWT.NONE);
- label.setText(Messages.TraceControl_NewNodeExistingConnectionGroupName);
- gd = new GridData();
- label.setLayoutData(gd);
- gd.widthHint = label.computeSize(-1, -1).x + convertWidthInCharsToPixels(NewConnectionWizard.LABEL_WIDTH_CHARS);
- // Existing connections group
- this.fConnectionTree = new TreeViewer(dialogComposite);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- this.fConnectionTree.getTree().setLayoutData(gd);
- gd.widthHint = convertWidthInCharsToPixels(NewConnectionWizard.CONNECTIONTREE_WIDTH_CHARS);
- gd.heightHint = convertHeightInCharsToPixels(NewConnectionWizard.CONNECTIONTREE_HEIGHT_CHARS);
- fConnectionTree.setLabelProvider(new ConnectionTreeLabelProvider());
- fConnectionTree.setContentProvider(new ConnectionContentProvider());
- fConnectionTree.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ConnectionPage.this.onSelectionChanged();
- }
- });
- fConnectionTree.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- getWizard().performFinish();
- }
- });
-
- Composite buttons = new Composite(dialogComposite, SWT.NONE);
- layout = new GridLayout(BUTTONS_NUMBER_OF_COLUMNS, true);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- buttons.setLayout(layout);
- buttons.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
-
- new Label(buttons, SWT.NONE);
-
- fEditButton = new Button(buttons, SWT.PUSH);
- fEditButton.setText(Messages.TraceControl_NewNodeEditButtonName);
- setButtonLayoutData(fEditButton);
- fEditButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- onEditConnection();
- }
- });
-
- fNewButton = new Button(buttons, SWT.PUSH);
- fNewButton.setText(Messages.TraceControl_NewNodeCreateButtonText);
- setButtonLayoutData(fNewButton);
- fNewButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- onNewConnection();
- }
- });
- setControl(dialogComposite);
-
- }
-
- private void onSelectionChanged() {
- setConnection();
- setPageComplete(true);
- fEditButton.setEnabled(canEdit(fConnection));
- fNewButton.setEnabled(getServiceForCreation() != null);
- }
-
- private void onEditConnection() {
- setConnection();
- if (fConnection != null) {
- IRemoteConnectionType connectionType = fConnection.getConnectionType();
- if (connectionType != null) {
- IRemoteUIConnectionService connManager = connectionType.getService(IRemoteUIConnectionService.class);
- if (connManager != null) {
- IRemoteUIConnectionWizard wiz = connManager.getConnectionWizard(getShell());
- wiz.setConnection(fConnection.getWorkingCopy());
- IRemoteConnectionWorkingCopy result = wiz.open();
- if (result != null) {
- try {
- result.save();
- } catch (RemoteConnectionException e) {
- Activator.getDefault().logError(e.toString(), e);
- }
- fConnectionTree.refresh();
- }
- }
- }
- }
- }
-
- private void setConnection() {
- Object o = ((IStructuredSelection) fConnectionTree.getSelection()).getFirstElement();
- fConnection = o instanceof IRemoteConnection ? (IRemoteConnection) o : null;
- }
-
- private static boolean canEdit(IRemoteConnection conn) {
- if (conn == null) {
- return false;
- }
- return conn.getConnectionType().canEdit();
- }
-
- private IRemoteConnectionType getServiceForCreation() {
- Object o = ((IStructuredSelection) fConnectionTree.getSelection()).getFirstElement();
- IRemoteConnectionType result = null;
- if (o instanceof IRemoteConnectionType) {
- result = (IRemoteConnectionType) o;
- } else if (o instanceof IRemoteConnection) {
- IRemoteConnection iRemoteConnection = (IRemoteConnection) o;
- result = iRemoteConnection.getConnectionType();
- } else {
- return null;
- }
- if (!result.canAdd()) {
- return null;
- }
-
- return result;
- }
-
- public void onNewConnection() {
- IRemoteConnectionType rs = getServiceForCreation();
- if (rs != null) {
- IRemoteUIConnectionService uiService = rs.getService(IRemoteUIConnectionService.class);
- if (uiService != null) {
- IRemoteUIConnectionWizard wiz = uiService.getConnectionWizard(getShell());
- if (wiz != null) {
- IRemoteConnectionWorkingCopy wc = wiz.open();
- if (wc != null) {
- IRemoteConnection conn = null;
- try {
- conn = wc.save();
- fConnectionTree.refresh();
- fConnectionTree.setSelection(new StructuredSelection(conn), true);
- } catch (RemoteConnectionException e) {
- Activator.getDefault().logError(e.toString(), e);
- }
- }
- }
- }
- }
- }
-}
\ No newline at end of file
initializeTraceResource(connectionInfo, lttngRelaydConsumer.getTracePath(), project);
return Status.OK_STATUS;
} catch (CoreException | TmfTraceImportException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportHandler_LiveTraceInitError, e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LiveTraceInitError, e);
}
}
}
if (found == null) {
- throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ImportHandler_LiveTraceElementError));
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LiveTraceElementError));
}
// Properties used to be able to reopen a trace in live mode
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2015 École Polytechnique de Montréal, 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:
+ * Patrick-Jeffrey Pollo Guilbert - Added headers, exporting .lttng profiles
+ * William Enright - Added ProfileHandler implementation
+ * William Tri-Khiem Truong - Completed documentation
+ * Bernd Hufmann - Renamed from ProfileHandler and redesign
+ **********************************************************************/
+package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
+
+import java.util.ArrayList;
+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.IFileStore;
+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.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteFileService;
+import org.eclipse.remote.core.IRemoteProcessService;
+import org.eclipse.remote.core.RemoteServicesUtils;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ILoadDialog;
+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.TraceSessionGroup;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
+import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * Command handler implementation to execute load command.
+ *
+ * @author Bernd Hufmann
+ * @author Patrick-Jeffrey Pollo Guilbert
+ * @author William Enright
+ * @author William Tri-Khiem Truong
+ */
+public class LoadHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The trace session group the command is to be executed on.
+ */
+ private TraceSessionGroup fSessionGroup = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ final TraceSessionGroup sessionGroup;
+ final IRemoteConnection connection;
+
+ fLock.lock();
+ try {
+ sessionGroup = fSessionGroup;
+ if (sessionGroup == null) {
+ return null;
+ }
+ connection = sessionGroup.getTargetNode().getRemoteSystemProxy().getRemoteConnection();
+ } finally {
+ fLock.unlock();
+ }
+
+ // Open dialog box for the session input path
+ final ILoadDialog dialog = TraceControlDialogFactory.getInstance().getLoadDialog();
+ dialog.initialize(connection);
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_LoadJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+
+ SubMonitor subMonitor = SubMonitor.convert(monitor, 3);
+ // create destination directory (if necessary)
+ IRemoteProcessService processService = connection.getService(IRemoteProcessService.class);
+ IPath path = null;
+ if (processService != null) {
+ String cwd = processService.getWorkingDirectory();
+ path = RemoteServicesUtils.posixPath(cwd);
+ path = path.append(LTTngControlServiceConstants.DEFAULT_PATH);
+ }
+
+ if (path == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ ILttngControlService service = sessionGroup.getControlService();
+ List<String> commands = new ArrayList<>();
+ commands.add("mkdir -p " + path.toString()); //$NON-NLS-1$
+ service.runCommands(subMonitor.newChild(1), commands);
+
+ // upload files
+ IRemoteFileService fileService = connection.getService(IRemoteFileService.class);
+ if (fileService == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ List<IFileStore> localFiles = dialog.getLocalResources();
+ List<IFileStore> remoteResources;
+ if (localFiles != null) {
+ remoteResources = new ArrayList<>();
+ SubMonitor childMonitor = subMonitor.newChild(1);
+ for (IFileStore local : localFiles) {
+ IPath remotePath = RemoteServicesUtils.posixPath(path.toString()).append(local.getName());
+ IFileStore remoteResource = fileService.getResource(remotePath.toString());
+ local.copy(remoteResource, EFS.OVERWRITE, childMonitor);
+ remoteResources.add(remoteResource);
+ }
+ } else {
+ subMonitor.newChild(1);
+ remoteResources = dialog.getRemoteResources();
+ }
+ loadRemoteProfile(sessionGroup, subMonitor.newChild(1), remoteResources, dialog.isForce());
+ } catch (ExecutionException | CoreException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LoadFailure, e);
+ } catch (InterruptedException e) {
+ return Status.CANCEL_STATUS;
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceSessionGroup sessionGroup = null;
+
+ // Check if the session group project is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ Object element = ((StructuredSelection) selection).getFirstElement();
+ sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ }
+
+ boolean isEnabled = sessionGroup != null;
+ fLock.lock();
+ try {
+ fSessionGroup = null;
+ if(isEnabled) {
+ fSessionGroup = sessionGroup;
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
+ }
+
+ private static void loadRemoteProfile(final TraceSessionGroup sessionGroup, IProgressMonitor monitor, List<IFileStore> files, boolean isForce) throws ExecutionException, InterruptedException {
+ SubMonitor subMonitor = SubMonitor.convert(monitor, files.size());
+ for (IFileStore file : files) {
+ // Check if operation was cancelled.
+ if (subMonitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+ subMonitor.beginTask(NLS.bind(Messages.TraceControl_LoadTask, file.getName()), 1);
+ sessionGroup.loadSession(file.toURI().getPath(), isForce, subMonitor);
+ subMonitor.done();
+ }
+ }
+}
import java.util.Map;
-import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.services.IServiceLocator;
/**
* <p>
fLock.unlock();
}
}
-
- // Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench():
- IServiceLocator serviceLocator = PlatformUI.getWorkbench();
- // or a site from within a editor or view:
- // IServiceLocator serviceLocator = getSite();
-
- ICommandService commandService = serviceLocator.getService(ICommandService.class);
-
-
- // Lookup commmand with its ID
- Command command = commandService.getCommand("org.eclipse.linuxtools.internal.lttng2.ui.commands.control.createSession"); //$NON-NLS-1$
-
- // Optionally pass a ExecutionEvent instance, default no-param arg creates blank event
- try {
- // execute new connection command directly
- command.executeWithChecks(new ExecutionEvent());
- // FIX THIS OH GOD THE INHUMANITY
- } catch (Exception e) {
-
- e.printStackTrace();
- }
-
return null;
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
-
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-//import org.eclipse.swt.custom.CTabFolder;
-//import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.graphics.Color;
-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.Group;
-//import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.INewConnectionDialog;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.NewConnectionDialog;
-
-
-public class NewConnectionWizard {
-
- static final int LABEL_WIDTH_CHARS = 4;
- private NewConnectionDialog fNewConnectionDialog;
-
- static final int CONNECTIONTREE_HEIGHT_CHARS = 10;
- static final int CONNECTIONTREE_WIDTH_CHARS = 40;
-
- TreeViewer fConnectionTree = null;
- private CheckboxTreeViewer treeViewer;
-
-
-
- // TODO: refactor name of class and all classes associated with it
- public NewConnectionWizard()
- {
-
- Shell shell = new Shell();
-
- shell.setLayout(new GridLayout());
- Composite composite = new Composite(shell, SWT.BORDER);
- Composite compositeDescription = new Composite(shell, SWT.BORDER);
- composite.setBackground(new Color(null, 255,255,255));
- compositeDescription.setBackground(new Color(null, 255,255,255));
-
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- gridData.horizontalSpan = 2;
-
-
-
-
-
-
-
-
- Group groupProfile = new Group(composite, SWT.SHADOW_ETCHED_IN);
- groupProfile.setText("Profiles List");
-
-
- composite.setLayoutData(gridData);
- composite.setLayout(new GridLayout(1, false));
- groupProfile.setLayoutData(gridData);
- groupProfile.setLayout(new GridLayout());
- groupProfile.setBackground(new Color(null, 255,255,255));
-
-
-
-
- new FilteredTree(groupProfile, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true){
- @Override
- protected TreeViewer doCreateTreeViewer(Composite aparent, int style) {
- treeViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- //TODO: change string to one recorded in Messages class
- treeViewer.getTree().setToolTipText("Select one or multiple profiles from the list below."); //$NON-NLS-1$
- ArrayContentProvider test = new ArrayContentProvider();
-
- treeViewer.setContentProvider(test);
-
- test.inputChanged(treeViewer, null, new String[]{"allo", "bye"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
- return treeViewer;
- }
- };
-
-
-
-
- // TODO: modify the checkbox addition to be based on availble profiles
- Button b = new Button(groupProfile, SWT.CHECK);
- b.setText("CPU Usage");
- b.setBackground(new Color(null, 255,255,255));
-
- Button b2 = new Button(groupProfile, SWT.CHECK);
- b2.setText("Memory usage");
- b2.setBackground(new Color(null, 255,255,255));
-
- Button b3 = new Button(groupProfile, SWT.CHECK);
- b3.setText("Disk Activity");
- b3.setBackground(new Color(null, 255,255,255));
-
-
- Group groupDescription = new Group(composite, SWT.SHADOW_ETCHED_IN);
- groupDescription.setText("Description");
-
- groupDescription.setLayoutData(gridData);
- groupDescription.setLayout(new GridLayout());
- groupDescription.setBackground(new Color(null, 255,255,255));
-
-
- groupDescription.pack();
-
- Label descriptionLabel = new Label(groupDescription, 0);
- descriptionLabel.setText("No description available.");
- descriptionLabel.setBackground(new Color(null, 255,255,255));
-
- groupProfile.pack();
-
- shell.open();
-
-
- }
-
- WizardPage wp = new ConnectionPage("Wizard");
-
- protected void okPressed()
- {
-
- }
-
- WizardPage testPage = new WizardPage("Kappa")
- {
-
- @Override
- public void createControl(Composite parent) {
- // TODO Auto-generated method stub
- Composite canvas = new Composite(parent, SWT.NONE);
- canvas.setLayout(new GridLayout());
- this.setTitle("Session creation");
-
- setControl(canvas);
- Button b = new Button(canvas, SWT.RADIO);
- b.setText("Local");
-
- }
-
- };
-
- public INewConnectionDialog getfNewConnectionDialog() {
- return fNewConnectionDialog;
- }
-
- public void setNewConnectionDialog(INewConnectionDialog fNewConnectionDialog) {
- this.fNewConnectionDialog = (NewConnectionDialog) fNewConnectionDialog;
- }
-
- public CheckboxTreeViewer getTreeViewer() {
- return treeViewer;
- }
-
- public void setTreeViewer(CheckboxTreeViewer treeViewer) {
- this.treeViewer = treeViewer;
- }
-
-}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2015 École Polytechnique de Montréal
- *
- * 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:
- * Patrick-Jeffrey Pollo Guilbert - Added headers, exporting .lttng profiles
- * William Enright - Added ProfileHandler implementation
- * William Tri-Khiem Truong - Completed documentation
- **********************************************************************/
-package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.util.ArrayList;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.remote.core.IRemoteConnectionType;
-import org.eclipse.remote.core.IRemoteFileService;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs.ProfileDialog;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
-import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup;
-import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.handlers.IHandlerService;
-
-/**
- * <p>
- * Profile Handler to select and load session profiles for tracing purposes
- * </p>
- *
- * @author William Tri-Khiem Truong, William Enright, Patrick-Jeffrey Pollo Guilbert
- */
-public class ProfileHandler extends BaseControlViewHandler {
-
- /**
- * Id of the parameter for the remote services id.
- *
- * @see NewConnectionHandler
- * @see IRemoteConnectionType#getId()
- */
- public static final String PARAMETER_REMOTE_SERVICES_ID = "org.eclipse.linuxtools.lttng2.control.ui.remoteServicesIdParameter"; //$NON-NLS-1$
-
- /**
- * (INewConnectionDialog) wd).getConnection() Id of the parameter for the
- * name of the remote connection.
- *
- * @see NewConnectionHandler
- * @see IRemoteConnectionType#getName()
- */
- public static final String PARAMETER_CONNECTION_NAME = "org.eclipse.linuxtools.lttng2.control.ui.connectionNameParameter"; //$NON-NLS-1$
-
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- Shell s = new Shell(SWT.CENTER);
-
- Rectangle screenSize = Display.getCurrent().getPrimaryMonitor().getBounds();
- s.setLocation((screenSize.width - s.getBounds().width) / 2, (screenSize.height - s.getBounds().height) / 2);
- s.setMinimumSize(500, 500);
-
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- TargetNodeComponent elementParent = null;
-
- // Check if the session group project is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- final TraceSessionGroup sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
- if (sessionGroup != null)
- {
- if (sessionGroup.getParent() instanceof TargetNodeComponent) {
- elementParent = (TargetNodeComponent) sessionGroup.getParent();
- final ProfileDialog btd = new ProfileDialog(s);
- if (btd.open() != Window.OK) {
- return null;
- }
- final String remotePath = sessionGroup.getTargetNode().getRemoteSystemProxy().getRemoteConnection().getProperty("user.home") + "/.lttng/sessions"; //$NON-NLS-1$//$NON-NLS-2$
-
- RemoteSystemProxy proxy = elementParent.getRemoteSystemProxy();
- IRemoteFileService fsss = proxy.getRemoteConnection().getService(IRemoteFileService.class);
- ArrayList<File> checkedFiles = btd.getCheckedFiles();
-
- for (File file : checkedFiles) {
- final IFileStore remoteFolder = fsss.getResource(remotePath);
- final IFileStore remoteFile = remoteFolder.getFileStore(new Path(file.getName()));
- try {
- try (OutputStream out = remoteFile.openOutputStream(EFS.NONE, new NullProgressMonitor()))
- {
- Files.copy(file.toPath(), out);
- }
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- Job job = new Job(Messages.TraceControl_LoadSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- sessionGroup.loadSession(remotePath + "/" + remoteFile.getName(), monitor); //$NON-NLS-1$
- } catch (ExecutionException e) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_LoadSessionFailure, e);
- }
- return Status.OK_STATUS;
- }
- };
-
- job.setUser(true);
- job.schedule();
- }
-
- }
-
- }
- }
- // Refreshing the sessions in the control view by calling the refresh
- // command
-
- IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
-
- IHandlerService service = part.getSite().getService(IHandlerService.class);
-
- try {
- service.executeCommand("org.eclipse.linuxtools.internal.lttng2.ui.commands.control.refresh", null); //$NON-NLS-1$
- } catch (NotDefinedException e) {
-
- } catch (NotEnabledException e) {
-
- } catch (NotHandledException e) {
-
- }
- return null;
- }
-
- @Override
- public boolean isEnabled() {
-
- // Get workbench page for the Control View
- IWorkbenchPage page = getWorkbenchPage();
- if (page == null) {
- return false;
- }
-
- TraceSessionGroup sessionGroup = null;
-
- // Check if the session group project is selected
- ISelection selection = page.getSelection(ControlView.ID);
- if (selection instanceof StructuredSelection) {
- Object element = ((StructuredSelection) selection).getFirstElement();
- sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
- }
-
- boolean isEnabled = sessionGroup != null;
- fLock.lock();
- try {
- if (isEnabled) {
- }
- } finally {
- fLock.unlock();
- }
- return isEnabled;
- }
-}
\ No newline at end of file
// Failures
public static String TraceControl_ConnectionFailure;
public static String TraceControl_DisconnectionFailure;
- public static String TraceControl_LoadSessionFailure;
-
public static String TraceControl_CommandError;
- public static String ImportHandler_LiveTraceElementError;
- public static String ImportHandler_LiveTraceInitError;
+ public static String TraceControl_LiveTraceElementError;
+ public static String TraceControl_LiveTraceInitError;
public static String TraceControl_UnexpectedCommandOutputFormat;
public static String TraceControl_UnexpectedNameError;
public static String TraceControl_UnexpectedPathError;
public static String TraceControl_CreateSessionJob;
public static String TraceControl_CreateSessionFailure;
- public static String TraceControl_LoadSessionJob;
-
public static String TraceControl_DestroySessionJob;
public static String TraceControl_DestroySessionFailure;
public static String TraceControl_DestroyConfirmationTitle;
public static String TraceControl_DownloadTask;
public static String TraceControl_ImportFailure;
+ public static String TraceControl_LoadJob;
+ public static String TraceControl_LoadTask;
+ public static String TraceControl_LoadFailure;
+
public static String TraceControl_ChangeSessionStateJob;
public static String TraceControl_ChangeSessionStateFailure;
public static String EnableChannelDialog_DefaultMessage;
- public static String NoSelectionDescription;
-
-
- public static String ProfileDialog_5;
-
-
- public static String ProfileDialog_6;
-
-
- public static String ProfileDialog_LTTNG_Suffix;
-
public static String TraceControl_ChangeChannelStateJob;
public static String TraceControl_ChangeChannelStateFailure;
public static String TraceControl_ChangeEventStateJob;
public static String TraceControl_CreateSessionLiveDelayTooltip;
public static String TraceControl_InvalidSessionNameError;
- public static String TraceControl_SelectBasicProfile;
-
-
public static String TraceControl_SessionAlreadyExistsError;
public static String TraceControl_SessionPathAlreadyExistsError;
public static String TraceControl_InvalidSessionPathError;
public static String TraceControl_OverwriteModePropertyName;
public static String TraceControl_SubBufferSizePropertyName;
public static String TraceControl_NbSubBuffersPropertyName;
-
-
- public static String TraceControl_NoProfileSelected;
public static String TraceControl_SwitchTimerPropertyName;
- public static String TraceControl_ReadingPathError;
-
public static String TraceControl_ReadTimerPropertyName;
public static String TraceControl_OutputTypePropertyName;
public static String TraceControl_HostAddressPropertyName;
public static String TraceControl_SessionPathPropertyName;
-
- public static String TraceControl_SingleSelectionDescription;
public static String TraceControl_SnapshotPathPropertyName;
public static String TraceControl_SnapshotNamePropertyName;
public static String TraceControl_SnapshotIdPropertyName;
public static String TraceControl_ProbeSymbolPropertyName;
public static String TraceControl_MaxSizeTraceFilesPropertyName;
public static String TraceControl_MaxNumTraceFilesPropertyName;
-
-
- public static String TraceControl_MultipleSelectionDescription;
public static String TraceControl_ConfigureMetadataChannelName;
// Preferences
public static String TraceControl_TracingGroupPreference;
public static String TraceControl_LoggingPreference;
public static String TraceControl_LogfilePath;
-
-
- public static String TraceControl_LttngSuffix;
public static String TraceControl_AppendLogfilePreference;
public static String TraceControl_VerboseLevelsPreference;
public static String TraceControl_ExecuteScriptBrowseText;
public static String TraceControl_ExecuteScriptSelectLabel;
+ public static String TraceControl_LoadDialogTitle;
+
public static String TraceControl_UnknownNode;
- public static String TraceControl_BasicMode;
+ public static String TraceControl_SelectProfileText;
+ public static String TraceControl_LocalButtonText;
+ public static String TraceControl_RemoteButtonText;
+
+ public static String TraceControl_ForceButtonText;
static {
// initialize resource bundle
###############################################################################
EnableChannelDialog_DefaultMessage=Default
-ImportHandler_LiveTraceElementError=Could not find trace element
-ImportHandler_LiveTraceInitError=Error initializing live trace.
-NoSelectionDescription="No profile was checked"
-ProfileDialog_5=
-ProfileDialog_6=
-ProfileDialog_LTTNG_Suffix=
+TraceControl_LiveTraceElementError=Could not find trace element
+TraceControl_LiveTraceInitError=Error initializing live trace.
TraceControl_ConnectionFailure=Connecting to host failed
TraceControl_DisconnectionFailure=Disconnection from host failed
TraceControl_CommandError=Command failed! Command:
TraceControl_UnsupportedVersionError=Unsupported LTTng Tracer Control version
TraceControl_GettingVersionError=Could not get version of LTTng Tracer Control
-TraceControl_BasicMode=Basic mode
# Xml parsing related failures
TraceControl_InvalidSchemaError=Could not open/validate xsd Schema
TraceControl_NewNodeCreationFailure=Creation of new connection failed
TraceControl_CreateSessionJob=Creating Session...
TraceControl_CreateSessionFailure=Command to create session failed
-TraceControl_LoadSessionJob=Loading Session...
-TraceControl_LoadSessionFailure=Command to load session failed
TraceControl_DestroySessionJob=Destroying Session...
TraceControl_DestroySessionFailure=Command to destroy session failed
TraceControl_DownloadTask=Downloading
TraceControl_ImportFailure=Command to import traces failed
+TraceControl_LoadJob=Loading Session Profiles...
+TraceControl_LoadTask=Loading profile ''{0}''
+TraceControl_LoadFailure=Command to load session(s) failed
+
TraceControl_ChangeSessionStateJob=Changing Session State...
TraceControl_ChangeSessionStateFailure=Command to change session state failed...
TraceControl_CreateSessionLiveConnectionPortTooltip=The port for the live connection (Relayd)
TraceControl_InvalidSessionNameError=The session name is invalid
-TraceControl_SelectBasicProfile=Select your basic tracing profile and connection type.
TraceControl_SessionAlreadyExistsError=The session name already exists
TraceControl_SessionPathAlreadyExistsError=Session path already exists
TraceControl_InvalidSessionPathError=The session path is invalid
TraceControl_OverwriteModePropertyName=Overwrite Mode
TraceControl_SubBufferSizePropertyName=Sub Buffer Size
TraceControl_NbSubBuffersPropertyName=Number of Sub Buffers
-TraceControl_NoProfileSelected=No profile was selected. No description available.
TraceControl_SwitchTimerPropertyName=Switch Timer Interval
-TraceControl_ReadingPathError=Error reading file in path %s\n
TraceControl_ReadTimerPropertyName=Read Timer Interval
TraceControl_OutputTypePropertyName=Output Type
TraceControl_TraceFileCountPropertyName=Trace File Count
TraceControl_HostNamePropertyName=Connection Name
TraceControl_HostAddressPropertyName=Host Name
TraceControl_SessionPathPropertyName=Session Path
-TraceControl_SingleSelectionDescription=A profile was selected, but no description was found within the profile.
TraceControl_SnapshotPathPropertyName=Snapshot Path
TraceControl_SnapshotNamePropertyName=Snapshot Name
TraceControl_SnapshotIdPropertyName=Snapshot ID
TraceControl_ProbeSymbolPropertyName=Symbol
TraceControl_MaxSizeTraceFilesPropertyName=Maximum size of trace files
TraceControl_MaxNumTraceFilesPropertyName=Maximum number of trace files
-TraceControl_MultipleSelectionDescription=This configuration will attempt to trace with multiple profil1es simultaneously.
TraceControl_ConfigureMetadataChannelName=Configure metadata channel
# Preferences
TraceControl_TracingGroupPreference=&Tracing Group
TraceControl_LoggingPreference=&Logging
TraceControl_LogfilePath=Log file
-TraceControl_LttngSuffix=.lttng
TraceControl_AppendLogfilePreference=&Append
TraceControl_VerboseLevelsPreference=&Verbose Level
TraceControl_VerboseLevelNonePreference=None
TraceControl_ExecuteScriptBrowseText=Browse...
TraceControl_ExecuteScriptSelectLabel=Select Script
TraceControl_UnknownNode=<unknown>
+
+TraceControl_LoadDialogTitle=Load Sessions
+
+TraceControl_SelectProfileText=Select LTTng profile to load
+TraceControl_LocalButtonText=Local
+TraceControl_RemoteButtonText=Remote
+
+TraceControl_ForceButtonText=force
\ No newline at end of file
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
}
@Override
- public void loadSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
-
+ public void loadSession(@Nullable String inputPath, boolean isForce, IProgressMonitor monitor) throws ExecutionException {
}
}
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
}
}
- /**
- * Loads a session from a path
- *
- * @param sessionPath
- *
- * @param monitor
- * - a progress monitor
- * @throws ExecutionException
- * If the command fails
- */
- public void loadSession(String sessionPath, IProgressMonitor monitor) throws ExecutionException {
- getControlService().loadSession(sessionPath, monitor);
-
-
- }
-
/**
* Command to execute a list of commands
* @param monitor
session.removeAllChildren();
removeChild(session);
}
+
+ /**
+ * Load all or a given session.
+ *
+ * @param inputPath
+ * a input path to load session from or null for load all from default
+ * @param isForce
+ * flag whether to overwrite existing or not
+ * @param monitor
+ * a progress monitor
+ * @throws ExecutionException
+ * If the command fails
+ */
+ public void loadSession(@Nullable String inputPath, boolean isForce, IProgressMonitor monitor)
+ throws ExecutionException {
+ getControlService().loadSession(inputPath, isForce, monitor);
+ getTargetNode().refresh();
+ }
}
throws ExecutionException;
/**
- * Load a session with given session name.
+ * Load all or a given session.
*
- * @param sessionName
- * - a session name to start
+ * @param inputPath
+ * a input path to load session from or null for load all from default
+ * @param isForce
+ * flag whether to overwrite existing or not
* @param monitor
- * - a progress monitor
+ * a progress monitor
* @throws ExecutionException
* If the command fails
*/
- void loadSession(String sessionName, IProgressMonitor monitor)
+ void loadSession(@Nullable String inputPath, boolean isForce, IProgressMonitor monitor)
throws ExecutionException;
-
}
}
- @Override
- public void loadSession(String sessionPath, IProgressMonitor monitor) throws ExecutionException {
-
- ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_LOAD_SESSION, "-i", sessionPath); //$NON-NLS-1$
-
- executeCommand(command, monitor);
-
- // Session <sessionName> loaded
- }
-
@Override
public void enableChannels(String sessionName, List<String> channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
executeCommand(command, monitor);
}
+ @Override
+ public void loadSession(String inputPath, boolean isForce, IProgressMonitor monitor)
+ throws ExecutionException {
+ ICommandInput command = createCommand(LTTngControlServiceConstants.COMMAND_LOAD_SESSION);
+
+ if (inputPath != null) {
+ command.add(LTTngControlServiceConstants.OPTION_INPUT_PATH);
+ command.add(inputPath);
+ }
+
+ if (isForce) {
+ command.add(LTTngControlServiceConstants.OPTION_FORCE);
+ }
+ executeCommand(command, monitor);
+ }
+
@Override
public void runCommands(IProgressMonitor monitor, List<String> commandLines) throws ExecutionException {
for (String commandLine : commandLines) {
*/
String TRUE_NUMERICAL = "1"; //$NON-NLS-1$
+ /** The default directory for session */
+ public static final String DEFAULT_PATH = ".lttng/sessions"; //$NON-NLS-1$
+
// ------------------------------------------------------------------------
// LTTng Machine Interface constants
// ------------------------------------------------------------------------
* Command line option for maximum trace files
*/
String OPTION_MAX_TRACE_FILES = "-W"; //$NON-NLS-1$
+ /**
+ * Command line option for force overwrite
+ */
+ String OPTION_FORCE = "-f"; //$NON-NLS-1$
+ /**
+ * Command line option for specifying input path
+ */
+ String OPTION_INPUT_PATH = "-i"; //$NON-NLS-1$
/**
* Maximum live timer interval value