Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2013-12-10 17:18:11 +0000
committerBernd Hufmann2014-06-13 16:48:41 +0000
commit536bbfe65427d4fb11e7c9db7092f0b905c2955e (patch)
treea3564a9e4fd233d6c78e4a387214662cecb96aea
parentc6dbd1221fb63801d908fe3ac119bbb6f8710b79 (diff)
downloadorg.eclipse.linuxtools-536bbfe65427d4fb11e7c9db7092f0b905c2955e.tar.gz
org.eclipse.linuxtools-536bbfe65427d4fb11e7c9db7092f0b905c2955e.tar.xz
org.eclipse.linuxtools-536bbfe65427d4fb11e7c9db7092f0b905c2955e.zip
lttng.control: add possibility to run a list of lttng commands
Change-Id: Ib391f02da6980f1d9381212bc448c12de2d69279 Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/26757 Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/META-INF/MANIFEST.MF3
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/build.properties2
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties3
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml39
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/ISelectCommandScriptDialog.java32
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/OpenCommandScriptDialog.java200
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java15
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ExecuteCommandScriptHandler.java116
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties7
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java16
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/ILttngControlService.java13
-rw-r--r--lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java14
13 files changed, 466 insertions, 1 deletions
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.lttng2.control.ui/META-INF/MANIFEST.MF
index e65c47f8a0..6902dfd3c2 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/META-INF/MANIFEST.MF
@@ -38,7 +38,8 @@ Export-Package: org.eclipse.linuxtools.internal.lttng2.control.ui;x-fr
x-friends:="org.eclipse.linuxtools.lttng2.control.ui.tests",org.eclip
se.linuxtools.internal.lttng2.control.ui.views.service;x-friends:="or
g.eclipse.linuxtools.lttng2.control.ui.tests"
-Import-Package: org.eclipse.rse.core,
+Import-Package: com.google.common.collect,
+ org.eclipse.rse.core,
org.eclipse.rse.core.model,
org.eclipse.rse.core.subsystems,
org.eclipse.rse.services,
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/build.properties b/lttng/org.eclipse.linuxtools.lttng2.control.ui/build.properties
index cb21f79b76..94af68f058 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/build.properties
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/build.properties
@@ -19,3 +19,5 @@ bin.includes = META-INF/,\
about.html,\
plugin.properties
src.includes = about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
index 399f2d513a..81a564ee79 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.properties
@@ -86,6 +86,9 @@ commands.control.delete.description=Delete Target Node
commands.control.create.session=Create Session...
commands.control.create.session.description=Create a Trace Session
+commands.control.execute.command.script=Execute Command Script...
+commands.control.execute.command.script.description=Execute Command Script
+
commands.control.destroy.session=Destroy Session...
commands.control.destroy.session.description=Destroy a Trace Session
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
index d47c061e03..9240836ca5 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/plugin.xml
@@ -64,6 +64,12 @@
</command>
<command
categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
+ description="%commands.control.execute.command.script.description"
+ id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.executeScript"
+ name="%commands.control.execute.command.script">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.category"
description="%commands.control.destroy.session.description"
id="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession"
name="%commands.control.destroy.session">
@@ -363,6 +369,24 @@
</visibleWhen>
</command>
<command
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.executeScript"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.execute.command.script"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.start"
icon="icons/elcl16/start_trace.gif"
label="%commands.control.start"
@@ -890,6 +914,21 @@
</activeWhen>
</handler>
<handler
+ class="org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers.ExecuteCommandScriptHandler"
+ commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.executeScript">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
class="org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers.DestroySessionHandler"
commandId="org.eclipse.linuxtools.internal.lttng2.ui.commands.control.destroySession">
<activeWhen>
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/ISelectCommandScriptDialog.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/ISelectCommandScriptDialog.java
new file mode 100644
index 0000000000..15dd52e9f3
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/ISelectCommandScriptDialog.java
@@ -0,0 +1,32 @@
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs;
+
+import java.util.List;
+
+/**
+ * Interface for dialog for selecting a command script.
+ *
+ * @author Bernd Hufmann
+ *
+ */
+public interface ISelectCommandScriptDialog {
+ /**
+ * @return a list of command
+ */
+ List<String> getCommands();
+
+ /**
+ * @return the open return value
+ */
+ int open();
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/OpenCommandScriptDialog.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/OpenCommandScriptDialog.java
new file mode 100644
index 0000000000..7957f414a5
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/OpenCommandScriptDialog.java
@@ -0,0 +1,200 @@
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
+import org.eclipse.linuxtools.tmf.core.io.BufferedRandomAccessFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * <p>
+ * Dialog box for selecting a command script. It parses the script and
+ * provides a list of shell commands to be executed.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public class OpenCommandScriptDialog extends Dialog implements ISelectCommandScriptDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ // Dialog attributes
+ private Control fControl = null;
+ private Composite fDialogComposite = null;
+ private Button fBrowseButton;
+ private Label fFileNameLabel = null;
+ private Text fFileNameText = null;
+
+ // Output list of commands
+ private List<String> fCommands = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public OpenCommandScriptDialog(Shell shell) {
+ super(shell);
+ setShellStyle(SWT.RESIZE | getShellStyle());
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ @Override
+ @NonNull public List<String> getCommands() {
+ if (fCommands != null) {
+ return fCommands;
+ }
+ return new ArrayList<>();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ protected Control createContents(Composite parent) {
+ fControl = super.createContents(parent);
+
+ /* set the shell minimum size */
+ Point clientArea = fControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ Rectangle trim = getShell().computeTrim(0, 0, clientArea.x, clientArea.y);
+ getShell().setMinimumSize(trim.width, trim.height);
+
+ return fControl;
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(Messages.TraceControl_ExecuteScriptDialogTitle);
+ newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE));
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ // Main dialog panel
+ fDialogComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ fDialogComposite.setLayout(layout);
+ fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Group sessionGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ sessionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ sessionGroup.setLayout(new GridLayout(6, true));
+
+ fFileNameLabel = new Label(sessionGroup, SWT.RIGHT);
+ fFileNameLabel.setText(Messages.TraceControl_ExecuteScriptSelectLabel);
+ fFileNameText = new Text(sessionGroup, SWT.NONE);
+
+ fBrowseButton = new Button(sessionGroup, SWT.PUSH);
+ fBrowseButton.setText(Messages.TraceControl_ExecuteScriptBrowseText);
+ fBrowseButton.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ handleFilePathBrowseButtonPressed(SWT.OPEN);
+ }
+ });
+
+ // layout widgets
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+ data.grabExcessHorizontalSpace = false;
+ fFileNameLabel.setLayoutData(data);
+
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 4;
+ fFileNameText.setLayoutData(data);
+
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+
+ // Initialize a empty list
+ fCommands = new ArrayList<>();
+
+ return fDialogComposite;
+ }
+
+ private void handleFilePathBrowseButtonPressed(int fileDialogStyle) {
+ FileDialog dialog = new FileDialog(getShell(), fileDialogStyle | SWT.SHEET);
+ dialog.setFilterExtensions(new String[] { "*.*", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
+ dialog.setText(Messages.TraceControl_ExecuteScriptDialogTitle);
+ String selectedFileName = dialog.open();
+ fFileNameText.setText(selectedFileName);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ }
+
+ @Override
+ protected void okPressed() {
+ // Validate input data
+ String sessionPath = fFileNameText.getText();
+
+ if (!"".equals(sessionPath)) { //$NON-NLS-1$
+ ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
+ try (BufferedRandomAccessFile rafile = new BufferedRandomAccessFile(sessionPath, "r")) { //$NON-NLS-1$
+ String line = rafile.getNextLine();
+ while (line != null) {
+ builder.add(line);
+ line = rafile.getNextLine();
+ }
+ } catch (IOException e) {
+ return;
+ }
+ fCommands = builder.build();
+ super.okPressed();
+ }
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java
index fb87a70a2f..58364d2471 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/dialogs/TraceControlDialogFactory.java
@@ -49,6 +49,11 @@ public final class TraceControlDialogFactory {
private ICreateSessionDialog fCreateSessionDialog;
/**
+ * The command script selection dialog.
+ */
+ private ISelectCommandScriptDialog fCommandScriptDialog;
+
+ /**
* The enable events dialog.
*/
private IEnableEventsDialog fEnableEventsDialog;
@@ -149,6 +154,16 @@ public final class TraceControlDialogFactory {
}
/**
+ * @return command script selection dialog implementation
+ */
+ public ISelectCommandScriptDialog getCommandScriptDialog() {
+ if (fCommandScriptDialog == null) {
+ fCommandScriptDialog = new OpenCommandScriptDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ }
+ return fCommandScriptDialog;
+ }
+
+ /**
* Sets a create session dialog implementation.
* @param createSessionDialog - a create session implementation.
*/
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ExecuteCommandScriptHandler.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ExecuteCommandScriptHandler.java
new file mode 100644
index 0000000000..1db9731470
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/handlers/ExecuteCommandScriptHandler.java
@@ -0,0 +1,116 @@
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.control.ui.views.handlers;
+
+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.internal.lttng2.control.ui.Activator;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.ControlView;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.ISelectCommandScriptDialog;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs.TraceControlDialogFactory;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
+import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * <p>
+ * Command handler implementation to execute commands of a command script.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public class ExecuteCommandScriptHandler extends BaseControlViewHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The trace session group the command is to be executed on.
+ */
+ private TraceSessionGroup fSessionGroup = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ fLock.lock();
+ try {
+ final TraceSessionGroup sessionGroup = fSessionGroup;
+
+ // Open dialog box for the node name and address
+ final ISelectCommandScriptDialog dialog = TraceControlDialogFactory.getInstance().getCommandScriptDialog();
+
+ if (dialog.open() != Window.OK) {
+ return null;
+ }
+
+ Job job = new Job(Messages.TraceControl_ExecuteScriptJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ sessionGroup.executeCommands(monitor, dialog.getCommands());
+ } catch (ExecutionException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TraceControl_CreateSessionFailure, e);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ } finally {
+ fLock.unlock();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabled() {
+
+ // Get workbench page for the Control View
+ IWorkbenchPage page = getWorkbenchPage();
+ if (page == null) {
+ return false;
+ }
+
+ TraceSessionGroup sessionGroup = null;
+
+ // Check if the session group project is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ Object element = ((StructuredSelection) selection).getFirstElement();
+ sessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ }
+
+ boolean isEnabled = sessionGroup != null;
+ fLock.lock();
+ try {
+ fSessionGroup = null;
+ if(isEnabled) {
+ fSessionGroup = sessionGroup;
+ }
+ } finally {
+ fLock.unlock();
+ }
+ return isEnabled;
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java
index e1366ef159..893d1905c8 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/Messages.java
@@ -292,6 +292,13 @@ public final class Messages extends NLS {
public static String TraceControl_VerboseLevelVeryVerbosePreference;
public static String TraceControl_VerboseLevelVeryVeryVerbosePreference;
+ public static String TraceControl_ExecuteScriptJob;
+ public static String TraceControl_ExecuteScriptError;
+
+ public static String TraceControl_ExecuteScriptDialogTitle;
+ public static String TraceControl_ExecuteScriptBrowseText;
+ public static String TraceControl_ExecuteScriptSelectLabel;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties
index cd7c2fddd9..7fbf077abe 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/messages/messages.properties
@@ -278,3 +278,10 @@ TraceControl_VerboseLevelNonePreference=None
TraceControl_VerboseLevelVerbosePreference=Level 1
TraceControl_VerboseLevelVeryVerbosePreference=Level 2
TraceControl_VerboseLevelVeryVeryVerbosePreference=Level 3
+
+TraceControl_ExecuteScriptJob=Executing command script
+TraceControl_ExecuteScriptError=Error executing command script
+
+TraceControl_ExecuteScriptDialogTitle=Select command script
+TraceControl_ExecuteScriptBrowseText=Browse...
+TraceControl_ExecuteScriptSelectLabel=Select Script
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java
index fafa425a26..90c0ca31be 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/model/impl/TraceSessionGroup.java
@@ -12,6 +12,8 @@
**********************************************************************/
package org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -131,6 +133,20 @@ public class TraceSessionGroup extends TraceControlComponent {
}
/**
+ * Command to execute a list of commands
+ * @param monitor
+ * - a progress monitor
+ * @param commands
+ * - a list of commands to execute
+ * @throws ExecutionException
+ * If the command fails
+ */
+ public void executeCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException {
+ getControlService().runCommands(monitor, commands);
+ getTargetNode().refresh();
+ }
+
+ /**
* Destroys a session with given session name.
*
* @param session
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/ILttngControlService.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/ILttngControlService.java
index ebefe44f49..7684e8078e 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/ILttngControlService.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/ILttngControlService.java
@@ -381,4 +381,17 @@ public interface ILttngControlService {
*/
void recordSnapshot(String sessionName, IProgressMonitor monitor)
throws ExecutionException;
+
+ /**
+ * Executes a list of commands
+ *
+ * @param monitor
+ * - a progress monitor
+ * @param commands
+ * - array of commands
+ * @throws ExecutionException
+ * If a command fails
+ */
+ void runCommands(IProgressMonitor monitor, List<String> commands)
+ throws ExecutionException;
}
diff --git a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
index 92a8b25f17..52e11c76d2 100644
--- a/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
+++ b/lttng/org.eclipse.linuxtools.lttng2.control.ui/src/org/eclipse/linuxtools/internal/lttng2/control/ui/views/service/LTTngControlService.java
@@ -999,6 +999,20 @@ public class LTTngControlService implements ILttngControlService {
executeCommand(command.toString(), monitor);
}
+ @Override
+ public void runCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException {
+ for (String command : commands) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ if (command.isEmpty() || command.startsWith("#")) { //$NON-NLS-1$
+ continue;
+ }
+ executeCommand(command, monitor);
+ }
+ }
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------

Back to the top