From bbb3538a7c5b2953377e038ed021d1b72b38a5f0 Mon Sep 17 00:00:00 2001
From: Bernd Hufmann
Date: Tue, 21 Feb 2012 15:08:51 -0500
Subject: [PATCH] Add new LTTng commands (create/destroy/start/stop session,
enable/disable channels)
---
.../META-INF/MANIFEST.MF | 3 +-
.../service/LTTngControlServiceTest.java | 109 ++++-
.../stubs/service/CommandShellFactory.java | 5 +
.../stubs/service/TestRemoteSystemProxy.java | 6 +-
.../shells/SessionCreationErrorsShell.java | 47 +++
.../service/shells/SessionNamesShell.java | 9 +
.../plugin.properties | 28 +-
org.eclipse.linuxtools.lttng.ui/plugin.xml | 393 +++++++++++++++++-
.../lttng/ui/views/PerspectiveFactory.java | 3 +
.../lttng/ui/views/control/ControlView.java | 2 +-
.../lttng/ui/views/control/Messages.java | 49 +++
.../control/dialogs/CreateChannelDialog.java | 356 ++++++++++++++++
.../control/dialogs/CreateSessionDialog.java | 245 +++++++++++
.../control/dialogs/ICreateChannelDialog.java | 39 ++
.../ICreateChannelOnSessionDialog.java | 32 ++
.../control/dialogs/ICreateSessionDialog.java | 47 +++
.../control/dialogs/INewConnectionDialog.java | 8 +-
.../control/dialogs/NewConnectionDialog.java | 76 ++--
.../control/handlers/BaseNodeHandler.java | 13 +-
.../handlers/ChangeChannelStateHandler.java | 236 +++++++++++
.../handlers/ChangeSessionStateHandler.java | 153 +++++++
.../CreateChannelOnDomainHandler.java | 159 +++++++
.../CreateChannelOnSessionHandler.java | 160 +++++++
.../handlers/CreateSessionHandler.java | 123 ++++++
.../handlers/DestroySessionHandler.java | 139 +++++++
.../handlers/DisableChannelHandler.java | 52 +++
.../handlers/EnableChannelHandler.java | 52 +++
.../handlers/NewConnectionHandler.java | 7 +-
.../views/control/handlers/StartHandler.java | 50 +++
.../views/control/handlers/StopHandler.java | 50 +++
.../ui/views/control/messages.properties | 45 +-
.../ui/views/control/model/IChannelInfo.java | 32 ++
.../ui/views/control/model/IDomainInfo.java | 12 +
.../views/control/model/impl/DomainInfo.java | 27 ++
.../model/impl/TargetNodeComponent.java | 10 +
.../model/impl/TraceChannelComponent.java | 15 +-
.../model/impl/TraceDomainComponent.java | 88 +++-
.../model/impl/TraceSessionComponent.java | 51 ++-
.../control/model/impl/TraceSessionGroup.java | 53 ++-
.../control/remote/IRemoteSystemProxy.java | 17 +-
.../control/remote/RemoteSystemProxy.java | 22 +-
.../control/service/ILttngControlService.java | 80 +++-
.../control/service/LTTngControlService.java | 333 +++++++++++++--
43 files changed, 3268 insertions(+), 168 deletions(-)
create mode 100644 org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java
create mode 100644 org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF
index 25984cc05b..7f29dab918 100644
--- a/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.junit;bundle-version="3.8.2",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.rse.core;bundle-version="3.2.0",
org.eclipse.rse.services;bundle-version="3.2.100",
- org.eclipse.ui.views;bundle-version="3.6.0"
+ org.eclipse.ui.views;bundle-version="3.6.0",
+ org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100"
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java
index 3c65445093..779c272287 100644
--- a/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java
+++ b/org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java
@@ -16,6 +16,8 @@ import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.lttng.stubs.service.CommandShellFactory;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
@@ -75,7 +77,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSessionNames() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForLttngNotExistsShell());
- service.getSessionNames();
+ service.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
@@ -86,7 +88,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSessionNames1() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForNoSessionNames());
- String[] result = service.getSessionNames();
+ String[] result = service.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(0, result.length);
@@ -99,7 +101,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSessionNames2() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- String[] result = service.getSessionNames();
+ String[] result = service.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(2, result.length);
@@ -114,7 +116,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSessionNotExist() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNotExists());
- service.getSessionNames();
+ service.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
@@ -125,7 +127,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSessionNameGarbage() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionGarbage());
- String[] result = service.getSessionNames();
+ String[] result = service.getSessionNames(new NullProgressMonitor());
assertNotNull(result);
assertEquals(0, result.length);
@@ -138,7 +140,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetSession1() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- ISessionInfo session = service.getSession("mysession");
+ ISessionInfo session = service.getSession("mysession", new NullProgressMonitor());
// Verify Session
assertNotNull(session);
@@ -238,7 +240,7 @@ public class LTTngControlServiceTest extends TestCase {
assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
// next session (no detailed information available)
- session = service.getSession("mysession1");
+ session = service.getSession("mysession1", new NullProgressMonitor());
assertNotNull(session);
assertEquals("mysession1", session.getName());
assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
@@ -255,7 +257,7 @@ public class LTTngControlServiceTest extends TestCase {
public void testGetKernelProvider() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- List events = service.getKernelProvider();
+ List events = service.getKernelProvider(new NullProgressMonitor());
// Verify event info
assertNotNull(events);
@@ -349,4 +351,95 @@ public class LTTngControlServiceTest extends TestCase {
}
}
+ public void testCreateSession() {
+ try {
+ ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
+ ISessionInfo info = service.createSession("mysession2", null, new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("mysession2", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("mysession2"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ public void testCreateSessionErrors() {
+ ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionErrors());
+ try {
+ service.createSession("alreadyExist", null, new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ service.createSession("wrongName", null, new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ service.createSession("wrongPath", "/home/user/hallo", new NullProgressMonitor());
+ fail("No exeption thrown");
+ } catch (ExecutionException e) {
+ // success
+ }
+
+ try {
+ ISessionInfo info = service.createSession("session with spaces", null, new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("session with spaces", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("session with spaces"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+
+ try {
+ ISessionInfo info = service.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+ assertNotNull(info);
+ assertEquals("pathWithSpaces", info.getName());
+ assertNotNull(info.getSessionPath());
+ assertTrue(info.getSessionPath().contains("/home/user/hallo user/here"));
+ assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+ void testDestroySession() {
+ try {
+ ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionErrors());
+ service.destroySession("mysession2", new NullProgressMonitor());
+ } catch (ExecutionException e) {
+ fail(e.toString());
+ }
+ }
+
+// public void testCreateChannel() {
+// try {
+//
+//// public void enableChannel(String sessionName, List channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor);
+// ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
+//
+//
+// ISessionInfo info = service.createSession("mysession2", null, new NullProgressMonitor());
+// assertNotNull(info);
+// assertEquals("mysession2", info.getName());
+// assertNotNull(info.getSessionPath());
+// assertTrue(info.getSessionPath().contains("mysession2"));
+// assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+// } catch (ExecutionException e) {
+// fail(e.toString());
+// }
+// }
+
+
+
}
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java
index 03679efec2..c461ae6334 100644
--- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java
+++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java
@@ -4,6 +4,7 @@ import org.eclipse.linuxtools.lttng.stubs.service.shells.GetSessionGarbageShell;
import org.eclipse.linuxtools.lttng.stubs.service.shells.LttngNotExistsShell;
import org.eclipse.linuxtools.lttng.stubs.service.shells.NoSessionNamesShell;
import org.eclipse.linuxtools.lttng.stubs.service.shells.NoUstProviderShell;
+import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionCreationErrorsShell;
import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNotExistsShell;
import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNamesShell;
import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
@@ -44,4 +45,8 @@ public class CommandShellFactory {
public ICommandShell getShellForNoUstProvider() {
return new NoUstProviderShell();
}
+
+ public ICommandShell getShellForSessionErrors() {
+ return new SessionCreationErrorsShell();
+ }
}
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java
index 92efecaf9a..52ab21d45b 100644
--- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java
+++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java
@@ -2,7 +2,6 @@ package org.eclipse.linuxtools.lttng.stubs.service;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.TestCommandShell;
import org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy;
import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
import org.eclipse.rse.core.model.IRSECallback;
@@ -10,6 +9,7 @@ import org.eclipse.rse.core.subsystems.ICommunicationsListener;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.shells.IShellService;
import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
public class TestRemoteSystemProxy implements IRemoteSystemProxy {
@@ -32,6 +32,10 @@ public class TestRemoteSystemProxy implements IRemoteSystemProxy {
public ISubSystem getTerminalServiceSubSystem() {
return null;
}
+ @Override
+ public IFileServiceSubSystem getFileServiceSubSystem() {
+ return null;
+ }
@Override
public void connect(IRSECallback callback) throws ExecutionException {
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java
new file mode 100644
index 0000000000..32ff74cb8b
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java
@@ -0,0 +1,47 @@
+package org.eclipse.linuxtools.lttng.stubs.service.shells;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
+
+public class SessionCreationErrorsShell extends TestCommandShell {
+ @SuppressWarnings("nls")
+ @Override
+ public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
+ if ("lttng create alreadyExist".equals(command)) {
+ String[] output = new String[1];
+ //Error: Session name already exist
+ output[0] = String.valueOf("Error: Session name already exist");
+ return new CommandResult(1, output);
+ } else if("lttng create \"session with spaces\"".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session session with spaces created.");
+ list.add("Traces will be written in /home/user/lttng-traces/session with spaces-20120209-095418");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
+ } else if ("lttng create wrongName".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session auto created.");
+ list.add("Traces will be written in /home/user/lttng-traces/auto-20120209-095418");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
+ } else if ("lttng create wrongPath -o /home/user/hallo".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session wrongPath created.");
+ list.add("Traces will be written in /home/user/lttng-traces/wrongPath-20120209-095418");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
+ } else if ("lttng create pathWithSpaces -o \"/home/user/hallo user/here\"".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session pathWithSpaces created.");
+ list.add("Traces will be written in /home/user/hallo user/here/pathWithSpaces-20120209-095418");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
+ }
+
+ String[] output = new String[1];
+ output[0] = String.valueOf("Command not found");
+ return new CommandResult(1, output);
+ }
+}
+
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java
index 9d7a1dcd12..173986dcae 100644
--- a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java
+++ b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java
@@ -121,6 +121,15 @@ public class SessionNamesShell extends TestCommandShell {
list.add(" Trace path: /home/user/lttng-traces/mysession1-20120203-133225");
list.add("");
return new CommandResult(0, list.toArray(new String[list.size()]));
+ } else if ("lttng create mysession2".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session mysession2 created.");
+ list.add("Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
+ } else if ("lttng destroy mysession2".equals(command)) {
+ List list = new ArrayList();
+ list.add("Session mysession2 destrioyed.");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
}
String[] output = new String[1];
diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.properties b/org.eclipse.linuxtools.lttng.ui/plugin.properties
index a46de84915..8abacaa6a1 100644
--- a/org.eclipse.linuxtools.lttng.ui/plugin.properties
+++ b/org.eclipse.linuxtools.lttng.ui/plugin.properties
@@ -77,17 +77,39 @@ commands.control.category=LTTng Trace Control Commands
commands.control.category.description=LTTng Trace Control Commands
commands.control.new=New Connection
-commands.control.new.description=New Connection To Target Node
+commands.control.new.description=New Connection to Target Node
commands.control.connect=Connect
-commands.control.connect.description=Connect To Target Node
+commands.control.connect.description=Connect to Target Node
commands.control.disconnect=Disconnect
-commands.control.discconnect.description=Disconnect To Target Node
+commands.control.discconnect.description=Disconnect to Target Node
commands.control.delete=Delete
commands.control.deleete.description=Delete Target Node
+commands.control.create.session=Create Session
+commands.control.create.session.description=Create a Trace Session
+
+commands.control.destroy.session=Destroy Session
+commands.control.destroy.session.description=Destroy a Trace Session
+
+commands.control.create.channel=Create Channel
+commands.control.create.channel.description=Create a Trace Channel
+
+commands.control.enable.channel=Enable Channel
+commands.control.enable.channel.description=Enable a Trace Channel
+
+commands.control.disable.channel=Disable Channel
+commands.control.disable.channel.description=Disable a Trace Channel
+
+commands.control.start=Start
+commands.control.start.description=Start Trace Session
+
+commands.control.stop=Stop
+commands.control.stop.description=Stop Trace Session
+
+
# trace control (RSE) properties (LTTng 0.x)
lttng.rse.subsystem.type.name=LTTng (v0.x)
lttng.rse.subsystem.type.description=LTTng Trace Control (v0.x)
diff --git a/org.eclipse.linuxtools.lttng.ui/plugin.xml b/org.eclipse.linuxtools.lttng.ui/plugin.xml
index 9288644381..714dca9000 100644
--- a/org.eclipse.linuxtools.lttng.ui/plugin.xml
+++ b/org.eclipse.linuxtools.lttng.ui/plugin.xml
@@ -448,27 +448,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -476,35 +525,51 @@
allPopups="false"
locationURI="toolbar:org.eclipse.linuxtools.lttng.ui.views.control">
+
+
+
+
+
+
@@ -522,7 +587,7 @@
@@ -540,7 +605,7 @@
@@ -557,13 +622,188 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.newConnection">
@@ -575,7 +815,7 @@
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.connect">
@@ -590,7 +830,7 @@
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect">
@@ -605,7 +845,7 @@
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete">
@@ -618,6 +858,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java
index eadbe596cb..c801eb02ef 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.lttng.ui.views;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
import org.eclipse.linuxtools.lttng.ui.views.controlflow.ControlFlowView;
import org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramView;
import org.eclipse.linuxtools.lttng.ui.views.resources.ResourcesView;
@@ -35,6 +36,7 @@ public class PerspectiveFactory implements IPerspectiveFactory {
private static final String RESOURCES_VIEW_ID = ResourcesView.ID;
private static final String STATISTICS_VIEW_ID = StatisticsView.ID;
private static final String HISTOGRAM_VIEW_ID = HistogramView.ID;
+ private static final String CONTROL_VIEW_ID = ControlView.ID;
// Standard Eclipse views
private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
@@ -59,6 +61,7 @@ public class PerspectiveFactory implements IPerspectiveFactory {
IFolderLayout topLeftFolder = layout.createFolder(
"topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
topLeftFolder.addView(PROJECT_VIEW_ID);
+ topLeftFolder.addView(CONTROL_VIEW_ID);
// Create the top right folder
IFolderLayout topRightFolder = layout.createFolder(
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java
index f2ed3457be..e5643d58c1 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java
@@ -82,7 +82,7 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
@Override
public void createPartControl(Composite parent) {
// Create tree viewer
- fTreeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ fTreeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
ColumnViewerToolTipSupport.enableFor(fTreeViewer);
fTreeViewer.setContentProvider(new TraceControlContentProvider());
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 943cc21203..f54336e72c 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
@@ -33,12 +33,26 @@ final public class Messages extends NLS {
public static String TraceControl_CommandShellError;
public static String TraceControl_CommandError;
+ public static String TraceControl_UnexpectedCommnadOutputFormat;
+ public static String TraceControl_UnexpectedNameError;
+ public static String TraceControl_UnexpectedPathError;
// Commands
public static String TraceControl_RetrieveNodeConfigurationJob;
public static String TraceControl_ListSessionFailure;
public static String TraceControl_EclipseCommandFailure;
public static String TraceControl_NewNodeCreationFailure;
+ public static String TraceControl_CreateSessionJob;
+
+ public static String TraceControl_DestroySessionJob;
+ 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;
// Dialogs
public static String TraceControl_NewDialogTitle;
@@ -51,8 +65,43 @@ final public class Messages extends NLS {
public static String TraceControl_NewNodeHostNameTooltip;
public static String TraceControl_AlreadyExistsError;
+ public static String TraceControl_CreateSessionDialogTitle;
+ public static String TraceControl_CreateSessionNameLabel;
+ public static String TraceControl_CreateSessionNameTooltip;
+ public static String TraceControl_CreateSessionPathLabel;
+ public static String TraceControl_CreateSessionPathTooltip;
+ public static String TraceControl_InvalidSessionNameError;
+ public static String TraceControl_SessionAlreadyExistsError;
+ 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;
+ public static String TraceControl_EnableChannelNameLabelTooltip;
+ public static String TraceControl_EnableChannelSubBufferSizeTooltip;
+ public static String TraceControl_EnableChannelNbSubBuffersTooltip;
+ public static String TraceControl_EnableChannelSwitchTimerTooltip;
+ public static String TraceControl_EnableChannelReadTimerTooltip;
+ public static String TraceControl_EnableChannelOutputTypeTooltip;
+ public static String TraceControl_EnableChannelOverwriteModeTooltip;
+
+ public static String TraceControl_InvalidChannelNameError;
+ public static String TraceControl_ChannelAlreadyExistsError;
+
+// public static String TraceControl_CreateSessionNameTooltip;
+// public static String TraceControl_CreateSessionPathLabel;
+// public static String TraceControl_CreateSessionPathTooltip;
+// public static String TraceControl_SessionAlreadyExistsError;
+// public static String TraceControl_SessionPathAlreadyExistsError;
+// public static String TraceControl_InvalidSessionPathError;
+// public static String TraceControl_FileSubSystemError;
+
+
// Tree structure strings
public static String TraceControl_KernelDomainDisplayName;
+ public static String TraceControl_UstDisplayName;
public static String TraceControl_UstGlobalDomainDisplayName;
public static String TraceControl_AllSessionsDisplayName;
public static String TraceControl_SessionDisplayName;
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java
new file mode 100644
index 0000000000..a27af8513e
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java
@@ -0,0 +1,356 @@
+/**********************************************************************
+ * 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.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.IChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * CreateChannelDialog
+ *
+ * Dialog box for collecting channel creation information.
+ *
+ */
+public class CreateChannelDialog extends Dialog implements ICreateChannelOnSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * The icon file for this dialog box.
+ */
+ public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/edit.gif"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The text widget for the channel name
+ */
+ private Text fChannelNameText = null;
+ /**
+ * The overwrite mode of the channel.
+ */
+ private Button fOverwriteModeButton;
+ /**
+ * The sub-buffer size of the channel.
+ */
+ private Text fSubBufferSizeText;
+ /**
+ * The number of sub-buffers of the channel.
+ */
+ private Text fNumberOfSubBuffersText;
+ /**
+ * The switch timer interval of the channel.
+ */
+ private Text fSwitchTimerText;
+ /**
+ * The read timer interval of the channel.
+ */
+ private Text fReadTimerText;
+ /**
+ * Group composite for domain selection.
+ */
+ private Group fDomainGroup = null;
+ /**
+ * Radio button for selecting kernel domain.
+ */
+ private Button fKernelButton;
+ /**
+ * Radio button for selecting UST domain.
+ */
+ private Button fUstButton;
+ /**
+ * The parent domain component where the channel node should be added.
+ * Null in case of creation on session level.
+ */
+ private TraceDomainComponent fDomain;
+ /**
+ * Common verify listener for numeric text input.
+ */
+ private VerifyListener fVerifyListener;
+ /**
+ * Output channel information.
+ */
+ private IChannelInfo fChannelInfo;
+ /**
+ * Output domain information. True in case of Kernel domain. False for UST.
+ */
+ private boolean fIsKernel;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ */
+ public CreateChannelDialog(Shell shell) {
+ this(shell, null);
+ }
+
+
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ * @param domain - a domain to create channel on. Use null for creating a channel on session level.
+ */
+ public CreateChannelDialog(Shell shell, TraceDomainComponent domain) {
+ super(shell);
+ fDomain = domain;
+ if (fDomain != null) {
+ fIsKernel = fDomain.isKernel();
+ } else {
+ fIsKernel = true;
+ }
+
+ // Common verify listener
+ fVerifyListener = new VerifyListener() {
+ @Override
+ public void verifyText(VerifyEvent e) {
+ // only numbers are allowed.
+ e.doit = e.text.matches("[0-9]*"); //$NON-NLS-1$
+ }
+ };
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelDialog#getChannelInfo()
+ */
+ @Override
+ public IChannelInfo getChannelInfo() {
+ return fChannelInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ // ------------------------------------------------------------------------
+ // 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_EnableChannelDialogTitle);
+ newShell.setImage(LTTngUiPlugin.getDefault().loadIcon(ENABLE_CHANNEL_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(2, true);
+ fDialogComposite.setLayout(layout);
+
+ Label channelNameLabel = new Label(fDialogComposite, SWT.RIGHT);
+ channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel);
+ fChannelNameText = new Text(fDialogComposite, SWT.NONE);
+ fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameLabelTooltip);
+
+ Label subBufferSizeLabel = new Label(fDialogComposite, SWT.RIGHT);
+ subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName);
+ fSubBufferSizeText = new Text(fDialogComposite, SWT.NONE);
+ fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip);
+ fSubBufferSizeText.addVerifyListener(fVerifyListener);
+
+ Label numSubBufferLabel = new Label(fDialogComposite, SWT.RIGHT);
+ numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName);
+ fNumberOfSubBuffersText = new Text(fDialogComposite, SWT.NONE);
+ fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip);
+ fNumberOfSubBuffersText.addVerifyListener(fVerifyListener);
+
+ Label switchTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName);
+ fSwitchTimerText = new Text(fDialogComposite, SWT.NONE);
+ fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip);
+ fSwitchTimerText.addVerifyListener(fVerifyListener);
+
+ Label readTimerLabel = new Label(fDialogComposite, SWT.RIGHT);
+ readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName);
+ fReadTimerText = new Text(fDialogComposite, SWT.NONE);
+ fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip);
+ fReadTimerText.addVerifyListener(fVerifyListener);
+
+ fOverwriteModeButton = new Button(fDialogComposite, SWT.CHECK);
+ fOverwriteModeButton.setText(Messages.TraceControl_OverwriteModePropertyName);
+ fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip);
+ new Label(fDialogComposite, SWT.RIGHT);
+
+ fDomainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+ fDomainGroup.setText(Messages.TraceControl_DomainDisplayName);
+ layout = new GridLayout(2, true);
+ fDomainGroup.setLayout(layout);
+
+ fKernelButton = new Button(fDomainGroup, SWT.RADIO);
+ fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
+ fKernelButton.setSelection(fIsKernel);
+ fUstButton = new Button(fDomainGroup, SWT.RADIO);
+ fUstButton.setText(Messages.TraceControl_UstDisplayName);
+ fUstButton.setSelection(!fIsKernel);
+
+ if (fDomain != null) {
+ fKernelButton.setEnabled(false);
+ fUstButton.setEnabled(false);
+ }
+
+ // layout widgets
+ GridData data = new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
+ fDomainGroup.setLayoutData(data);
+
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fKernelButton.setLayoutData(data);
+ data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
+ fUstButton.setLayoutData(data);
+
+ data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ fSubBufferSizeText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fSubBufferSizeText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = minSize.x + 5;
+
+ fChannelNameText.setLayoutData(data);
+ fSubBufferSizeText.setLayoutData(data);
+ fNumberOfSubBuffersText.setLayoutData(data);
+ fSwitchTimerText.setLayoutData(data);
+ fReadTimerText.setLayoutData(data);
+
+ fSubBufferSizeText.setText(""); //$NON-NLS-1$
+
+ setDefaults();
+
+ 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.DETAILS_ID, "Default", true); //$NON-NLS-1$
+ createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Set channel information
+ fChannelInfo = new ChannelInfo(fChannelNameText.getText());
+ fChannelInfo.setSubBufferSize(Long.parseLong(fSubBufferSizeText.getText()));
+ fChannelInfo.setNumberOfSubBuffers(Integer.parseInt(fNumberOfSubBuffersText.getText()));
+ fChannelInfo.setSwitchTimer(Long.parseLong(fSwitchTimerText.getText()));
+ fChannelInfo.setReadTimer(Long.parseLong(fReadTimerText.getText()));
+ fChannelInfo.setOverwriteMode(fOverwriteModeButton.getSelection());
+
+ if (fKernelButton.getSelection() == true) {
+ fIsKernel = true;
+ } else {
+ fIsKernel = false;
+ }
+
+ // Check for invalid names
+ if (!fChannelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{2,}$")) { //$NON-NLS-1$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_InvalidChannelNameError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // Check for duplicate names
+ if (fDomain != null && fDomain.containsChild(fChannelInfo.getName())) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_EnableChannelDialogTitle,
+ Messages.TraceControl_ChannelAlreadyExistsError + " (" + fChannelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.DETAILS_ID) {
+ setDefaults();
+ return;
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ // ------------------------------------------------------------------------
+ // Helper methods
+ // ------------------------------------------------------------------------
+ /**
+ * Sets default value depending on Kernel or UST
+ */
+ private void setDefaults() {
+ fSwitchTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_SWITCH_TIMER));
+ fReadTimerText.setText(String.valueOf(IChannelInfo.DEFAULT_READ_TIMER));
+ fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE);
+ if (fKernelButton.getSelection()) {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_KERNEL));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL));
+ } else {
+ fSubBufferSizeText.setText(String.valueOf(IChannelInfo.DEFAULT_SUB_BUFFER_SIZE_UST));
+ fNumberOfSubBuffersText.setText(String.valueOf(IChannelInfo.DEFAULT_NUMBER_OF_SUB_BUFFERS_UST));
+ }
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java
new file mode 100644
index 0000000000..1a3073a8de
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java
@@ -0,0 +1,245 @@
+/**********************************************************************
+ * 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.core.runtime.NullProgressMonitor;
+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.TargetNodeComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * CreateSessionDialog
+ *
+ * Dialog box for collecting session creation information.
+ *
+ */
+public class CreateSessionDialog extends Dialog implements ICreateSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // 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
+ // ------------------------------------------------------------------------
+ /**
+ * The dialog composite.
+ */
+ private Composite fDialogComposite = null;
+ /**
+ * The text widget for the session name
+ */
+ private Text fSessionNameText = null;
+ /**
+ * The text widget for the session path
+ */
+ private Text fSessionPathText = null;
+ /**
+ * The parent where the new node should be added.
+ */
+ private TraceSessionGroup fParent;
+ /**
+ * The session name string.
+ */
+ private String fSessionName = null;
+ /**
+ * The session path string.
+ */
+ private String fSessionPath = null;
+ /**
+ * Flag whether default location (path) shall be used or not
+ */
+ private boolean fIsDefaultPath = true;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param shell - a shell for the display of the dialog
+ * @param parent - trace control parent for validation of session name
+ */
+ public CreateSessionDialog(Shell shell, TraceSessionGroup parent) {
+ super(shell);
+ fParent = parent;
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog#getSessionName()
+ */
+ @Override
+ public String getSessionName() {
+ return fSessionName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog#getSessionPath()
+ */
+ @Override
+ public String getSessionPath() {
+ return fSessionPath;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog#isDefaultSessionPath()
+ */
+ @Override
+ public boolean isDefaultSessionPath() {
+ return fIsDefaultPath;
+ }
+
+ // ------------------------------------------------------------------------
+ // 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_CreateSessionDialogTitle);
+ newShell.setImage(LTTngUiPlugin.getDefault().loadIcon(CREATE_SESSION_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(2, true);
+ fDialogComposite.setLayout(layout);
+
+ Label sessionNameLabel = new Label(fDialogComposite, SWT.RIGHT);
+ sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel);
+ fSessionNameText = new Text(fDialogComposite, SWT.NONE);
+ fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip);
+
+ Label sessionPath = new Label(fDialogComposite, SWT.RIGHT);
+ sessionPath.setText(Messages.TraceControl_CreateSessionPathLabel);
+ fSessionPathText = new Text(fDialogComposite, SWT.NONE);
+ fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip);
+
+ // layout widgets
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ fSessionPathText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fSessionPathText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ data.widthHint = minSize.x + 5;
+
+ fSessionNameText.setLayoutData(data);
+ fSessionPathText.setLayoutData(data);
+
+ fSessionPathText.setText(""); //$NON-NLS-1$
+
+ 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() {
+ // Validate input data
+ fSessionName = fSessionNameText.getText();
+ fSessionPath = fSessionPathText.getText();
+
+ if (!"".equals(fSessionPath)) { //$NON-NLS-1$
+ // validate sessionPath
+
+ TargetNodeComponent node = (TargetNodeComponent)fParent.getParent();
+ IRemoteSystemProxy proxy = node.getRemoteSystemProxy();
+ IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem();
+ if (fsss != null) {
+ try {
+ IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSessionPath, new NullProgressMonitor());
+ if (remoteFolder.exists()) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+ } catch (SystemMessageException e) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_FileSubSystemError + "\n" + e); //$NON-NLS-1$
+ return;
+ }
+ }
+ fIsDefaultPath = false;
+ }
+
+ // If no session name is specified use default name auto
+ if ("".equals(fSessionName)) { //$NON-NLS-1$
+ fSessionName = "auto"; //$NON-NLS-1$
+ }
+
+ // Check for invalid names
+ if (!fSessionName.matches("^[a-zA-Z0-9\\-\\_]{2,}$")) { //$NON-NLS-1$
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // Check if node with name already exists in parent
+ if(fParent.containsChild(fSessionName)) {
+ MessageDialog.openError(getShell(),
+ Messages.TraceControl_CreateSessionDialogTitle,
+ Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ return;
+ }
+
+ // validation successful -> call super.okPressed()
+ super.okPressed();
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java
new file mode 100644
index 0000000000..26cd0ce2b7
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * 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.IChannelInfo;
+
+/**
+ * ICreateChannelDialog
+ *
+ * Interface for the create channel dialog when domain is known.
+ *
+ */
+public interface ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the configuration info for the new channel.
+ */
+ public IChannelInfo getChannelInfo();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java
new file mode 100644
index 0000000000..f8521593b4
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java
@@ -0,0 +1,32 @@
+/**********************************************************************
+ * 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;
+
+
+/**
+ * ICreateChannelOnSessionDialog
+ *
+ * Interface for the create channel dialog when domain is known, i.e. dialog
+ * was opened on session level.
+ *
+ */
+public interface ICreateChannelOnSessionDialog extends ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return true for Kernel domain. False for UST.
+ */
+ public boolean isKernel();
+
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java
new file mode 100644
index 0000000000..eb42ac2af2
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * 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;
+
+/**
+ * ICreateSessionDialog
+ *
+ * Interface for create session dialog.
+ *
+ */
+public interface ICreateSessionDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the session name.
+ */
+ public String getSessionName();
+
+ /**
+ * @return the session path (null for default path)
+ */
+ public String getSessionPath();
+
+ /**
+ * @return true for default location else false
+ */
+ public boolean isDefaultSessionPath();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java
index 5dc342b9a4..acdceac6e4 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java
@@ -23,14 +23,14 @@ public interface INewConnectionDialog {
// Accessors
// ------------------------------------------------------------------------
/**
- * @return returns the node name (alias).
+ * @return the connection name (alias).
*/
- public String getNodeName();
+ public String getConnectionName();
/**
- * @return returns the node address (IP address or DNS name)
+ * @return the host name (IP address or DNS name)
*/
- public String getNodeAddress();
+ public String getHostName();
// ------------------------------------------------------------------------
// Operations
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java
index 035c4153a0..0adec5e0f1 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java
@@ -77,11 +77,11 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
/**
* The text widget for the node name (alias)
*/
- private Text fNodeNameText = null;
+ private Text fConnectionNameText = null;
/**
* The text widget for the node address (IP or DNS name)
*/
- private Text fNodeAddressText = null;
+ private Text fHostNameText = null;
/**
* The parent where the new node should be added.
*/
@@ -89,11 +89,11 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
/**
* The node name (alias) string.
*/
- private String fNodeName = null;
+ private String fConnectionName = null;
/**
* The node address (IP or DNS name) string.
*/
- private String fNodeAddress = null;
+ private String fHostName = null;
/**
* Input list of existing RSE hosts available for selection.
@@ -116,20 +116,20 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
// ------------------------------------------------------------------------
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getNodeName()
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getConnectionName()
*/
@Override
- public String getNodeName() {
- return fNodeName;
+ public String getConnectionName() {
+ return fConnectionName;
}
/*
* (non-Javadoc)
- * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getNodeAddress()
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getHostName()
*/
@Override
- public String getNodeAddress() {
- return fNodeAddress;
+ public String getHostName() {
+ return fHostName;
}
// ------------------------------------------------------------------------
@@ -190,17 +190,17 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
fButton.setText(Messages.TraceControl_NewNodeEditButtonName);
fButton.setEnabled(fExistingHosts.length > 0);
- Label nodeNameLabel = new Label(fTextGroup, SWT.RIGHT);
- nodeNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
- fNodeNameText = new Text(fTextGroup, SWT.NONE);
- fNodeNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
- fNodeNameText.setEnabled(fExistingHosts.length == 0);
+ Label connectionNameLabel = new Label(fTextGroup, SWT.RIGHT);
+ connectionNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
+ fConnectionNameText = new Text(fTextGroup, SWT.NONE);
+ fConnectionNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
+ fConnectionNameText.setEnabled(fExistingHosts.length == 0);
- Label nodeAddressLabel = new Label(fTextGroup, SWT.RIGHT);
- nodeAddressLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
- fNodeAddressText = new Text(fTextGroup, SWT.NONE);
- fNodeAddressText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
- fNodeAddressText.setEnabled(fExistingHosts.length == 0);
+ Label hostNameLabel = new Label(fTextGroup, SWT.RIGHT);
+ hostNameLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
+ fHostNameText = new Text(fTextGroup, SWT.NONE);
+ fHostNameText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
+ fHostNameText.setEnabled(fExistingHosts.length == 0);
fButton.addSelectionListener(new SelectionListener() {
@Override
@@ -208,12 +208,12 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
if (fButton.getSelection()) {
fExistingHostsCombo.deselectAll();
fExistingHostsCombo.setEnabled(false);
- fNodeNameText.setEnabled(true);
- fNodeAddressText.setEnabled(true);
+ fConnectionNameText.setEnabled(true);
+ fHostNameText.setEnabled(true);
} else {
fExistingHostsCombo.setEnabled(true);
- fNodeNameText.setEnabled(false);
- fNodeAddressText.setEnabled(false);
+ fConnectionNameText.setEnabled(false);
+ fHostNameText.setEnabled(false);
}
}
@@ -226,8 +226,8 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
@Override
public void widgetSelected(SelectionEvent e) {
int index = fExistingHostsCombo.getSelectionIndex();
- fNodeNameText.setText(fExistingHosts[index].getAliasName());
- fNodeAddressText.setText(fExistingHosts[index].getHostName());
+ fConnectionNameText.setText(fExistingHosts[index].getAliasName());
+ fHostNameText.setText(fExistingHosts[index].getHostName());
}
@Override
@@ -237,14 +237,14 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
// layout widgets
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fNodeAddressText.setText("666.666.666.666"); //$NON-NLS-1$
- Point minSize = fNodeAddressText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+ fHostNameText.setText("666.666.666.666"); //$NON-NLS-1$
+ Point minSize = fHostNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
data.widthHint = minSize.x + 5;
- fNodeNameText.setLayoutData(data);
- fNodeAddressText.setLayoutData(data);
+ fConnectionNameText.setLayoutData(data);
+ fHostNameText.setLayoutData(data);
- fNodeAddressText.setText(""); //$NON-NLS-1$
+ fHostNameText.setText(""); //$NON-NLS-1$
return fDialogComposite;
}
@@ -265,19 +265,19 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
@Override
protected void okPressed() {
// Validate input data
- fNodeName = fNodeNameText.getText();
- fNodeAddress = fNodeAddressText.getText();
+ fConnectionName = fConnectionNameText.getText();
+ fHostName = fHostNameText.getText();
- if (!"".equals(fNodeAddress)) { //$NON-NLS-1$
+ if (!"".equals(fHostName)) { //$NON-NLS-1$
// If no node name is specified use the node address as name
- if ("".equals(fNodeName)) { //$NON-NLS-1$
- fNodeName = fNodeAddress;
+ if ("".equals(fConnectionName)) { //$NON-NLS-1$
+ fConnectionName = fHostName;
}
// Check if node with name already exists in parent
- if(fParent.containsChild(fNodeName)) {
+ if(fParent.containsChild(fConnectionName)) {
MessageDialog.openError(getShell(),
Messages.TraceControl_NewDialogTitle,
- Messages.TraceControl_AlreadyExistsError + " (" + fNodeName + ")"); //$NON-NLS-1$//$NON-NLS-2$
+ Messages.TraceControl_AlreadyExistsError + " (" + fConnectionName + ")"); //$NON-NLS-1$//$NON-NLS-2$
return;
}
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseNodeHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseNodeHandler.java
index dc95d6b68f..feecfb3f6a 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseNodeHandler.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseNodeHandler.java
@@ -37,17 +37,6 @@ abstract public class BaseNodeHandler extends AbstractHandler {
*/
protected TargetNodeComponent fTargetNode = null;
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- public TargetNodeComponent getTargetNode() {
- return fTargetNode;
- }
-
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -76,7 +65,7 @@ abstract public class BaseNodeHandler extends AbstractHandler {
return false;
}
- // Check if a project is selected
+ // Check if the node component is selected
ISelection selection = page.getSelection(ControlView.ID);
if (selection instanceof StructuredSelection) {
Object element = ((StructuredSelection) selection).getFirstElement();
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
new file mode 100644
index 0000000000..25bc1760cb
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
@@ -0,0 +1,236 @@
+/**********************************************************************
+ * 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.TraceDomainComponent;
+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 ChangeChannelStateHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * Kernel domain component reference.
+ */
+ protected TraceDomainComponent fKernelDomain = null;
+ /**
+ * UST domain component reference.
+ */
+ protected TraceDomainComponent fUstDomain = null;
+ /**
+ * The list of kernel channel components the command is to be executed on.
+ */
+ protected List fKernelChannels = new ArrayList();
+ /**
+ * The list of USTl channel components the command is to be executed on.
+ */
+ protected List fUstChannels = new ArrayList();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the new state to set
+ */
+ abstract protected TraceEnablement getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the new state to set
+ */
+ abstract protected void changeState(TraceDomainComponent domain, List channelNames, 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_EnableChannelJob) { // TODO
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String errorString = null;
+
+ TraceSessionComponent session = null;
+
+ try {
+ if (fKernelDomain != null) {
+ session = (TraceSessionComponent)fKernelDomain.getParent();
+ List channelNames = new ArrayList();
+ for (Iterator iterator = fKernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(fKernelDomain, channelNames, monitor);
+
+ for (Iterator iterator = fKernelChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channel.setState(getNewState());
+ }
+ }
+
+ if (fUstDomain != null) {
+ if (session == null) {
+ session = (TraceSessionComponent)fUstDomain.getParent();
+ }
+
+ List channelNames = new ArrayList();
+ for (Iterator iterator = fUstChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) iterator.next();
+ channelNames.add(channel.getName());
+ }
+
+ changeState(fUstDomain, channelNames, monitor);
+
+ for (Iterator iterator = fUstChannels.iterator(); iterator.hasNext();) {
+ // Enable all selected channels which are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) 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;
+ for (Iterator> iterator = structered.iterator(); iterator.hasNext();) {
+ Object element = (Object) iterator.next();
+
+ if (element instanceof TraceChannelComponent) {
+
+ // Add only TraceChannelComponents that are disabled
+ TraceChannelComponent channel = (TraceChannelComponent) element;
+ if (sessionName == null) {
+ sessionName = String.valueOf(channel.getSessionName());
+ }
+
+ // Enable command only for channels of same session
+ if (!sessionName.equals(channel.getSessionName())) {
+ reset();
+ break;
+ }
+
+ if ((channel.getState() != getNewState())) {
+ if (channel.isKernel()) {
+ fKernelChannels.add(channel);
+ if (fKernelDomain == null) {
+ fKernelDomain = (TraceDomainComponent) channel.getParent();
+ }
+ } else {
+ fUstChannels.add(channel);
+ if (fUstDomain == null) {
+ fUstDomain = (TraceDomainComponent) channel.getParent();
+ }
+ }
+ }
+ }
+ }
+ }
+ return fKernelChannels.size() + fUstChannels.size() > 0;
+ }
+
+ /**
+ * Reset members
+ */
+ private void reset() {
+ fKernelDomain = null;
+ fUstDomain = null;
+ fKernelChannels.clear();
+ fUstChannels.clear();
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java
new file mode 100644
index 0000000000..08f28df4a6
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java
@@ -0,0 +1,153 @@
+/**********************************************************************
+ * 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.TraceSessionState;
+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;
+
+/**
+ * ChangeSessionStateHandler
+ *
+ * Abstract command handler implementation to start or stop one or more trace sessions.
+ *
+ */
+abstract public class ChangeSessionStateHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ protected List fSessions = new ArrayList();
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return new required state.
+ */
+ abstract TraceSessionState getNewState();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Performs the state change on given session.
+ * @param session - a session which state is to be changed
+ * @param monitor - a progress monitor
+ */
+ abstract public void changeState(TraceSessionComponent session, 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_StartSessionJob) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ for (Iterator iterator = fSessions.iterator(); iterator.hasNext();) {
+
+ // Start all selected sessions
+ TraceSessionComponent session = (TraceSessionComponent) iterator.next();
+ changeState(session, monitor);
+
+ // Set Session state
+ session.setSessionState(getNewState());
+ session.fireComponentChanged(session);
+ }
+ } catch (ExecutionException e) {
+ return new Status(Status.ERROR, LTTngUiPlugin.PLUGIN_ID, e.toString());
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fSessions.clear();
+
+ // 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 TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() != getNewState()) && (!session.isDestroyed())) {
+ fSessions.add((TraceSessionComponent)element);
+ }
+ }
+ }
+ }
+ return fSessions.size() > 0;
+ }
+}
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
new file mode 100644
index 0000000000..e66d1d069c
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
@@ -0,0 +1,159 @@
+/**********************************************************************
+ * 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.CreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+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.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * CreateChannelOnDomainHandler
+ *
+ * Command handler implementation to create a trace channel for known domain.
+ *
+ */
+public class CreateChannelOnDomainHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The the domain component the command is to be executed on.
+ */
+ private TraceDomainComponent fDomain;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (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;
+ }
+
+ // 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$
+ }
+
+ // 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$
+ }
+
+ 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() {
+ fDomain = 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 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 domain = (TraceDomainComponent) element;
+ TraceSessionComponent session = (TraceSessionComponent) domain.getParent();
+ // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fDomain = domain;
+ }
+ }
+ }
+ }
+ return fDomain != 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
new file mode 100644
index 0000000000..fd0262f796
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
@@ -0,0 +1,160 @@
+/**********************************************************************
+ * 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.CreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+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.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * CreateChannelOnSessionHandler
+ *
+ * Command handler implementation to create a trace channel for unknown domain
+ * (on session level).
+ *
+ */
+public class CreateChannelOnSessionHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The session component the command is to be executed on.
+ */
+ private TraceSessionComponent fSession = null;
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (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;
+ }
+
+ 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$
+ }
+
+ // 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$
+ }
+
+ 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() {
+ fSession = 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 session 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 TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fSession = session;
+ }
+ }
+ }
+ }
+ return fSession != 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
new file mode 100644
index 0000000000..e4347d95d9
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
@@ -0,0 +1,123 @@
+/**********************************************************************
+ * 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 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.CreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * CreateSessionHandler
+ *
+ * Command handler implementation to create a trace session.
+ *
+ */
+public class CreateSessionHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The trace session group the command is to be executed on.
+ */
+ private TraceSessionGroup fSessionGroup = 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 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();
+ }
+
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fSessionGroup = 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 the session group project is selected
+ ISelection selection = page.getSelection(ControlView.ID);
+ if (selection instanceof StructuredSelection) {
+ Object element = ((StructuredSelection) selection).getFirstElement();
+ fSessionGroup = (element instanceof TraceSessionGroup) ? (TraceSessionGroup) element : null;
+ }
+ return fSessionGroup != 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
new file mode 100644
index 0000000000..62e04a4558
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
@@ -0,0 +1,139 @@
+/**********************************************************************
+ * 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.dialogs.MessageDialog;
+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.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * DestroySessionHandler
+ *
+ * Command handler implementation to destroy one or more trace sessions.
+ *
+ */
+public class DestroySessionHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ private List fSessions = new ArrayList();
+
+ // ------------------------------------------------------------------------
+ // 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;
+ }
+ // Get user confirmation
+ 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;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ fSessions.clear();
+
+ // 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 TraceSessionComponent) {
+ // Add only TraceSessionComponents that are inactive and not destroyed
+ TraceSessionComponent session = (TraceSessionComponent) element;
+ if ((session.getSessionState() == TraceSessionState.INACTIVE) && (!session.isDestroyed())) {
+ fSessions.add((TraceSessionComponent)element);
+ }
+ }
+ }
+ }
+ return fSessions.size() > 0;
+ }
+}
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
new file mode 100644
index 0000000000..1102844fc8
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.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.TraceDomainComponent;
+
+/**
+ * DisableChannelHandler
+ *
+ * Command handler implementation to enable a trace channel.
+ *
+ */
+public class DisableChannelHandler extends ChangeChannelStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.DISABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceDomainComponent domain, List channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.disableChannels(channelNames, 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
new file mode 100644
index 0000000000..1264f910f0
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.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.TraceDomainComponent;
+
+/**
+ * EnableChannelHandler
+ *
+ * Command handler implementation to enable a trace channel.
+ *
+ */
+public class EnableChannelHandler extends ChangeChannelStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#getNewState()
+ */
+ @Override
+ protected TraceEnablement getNewState() {
+ return TraceEnablement.ENABLED;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseChangeChannelStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void changeState(TraceDomainComponent domain, List channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.enableChannels(channelNames, null, 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 5e96e5f5ac..c3bf8fdd58 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
@@ -81,8 +81,8 @@ public class NewConnectionHandler extends AbstractHandler {
if (dialog.open() == Window.OK) {
- String hostName = dialog.getNodeName();
- String hostAddress = dialog.getNodeAddress();
+ String hostName = dialog.getConnectionName();
+ String hostAddress = dialog.getHostName();
// get the singleton RSE registry
IHost host = null;
@@ -97,7 +97,6 @@ public class NewConnectionHandler extends AbstractHandler {
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
@@ -145,7 +144,7 @@ public class NewConnectionHandler extends AbstractHandler {
return false;
}
- // Check if we are in the Project View
+ // Check if we are in the Control View
IWorkbenchPage page = window.getActivePage();
if (page == null) return false;
IWorkbenchPart part = page.getActivePart();
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java
new file mode 100644
index 0000000000..96d1869a32
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * 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 org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * StartHandler
+ *
+ * Command handler implementation to start one or more trace sessions.
+ *
+ */
+public class StartHandler extends ChangeSessionStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
+ */
+ @Override
+ public TraceSessionState getNewState() {
+ return TraceSessionState.ACTIVE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ session.startSession(monitor);
+ }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java
new file mode 100644
index 0000000000..de60178b2d
--- /dev/null
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * 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 org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * StopHandler
+ *
+ * Command handler implementation to stop one or more trace sessions.
+ *
+ */
+public class StopHandler extends ChangeSessionStateHandler {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeSessionStateHandler#getNewState()
+ */
+ @Override
+ public TraceSessionState getNewState() {
+ return TraceSessionState.INACTIVE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.ChangeSessionStateHandler#changeState(org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
+ session.stopSession(monitor);
+ }
+}
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 9ff24f5087..be504a99b3 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
@@ -5,14 +5,30 @@ TraceControl_ExecutionFailure=Command Execution failed
TraceControl_ExecutionTimeout=Command Execution timed-out
TraceControl_ShellNotConnected=Command shell not connected
TraceControl_CommandShellError=Could not create HostShellProcessAdapter
-TraceControl_CommandError=Command failed! Command:
+TraceControl_CommandError=Command failed! Command:
+TraceControl_UnexpectedCommnadOutputFormat=Unexpected command output
+TraceControl_UnexpectedNameError=Unexpected session name returned
+TraceControl_UnexpectedPathError=Unexpected session path returned
# Commands
TraceControl_ListSessionFailure=List sessions failed
-TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration ...
+TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration...
TraceControl_EclipseCommandFailure=Command failed
TraceControl_NewNodeCreationFailure=Creation of new connection failed
+TraceControl_CreateSessionJob=Creating Session...
+
+TraceControl_DestroySessionJob=Destroying Session...
+TraceControl_DestroyConfirmationTitle=Destroy Confirmation
+TraceControl_DestroyConfirmationMessage=Do you want to delete all selected sessions?
+
+TraceControl_StartSessionJob=Starting Session...
+TraceControl_StopSessionJob=Stopping Session...
+TraceControl_EnableChannelJob=Enabling Channels...
+TraceControl_EnableChannelDialogTitle=Enable Channel
+TraceControl_DisableChannelJob=Disabling Channels...
+
+
# Dialogs
TraceControl_NewDialogTitle=New Connection
@@ -25,9 +41,34 @@ TraceControl_NewNodeHostNameLabel=Host Name
TraceControl_NewNodeHostNameTooltip=IP Address or DNS name of node to connect to.
TraceControl_AlreadyExistsError=Node name already exists in Control View
+TraceControl_CreateSessionDialogTitle=Create Session
+TraceControl_CreateSessionNameLabel=Session Name
+TraceControl_CreateSessionNameTooltip=The name of the session to be created.
+TraceControl_CreateSessionPathLabel=Session Path
+TraceControl_CreateSessionPathTooltip=The session path (keep empty for default location)
+TraceControl_InvalidSessionNameError=The session name is invalid
+TraceControl_SessionAlreadyExistsError=The session name already exists
+TraceControl_SessionPathAlreadyExistsError=Session path already exists
+TraceControl_InvalidSessionPathError=The session path is invalid
+TraceControl_FileSubSystemError=File subsystem error in session creation dialog.
+
+TraceControl_EnableChannelDialogTitle=Enable Channel
+TraceControl_EnableChannelNameLabel=Channel Name
+TraceControl_EnableChannelNameLabelTooltip=The name of the channel to be enabled.
+TraceControl_EnableChannelSubBufferSizeTooltip=The sub-buffers size of the channel.
+TraceControl_EnableChannelNbSubBuffersTooltip=The number of sub-buffers of the channel.
+TraceControl_EnableChannelSwitchTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelReadTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelOutputTypeTooltip=The output type of the channel.
+TraceControl_EnableChannelOverwriteModeTooltip=Select for overwrite mode (Flight recorder mode).
+
+TraceControl_InvalidChannelNameError=The channel name is invalid or empty
+TraceControl_ChannelAlreadyExistsError=Channel already exists
+
# Tree structure strings
TraceControl_KernelDomainDisplayName=Kernel
TraceControl_UstGlobalDomainDisplayName=UST global
+TraceControl_UstDisplayName=UST
TraceControl_AllSessionsDisplayName=Sessions
TraceControl_SessionDisplayName=Session
TraceControl_DomainDisplayName=Domain
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IChannelInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IChannelInfo.java
index 7de4092a34..9d7d37ba1a 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IChannelInfo.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IChannelInfo.java
@@ -21,6 +21,38 @@ import java.util.List;
*/
public interface IChannelInfo extends ITraceInfo {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ /**
+ * Default value for overwrite mode.
+ */
+ public final static boolean DEFAULT_OVERWRITE_MODE = false;
+ /**
+ * Default value for sub-buffer size for a UST channel.
+ */
+ public final static long DEFAULT_SUB_BUFFER_SIZE_UST = 4096L;
+ /**
+ * Default value for sub-buffer size for a Kernel channel.
+ */
+ public final static long DEFAULT_SUB_BUFFER_SIZE_KERNEL = 262144L;
+ /**
+ * Default value for number of sub-buffer a UST channel.
+ */
+ public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_UST = 8;
+ /**
+ * Default value for number of sub-buffer a Kernel channel.
+ */
+ public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL = 4;
+ /**
+ * Default value for number of the switch timer interval.
+ */
+ public final static long DEFAULT_SWITCH_TIMER = 0;
+ /**
+ * Default value for number of the read timer interval.
+ */
+ public final static long DEFAULT_READ_TIMER = 200;
+
/**
* @return the overwrite mode value.
*/
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IDomainInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IDomainInfo.java
index 9056c57963..e7e20d7c1c 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IDomainInfo.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IDomainInfo.java
@@ -38,5 +38,17 @@ public interface IDomainInfo extends ITraceInfo {
* @param channel - channel information to add.
*/
public void addChannel(IChannelInfo channel);
+
+ /**
+ * @return true if domain is kernel, false for UST
+ */
+ public boolean isKernel();
+
+ /**
+ * Sets whether domain is Kernel domain or UST
+ * @param isKernel true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel);
+
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java
index 1269b85ff5..95c1d26366 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java
@@ -34,6 +34,7 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
* The channels information of the domain.
*/
private List fChannels = new ArrayList();
+ private boolean fIsKernel = false;
// ------------------------------------------------------------------------
// Constructors
@@ -59,6 +60,25 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
fChannels.add(other.fChannels.get(i));
}
}
+ fIsKernel = other.fIsKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#isKernel()
+ */
+ @Override
+ public boolean isKernel() {
+ return fIsKernel;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
+ */
+ @Override
+ public void setIsKernel(boolean isKernel) {
+ fIsKernel = isKernel;
}
// ------------------------------------------------------------------------
@@ -106,6 +126,7 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
IChannelInfo channel = (IChannelInfo) iterator.next();
result = 37 * result + channel.hashCode();
}
+ result += 37 * result + (fIsKernel ? 1 : 0);
return result;
}
@@ -132,6 +153,10 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
return false;
}
}
+
+ if (fIsKernel != otherInfo.fIsKernel) {
+ return false;
+ }
return true;
}
@@ -154,6 +179,8 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
output.append(channel.toString());
}
}
+ output.append(",isKernel=");
+ output.append(String.valueOf(fIsKernel));
output.append(")]");
return output.toString();
}
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 650d6fa4ae..5ef8b96279 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
@@ -175,10 +175,20 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu
return null;
}
+ /**
+ * @return remote host name
+ */
public String getHostName() {
return fHost.getHostName();
}
+ /**
+ * @return remote system proxy implementation
+ */
+ public IRemoteSystemProxy getRemoteSystemProxy() {
+ return fRemoteProxy;
+ }
+
// ------------------------------------------------------------------------
// 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 f443d28d66..00311b745c 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
@@ -208,7 +208,20 @@ public class TraceChannelComponent extends TraceControlComponent {
}
return null;
}
-
+
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceDomainComponent)getParent()).getSessionName();
+ }
+
+ /**
+ * @return if domain is kernel or UST
+ */
+ public boolean isKernel() {
+ return ((TraceDomainComponent)getParent()).isKernel();
+ }
// ------------------------------------------------------------------------
// 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 ec1febbde5..8d88a69b23 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
@@ -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.views.control.Messages;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
@@ -39,7 +44,7 @@ public class TraceDomainComponent extends TraceControlComponent {
/**
* The domain information.
*/
- private IDomainInfo fDomainInfo = null;
+ private IDomainInfo fDomainInfo = null;
// ------------------------------------------------------------------------
// Constructors
@@ -84,8 +89,87 @@ public class TraceDomainComponent extends TraceControlComponent {
return new TraceDomainPropertySource(this);
}
return null;
- }
+ }
+
+ /**
+ * @return session name from parent
+ */
+ public String getSessionName() {
+ return ((TraceSessionComponent)getParent()).getName();
+ }
+
+ /**
+ * @return true if domain is kernel, false for UST
+ */
+ public boolean isKernel() {
+ return fDomainInfo.isKernel();
+ }
+
+ /**
+ * Sets whether domain is Kernel domain or UST
+ * @param isKernel true for kernel, false for UST
+ */
+ public void setIsKernel(boolean isKernel) {
+ fDomainInfo.setIsKernel(isKernel);
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
+ /**
+ * Retrieves the session configuration from the node.
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode() throws ExecutionException {
+ getConfigurationFromNode(new NullProgressMonitor());
+ }
+ /**
+ * Retrieves the session configuration from the node.
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+ TraceSessionComponent session = (TraceSessionComponent) getParent();
+ session.getConfigurationFromNode(monitor);
+ }
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @throws ExecutionException
+ */
+ public void enableChannels(List channelNames, IChannelInfo info) throws ExecutionException {
+ enableChannels(channelNames, info, new NullProgressMonitor());
+ }
+ /**
+ * Enables channels with given names which are part of this domain. If a given channel
+ * doesn't exists it creates a new channel with the given parameters (or default values
+ * if given parameter is null).
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param info - channel information to set for the channel (use null for default)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableChannels(List channelNames, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().enableChannel(getParent().getName(), channelNames, isKernel(), info, monitor);
+ }
+ /**
+ * Disables channels with given names which are part of this domain.
+ * @param channelNames - a list of channel names to enable on this domain
+ * @throws ExecutionException
+ */
+ public void disableChannels(List channelNames) throws ExecutionException {
+ disableChannels(channelNames, new NullProgressMonitor());
+ }
+ /**
+ * Disables channels with given names which are part of this domain.
+ * @param channelNames - a list of channel names to enable on this domain
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableChannels(List channelNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().disableChannel(getParent().getName(), channelNames, isKernel(), monitor);
+ }
}
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 b7c29acaaf..4bcc4635d3 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
@@ -105,14 +105,13 @@ public class TraceSessionComponent extends TraceControlComponent {
return fActiveImage;
}
-
/**
* @return the whether the session is destroyed or not.
*/
public boolean isDestroyed() {
return fIsDestroyed;
}
-
+
/**
* Sets the session destroyed state to the given value.
* @param destroyed - value to set.
@@ -120,7 +119,7 @@ public class TraceSessionComponent extends TraceControlComponent {
public void setDestroyed(boolean destroyed) {
fIsDestroyed = destroyed;
}
-
+
/**
* @return the session state state (active or inactive).
*/
@@ -135,7 +134,7 @@ public class TraceSessionComponent extends TraceControlComponent {
public void setSessionState(TraceSessionState state) {
fSessionInfo.setSessionState(state);
}
-
+
/**
* Sets the event state to the value specified by the given name.
* @param stateName - state to set.
@@ -171,7 +170,7 @@ public class TraceSessionComponent extends TraceControlComponent {
}
return null;
}
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -189,12 +188,48 @@ public class TraceSessionComponent extends TraceControlComponent {
* @throws ExecutionException
*/
public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+ removeAllChildren();
fSessionInfo = getControlService().getSession(getName(), monitor);
IDomainInfo[] domains = fSessionInfo.getDomains();
for (int i = 0; i < domains.length; i++) {
- TraceDomainComponent domainComponenent = new TraceDomainComponent(domains[i].getName(), this);
- addChild(domainComponenent);
- domainComponenent.setDomainInfo(domains[i]);
+ TraceDomainComponent domainComponent = new TraceDomainComponent(domains[i].getName(), this);
+ addChild(domainComponent);
+ domainComponent.setDomainInfo(domains[i]);
}
}
+
+ /**
+ * Starts the session.
+ * throws ExecutionExecption
+ */
+ public void startSession() throws ExecutionException {
+ startSession(new NullProgressMonitor());
+ }
+
+ /**
+ * Starts the session.
+ * @param monitor - a progress monitor
+ * throws ExecutionExecption
+ */
+ public void startSession(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().startSession(getName(), monitor);
+ }
+
+ /**
+ * Starts the session.
+ * throws ExecutionExecption
+ */
+ public void stopSession() throws ExecutionException {
+ startSession(new NullProgressMonitor());
+ }
+
+ /**
+ * Starts the session.
+ * @param monitor - a progress monitor
+ * throws ExecutionExecption
+ */
+ public void stopSession(IProgressMonitor monitor) throws ExecutionException {
+ getControlService().stopSession(getName(), 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 105f76a738..e8ba692335 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
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
/**
@@ -47,7 +48,7 @@ public class TraceSessionGroup extends TraceControlComponent {
super(name, parent);
setImage(TRACE_SESSIONS_ICON_FILE);
}
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
@@ -76,4 +77,54 @@ public class TraceSessionGroup extends TraceControlComponent {
session.getConfigurationFromNode(monitor);
}
}
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @return the session information
+ * throws ExecutionExecption
+ */
+ public void createSession(final String sessionName, final String sessionPath) throws ExecutionException {
+ createSession(sessionName, sessionPath, new NullProgressMonitor());
+ }
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @Param monitor - a progress monitor
+ * @return the session information
+ * throws ExecutionExecption
+ */
+ public void createSession(final String sessionName, final String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+ ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
+ if (sessionInfo != null) {
+ TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
+ addChild(session);
+ session.getConfigurationFromNode(monitor);
+ }
+ }
+
+ /**
+ * Destroys a session with given session name.
+ * @param sessionName - a session name to destroy
+ * throws ExecutionExecption
+ */
+ public void destroySession(final String sessionName) throws ExecutionException {
+ destroySession(sessionName, new NullProgressMonitor());
+ }
+
+ /**
+ * Destroys a session with given session name.
+ * @param sessionName - a session name 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);
+ session.removeAllChildren();
+ removeChild(session);
+ }
}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/IRemoteSystemProxy.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/IRemoteSystemProxy.java
index 97e941e38e..ef2849d98c 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/IRemoteSystemProxy.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/IRemoteSystemProxy.java
@@ -18,6 +18,7 @@ import org.eclipse.rse.core.subsystems.ICommunicationsListener;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.shells.IShellService;
import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
/**
* IRemoteSystemProxy
@@ -31,34 +32,40 @@ public interface IRemoteSystemProxy {
// Operations
// ------------------------------------------------------------------------
/**
- * Find the first shell service associated with the host.
+ * Find the first shell service.
*
* @return shell service object, or null
if not found.
*/
public IShellService getShellService();
/**
- * Find the first terminal service associated with the host.
+ * Find the first terminal service.
*
* @return shell service object, or null
if not found.
*/
public ITerminalService getTerminalService();
/**
- * Find the first IShellServiceSubSystem service associated with the host.
+ * Find the first IShellServiceSubSystem service.
*
* @return shell service subsystem, or null
if not found.
*/
public ISubSystem getShellServiceSubSystem();
/**
- * Find the first ITerminalServiceSubSystem service associated with the host.
+ * Find the first ITerminalServiceSubSystem service.
*
* @param host the connection
* @return shell service subsystem, or null
if not found.
*/
public ISubSystem getTerminalServiceSubSystem();
-
+
+ /**
+ * Finds the File Service Subsystem.
+ * @return file service subsystem, or null
if not found.
+ */
+ public IFileServiceSubSystem getFileServiceSubSystem();
+
/**
* Connects the shell service sub system.
*
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/RemoteSystemProxy.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/RemoteSystemProxy.java
index 9d47cbfe89..882c7a8221 100644
--- a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/RemoteSystemProxy.java
+++ b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/RemoteSystemProxy.java
@@ -23,6 +23,7 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.IService;
import org.eclipse.rse.services.shells.IShellService;
import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
/**
* RemoteSystemProxy
@@ -36,7 +37,7 @@ public class RemoteSystemProxy implements IRemoteSystemProxy {
// Attributes
// ------------------------------------------------------------------------
private IHost fHost;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@@ -115,7 +116,24 @@ public class RemoteSystemProxy implements IRemoteSystemProxy {
return null;
}
-
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
+ */
+ @Override
+ public IFileServiceSubSystem getFileServiceSubSystem() {
+ if (fHost == null) {
+ return null;
+ }
+ ISubSystem[] subSystems = fHost.getSubSystems();
+ for (int i = 0; subSystems != null && i < subSystems.length; i++) {
+ if (subSystems[i] instanceof IFileServiceSubSystem) {
+ return (IFileServiceSubSystem)subSystems[i];
+ }
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.linuxtools.lttng.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
*/
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 572c357434..8d1cc48bed 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
@@ -16,6 +16,7 @@ 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.IBaseEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
@@ -26,12 +27,6 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
*
*/
public interface ILttngControlService {
- /**
- * Retrieves the existing sessions names from the node.
- * @return an array with session names.
- * @throws ExecutionException
- */
- public String[] getSessionNames() throws ExecutionException;
/**
* Retrieves the existing sessions names from the node.
* @param monitor - a progress monitor
@@ -40,14 +35,6 @@ public interface ILttngControlService {
*/
public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException;
- /**
- * Retrieves the session information with the given name the node.
- * @param sessionName - the session name
- * @return session information
- * @throws ExecutionException
- */
- public ISessionInfo getSession(String sessionName) throws ExecutionException;
-
/**
* Retrieves the session information with the given name the node.
* @param sessionName - the session name
@@ -57,12 +44,6 @@ public interface ILttngControlService {
*/
public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
- /**
- * Retrieves the kernel provider information (i.e. the kernel events)
- * @return the list of existing kernel events.
- * @throws ExecutionException
- */
- public List getKernelProvider() throws ExecutionException;
/**
* Retrieves the kernel provider information (i.e. the kernel events)
* @param monitor - a progress monitor
@@ -80,8 +61,65 @@ public interface ILttngControlService {
/**
* Retrieves the UST provider information from the node.
* @param monitor - a progress monitor
- * @return - the UST provider information.
+ * @return the UST provider information.
* @throws ExecutionException
*/
public List getUstProvider(IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Creates a session with given session name and location.
+ * @param sessionName - a session name to create
+ * @param sessionPath - a path for storing the traces (use null for default)
+ * @param monitor - a progress monitor
+ * @return the session information
+ * @throws ExecutionException
+ */
+ public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Destroys a session with given session name.
+ * @param sessionName - a session name to destroy
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Starts a session with given session name.
+ * @param sessionName - a session name to start
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Stops a session with given session name.
+ * @param sessionName - a session name to stop
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
+
+
+ /**
+ * Enables a list of channels for given session and given channel information (configuration).
+ * @param sessionName - a session name to create
+ * @param channelNames - a list of channel names to enable
+ * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
+ * @param info - channel information used for creation of a channel (or null for default)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void enableChannel(String sessionName, List channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException;
+
+ /**
+ * Disables a list of channels for given session and given channel information (configuration).
+ * @param sessionName - a session name to create
+ * @param channelNames - a list of channel names to enable
+ * @param isKernel - a flag to indicate Kernel or UST (true for Kernel, false for UST)
+ * @param monitor - a progress monitor
+ * @throws ExecutionException
+ */
+ public void disableChannel(String sessionName, List channelNames, 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 f26912f4bf..34fc55189f 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
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.lttng.ui.views.control.service;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -60,7 +61,31 @@ public class LTTngControlService implements ILttngControlService {
/**
* Command to list user space trace information.
*/
- private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u"; //$NON-NLS-1$
+ private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u"; //$NON-NLS-1$
+ /**
+ * Command to create a session.
+ */
+ private final static String COMMAND_CREATE_SESSION = CONTROL_COMMAND + " create "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_DESTROY_SESSION = CONTROL_COMMAND + " destroy "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_START_SESSION = CONTROL_COMMAND + " start "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_STOP_SESSION = CONTROL_COMMAND + " stop "; //$NON-NLS-1$
+ /**
+ * Command to enable a channel.
+ */
+ private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
+ /**
+ * Command to destroy a session.
+ */
+ private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
// Parsing constants
/**
@@ -154,7 +179,19 @@ public class LTTngControlService implements ILttngControlService {
* Pattern to match for UST provider information (lttng list -u)
*/
private final static Pattern UST_PROVIDER_PATTERN = Pattern.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
-
+ /**
+ * Pattern to match for session information (lttng create )
+ */
+ private final static Pattern CREATE_SESSION_NAME_PATTERN = Pattern.compile("\\s*Session\\s+(.*)\\s+created\\."); //$NON-NLS-1$
+ /**
+ * Pattern to match for session path information (lttng create )
+ */
+ private final static Pattern CREATE_SESSION_PATH_PATTERN = Pattern.compile("\\s*Traces\\s+will\\s+be\\s+written\\s+in\\s+(.*).*"); //$NON-NLS-1$
+ /**
+ * 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$
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
@@ -181,18 +218,6 @@ public class LTTngControlService implements ILttngControlService {
// Operations
// ------------------------------------------------------------------------
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
- * #getSessionNames()
- */
- @Override
- public String[] getSessionNames() throws ExecutionException {
- return getSessionNames(new NullProgressMonitor());
- }
-
/*
* (non-Javadoc)
*
@@ -232,18 +257,6 @@ public class LTTngControlService implements ILttngControlService {
return retArray.toArray(new String[retArray.size()]);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
- * #getSession(java.lang.String)
- */
- @Override
- public ISessionInfo getSession(String sessionName) throws ExecutionException {
- return getSession(sessionName, new NullProgressMonitor());
- }
-
/*
* (non-Javadoc)
*
@@ -300,6 +313,9 @@ public class LTTngControlService implements ILttngControlService {
// set channels
domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(true);
continue;
}
@@ -308,12 +324,15 @@ public class LTTngControlService implements ILttngControlService {
IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
sessionInfo.addDomain(domainInfo);
- // in domain kernel
+ // in domain UST
ArrayList channels = new ArrayList();
index = parseDomain(result.getOutput(), index, channels);
// set channels
domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(false);
continue;
}
index++;
@@ -321,18 +340,6 @@ public class LTTngControlService implements ILttngControlService {
return sessionInfo;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
- * #getKernelProvider()
- */
- @Override
- public List getKernelProvider() throws ExecutionException {
- return getKernelProvider(new NullProgressMonitor());
- }
-
/*
* (non-Javadoc)
*
@@ -423,6 +430,236 @@ public class LTTngControlService implements ILttngControlService {
return allProviders;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+
+ String newName = formatParameter(sessionName);
+ String newPath = formatParameter(sessionPath);
+
+ String command = COMMAND_CREATE_SESSION + newName;
+ if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
+ command += " -o " + newPath; //$NON-NLS-1$
+ }
+
+ 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$
+ }
+ //Session myssession2 created.
+ //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
+ String[] output = result.getOutput();
+
+ // Get and verify session name
+ Matcher matcher = CREATE_SESSION_NAME_PATTERN.matcher(output[0]);
+ String name = null;
+
+ if (matcher.matches()) {
+ name = String.valueOf(matcher.group(1).trim());
+ } else {
+ // Output format not expected
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
+ formatOutput(result.getOutput()));
+ }
+
+ if ((name == null) || (!name.equals(sessionName))) {
+ // Unexpected name returned
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$
+ }
+
+ // Get and verify session path
+ matcher = CREATE_SESSION_PATH_PATTERN.matcher(output[1]);
+ String path = null;
+
+ if (matcher.matches()) {
+ path = String.valueOf(matcher.group(1).trim());
+ } else {
+ // Output format not expected
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$
+ formatOutput(result.getOutput()));
+ }
+
+ if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
+ // Unexpected path
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
+ }
+
+ SessionInfo sessionInfo = new SessionInfo(name);
+ sessionInfo.setSessionPath(path);
+
+ return sessionInfo;
+ }
+
+ @Override
+ public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+ String newName = formatParameter(sessionName);
+ String command = COMMAND_DESTROY_SESSION + newName;
+
+ ICommandResult result = fCommandShell.executeCommand(command, monitor);
+ String[] output = result.getOutput();
+
+ if (isError(result)) {
+ // In case "session not found" treat it as success
+ if ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches())) {
+ throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ //Session destroyed
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#startSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void startSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+
+ String newSessionName = formatParameter(sessionName);
+
+ String command = COMMAND_START_SESSION + newSessionName;
+
+ 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$
+ }
+ //Session started
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#stopSession(java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void stopSession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+ String newSessionName = formatParameter(sessionName);
+ String command = COMMAND_STOP_SESSION + newSessionName;
+
+ 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$
+ }
+ //Session stopped
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#enableChannel(java.lang.String, java.util.List, boolean, org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void enableChannel(String sessionName, List channelNames, boolean isKernel, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException {
+
+ // no channels to enable
+ if (channelNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_ENABLE_CHANNEL);
+
+ for (Iterator iterator = channelNames.iterator(); iterator.hasNext();) {
+ String channel = (String) iterator.next();
+ command.append(channel);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(" -k ");
+ } else {
+ command.append(" -u ");
+ }
+
+ command.append(" -s "); //$NON-NLS-1$
+ 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 ");
+ }
+// --subbuf-size SIZE Subbuffer size in bytes
+// (default: 4096, kernel default: 262144)
+ command.append(" --subbuf-size ");
+ command.append(String.valueOf(info.getSubBufferSize()));
+
+// --num-subbuf NUM Number of subbufers
+// (default: 8, kernel default: 4)
+ command.append(" --num-subbuf ");
+ command.append(String.valueOf(info.getNumberOfSubBuffers()));
+
+// --switch-timer USEC Switch timer interval in usec (default: 0)
+ command.append(" --switch-timer ");
+ command.append(String.valueOf(info.getSwitchTimer()));
+
+// --read-timer USEC Read timer interval in usec (default: 200)
+ command.append(" --read-timer ");
+ command.append(String.valueOf(info.getReadTimer()));
+ }
+
+ 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#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{
+
+ // no channels to enable
+ if (channelNames.size() == 0) {
+ return;
+ }
+
+ String newSessionName = formatParameter(sessionName);
+
+ StringBuffer command = new StringBuffer(COMMAND_DISABLE_CHANNEL);
+
+ for (Iterator iterator = channelNames.iterator(); iterator.hasNext();) {
+ String channel = (String) iterator.next();
+ command.append(channel);
+ if (iterator.hasNext()) {
+ command.append(","); //$NON-NLS-1$
+ }
+ }
+
+ if (isKernel) {
+ command.append(" -k ");
+ } else {
+ command.append(" -u ");
+ }
+
+ command.append(" -s "); //$NON-NLS-1$
+ 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$
+ }
+ }
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
@@ -640,4 +877,22 @@ public class LTTngControlService implements ILttngControlService {
return index;
}
+ /**
+ * Formats a command parameter for the command execution i.e. adds quotes
+ * at the beginning and end if necessary.
+ * @param parameter - parameter to format
+ * @return formated parameter
+ */
+ private String formatParameter(String parameter) {
+ if (parameter != null) {
+ String newString = String.valueOf(parameter);
+
+ if (parameter.contains(" ")) { //$NON-NLS-1$
+ newString = "\"" + newString + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return newString;
+ }
+ return null;
+ }
+
}
--
2.34.1