commands.experiment.delete = Delete Experiment
commands.experiment.delete.description = Delete an LTTng Experiment
-
-# trace control (RSE) properties
-lttng.rse.subsystem.type.name=LTTng
-lttng.rse.subsystem.type.description=LTTng TCF Subsystem
-lttng.rse.subsystem.config.name = LTTng Tracing
-lttng.rse.subsystem.config.description = LTTng Tracing Subsystem Configuration
-
-action.set.label = LTTng RSE action set
-action.set.description = LTTng RSE action set
-
-menu.lttng.label = LTTng
-action.stop.label = Stop
-action.stop.tooltip = Stop the selected trace
-action.pause.label = Pause
-action.pause.tooltip = Pause tracing
-action.start.label = Start
-action.start.tooltip = Start tracing
-action.newtrace.label = New Trace
-action.newtrace.tooltip = Create a new trace
-action.configuretrace.label = Configure Trace
-action.configuretrace.tooltip = Configure the selected trace
-action.browse.label = Browse Trace
-action.browse.tooltip = Browse the trace folder of selected trace
-action.configuremarkers.label = Configure Markers
-action.configuremarkers.tooltip = Configure the markers of selected target
-action.delete.label = Delete Trace
-action.delete.tooltip = Delete the selected trace
-
-action.import.label = Import To Project
-action.import.tooltip = Import selected trace to a project
-
# LTTng 2.0 trace control commands
trace.control.rse.system.type.name=LTTng (v2.0 or later)
trace.control.rse.system.type.description=LTTng Trace Control (v2.0 or later)
commands.control.refresh=Refresh
commands.control.refresh.description=Refresh Node Configuration
-
commands.control.delete=Delete
commands.control.delete.description=Delete Target Node
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 Event
commands.control.enable.eventOnSession=Enable Event (default channel)
commands.control.enable.eventOnSession.description=Enable Event on Default Channel
-
commands.control.disable.event=Disable Event
commands.control.disable.event.description=Disable Event
+
+commands.control.add.context=Add Context
+commands.control.add.context.description=Add Context to Channel(s) and/or Event(s)
id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEventOnSession"
name="%commands.control.enable.eventOnSession">
</command>
-
+
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.add.context.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnDomain"
+ name="%commands.control.add.context">
+ </command>
+
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.add.context.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnChannel"
+ name="%commands.control.add.context">
+ </command>
+
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.add.context.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnEvent"
+ name="%commands.control.add.context">
+ </command>
+
</extension>
<extension
point="org.eclipse.ui.menus">
</with>
</visibleWhen>
</command>
-
<command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.enableEventOnChannel"
icon="icons/elcl16/edit.gif"
</with>
</visibleWhen>
</command>
-
-
-
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnDomain"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.add.context"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.add.context"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnEvent"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.add.context"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
</menuContribution>
</extension>
</with>
</activeWhen>
</handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.AddContextOnDomainHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnDomain">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.AddContextOnChannelHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.AddContextOnEventHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.addContextOnEvent">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
</extension>
<extension
public static String TraceControl_EnableEventsFailure;
public static String TraceControl_DisableEventsJob;
+ public static String TraceControl_GetContextJob;
+ public static String TraceControl_AddContextJob;
+
// Dialogs
public static String TraceControl_NewDialogTitle;
public static String TraceControl_NewNodeExistingConnectionGroupName;
public static String TraceControl_InvalidLogLevelEventNameError;
public static String TraceControl_InvalidLogLevel;
+ public static String TraceControl_AddContextDialogTitle;
+ public static String TraceControl_AddContextAvailableContextsLabel;
+ public static String TraceControl_AddContextAvailableContextsTooltip;
+ public static String TraceControl_AddContextAllLabel;
// Tree structure strings
public static String TraceControl_KernelDomainDisplayName;
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+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.Shell;
+
+/**
+ * <b><u>AddContextDialog</u></b>
+ * <p>
+ * Dialog box for collecting information about contexts to be added to channels/events.
+ * </p>
+ */
+public class AddContextDialog extends Dialog implements IAddContextDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String ADD_CONTEXT_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite;
+ /**
+ * A tree viewer for displaying and selection of available contexts.
+ */
+ private CheckboxTreeViewer fContextsViewer;
+ /**
+ * A Tree model for the checkbox tree viewer.
+ */
+ private ContextModel fContextModel = new ContextModel();
+ /**
+ * The contexts to add.
+ */
+ private List<String> fSelectedContexts = new ArrayList<String>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public AddContextDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IAddContextDialog#setAvalibleContexts(java.util.List)
+ */
+ @Override
+ public void setAvalibleContexts(List<String> contexts) {
+ fContextModel.setAvalibleContexts(contexts);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IAddContextDialog#getContexts()
+ */
+ @Override
+ public List<String> getContexts() {
+ List<String> ret = new ArrayList<String>();
+ ret.addAll(fSelectedContexts);
+ return ret;
+ }
+
+ // ------------------------------------------------------------------------
+ // 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_AddContextDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(ADD_CONTEXT_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);
+ fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // Contexts list
+ Group contextGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ contextGroup.setText(Messages.TraceControl_AddContextAvailableContextsLabel);
+ layout = new GridLayout(1, true);
+ contextGroup.setLayout(layout);
+ contextGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fContextsViewer = new CheckboxTreeViewer(contextGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ fContextsViewer.getTree().setToolTipText(Messages.TraceControl_AddContextAvailableContextsTooltip);
+
+ fContextsViewer.setContentProvider(new ContextsContentProvider());
+ fContextsViewer.setLabelProvider(new ContextsLabelProvider());
+ fContextsViewer.addCheckStateListener(new ContextCheckListener());
+ fContextsViewer.setInput(fContextModel);
+ fContextsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ getShell().setMinimumSize(new Point(500, 650));
+
+ 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() {
+ fSelectedContexts.clear();
+
+ Object[] checkedElements = fContextsViewer.getCheckedElements();
+ for (int i = 0; i < checkedElements.length; i++) {
+ IContextModelComponent component = (IContextModelComponent)checkedElements[i];
+ fSelectedContexts.add(component.getName());
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper classes and methods
+ // ------------------------------------------------------------------------
+ /**
+ * Content provider for the contexts tree
+ */
+ final public static class ContextsContentProvider implements ITreeContentProvider {
+
+ @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 Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IContextModelComponent) {
+ return ((IContextModelComponent)parentElement).getChildren();
+ }
+ return null;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof IContextModelComponent) {
+ return ((IContextModelComponent)element).getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof IContextModelComponent) {
+ return ((IContextModelComponent)element).hasChildren();
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Label provider for the contexts tree
+ */
+ final public static class ContextsLabelProvider extends ColumnLabelProvider {
+ @Override
+ public String getText(Object element) {
+
+ if ((element != null) && (element instanceof IContextModelComponent)) {
+ return ((IContextModelComponent)element).getName();
+ }
+
+ return "";//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Check state listener for the contexts tree.
+ */
+ final public class ContextCheckListener implements ICheckStateListener {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getChecked()) {
+ if (event.getElement() instanceof AllContexts) {
+ fContextsViewer.setSubtreeChecked(event.getElement(), true);
+ }
+ } else {
+ if (event.getElement() instanceof AllContexts) {
+ fContextsViewer.setSubtreeChecked(event.getElement(), false);
+ } else {
+ IContextModelComponent component = (IContextModelComponent) event.getElement();
+ fContextsViewer.setChecked(component.getParent(), false);
+ }
+ }
+ }
+ }
+
+ /**
+ * Model for the context tree viewer (root component)
+ */
+ public static class ContextModel implements IContextModelComponent {
+
+ private AllContexts fAllContexts;
+
+ public ContextModel() {
+ fAllContexts = new AllContexts(this);
+ }
+
+ public void setAvalibleContexts(List<String> contexts) {
+ fAllContexts.setAvalibleContexts(contexts);
+ }
+
+ @Override
+ public String getName() {
+ return "root"; //$NON-NLS-1$
+ }
+
+ @Override
+ public Object getParent() {
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ Object[] ret = new Object[1];
+ ret[0] = fAllContexts;
+ return ret;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+ }
+
+ /**
+ * Model element (to select/deselect) all contexts) for the context tree viewer
+ */
+ public static class AllContexts implements IContextModelComponent {
+ /**
+ * The available list of contexts.
+ */
+ private List<Context> fAvailableContexts;
+
+ private IContextModelComponent fParent;
+
+ public AllContexts(IContextModelComponent parent) {
+ fParent = parent;
+ }
+
+ public void setAvalibleContexts(List<String> contexts) {
+ fAvailableContexts = new ArrayList<Context>();
+ if (contexts != null) {
+ for (Iterator<String> iterator = contexts.iterator(); iterator.hasNext();) {
+ String name = (String) iterator.next();
+ fAvailableContexts.add(new Context(this, name));
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return Messages.TraceControl_AddContextAllLabel;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ return fAvailableContexts.toArray();
+ }
+
+ @Override
+ public Object getParent() {
+ return fParent;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return true;
+ }
+ }
+
+ /**
+ * Model element (the context) for the context tree viewer
+ */
+ public static class Context implements IContextModelComponent {
+
+ private String fContextName;
+ private IContextModelComponent fParent;
+
+ public Context(IContextModelComponent parent, String name) {
+ fParent = parent;
+ fContextName = name;
+ }
+
+ @Override
+ public String getName() {
+ return fContextName;
+ }
+
+ @Override
+ public Object getParent() {
+ return fParent;
+ }
+
+ @Override
+ public Object[] getChildren() {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return false;
+ }
+ }
+
+ /**
+ * Interface for the tree model used for the context tree viewer.
+ */
+ public interface IContextModelComponent {
+ public String getName();
+ public Object getParent();
+ public Object[] getChildren();
+ public boolean hasChildren();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.dialogs;
+
+import java.util.List;
+
+/**
+ * <b><u>IAddContextDialog</u></b>
+ * <p>
+ * Interface for providing information about contexts to be added to channels/events.
+ * </p>
+ */
+public interface IAddContextDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Sets the available contexts to choose from.
+ * @param contexts - a list of available contexts.
+ */
+ public void setAvalibleContexts(List<String> contexts);
+
+ /**
+ * @return array of contexts to be added
+ */
+ public List<String> getContexts();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return returns the open return value
+ */
+ int open();
+}
* The confirmation dialog implementation
*/
private IConfirmDialog fConfirmDialog;
+
+ /**
+ * The add context dialog implementation
+ */
+ private IAddContextDialog fAddContextDialog;
// ------------------------------------------------------------------------
// Constructors
public void setConfirmDialog(IConfirmDialog confirmDialog) {
fConfirmDialog = confirmDialog;
}
+
+ /**
+ * @return the add context dialog implementation
+ */
+ public IAddContextDialog getAddContextDialog() {
+ if (fAddContextDialog == null) {
+ fAddContextDialog = new AddContextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fAddContextDialog;
+ }
+
+ /**
+ * Sets the add context dialog information
+ * @param addContextDialog
+ */
+ public void setAddContextDialog(IAddContextDialog addContextDialog) {
+ fAddContextDialog = addContextDialog;
+ }
}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>AddContextOnChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to add contexts to a given channel and all of its events.
+ * </p>
+ */
+public class AddContextOnChannelHandler extends BaseAddContextHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseAddContextHandler#addContexts(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void addContexts(CommandParameter param, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof ChannelCommandParameter) {
+ TraceChannelComponent channel = ((ChannelCommandParameter)param).getChannel();
+ channel.addContexts(contextNames, monitor);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceChannelComponent channel = null;
+ TraceSessionComponent session = null;
+ 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 TraceChannelComponent) {
+ // Add only if corresponding TraceSessionComponents is inactive and not destroyed
+ TraceChannelComponent tmpChannel = (TraceChannelComponent) element;
+ session = tmpChannel.getSession();
+ if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
+ channel = tmpChannel;
+ }
+ }
+ }
+ }
+
+ boolean isEnabled = (channel != null);
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new ChannelCommandParameter(session, channel);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>AddContextOnDomainHandler</u></b>
+ * <p>
+ * Command handler implementation to add contexts to all channels and all events.
+ * </p>
+ */
+public class AddContextOnDomainHandler extends BaseAddContextHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseAddContextHandler#addContexts(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void addContexts(CommandParameter param, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof DomainCommandParameter) {
+ TraceDomainComponent domain = ((DomainCommandParameter)param).getDomain();
+ domain.addContexts(contextNames, monitor);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceDomainComponent domain = null;
+ TraceSessionComponent session = null;
+
+ // Check if one domain is 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 TraceDomainComponent) {
+ TraceDomainComponent tmpDomain = (TraceDomainComponent) element;
+ session = (TraceSessionComponent) tmpDomain.getParent();
+
+ // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ domain = tmpDomain;
+ }
+ }
+ }
+ }
+
+ boolean isEnabled = domain != null;
+
+ fLock.lock();
+ try {
+ fParam = null;
+ if (isEnabled) {
+ fParam = new DomainCommandParameter(session, domain);
+ }
+ } finally {
+ fLock.unlock();
+ }
+
+ return isEnabled;
+ }
+
+
+}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.handlers;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <b><u>AddContextOnEventHandler</u></b>
+ * <p>
+ * Command handler implementation to add contexts to a given event.
+ * </p>
+ */
+public class AddContextOnEventHandler extends BaseAddContextHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseAddContextHandler#addContexts(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void addContexts(CommandParameter param, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
+ if (param instanceof EventCommandParameter) {
+ TraceEventComponent event = ((EventCommandParameter)param).getEvent();
+ event.addContexts(contextNames, monitor);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceEventComponent event = null;
+ TraceSessionComponent session = null;
+ 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 TraceEventComponent) {
+ // Add only if corresponding TraceSessionComponents is inactive and not destroyed
+ TraceEventComponent tmpEvent = (TraceEventComponent) element;
+ session = tmpEvent.getSession();
+ if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
+ event = tmpEvent;
+ }
+ }
+ }
+ }
+
+ boolean isEnabled = (event != null);
+ fLock.lock();
+ try {
+ fParam = null;
+ if(isEnabled) {
+ fParam = new EventCommandParameter(session, event);
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.handlers;
+
+import java.util.List;
+
+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.window.Window;
+import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IAddContextDialog;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.TraceControlDialogFactory;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * <b><u>BaseAddContextHandler</u></b>
+ * <p>
+ * Base command handler implementation to add contexts.
+ * </p>
+ */
+abstract public class BaseAddContextHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The command execution parameter.
+ */
+ protected CommandParameter fParam = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Adds contexts to channel(s) and/or event(s)
+ * @param param - a parameter instance with data for the command execution
+ * @param contextNames - list contexts to add
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ abstract public void addContexts(CommandParameter param, List<String> contextNames, 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 {
+
+ final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+
+ if (window == null) {
+ return false;
+ }
+ fLock.lock();
+ try {
+ // Make a copy for thread safety
+ final CommandParameter param = fParam.clone();
+
+ UIJob getJob = new UIJob(Messages.TraceControl_GetContextJob) {
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+
+ try {
+ final List<String> availableContexts = param.getSession().getContextList(monitor);
+ final IAddContextDialog dialog = TraceControlDialogFactory.getInstance().getAddContextDialog();
+ dialog.setAvalibleContexts(availableContexts);
+
+ if ((dialog.open() != Window.OK) || (dialog.getContexts().isEmpty())) {
+ return Status.OK_STATUS;
+ }
+
+ Job addJob = new Job(Messages.TraceControl_AddContextJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ StringBuffer errorString = new StringBuffer();
+
+ try {
+ List<String> contextNames = dialog.getContexts();
+ addContexts(param, contextNames, monitor);
+
+ } catch (ExecutionException e) {
+ errorString.append(e.toString());
+ errorString.append('\n');
+ }
+
+ // get session configuration in all cases
+ try {
+ param.getSession().getConfigurationFromNode(monitor);
+ } catch (ExecutionException e) {
+ errorString.append(Messages.TraceControl_ListSessionFailure);
+ errorString.append(": "); //$NON-NLS-1$
+ errorString.append(e.toString());
+ }
+
+ if (errorString.length() > 0) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, errorString.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ addJob.setUser(true);
+ addJob.schedule();
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, Activator.PLUGIN_ID, e.toString());
+ }
+
+ return Status.OK_STATUS;
+ }
+ };
+ getJob.setUser(false);
+ getJob.schedule();
+
+ } finally {
+ fLock.unlock();
+ }
+ return null;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * 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.internal.lttng2.ui.views.control.handlers;
+
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * Class containing parameter for a command execution.
+ */
+public class EventCommandParameter extends CommandParameter {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ private TraceEventComponent fEvent;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param session - a trace session component.
+ * @param event - a trace event component
+ */
+ public EventCommandParameter(TraceSessionComponent session, TraceEventComponent event) {
+ super(session);
+ fEvent = event;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the trace event component
+ */
+ public TraceEventComponent getEvent() {
+ return fEvent;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public EventCommandParameter clone() {
+ EventCommandParameter clone = (EventCommandParameter) super.clone();
+ clone.fEvent = fEvent;
+ return clone;
+ }
+}
\ No newline at end of file
TraceControl_EnableEventsFailure=Enable Events failed
TraceControl_DisableEventsJob=Disabling Events...
+TraceControl_GetContextJob=Getting Available Contexts...
+TraceControl_AddContextJob=Adding Contexts...
+
# Dialogs
TraceControl_NewDialogTitle=New Connection
TraceControl_NewNodeExistingConnectionGroupName=Existing Connections
TraceControl_InvalidLogLevelEventNameError=The event name for log level is invalid
TraceControl_InvalidLogLevel=No log level selected
+TraceControl_AddContextDialogTitle=Add Contexts
+TraceControl_AddContextAvailableContextsLabel=Contexts
+TraceControl_AddContextAvailableContextsTooltip=Available Contexts
+TraceControl_AddContextAllLabel=All Contexts
+
# Tree structure strings
TraceControl_KernelDomainDisplayName=Kernel
TraceControl_UstGlobalDomainDisplayName=UST global
public void disableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
}
+
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts) throws ExecutionException {
+ addContexts(contexts, new NullProgressMonitor());
+ }
+
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().addContexts(getSessionName(), getName(), null, isKernel(), contexts, monitor);
+ }
}
getControlService().enableLogLevel(getSessionName(), null, eventName, logLevelType, level, monitor);
}
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts) throws ExecutionException {
+ addContexts(contexts, new NullProgressMonitor());
+ }
+
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().addContexts(getSessionName(), null, null, isKernel(), contexts, monitor);
+ }
}
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.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.internal.lttng2.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IEventInfo;
return ((TraceChannelComponent)getParent()).getSessionName();
}
+ /**
+ * @return session from parent
+ */
+ public TraceSessionComponent getSession() {
+ return ((TraceChannelComponent)getParent()).getSession();
+ }
+
/**
* @return channel name from parent
*/
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts) throws ExecutionException {
+ addContexts(contexts, new NullProgressMonitor());
+ }
+
+ /**
+ * Add contexts to given channels and or events
+ * @param contexts - a list of contexts to add
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void addContexts(List<String> contexts, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().addContexts(getSessionName(),getChannelName(), getName(), isKernel(), contexts, monitor);
+ }
}
public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
getControlService().enableLogLevel(getName(), null, eventName, logLevelType, level, monitor);
}
+
+ /**
+ * Gets all available contexts to be added to channels/events.
+ * @return the list of available contexts
+ */
+ public List<String> getContextList() throws ExecutionException {
+ return getContextList(new NullProgressMonitor());
+ }
+
+ /**
+ * Gets all available contexts to be added to channels/events.
+ * @param monitor
+ * @return the list of available contexts
+ */
+ public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException {
+ return getControlService().getContextList(monitor);
+ }
}
* @throws ExecutionException
*/
public void disableEvent(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Gets all available context names to be added to channels/events.
+ * @param monitor
+ * @return the list of available contexts
+ */
+ public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Add contexts to given channels and or events
+ * @param sessionName - a session name
+ * @param channelName - a channel name (null for all channels)
+ * @param eventName - a event name (null for all events)
+ * @param isKernel - a flag for indicating kernel or UST.
+ * @param contexts - a list of name of contexts to add
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void addContexts(String sessionName, String channelName, String eventName, boolean isKernel, List<String> contexts, IProgressMonitor monitor) throws ExecutionException;
}
* Command to disable a event.
*/
private final static String COMMAND_DISABLE_EVENT = CONTROL_COMMAND + " disable-event "; //$NON-NLS-1$
-
+ /**
+ * Command to add a context to channels and/or events
+ */
+ private final static String COMMAND_ADD_CONTEXT = CONTROL_COMMAND + " add-context "; //$NON-NLS-1$
+
// Command options constants
/**
* Command line option for output path.
* Command line option for specifying a channel.
*/
private final static String OPTION_CHANNEL = " -c "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a event.
+ */
+ private final static String OPTION_EVENT = " -e "; //$NON-NLS-1$
/**
* Command line option for specifying all events.
*/
private final static String OPTION_ALL = " -a "; //$NON-NLS-1$
+ /**
+ * Command line option for specifying a context.
+ */
+ private final static String OPTION_CONTEXT_TYPE = " -t "; //$NON-NLS-1$
/**
* Command line option for specifying tracepoint events.
*/
* Optional command line option for configuring a channel's read timer interval.
*/
private final static String OPTION_READ_TIMER = " --read-timer "; //$NON-NLS-1$
+ /**
+ * Command line option for printing the help of a specif command
+ */
+ private final static String OPTION_HELP = " -h "; //$NON-NLS-1$
// Parsing constants
/**
* Pattern to match for session command output for "session name not found".
*/
private final static Pattern SESSION_NOT_FOUND_ERROR_PATTERN = Pattern.compile("\\s*Error:\\s+Session\\s+name\\s+not\\s+found"); //$NON-NLS-1$
+ /**
+ * Pattern to match introduction line of context list.
+ */
+ private final static Pattern ADD_CONTEXT_HELP_CONTEXTS_INTRO = Pattern.compile("\\s*TYPE can\\s+be\\s+one\\s+of\\s+the\\s+strings\\s+below.*"); //$NON-NLS-1$
+
+ /**
+ * Pattern to match introduction line of context list.
+ */
+ private final static Pattern ADD_CONTEXT_HELP_CONTEXTS_END_LINE = Pattern.compile("\\s*Example.*"); //$NON-NLS-1$
// ------------------------------------------------------------------------
// Attributes
throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#getContexts(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public List<String> getContextList(IProgressMonitor monitor) throws ExecutionException {
+
+ String command = COMMAND_ADD_CONTEXT + OPTION_HELP;
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+
+ if (isError(result)) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ String[] output = result.getOutput();
+
+ List<String> contexts = new ArrayList<String>(0);
+
+ int index = 0;
+ boolean inList = false;
+ while (index < output.length) {
+ String line = result.getOutput()[index];
+
+ Matcher startMatcher = ADD_CONTEXT_HELP_CONTEXTS_INTRO.matcher(line);
+ Matcher endMatcher = ADD_CONTEXT_HELP_CONTEXTS_END_LINE.matcher(line);
+
+ if (startMatcher.matches()) {
+ inList = true;
+ } else if (endMatcher.matches()) {
+ break;
+ } else if (inList == true) {
+ String[] tmp = line.split(","); //$NON-NLS-1$
+ for (int i = 0; i < tmp.length; i++) {
+ contexts.add(tmp[i].trim());
+ }
+ }
+ index++;
+ }
+ return contexts;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#addContexts(java.lang.String, java.lang.String, java.lang.String, boolean, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void addContexts(String sessionName, String channelName, String eventName, boolean isKernel, List<String> contextNames, IProgressMonitor monitor) throws ExecutionException {
+
+ String newSessionName = formatParameter(sessionName);
+ StringBuffer command = new StringBuffer(COMMAND_ADD_CONTEXT);
+
+ command.append(OPTION_SESSION);
+ command.append(newSessionName);
+
+ if (channelName != null) {
+ command.append(OPTION_CHANNEL);
+ command.append(channelName);
+ }
+
+ if (eventName != null) {
+ command.append(OPTION_EVENT);
+ command.append(eventName);
+ }
+
+ if (isKernel) {
+ command.append(OPTION_KERNEL);
+ } else {
+ command.append(OPTION_UST);
+ }
+
+ for (Iterator<String> iterator = contextNames.iterator(); iterator.hasNext();) {
+ String context = (String) iterator.next();
+ command.append(OPTION_CONTEXT_TYPE);
+ command.append(context);
+ }
+
+ 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
// ------------------------------------------------------------------------
}
return null;
}
-
}