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
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;
public void testGetSessionNames() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForLttngNotExistsShell());
- service.getSessionNames();
+ service.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
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);
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);
public void testGetSessionNotExist() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNotExists());
- service.getSessionNames();
+ service.getSessionNames(new NullProgressMonitor());
fail("No exeption thrown");
} catch (ExecutionException e) {
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);
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);
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());
public void testGetKernelProvider() {
try {
ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
- List<IBaseEventInfo> events = service.getKernelProvider();
+ List<IBaseEventInfo> events = service.getKernelProvider(new NullProgressMonitor());
// Verify event info
assertNotNull(events);
}
}
+ 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<String> 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());
+// }
+// }
+
+
+
}
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;
public ICommandShell getShellForNoUstProvider() {
return new NoUstProviderShell();
}
+
+ public ICommandShell getShellForSessionErrors() {
+ return new SessionCreationErrorsShell();
+ }
}
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;
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 {
public ISubSystem getTerminalServiceSubSystem() {
return null;
}
+ @Override
+ public IFileServiceSubSystem getFileServiceSubSystem() {
+ return null;
+ }
@Override
public void connect(IRSECallback callback) throws ExecutionException {
--- /dev/null
+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<String> list = new ArrayList<String>();
+ 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<String> list = new ArrayList<String>();
+ 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<String> list = new ArrayList<String>();
+ 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<String> list = new ArrayList<String>();
+ 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);
+ }
+}
+
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<String> list = new ArrayList<String>();
+ 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<String> list = new ArrayList<String>();
+ list.add("Session mysession2 destrioyed.");
+ return new CommandResult(0, list.toArray(new String[list.size()]));
}
String[] output = new String[1];
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)
<command
categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
description="%commands.control.new.description"
- id="org.eclipse.linuxtools.lttng.ui.command.newConnection"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.newConnection"
name="%commands.control.new">
</command>
<command
categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
description="%commands.control.connect.description"
- id="org.eclipse.linuxtools.lttng.ui.command.connect"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.connect"
name="%commands.control.connect">
</command>
<command
categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
description="%commands.control.disconnect.description"
- id="org.eclipse.linuxtools.lttng.ui.command.disconnect"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect"
name="%commands.control.disconnect">
</command>
<command
categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
description="%commands.control.delete.description"
- id="org.eclipse.linuxtools.lttng.ui.command.delete"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.delete"
name="%commands.control.delete">
</command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.create.session.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.createSession"
+ name="%commands.control.create.session">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.destroy.session.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.destroySession"
+ name="%commands.control.destroy.session">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.create.channel.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnSession"
+ name="%commands.control.create.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.create.channel.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnDomain"
+ name="%commands.control.create.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.enable.channel.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.enableChannel"
+ name="%commands.control.enable.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.disable.channel.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.disableChannel"
+ name="%commands.control.disable.channel">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.start.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.start"
+ name="%commands.control.start">
+ </command>
+ <command
+ categoryId="org.eclipse.linuxtools.lttng.ui.commands.control.category"
+ description="%commands.control.stop.description"
+ id="org.eclipse.linuxtools.lttng.ui.commands.control.stop"
+ name="%commands.control.stop">
+ </command>
+
</extension>
<extension
point="org.eclipse.ui.menus">
allPopups="false"
locationURI="toolbar:org.eclipse.linuxtools.lttng.ui.views.control">
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.newConnection"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.newConnection"
icon="icons/elcl16/target_add.gif"
label="%commands.control.new"
style="push">
</command>
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.connect"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.connect"
icon="icons/elcl16/connect.gif"
label="%commands.control.connect"
style="push">
</command>
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.disconnect"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect"
icon="icons/elcl16/disconnect.gif"
label="%commands.control.disconnect"
style="push">
</command>
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.delete"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete"
icon="icons/elcl16/target_delete.gif"
label="%commands.control.delete"
style="push">
</command>
+ <separator
+ name="org.eclipse.linuxtools.lttng.ui.views.control.toolbar.separator1"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.start"
+ icon="icons/elcl16/start_trace.gif"
+ label="%commands.control.start"
+ style="push">
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.stop"
+ icon="icons/elcl16/pause_trace.gif"
+ label="%commands.control.stop"
+ style="push">
+ </command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.linuxtools.lttng.ui.views.control">
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.connect"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.connect"
icon="icons/elcl16/connect.gif"
label="%commands.control.connect"
style="push">
</visibleWhen>
</command>
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.disconnect"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect"
icon="icons/elcl16/disconnect.gif"
label="%commands.control.disconnect"
style="push">
</visibleWhen>
</command>
<command
- commandId="org.eclipse.linuxtools.lttng.ui.command.delete"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete"
icon="icons/elcl16/target_delete.gif"
label="%commands.control.delete"
style="push">
</with>
</visibleWhen>
</command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createSession"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.session"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.destroySession"
+ icon="icons/elcl16/delete_trace.gif"
+ label="%commands.control.destroy.session"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnSession"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ <not>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </not>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnDomain"
+ icon="icons/elcl16/add_button.gif"
+ label="%commands.control.create.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <and>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ <not>
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </not>
+ <count
+ value="1">
+ </count>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.enableChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.enable.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disableChannel"
+ icon="icons/elcl16/edit.gif"
+ label="%commands.control.disable.channel"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.start"
+ icon="icons/elcl16/start_trace.gif"
+ label="%commands.control.start"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
+ <command
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.stop"
+ icon="icons/elcl16/pause_trace.gif"
+ label="%commands.control.stop"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeMenuSelection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+
</menuContribution>
+
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.NewConnectionHandler"
- commandId="org.eclipse.linuxtools.lttng.ui.command.newConnection">
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.newConnection">
<activeWhen>
<with
variable="activePart">
</handler>
<handler
class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.ConnectHandler"
- commandId="org.eclipse.linuxtools.lttng.ui.command.connect">
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.connect">
<activeWhen>
<with
variable="selection">
</handler>
<handler
class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.DisconnectHandler"
- commandId="org.eclipse.linuxtools.lttng.ui.command.disconnect">
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disconnect">
<activeWhen>
<with
variable="selection">
</handler>
<handler
class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.DeleteHandler"
- commandId="org.eclipse.linuxtools.lttng.ui.command.delete">
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.delete">
<activeWhen>
<with
variable="selection">
</with>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.CreateSessionHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createSession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.DestroySessionHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.destroySession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.CreateChannelOnSessionHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnSession">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.CreateChannelOnDomainHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.createChannelOnDomain">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.EnableChannelHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.enableChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.DisableChannelHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.disableChannel">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.StartHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.start">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.linuxtools.lttng.ui.views.control.handlers.StopHandler"
+ commandId="org.eclipse.linuxtools.lttng.ui.commands.control.stop">
+ <activeWhen>
+ <with
+ variable="selection">
+ <iterate
+ operator="or">
+ <instanceof
+ value="org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent">
+ </instanceof>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
</extension>
<!-- ======================================= -->
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;
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;
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(
@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());
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;
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;
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>CreateChannelDialog</u></b>
+ * <p>
+ * Dialog box for collecting channel creation information.
+ * </p>
+ */
+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));
+ }
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>CreateSessionDialog</u></b>
+ * <p>
+ * Dialog box for collecting session creation information.
+ * </p>
+ */
+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();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+
+/**
+ * <b><u>ICreateChannelDialog</u></b>
+ * <p>
+ * Interface for the create channel dialog when domain is known.
+ * </p>
+ */
+public interface ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return the configuration info for the new channel.
+ */
+ public IChannelInfo getChannelInfo();
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+ /**
+ * @return the open return value
+ */
+ int open();
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+
+/**
+ * <b><u>ICreateChannelOnSessionDialog</u></b>
+ * <p>
+ * Interface for the create channel dialog when domain is known, i.e. dialog
+ * was opened on session level.
+ * </p>
+ */
+public interface ICreateChannelOnSessionDialog extends ICreateChannelDialog {
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+ /**
+ * @return true for Kernel domain. False for UST.
+ */
+ public boolean isKernel();
+
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+/**
+ * <b><u>ICreateSessionDialog</u></b>
+ * <p>
+ * Interface for create session dialog.
+ * </p>
+ */
+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();
+}
// 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
/**
* 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.
*/
/**
* 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.
// ------------------------------------------------------------------------
/*
* (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;
}
// ------------------------------------------------------------------------
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
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);
}
}
@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
// 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;
}
@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;
}
}
*/
protected TargetNodeComponent fTargetNode = null;
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
- public TargetNodeComponent getTargetNode() {
- return fTargetNode;
- }
-
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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();
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>EnableChannelHandler</u></b>
+ * <p>
+ * Base Command handler implementation to enable or disabling a trace channel.
+ * </p>
+ */
+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<TraceChannelComponent> fKernelChannels = new ArrayList<TraceChannelComponent>();
+ /**
+ * The list of USTl channel components the command is to be executed on.
+ */
+ protected List<TraceChannelComponent> fUstChannels = new ArrayList<TraceChannelComponent>();
+
+ // ------------------------------------------------------------------------
+ // 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<String> 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<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> 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<TraceChannelComponent> 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<String> channelNames = new ArrayList<String>();
+ for (Iterator<TraceChannelComponent> 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<TraceChannelComponent> 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();
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>ChangeSessionStateHandler</u></b>
+ * <p>
+ * Abstract command handler implementation to start or stop one or more trace sessions.
+ * </p>
+ */
+abstract public class ChangeSessionStateHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ protected List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
+
+ // ------------------------------------------------------------------------
+ // 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<TraceSessionComponent> 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;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>CreateChannelOnDomainHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace channel for known domain.
+ * </p>
+ */
+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<String> channelNames = new ArrayList<String>();
+ 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;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>CreateChannelOnSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace channel for unknown domain
+ * (on session level).
+ * </p>
+ */
+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<String> channelNames = new ArrayList<String>();
+ 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;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>CreateSessionHandler</u></b>
+ * <p>
+ * Command handler implementation to create a trace session.
+ * </p>
+ */
+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;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>DestroySessionHandler</u></b>
+ * <p>
+ * Command handler implementation to destroy one or more trace sessions.
+ * </p>
+ */
+public class DestroySessionHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+ /**
+ * The list of session components the command is to be executed on.
+ */
+ private List<TraceSessionComponent> fSessions = new ArrayList<TraceSessionComponent>();
+
+ // ------------------------------------------------------------------------
+ // 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<TraceSessionComponent> 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;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>DisableChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to enable a trace channel.
+ * </p>
+ */
+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<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.disableChannels(channelNames, monitor);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>EnableChannelHandler</u></b>
+ * <p>
+ * Command handler implementation to enable a trace channel.
+ * </p>
+ */
+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<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ domain.enableChannels(channelNames, null, monitor);
+ }
+}
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;
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
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();
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>StartHandler</u></b>
+ * <p>
+ * Command handler implementation to start one or more trace sessions.
+ * </p>
+ */
+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);
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.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;
+
+/**
+ * <b><u>StopHandler</u></b>
+ * <p>
+ * Command handler implementation to stop one or more trace sessions.
+ * </p>
+ */
+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);
+ }
+}
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
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
*/
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.
*/
* @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);
+
}
* The channels information of the domain.
*/
private List<IChannelInfo> fChannels = new ArrayList<IChannelInfo>();
+ private boolean fIsKernel = false;
// ------------------------------------------------------------------------
// Constructors
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;
}
// ------------------------------------------------------------------------
IChannelInfo channel = (IChannelInfo) iterator.next();
result = 37 * result + channel.hashCode();
}
+ result += 37 * result + (fIsKernel ? 1 : 0);
return result;
}
return false;
}
}
+
+ if (fIsKernel != otherInfo.fIsKernel) {
+ return false;
+ }
return true;
}
output.append(channel.toString());
}
}
+ output.append(",isKernel=");
+ output.append(String.valueOf(fIsKernel));
output.append(")]");
return output.toString();
}
return null;
}
+ /**
+ * @return remote host name
+ */
public String getHostName() {
return fHost.getHostName();
}
+ /**
+ * @return remote system proxy implementation
+ */
+ public IRemoteSystemProxy getRemoteSystemProxy() {
+ return fRemoteProxy;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
}
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
**********************************************************************/
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;
/**
* The domain information.
*/
- private IDomainInfo fDomainInfo = null;
+ private IDomainInfo fDomainInfo = null;
// ------------------------------------------------------------------------
// Constructors
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<String> 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<String> 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<String> 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<String> channelNames, IProgressMonitor monitor) throws ExecutionException {
+ getControlService().disableChannel(getParent().getName(), channelNames, isKernel(), monitor);
+ }
}
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.
public void setDestroyed(boolean destroyed) {
fIsDestroyed = destroyed;
}
-
+
/**
* @return the session state state (active or inactive).
*/
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.
}
return null;
}
-
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
* @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);
+ }
+
}
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;
/**
super(name, parent);
setImage(TRACE_SESSIONS_ICON_FILE);
}
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
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);
+ }
}
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;
/**
* <b><u>IRemoteSystemProxy</u></b>
// Operations
// ------------------------------------------------------------------------
/**
- * Find the first shell service associated with the host.
+ * Find the first shell service.
*
* @return shell service object, or <code>null</code> 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 <code>null</code> 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 <code>null</code> 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 <code>null</code> if not found.
*/
public ISubSystem getTerminalServiceSubSystem();
-
+
+ /**
+ * Finds the File Service Subsystem.
+ * @return file service subsystem, or <code>null</code> if not found.
+ */
+ public IFileServiceSubSystem getFileServiceSubSystem();
+
/**
* Connects the shell service sub system.
*
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;
/**
* <b><u>RemoteSystemProxy</u></b>
// Attributes
// ------------------------------------------------------------------------
private IHost fHost;
-
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
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)
*/
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;
* </p>
*/
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
*/
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
*/
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<IBaseEventInfo> getKernelProvider() throws ExecutionException;
/**
* Retrieves the kernel provider information (i.e. the kernel events)
* @param monitor - a progress monitor
/**
* 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<IUstProviderInfo> 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<String> 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<String> channelNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+
}
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;
/**
* 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
/**
* 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 <session name>)
+ */
+ 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 <session name>)
+ */
+ 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
// ------------------------------------------------------------------------
// 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)
*
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)
*
// set channels
domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(true);
continue;
}
IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
sessionInfo.addDomain(domainInfo);
- // in domain kernel
+ // in domain UST
ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
index = parseDomain(result.getOutput(), index, channels);
// set channels
domainInfo.setChannels(channels);
+
+ // set kernel flag
+ domainInfo.setIsKernel(false);
continue;
}
index++;
return sessionInfo;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
- * #getKernelProvider()
- */
- @Override
- public List<IBaseEventInfo> getKernelProvider() throws ExecutionException {
- return getKernelProvider(new NullProgressMonitor());
- }
-
/*
* (non-Javadoc)
*
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 <sessionName> 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 <sessionName> 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 <sessionName> 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<String> 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<String> 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<String> 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<String> 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
// ------------------------------------------------------------------------
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;
+ }
+
}