From 6503ae0f815ed6cb711fda3691c0ff5caa2478f6 Mon Sep 17 00:00:00 2001
From: Bernd Hufmann
Date: Thu, 23 Feb 2012 10:14:47 -0500
Subject: [PATCH] Added command support for enabling/disabling events (first
part)
---
.../plugin.properties | 8 +
org.eclipse.linuxtools.lttng.ui/plugin.xml | 136 ++++++++-
.../lttng/ui/views/control/Messages.java | 21 +-
.../control/dialogs/GetEventInfoDialog.java | 274 ++++++++++++++++++
.../control/dialogs/IGetEventInfoDialog.java | 45 +++
.../control/handlers/AssignEventHandler.java | 210 ++++++++++++++
.../handlers/ChangeChannelStateHandler.java | 17 +-
.../handlers/ChangeEventStateHandler.java | 212 ++++++++++++++
.../CreateChannelOnDomainHandler.java | 70 ++---
.../CreateChannelOnSessionHandler.java | 71 ++---
.../handlers/CreateSessionHandler.java | 36 +--
.../handlers/DestroySessionHandler.java | 47 +--
.../handlers/DisableChannelHandler.java | 2 +-
.../control/handlers/DisableEventHandler.java | 52 ++++
.../handlers/EnableChannelHandler.java | 2 +-
.../control/handlers/EnableEventHandler.java | 52 ++++
.../handlers/NewConnectionHandler.java | 79 ++---
.../ui/views/control/messages.properties | 17 +-
.../control/model/ITraceControlComponent.java | 18 +-
.../model/impl/BaseEventComponent.java | 15 +
.../model/impl/TargetNodeComponent.java | 15 +
.../model/impl/TraceChannelComponent.java | 49 ++++
.../model/impl/TraceControlComponent.java | 69 +++--
.../model/impl/TraceDomainComponent.java | 15 +
.../model/impl/TraceEventComponent.java | 21 ++
.../model/impl/TraceSessionComponent.java | 30 ++
.../control/model/impl/TraceSessionGroup.java | 17 +-
.../control/service/ILttngControlService.java | 22 ++
.../control/service/LTTngControlService.java | 165 +++++++++--
29 files changed, 1562 insertions(+), 225 deletions(-)
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableEventHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventHandler.java
diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.properties b/org.eclipse.linuxtools.lttng.ui/plugin.properties
index 8abacaa6a1..e2b2cb4f00 100644
--- a/org.eclipse.linuxtools.lttng.ui/plugin.properties
+++ b/org.eclipse.linuxtools.lttng.ui/plugin.properties
@@ -109,6 +109,14 @@ commands.control.start.description=Start Trace Session
commands.control.stop=Stop
commands.control.stop.description=Stop Trace Session
+#commands.control.enable.event=Enable
+commands.control.enable.assign.description=Assign Event to Session and Channel and Enable Event
+
+commands.control.enable.event=Enable
+commands.control.enable.event.description=Enable Event
+
+commands.control.disable.event=Disable
+commands.control.disable.event.description=Disable Event
# trace control (RSE) properties (LTTng 0.x)
lttng.rse.subsystem.type.name=LTTng (v0.x)
diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.xml b/org.eclipse.linuxtools.lttng.ui/plugin.xml
index d24c834675..5cec38e3fa 100644
--- a/org.eclipse.linuxtools.lttng.ui/plugin.xml
+++ b/org.eclipse.linuxtools.lttng.ui/plugin.xml
@@ -508,7 +508,24 @@
id="org.eclipse.linuxtools.lttng.ui.commands.control.stop"
name="%commands.control.stop">
-
+
+
+
+
+
+
@@ -555,6 +572,13 @@
label="%commands.control.stop"
style="push">
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -971,6 +1049,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java
index f54336e72c..e96da01d05 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java
@@ -48,11 +48,15 @@ final public class Messages extends NLS {
public static String TraceControl_DestroyConfirmationTitle;
public static String TraceControl_DestroyConfirmationMessage;
- public static String TraceControl_EnableChannelJob;
- public static String TraceControl_DisableChannelJob;
-
public static String TraceControl_StartSessionJob;
public static String TraceControl_StopSessionJob;
+
+ public static String TraceControl_ChangeChannelStateJob;
+ public static String TraceControl_ChangeEventStateJob;
+
+ public static String TraceControl_EnableEventsJob;
+ public static String TraceControl_EnableEventsFailure;
+ public static String TraceControl_DisableEventsJob;
// Dialogs
public static String TraceControl_NewDialogTitle;
@@ -75,7 +79,6 @@ final public class Messages extends NLS {
public static String TraceControl_SessionPathAlreadyExistsError;
public static String TraceControl_InvalidSessionPathError;
public static String TraceControl_FileSubSystemError;
-
public static String TraceControl_EnableChannelDialogTitle;
public static String TraceControl_EnableChannelNameLabel;
@@ -90,7 +93,15 @@ final public class Messages extends NLS {
public static String TraceControl_InvalidChannelNameError;
public static String TraceControl_ChannelAlreadyExistsError;
-// public static String TraceControl_CreateSessionNameTooltip;
+ public static String TraceControl_EnableEventsDialogTitle;
+ public static String TraceControl_EnableEventsSessionGroupName;
+ public static String TraceControl_EnableEventsChannelGroupName;
+ public static String TraceControl_EnableEventsSessionsTooltip;
+ public static String TraceControl_EnableEventsChannelsTooltip;
+ public static String TraceControl_EnableEventsNoSessionError;
+ public static String TraceControl_EnableEventsNoChannelError;
+
+
// public static String TraceControl_CreateSessionPathLabel;
// public static String TraceControl_CreateSessionPathTooltip;
// public static String TraceControl_SessionAlreadyExistsError;
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java
new file mode 100644
index 0000000000..8729eb4f95
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/GetEventInfoDialog.java
@@ -0,0 +1,274 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.dialogs;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * EnableEventsDialog
+ *
+ * Dialog box for collecting information about the events to enable.
+ *
+ */
+public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String TARGET_NEW_CONNECTION_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The Group for the session combo box.
+ */
+ private Group fSessionsGroup = null;
+ /**
+ * The Group for the channel combo box.
+ */
+ private Group fChannelsGroup = null;
+ /**
+ * The session combo box.
+ */
+ private CCombo fSessionsCombo = null;
+ /**
+ * The channel combo box.
+ */
+ private CCombo fChannelsCombo = null;
+ /**
+ * The list of available sessions.
+ */
+ private TraceSessionComponent[] fSessions;
+ /**
+ * True for kernel, false for UST.
+ */
+ private boolean fIsKernel;
+ /**
+ * Index in session array (selected session).
+ */
+ private int fSessionIndex = 0;
+ /**
+ * The Channel where the events should be enabled.
+ */
+ private TraceChannelComponent fChannel;
+ /**
+ * List of available channels of the selected session.
+ */
+ private TraceChannelComponent[] fChannels;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor of dialog box.
+ * @param shell - the shell for the dialog box
+ * @param isKernel - a flag to indicate Kernel or UST events.
+ * @param sessions - a list of available sessions
+ */
+ public GetEventInfoDialog(Shell shell, boolean isKernel, TraceSessionComponent[] sessions) {
+ super(shell);
+ fIsKernel = isKernel;
+ fSessions = Arrays.copyOf(sessions, sessions.length);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IEnableEventsDialog#getSession()
+ */
+ @Override
+ public TraceSessionComponent getSession() {
+ return fSessions[fSessionIndex];
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IEnableEventsDialog#getChannel()
+ */
+ @Override
+ public TraceChannelComponent getChannel() {
+ return fChannel;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
+ newShell.setImage(LTTngUiPlugin.getDefault().loadIcon(TARGET_NEW_CONNECTION_ICON_FILE));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ fDialogComposite.setLayout(layout);
+ Label label = new Label(fDialogComposite, SWT.NONE);
+ // a simple way to make dialog wider :-)
+ label.setText(" "); //$NON-NLS-1$
+ fSessionsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fSessionsGroup.setText(Messages.TraceControl_EnableEventsSessionGroupName);
+ layout = new GridLayout(1, true);
+ fSessionsGroup.setLayout(layout);
+// GridData data = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ fSessionsGroup.setLayoutData(data);
+
+ fSessionsCombo = new CCombo(fSessionsGroup, SWT.READ_ONLY);
+ fSessionsCombo.setToolTipText(Messages.TraceControl_EnableEventsSessionsTooltip);
+ fSessionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+// fSessionsCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
+
+ String items[] = new String[fSessions.length];
+ for (int i = 0; i < items.length; i++) {
+ items[i] = String.valueOf(fSessions[i].getName());
+ }
+
+ fSessionsCombo.setItems(items);
+ fSessionsCombo.setEnabled(fSessions.length > 0);
+
+ fChannelsGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fChannelsGroup.setText(Messages.TraceControl_EnableEventsChannelGroupName);
+ layout = new GridLayout(1, true);
+ fChannelsGroup.setLayout(layout);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+// data = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
+ fChannelsGroup.setLayoutData(data);
+
+ fChannelsCombo = new CCombo(fChannelsGroup, SWT.READ_ONLY);
+ fChannelsCombo.setToolTipText(Messages.TraceControl_EnableEventsChannelsTooltip);
+// fChannelsCombo.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1));
+ fChannelsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fChannelsCombo.setEnabled(false);
+
+ fSessionsCombo.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ fSessionIndex = fSessionsCombo.getSelectionIndex();
+
+ if (fSessionIndex >= 0) {
+ TraceDomainComponent domain = null;
+ TraceDomainComponent[] domains = fSessions[fSessionIndex].getDomains();
+ for (int i = 0; i < domains.length; i++) {
+
+ if (domains[i].isKernel() == fIsKernel) {
+ domain = domains[i];
+ break;
+ }
+ }
+
+ if (domain != null) {
+ fChannels = domain.getChannels();
+ String items[] = new String[fChannels.length];
+ for (int i = 0; i < items.length; i++) {
+ items[i] = String.valueOf(fChannels[i].getName());
+ }
+ fChannelsCombo.setItems(items);
+ fChannelsCombo.setEnabled(fChannels.length > 0);
+ } else {
+ fChannelsCombo.setItems(new String[0]);
+ fChannelsCombo.setEnabled(false);
+ fChannels = null;
+ }
+ fChannelsCombo.getParent().getParent().layout();
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+// label.setText("");
+ return fDialogComposite;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+
+ if (fSessionsCombo.getSelectionIndex() < 0) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_EnableEventsNoSessionError);
+ return;
+ }
+
+ fSessionIndex = fSessionsCombo.getSelectionIndex();
+
+ if ((fChannels != null) && (fChannels.length > 0) && (fChannelsCombo.getSelectionIndex() < 0)) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableEventsDialogTitle,
+ Messages.TraceControl_EnableEventsNoChannelError);
+ return;
+ }
+
+ if ((fChannels != null) && (fChannels.length > 0)) {
+ fChannel = fChannels[fChannelsCombo.getSelectionIndex()];
+ }
+
+ super.okPressed();
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java
new file mode 100644
index 0000000000..b4b09e1751
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/IGetEventInfoDialog.java
@@ -0,0 +1,45 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * IEnableEventsDialog
+ *
+ * Interface for a dialog box for collecting information about the events to enable.
+ *
+ */
+public interface IGetEventInfoDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the session the events shall be enabled.
+ */
+ public TraceSessionComponent getSession();
+
+ /**
+ * @return the channel the events shall be enabled. Null for default channel.
+ */
+ public TraceChannelComponent getChannel();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the open return value
+ */
+ int open();
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java
new file mode 100644
index 0000000000..b637ddde49
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/AssignEventHandler.java
@@ -0,0 +1,210 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+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.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.GetEventInfoDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.IGetEventInfoDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * EnableEventHandler
+ *
+ * Command handler implementation to assign events to a session and channel and enable/configure them.
+ * This is done on the trace provider level.
+ *
+ */
+public class AssignEventHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of event components the command is to be executed on.
+ */
+ private List fEvents = new ArrayList();
+
+ /**
+ * The list of available sessions.
+ */
+ private TraceSessionComponent[] fSessions;
+
+ /**
+ * Flag for indicating Kernel or UST.
+ */
+ Boolean fIsKernel = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ // Open dialog box to retrieve the session and channel where the events should be enabled in.
+ final IGetEventInfoDialog dialog = new GetEventInfoDialog(window.getShell(), fIsKernel, fSessions);
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_EnableEventsJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ String errorString = null;
+ try {
+ List eventNames = new ArrayList();
+ // Create list of event names
+ for (Iterator iterator = fEvents.iterator(); iterator.hasNext();) {
+ BaseEventComponent event = (BaseEventComponent) iterator.next();
+ eventNames.add(event.getName());
+ }
+
+ TraceChannelComponent channel = dialog.getChannel();
+ if (channel == null) {
+ // enable events on default channel (which will be created by lttng-tools)
+ dialog.getSession().enableEvent(eventNames, fIsKernel, monitor);
+ } else {
+ channel.enableEvent(eventNames, monitor);
+ }
+
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // get session configuration in all cases
+ try {
+ dialog.getSession().getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
+ }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fEvents.clear();
+ fSessions = null;
+ fIsKernel = null;
+
+ // Check if we are closing down
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return false;
+ }
+
+ // Check if we are in the Project View
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return false;
+ }
+
+ IWorkbenchPart part = page.getActivePart();
+ if (!(part instanceof ControlView)) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+
+ StructuredSelection structered = ((StructuredSelection) selection);
+ for (Iterator> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+ if (element instanceof BaseEventComponent) {
+ BaseEventComponent event = (BaseEventComponent) element;
+ ITraceControlComponent provider = event.getParent();
+
+ // check for kernel or UST provider
+ boolean temp = false;
+ if (provider instanceof KernelProviderComponent) {
+ temp = true;
+ } else if (provider instanceof UstProviderComponent) {
+ temp = false;
+ } else {
+ return false;
+ }
+ if (fIsKernel == null) {
+ fIsKernel = Boolean.valueOf(temp);
+ } else {
+ // don't mix events from Kernel and UST provider
+ if (fIsKernel.booleanValue() != temp) {
+ return false;
+ }
+ }
+
+ // Add BaseEventComponents
+ fEvents.add(event);
+
+ if (fSessions == null) {
+ TargetNodeComponent root = (TargetNodeComponent)event.getParent().getParent().getParent();
+ fSessions = root.getSessions();
+ }
+ }
+ }
+ }
+ return ((fEvents.size() > 0) && (fSessions != null) && (fSessions.length > 0));
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
index 25bc1760cb..ac1d2cc72d 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
@@ -37,9 +37,9 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
/**
- * EnableChannelHandler
+ * ChangeChannelStateHandler
*
- * Base Command handler implementation to enable or disabling a trace channel.
+ * Abstract command handler implementation to enable or disabling a trace channel.
*
*/
abstract public class ChangeChannelStateHandler extends AbstractHandler {
@@ -60,7 +60,7 @@ abstract public class ChangeChannelStateHandler extends AbstractHandler {
*/
protected List fKernelChannels = new ArrayList();
/**
- * The list of USTl channel components the command is to be executed on.
+ * The list of UST channel components the command is to be executed on.
*/
protected List fUstChannels = new ArrayList();
@@ -76,7 +76,11 @@ abstract public class ChangeChannelStateHandler extends AbstractHandler {
// Operations
// ------------------------------------------------------------------------
/**
- * @return the new state to set
+ * Changes the state of the given channels.
+ * @param domain - the domain of the channels.
+ * @param channelNames - a list of channel names
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
*/
abstract protected void changeState(TraceDomainComponent domain, List channelNames, IProgressMonitor monitor) throws ExecutionException;
@@ -93,7 +97,7 @@ abstract public class ChangeChannelStateHandler extends AbstractHandler {
return false;
}
- Job job = new Job(Messages.TraceControl_EnableChannelJob) { // TODO
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
@Override
protected IStatus run(IProgressMonitor monitor) {
String errorString = null;
@@ -151,7 +155,8 @@ abstract public class ChangeChannelStateHandler extends AbstractHandler {
}
return Status.OK_STATUS;
- }};
+ }
+ };
job.setUser(true);
job.schedule();
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java
new file mode 100644
index 0000000000..fbfff8656e
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeEventStateHandler.java
@@ -0,0 +1,212 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+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.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * EnableChannelHandler
+ *
+ * Base Command handler implementation to enable or disabling a trace channel.
+ *
+ */
+abstract public class ChangeEventStateHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Channel component reference.
+ */
+ protected TraceChannelComponent fChannel = null;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ protected List fEvents = new ArrayList();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the new state to set
+ */
+ abstract protected TraceEnablement getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * Change the state
+ * @param channel - channel of events to be enabled
+ * @param eventNames - list event names
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract protected void changeState(TraceChannelComponent channel, List eventNames, IProgressMonitor monitor) throws ExecutionException;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ TraceSessionComponent session = null;
+
+ try {
+ if (fChannel != null) {
+ session = fChannel.getSession();
+ List channelNames = new ArrayList();
+ for (Iterator iterator = fEvents.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceEventComponent channel = (TraceEventComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(fChannel, channelNames, monitor);
+
+ for (Iterator iterator = fEvents.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceEventComponent channel = (TraceEventComponent) iterator.next();
+ channel.setState(getNewState());
+ }
+ }
+ } catch (ExecutionException e) {
+ errorString = e.toString() + "\n"; //$NON-NLS-1$
+ }
+
+ // In all cases notify listeners
+ session.fireComponentChanged(session);
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ reset();
+
+ // Check if we are closing down
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null) {
+ return false;
+ }
+
+ // Check if we are in the Project View
+ IWorkbenchPage page = window.getActivePage();
+ if (page == null) {
+ return false;
+ }
+
+ IWorkbenchPart part = page.getActivePart();
+ if (!(part instanceof ControlView)) {
+ return false;
+ }
+
+ // Check if one or more session are selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ StructuredSelection structered = ((StructuredSelection) selection);
+ String sessionName = null;
+ String channelName = null;
+
+ for (Iterator> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+
+ if (element instanceof TraceEventComponent) {
+
+ // Add only TraceChannelComponents that are disabled
+ TraceEventComponent channel = (TraceEventComponent) element;
+ if (sessionName == null) {
+ sessionName = String.valueOf(channel.getSessionName());
+ }
+
+ if (fChannel == null) {
+ fChannel = (TraceChannelComponent)channel.getParent();
+ }
+
+ if (channelName == null) {
+ channelName = channel.getChannelName();
+ }
+
+ // Enable command only for events of same session, same channel and domain
+ if ((!sessionName.equals(channel.getSessionName())) ||
+ (!channelName.equals(channel.getChannelName())) ||
+ (fChannel.isKernel() != channel.isKernel())) {
+ reset();
+ break;
+ }
+
+ if ((channel.getState() != getNewState())) {
+ fEvents.add(channel);
+ }
+ }
+ }
+ }
+ return fEvents.size() > 0;
+ }
+
+ /**
+ * Reset members
+ */
+ private void reset() {
+ fChannel = null;
+ fEvents.clear();
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
index e66d1d069c..30a8d8d9b9 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
@@ -73,43 +73,47 @@ public class CreateChannelOnDomainHandler extends AbstractHandler {
// Get channel information from user
final ICreateChannelDialog dialog = new CreateChannelDialog(window.getShell(), fDomain);
- if (dialog.open() == Window.OK) {
-
- Job job = new Job(Messages.TraceControl_EnableChannelJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List channelNames = new ArrayList();
- channelNames.add(dialog.getChannelInfo().getName());
-
- try {
- fDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
- // get session configuration in all cases
- try {
- fDomain.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ List channelNames = new ArrayList();
+ channelNames.add(dialog.getChannelInfo().getName());
+
+ try {
+ fDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
}
+ errorString += e.toString() + "\n"; //$NON-NLS-1$
+ }
- if (errorString != null) {
- return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ // get session configuration in all cases
+ try {
+ fDomain.getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
}
- return Status.OK_STATUS;
- }};
- job.setUser(true);
- job.schedule();
- }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+
+ job.setUser(true);
+ job.schedule();
+
return null;
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
index fd0262f796..6da2c81d14 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
@@ -73,44 +73,47 @@ public class CreateChannelOnSessionHandler extends AbstractHandler {
final ICreateChannelOnSessionDialog dialog = new CreateChannelDialog(window.getShell());
- if (dialog.open() == Window.OK) {
- Job job = new Job(Messages.TraceControl_EnableChannelJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String errorString = null;
-
- List channelNames = new ArrayList();
- TraceDomainComponent newDomain = new TraceDomainComponent("dummy", fSession); //$NON-NLS-1$
- channelNames.add(dialog.getChannelInfo().getName());
- newDomain.setIsKernel(dialog.isKernel());
-
- try {
- newDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += e.toString() + "\n"; //$NON-NLS-1$
- }
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- // get session configuration in all cases
- try {
- fSession.getConfigurationFromNode(monitor);
- } catch (ExecutionException e) {
- if (errorString == null) {
- errorString = new String();
- }
- errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ Job job = new Job(Messages.TraceControl_ChangeChannelStateJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ List channelNames = new ArrayList();
+ TraceDomainComponent newDomain = new TraceDomainComponent("dummy", fSession); //$NON-NLS-1$
+ channelNames.add(dialog.getChannelInfo().getName());
+ newDomain.setIsKernel(dialog.isKernel());
+
+ try {
+ newDomain.enableChannels(channelNames, dialog.getChannelInfo(), monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
}
+ errorString += e.toString() + "\n"; //$NON-NLS-1$
+ }
- if (errorString != null) {
- return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ // get session configuration in all cases
+ try {
+ fSession.getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ if (errorString == null) {
+ errorString = new String();
}
- return Status.OK_STATUS;
- }};
- job.setUser(true);
- job.schedule();
- }
+ errorString += Messages.TraceControl_ListSessionFailure + ": " + e.toString(); //$NON-NLS-1$
+ }
+
+ if (errorString != null) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, errorString);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
index e4347d95d9..77ecd2c9f4 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
@@ -65,24 +65,26 @@ public class CreateSessionHandler extends AbstractHandler {
// Open dialog box for the node name and address
ICreateSessionDialog dialog = new CreateSessionDialog(window.getShell(), fSessionGroup);
- if (dialog.open() == Window.OK) {
- final String sessionName = dialog.getSessionName();
- final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
-
- Job job = new Job(Messages.TraceControl_CreateSessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- fSessionGroup.createSession(sessionName, sessionPath, monitor);
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ if (dialog.open() != Window.OK) {
+ return null;
}
+
+ final String sessionName = dialog.getSessionName();
+ final String sessionPath = dialog.isDefaultSessionPath() ? null : dialog.getSessionPath();
+
+ Job job = new Job(Messages.TraceControl_CreateSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ fSessionGroup.createSession(sessionName, sessionPath, monitor);
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
return null;
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
index 62e04a4558..67a6d01460 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
@@ -68,29 +68,38 @@ public class DestroySessionHandler extends AbstractHandler {
return false;
}
// Get user confirmation
- if (MessageDialog.openConfirm(window.getShell(),
+ if (!MessageDialog.openConfirm(window.getShell(),
Messages.TraceControl_DestroyConfirmationTitle,
Messages.TraceControl_DestroyConfirmationMessage)) {
- Job job = new Job(Messages.TraceControl_DestroySessionJob) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- for (Iterator iterator = fSessions.iterator(); iterator.hasNext();) {
- // Destroy all selected sessions
- TraceSessionComponent session = (TraceSessionComponent) iterator.next();
- TraceSessionGroup sessionGroup = (TraceSessionGroup)session.getParent();
- sessionGroup.destroySession(session.getName(), monitor);
- }
- } catch (ExecutionException e) {
- return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, e.toString());
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ return null;
+
}
+
+ Job job = new Job(Messages.TraceControl_DestroySessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ // Make a copy of the list of sessions to avoid ConcurrentModificationException when iterating
+ // over fSessions, since fSessions is modified in another thread triggered by the tree viewer refresh
+ // after removing a session.
+ TraceSessionComponent[] sessions = (TraceSessionComponent[])fSessions.toArray(new TraceSessionComponent[fSessions.size()]);
+
+ for (int i = 0; i < sessions.length; i++) {
+ // Destroy all selected sessions
+ TraceSessionComponent session = sessions[i];
+ TraceSessionGroup sessionGroup = (TraceSessionGroup)session.getParent();
+ sessionGroup.destroySession(session, monitor);
+ }
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+
return null;
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java
index 1102844fc8..8c455806b3 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java
@@ -21,7 +21,7 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainCompo
/**
* DisableChannelHandler
*
- * Command handler implementation to enable a trace channel.
+ * Command handler implementation to disable one or more trace channels per session and domain.
*
*/
public class DisableChannelHandler extends ChangeChannelStateHandler {
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableEventHandler.java
new file mode 100644
index 0000000000..ef3bd32c9d
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableEventHandler.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+
+/**
+ * DisableEventHandler
+ *
+ * Command handler implementation to disable one or more events session, domain and channel.
+ *
+ */
+public class DisableEventHandler extends ChangeEventStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.DISABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceChannelComponent channel, List eventNames, IProgressMonitor monitor) throws ExecutionException{
+ channel.disableEvent(eventNames, monitor);
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java
index 1264f910f0..6ad7e7fea7 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java
@@ -21,7 +21,7 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainCompo
/**
* EnableChannelHandler
*
- * Command handler implementation to enable a trace channel.
+ * Command handler implementation to enable one or more trace channels per session and domain.
*
*/
public class EnableChannelHandler extends ChangeChannelStateHandler {
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventHandler.java
new file mode 100644
index 0000000000..e021cc535e
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableEventHandler.java
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+
+/**
+ * EnableEventHandler
+ *
+ * Command handler implementation to enable one or more events session, domain and channel.
+ *
+ */
+public class EnableEventHandler extends ChangeEventStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeEventStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.ENABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeEventStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceChannelComponent channel, List eventNames, IProgressMonitor monitor) throws ExecutionException{
+ channel.enableEvent(eventNames, monitor);
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java
index c3bf8fdd58..118e8206c5 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java
@@ -79,53 +79,54 @@ public class NewConnectionHandler extends AbstractHandler {
// Open dialog box for the node name and address
INewConnectionDialog dialog = new NewConnectionDialog(window.getShell(), fRoot, hosts);
- if (dialog.open() == Window.OK) {
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
- String hostName = dialog.getConnectionName();
- String hostAddress = dialog.getHostName();
+ String hostName = dialog.getConnectionName();
+ String hostAddress = dialog.getHostName();
- // get the singleton RSE registry
- IHost host = null;
+ // get the singleton RSE registry
+ IHost host = null;
- for (int i = 0; i < hosts.length; i++) {
- if (hosts[i].getAliasName().equals(hostName)) {
- host = hosts[i];
- break;
- }
+ for (int i = 0; i < hosts.length; i++) {
+ if (hosts[i].getAliasName().equals(hostName)) {
+ host = hosts[i];
+ break;
}
+ }
- if (host == null) {
- // if there's no host then we will create it
- try {
- // create the host object as an SSH Only connection
- host = registry.createHost(
- sysType, //System Type Name
- hostName, //Connection name
- hostAddress, //IP Address
- "Connection to Host"); //description //$NON-NLS-1$
- }
- catch (Exception e) {
- MessageDialog.openError(window.getShell(),
- Messages.TraceControl_EclipseCommandFailure,
- Messages.TraceControl_NewNodeCreationFailure + " (" + hostName + ", " + hostAddress + ")" + ":\n" + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return null;
- }
+ if (host == null) {
+ // if there's no host then we will create it
+ try {
+ // create the host object as an SSH Only connection
+ host = registry.createHost(
+ sysType, //System Type Name
+ hostName, //Connection name
+ hostAddress, //IP Address
+ "Connection to Host"); //description //$NON-NLS-1$
}
-
- if (host != null) {
- // successful creation of host
- TargetNodeComponent node = null;
- if (!fRoot.containsChild(hostName)) {
- node = new TargetNodeComponent(hostName, fRoot, host);
- fRoot.addChild(node);
- }
- else {
- node = (TargetNodeComponent)fRoot.getChild(hostName);
- }
-
- node.connect();
+ catch (Exception e) {
+ MessageDialog.openError(window.getShell(),
+ Messages.TraceControl_EclipseCommandFailure,
+ Messages.TraceControl_NewNodeCreationFailure + " (" + hostName + ", " + hostAddress + ")" + ":\n" + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return null;
}
}
+
+ if (host != null) {
+ // successful creation of host
+ TargetNodeComponent node = null;
+ if (!fRoot.containsChild(hostName)) {
+ node = new TargetNodeComponent(hostName, fRoot, host);
+ fRoot.addChild(node);
+ }
+ else {
+ node = (TargetNodeComponent)fRoot.getChild(hostName);
+ }
+
+ node.connect();
+ }
return null;
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties
index be504a99b3..00e6268e30 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties
@@ -24,11 +24,12 @@ TraceControl_DestroyConfirmationMessage=Do you want to delete all selected sessi
TraceControl_StartSessionJob=Starting Session...
TraceControl_StopSessionJob=Stopping Session...
-TraceControl_EnableChannelJob=Enabling Channels...
-TraceControl_EnableChannelDialogTitle=Enable Channel
-TraceControl_DisableChannelJob=Disabling Channels...
-
+TraceControl_ChangeChannelStateJob=Changing State of Channels...
+TraceControl_ChangeEventStateJob=Changing State of Events...
+TraceControl_EnableEventsJob=Enabling Events...
+TraceControl_EnableEventsFailure=Enable Events failed
+TraceControl_DisableEventsJob=Disabling Events...
# Dialogs
TraceControl_NewDialogTitle=New Connection
@@ -65,6 +66,14 @@ TraceControl_EnableChannelOverwriteModeTooltip=Select for overwrite mode (Flight
TraceControl_InvalidChannelNameError=The channel name is invalid or empty
TraceControl_ChannelAlreadyExistsError=Channel already exists
+TraceControl_EnableEventsDialogTitle=Enable Events
+TraceControl_EnableEventsSessionGroupName=Session List
+TraceControl_EnableEventsChannelGroupName=Channel List
+TraceControl_EnableEventsSessionsTooltip=List of available sessions.
+TraceControl_EnableEventsChannelsTooltip=List of available channels of selected session.\nIf no channel is available default channel will be created.
+TraceControl_EnableEventsNoSessionError=No session from session list is selected.
+TraceControl_EnableEventsNoChannelError=No channel from channel list is selected.
+
# Tree structure strings
TraceControl_KernelDomainDisplayName=Kernel
TraceControl_UstGlobalDomainDisplayName=UST global
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceControlComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceControlComponent.java
index 692e359b94..a528b8371f 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceControlComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/ITraceControlComponent.java
@@ -25,7 +25,7 @@ import org.eclipse.swt.graphics.Image;
*
*/
public interface ITraceControlComponent extends IAdaptable {
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
@@ -34,7 +34,6 @@ public interface ITraceControlComponent extends IAdaptable {
* @return the name of the component
*/
public String getName();
-
/**
* Sets the name of the component to the given value.
* @param name - name to set
@@ -55,11 +54,11 @@ public interface ITraceControlComponent extends IAdaptable {
* @param image - image to the image location
*/
public void setImage(Image image);
+
/**
* @return tool tip with information about the component.
*/
public String getToolTip();
-
/**
* Sets the tool tip with information about the component.
* @param toolTip - the tool tip to set.
@@ -80,7 +79,6 @@ public interface ITraceControlComponent extends IAdaptable {
* @return returns the parent component.
*/
public ITraceControlComponent getParent();
-
/**
* Sets the parent component.
* @param parent - the parent to set.
@@ -91,31 +89,35 @@ public interface ITraceControlComponent extends IAdaptable {
* @return the children components
*/
public ITraceControlComponent[] getChildren();
-
/**
* Sets the children components.
* @param children - the children to set.
*/
public void setChildren(List children);
-
/**
* Returns the child component with given name.
* @param name - name of child to find.
* @return child component or null.
*/
public ITraceControlComponent getChild(String name);
+ /**
+ * Gets children for given class type.
+ * @param clazz - a class type to get
+ * @return list of trace control components matching given class type.
+ */
+ public List getChildren(Class extends ITraceControlComponent> clazz);
/**
* @return the LTTng control service implementation.
*/
public ILttngControlService getControlService();
-
+
/**
* Sets the LTTng control service implementation.
* @param service - the service to set.
*/
public void setControlService(ILttngControlService service);
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventComponent.java
index a0eea7de01..023bd4c759 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/BaseEventComponent.java
@@ -125,6 +125,21 @@ public class BaseEventComponent extends TraceControlComponent {
}
return null;
}
+
+ /**
+ * @return target node component.
+ */
+ public TargetNodeComponent getTargetNode() {
+ return (TargetNodeComponent) getParent().getParent();
+ }
+
+ /**
+ * @return if provider kernel or UST
+ */
+ public boolean isKernel() {
+ return getParent() instanceof KernelProviderComponent;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java
index 5ef8b96279..97c8bc5ec9 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java
@@ -11,6 +11,8 @@
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -189,6 +191,19 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu
return fRemoteProxy;
}
+ /**
+ * @return all available sessions.
+ */
+ public TraceSessionComponent[] getSessions() {
+ List compenents = getChildren(TraceSessionGroup.class);
+ if (compenents.size() > 0) {
+ TraceSessionGroup group = (TraceSessionGroup)compenents.get(0);
+ List sessions = group.getChildren(TraceSessionComponent.class);
+ return (TraceSessionComponent[])sessions.toArray(new TraceSessionComponent[sessions.size()]);
+ }
+ return new TraceSessionComponent[0];
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java
index 00311b745c..cfda00de56 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java
@@ -11,6 +11,11 @@
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
@@ -216,6 +221,13 @@ public class TraceChannelComponent extends TraceControlComponent {
return ((TraceDomainComponent)getParent()).getSessionName();
}
+ /**
+ * @return session from parent
+ */
+ public TraceSessionComponent getSession() {
+ return ((TraceDomainComponent)getParent()).getSession();
+ }
+
/**
* @return if domain is kernel or UST
*/
@@ -226,4 +238,41 @@ public class TraceChannelComponent extends TraceControlComponent {
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @throws ExecutionException
+ */
+ public void enableEvent(List eventNames) throws ExecutionException {
+ enableEvent(eventNames, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvent(List eventNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @throws ExecutionException
+ */
+ public void disableEvent(List eventNames) throws ExecutionException {
+ disableEvent(eventNames, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableEvent(List eventNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
+ }
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceControlComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceControlComponent.java
index 4757641c59..82a7555bb4 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceControlComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceControlComponent.java
@@ -39,7 +39,7 @@ public class TraceControlComponent implements ITraceControlComponent {
// Attributes
// ------------------------------------------------------------------------
/**
- * The nambe of the component
+ * The name of the component
*/
private String fName = ""; //$NON-NLS-1$
/**
@@ -58,9 +58,8 @@ public class TraceControlComponent implements ITraceControlComponent {
* The list if children components.
*/
private List fChildren = new ArrayList();
-
/**
- * The list of listeners to be notfied about changes.
+ * The list of listeners to be notified about changes.
*/
private ListenerList fListeners = new ListenerList();
@@ -175,29 +174,6 @@ public class TraceControlComponent implements ITraceControlComponent {
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#getControlService()
- */
- @Override
- public ILttngControlService getControlService() {
- if (getParent() != null) {
- return getParent().getControlService();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#setControlService(org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService)
- */
- @Override
- public void setControlService(ILttngControlService service) {
- if (getParent() != null) {
- getParent().setControlService(service);
- }
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#getParent()
@@ -222,7 +198,7 @@ public class TraceControlComponent implements ITraceControlComponent {
*/
@Override
public ITraceControlComponent[] getChildren() {
- return (ITraceControlComponent [])fChildren.toArray(new TraceControlComponent[fChildren.size()]);
+ return (ITraceControlComponent [])fChildren.toArray(new ITraceControlComponent[fChildren.size()]);
}
/*
@@ -252,6 +228,45 @@ public class TraceControlComponent implements ITraceControlComponent {
}
return child;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#getChildren(java.lang.Class)
+ */
+ @Override
+ public List getChildren(Class extends ITraceControlComponent> clazz) {
+ List list = new ArrayList();
+
+ for (Iterator iterator = fChildren.iterator(); iterator.hasNext();) {
+ ITraceControlComponent child = (ITraceControlComponent) iterator.next();
+ if (child.getClass() == clazz) {
+ list.add(child);
+ }
+ }
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#getControlService()
+ */
+ @Override
+ public ILttngControlService getControlService() {
+ if (getParent() != null) {
+ return getParent().getControlService();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent#setControlService(org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService)
+ */
+ @Override
+ public void setControlService(ILttngControlService service) {
+ if (getParent() != null) {
+ getParent().setControlService(service);
+ }
+ }
// ------------------------------------------------------------------------
// Operations
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java
index 8d88a69b23..5163df7606 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java
@@ -98,6 +98,13 @@ public class TraceDomainComponent extends TraceControlComponent {
return ((TraceSessionComponent)getParent()).getName();
}
+ /**
+ * @return session from parent
+ */
+ public TraceSessionComponent getSession() {
+ return (TraceSessionComponent)getParent();
+ }
+
/**
* @return true if domain is kernel, false for UST
*/
@@ -112,6 +119,14 @@ public class TraceDomainComponent extends TraceControlComponent {
public void setIsKernel(boolean isKernel) {
fDomainInfo.setIsKernel(isKernel);
}
+
+ /**
+ * @return returns all available channels for this domain.
+ */
+ public TraceChannelComponent[] getChannels() {
+ List channels = getChildren(TraceChannelComponent.class);
+ return (TraceChannelComponent[])channels.toArray(new TraceChannelComponent[channels.size()]);
+ }
// ------------------------------------------------------------------------
// Operations
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java
index 6e76601024..936be7521f 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceEventComponent.java
@@ -175,6 +175,27 @@ public class TraceEventComponent extends TraceControlComponent {
return null;
}
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceChannelComponent)getParent()).getSessionName();
+ }
+
+ /**
+ * @return channel name from parent
+ */
+ public String getChannelName() {
+ return getParent().getName();
+ }
+
+ /**
+ * @return if domain is kernel or UST
+ */
+ public boolean isKernel() {
+ return ((TraceChannelComponent)getParent()).isKernel();
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java
index 4bcc4635d3..96a28d1913 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java
@@ -11,6 +11,8 @@
**********************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -171,6 +173,14 @@ public class TraceSessionComponent extends TraceControlComponent {
return null;
}
+ /**
+ * @return all available domains of this session.
+ */
+ public TraceDomainComponent[] getDomains() {
+ List sessions = getChildren(TraceDomainComponent.class);
+ return (TraceDomainComponent[])sessions.toArray(new TraceDomainComponent[sessions.size()]);
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -232,4 +242,24 @@ public class TraceSessionComponent extends TraceControlComponent {
getControlService().stopSession(getName(), monitor);
}
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @throws ExecutionException
+ */
+ public void enableEvent(List eventNames, boolean isKernel) throws ExecutionException {
+ enableEvent(eventNames, isKernel, new NullProgressMonitor());
+ }
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvent(List eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableEvent(getName(), null, eventNames, isKernel, monitor);
+ }
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionGroup.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionGroup.java
index e8ba692335..bce872311a 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionGroup.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionGroup.java
@@ -85,7 +85,7 @@ public class TraceSessionGroup extends TraceControlComponent {
* @return the session information
* throws ExecutionExecption
*/
- public void createSession(final String sessionName, final String sessionPath) throws ExecutionException {
+ public void createSession(String sessionName, String sessionPath) throws ExecutionException {
createSession(sessionName, sessionPath, new NullProgressMonitor());
}
@@ -97,7 +97,7 @@ public class TraceSessionGroup extends TraceControlComponent {
* @return the session information
* throws ExecutionExecption
*/
- public void createSession(final String sessionName, final String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+ public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
if (sessionInfo != null) {
TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
@@ -108,22 +108,21 @@ public class TraceSessionGroup extends TraceControlComponent {
/**
* Destroys a session with given session name.
- * @param sessionName - a session name to destroy
+ * @param session - a session component to destroy
* throws ExecutionExecption
*/
- public void destroySession(final String sessionName) throws ExecutionException {
- destroySession(sessionName, new NullProgressMonitor());
+ public void destroySession(TraceSessionComponent session) throws ExecutionException {
+ destroySession(session, new NullProgressMonitor());
}
/**
* Destroys a session with given session name.
- * @param sessionName - a session name to destroy
+ * @param session - a session component to destroy
* @param monitor - a progress monitor
* throws ExecutionExecption
*/
- public void destroySession(final String sessionName, IProgressMonitor monitor) throws ExecutionException {
- getControlService().destroySession(sessionName, monitor);
- ITraceControlComponent session = getChild(sessionName);
+ public void destroySession(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().destroySession(session.getName(), monitor);
session.removeAllChildren();
removeChild(session);
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java
index 8d1cc48bed..13a99e5611 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java
@@ -121,5 +121,27 @@ public interface ILttngControlService {
* @throws ExecutionException
*/
public void disableChannel(String sessionName, List channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Enables a list of events with no additional parameters.
+ * @param sessionName - a session name
+ * @param channelName - a channel name (null for default channel)
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableEvent(String sessionName, String channelName, List eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+ /**
+ * Disables a list of events with no additional parameters.
+ * @param sessionName - a session name
+ * @param channelName - a channel name (null for default channel)
+ * @param eventNames - a list of event names to enabled.
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableEvent(String sessionName, String channelName, List eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java
index 34fc55189f..51efae8c20 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java
@@ -83,10 +83,56 @@ public class LTTngControlService implements ILttngControlService {
*/
private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
/**
- * Command to destroy a session.
+ * Command to disable a channel.
*/
private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
+ /**
+ * Command to enable a event.
+ */
+ private final static String COMMAND_ENABLE_EVENT = CONTROL_COMMAND + " enable-event "; //$NON-NLS-1$
+ /**
+ * Command to disable a event.
+ */
+ private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
+ // Command options constants
+ /**
+ * Command line option for kernel tracer.
+ */
+ private final static String OPTION_KERNEL = " -k "; //$NON-NLS-1$
+ /**
+ * Command line option for UST tracer.
+ */
+ private final static String OPTION_UST = " -u "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a session.
+ */
+ private final static String OPTION_SESSION = " -s "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a channel.
+ */
+ private final static String OPTION_CHANNEL = " -c "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's overwrite mode.
+ */
+ private final static String OPTION_OVERWRITE = " --overwrite "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's number of sub buffers.
+ */
+ private final static String OPTION_NUM_SUB_BUFFERS = " --num-subbuf "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's sub buffer size.
+ */
+ private final static String OPTION_SUB_BUFFER_SIZE = " --subbuf-size "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's switch timer interval.
+ */
+ private final static String OPTION_SWITCH_TIMER = " --switch-timer "; //$NON-NLS-1$
+ /**
+ * Optional command line option for configuring a channel's read timer interval.
+ */
+ private final static String OPTION_READ_TIMER = " --read-timer "; //$NON-NLS-1$
+
// Parsing constants
/**
* Pattern to match for error output
@@ -125,8 +171,7 @@ public class LTTngControlService implements ILttngControlService {
*/
private final static Pattern EVENT_SECTION_PATTERN = Pattern.compile("\\s*Events\\:"); //$NON-NLS-1$
/**
- * Pattern to match for event information (no enabled events) (lttng list
- * )
+ * Pattern to match for event information (no enabled events) (lttng list )
*/
// private final static String EVENT_NONE_PATTERN = "\\s+None"; //$NON-NLS-1$
/**
@@ -577,38 +622,37 @@ public class LTTngControlService implements ILttngControlService {
}
if (isKernel) {
- command.append(" -k ");
+ command.append(OPTION_KERNEL);
} else {
- command.append(" -u ");
+ command.append(OPTION_UST);
}
- command.append(" -s "); //$NON-NLS-1$
+ command.append(OPTION_SESSION);
command.append(newSessionName);
if (info != null) {
// --discard Discard event when buffers are full (default)
- // TODO discard
// --overwrite Flight recorder mode
if (info.isOverwriteMode()) {
- command.append(" --overwrite ");
+ command.append(OPTION_OVERWRITE);
}
// --subbuf-size SIZE Subbuffer size in bytes
// (default: 4096, kernel default: 262144)
- command.append(" --subbuf-size ");
+ command.append(OPTION_SUB_BUFFER_SIZE);
command.append(String.valueOf(info.getSubBufferSize()));
// --num-subbuf NUM Number of subbufers
// (default: 8, kernel default: 4)
- command.append(" --num-subbuf ");
+ command.append(OPTION_NUM_SUB_BUFFERS);
command.append(String.valueOf(info.getNumberOfSubBuffers()));
// --switch-timer USEC Switch timer interval in usec (default: 0)
- command.append(" --switch-timer ");
+ command.append(OPTION_SWITCH_TIMER);
command.append(String.valueOf(info.getSwitchTimer()));
// --read-timer USEC Read timer interval in usec (default: 200)
- command.append(" --read-timer ");
+ command.append(OPTION_READ_TIMER);
command.append(String.valueOf(info.getReadTimer()));
}
@@ -617,7 +661,6 @@ public class LTTngControlService implements ILttngControlService {
if (isError(result)) {
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
-
}
/*
@@ -625,7 +668,7 @@ public class LTTngControlService implements ILttngControlService {
* @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#disableChannel(java.lang.String, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public void disableChannel(String sessionName, List channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException{
+ public void disableChannel(String sessionName, List channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
// no channels to enable
if (channelNames.size() == 0) {
@@ -645,14 +688,58 @@ public class LTTngControlService implements ILttngControlService {
}
if (isKernel) {
- command.append(" -k ");
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableEvent(String sessionName, String channelName, List eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ // no channels to enable
+ if (eventNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_EVENT);
+
+ for (Iterator iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
} else {
- command.append(" -u ");
+ command.append(OPTION_UST);
}
- command.append(" -s "); //$NON-NLS-1$
+ command.append(OPTION_SESSION);
command.append(newSessionName);
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
if (isError(result)) {
@@ -660,6 +747,50 @@ public class LTTngControlService implements ILttngControlService {
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void disableEvent(String sessionName, String channelName, List eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+ // no channels to enable
+ if (eventNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_DISABLE_EVENT);
+
+ for (Iterator iterator = eventNames.iterator(); iterator.hasNext();) {
+ String event = (String) iterator.next();
+ command.append(event);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ ICommandResult result = fCommandShell.executeCommand(command.toString(), monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
--
2.34.1