Add new LTTng commands (create/destroy/start/stop session,
authorBernd Hufmann <bhufmann@gmail.com>
Tue, 21 Feb 2012 20:08:51 +0000 (15:08 -0500)
committerBernd Hufmann <bhufmann@gmail.com>
Tue, 21 Feb 2012 20:08:51 +0000 (15:08 -0500)
enable/disable channels)

43 files changed:
org.eclipse.linuxtools.lttng.ui.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng.ui.tests/src/org/eclipse/linuxtools/lttng/ui/tests/control/service/LTTngControlServiceTest.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/CommandShellFactory.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/TestRemoteSystemProxy.java
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionNamesShell.java
org.eclipse.linuxtools.lttng.ui/plugin.properties
org.eclipse.linuxtools.lttng.ui/plugin.xml
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/PerspectiveFactory.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/ControlView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/Messages.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/INewConnectionDialog.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/NewConnectionDialog.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/BaseNodeHandler.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/NewConnectionHandler.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/messages.properties
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IChannelInfo.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/IDomainInfo.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/DomainInfo.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TargetNodeComponent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceChannelComponent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceDomainComponent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionComponent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/model/impl/TraceSessionGroup.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/IRemoteSystemProxy.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/remote/RemoteSystemProxy.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/ILttngControlService.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/service/LTTngControlService.java

index 25984cc05b7f3da64e453ea9fd6989584ca5f308..7f29dab9187ad2dd8692060dc112c3788a7e3881 100644 (file)
@@ -14,7 +14,8 @@ Require-Bundle: org.junit;bundle-version="3.8.2",
  org.eclipse.core.runtime;bundle-version="3.7.0",
  org.eclipse.rse.core;bundle-version="3.2.0",
  org.eclipse.rse.services;bundle-version="3.2.100",
- org.eclipse.ui.views;bundle-version="3.6.0"
+ org.eclipse.ui.views;bundle-version="3.6.0",
+ org.eclipse.rse.subsystems.files.core;bundle-version="3.2.100"
 Bundle-Localization: plugin
 Bundle-Activator: org.eclipse.linuxtools.lttng.ui.tests.LTTngUITestPlugin
 Bundle-ActivationPolicy: lazy
index 3c654450935e282c2e7399747c138de2d26f9ca5..779c272287e9cf2294c7af705f0d3fff27ce0176 100644 (file)
@@ -16,6 +16,8 @@ import java.util.List;
 import junit.framework.TestCase;
 
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.linuxtools.lttng.stubs.service.CommandShellFactory;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
@@ -75,7 +77,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSessionNames() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForLttngNotExistsShell());
-            service.getSessionNames();
+            service.getSessionNames(new NullProgressMonitor());
             fail("No exeption thrown");
             
         } catch (ExecutionException e) {
@@ -86,7 +88,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSessionNames1() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForNoSessionNames());
-            String[] result = service.getSessionNames();
+            String[] result = service.getSessionNames(new NullProgressMonitor());
 
             assertNotNull(result);
             assertEquals(0, result.length);
@@ -99,7 +101,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSessionNames2() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
-            String[] result = service.getSessionNames();
+            String[] result = service.getSessionNames(new NullProgressMonitor());
 
             assertNotNull(result);
             assertEquals(2, result.length);
@@ -114,7 +116,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSessionNotExist() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNotExists());
-            service.getSessionNames();
+            service.getSessionNames(new NullProgressMonitor());
             fail("No exeption thrown");
             
         } catch (ExecutionException e) {
@@ -125,7 +127,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSessionNameGarbage() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionGarbage());
-            String[] result = service.getSessionNames();
+            String[] result = service.getSessionNames(new NullProgressMonitor());
 
             assertNotNull(result);
             assertEquals(0, result.length);
@@ -138,7 +140,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetSession1() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
-            ISessionInfo session = service.getSession("mysession");
+            ISessionInfo session = service.getSession("mysession", new NullProgressMonitor());
 
             // Verify Session
             assertNotNull(session);
@@ -238,7 +240,7 @@ public class LTTngControlServiceTest extends TestCase {
             assertEquals(TraceEnablement.ENABLED, ustEvents[1].getState());
             
             // next session (no detailed information available)
-            session = service.getSession("mysession1");
+            session = service.getSession("mysession1", new NullProgressMonitor());
             assertNotNull(session);
             assertEquals("mysession1", session.getName());
             assertEquals("/home/user/lttng-traces/mysession1-20120203-133225", session.getSessionPath());
@@ -255,7 +257,7 @@ public class LTTngControlServiceTest extends TestCase {
     public void testGetKernelProvider() {
         try {
             ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
-            List<IBaseEventInfo> events = service.getKernelProvider();
+            List<IBaseEventInfo> events = service.getKernelProvider(new NullProgressMonitor());
 
             // Verify event info
             assertNotNull(events);
@@ -349,4 +351,95 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
     
+    public void testCreateSession() {
+        try {
+            ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionNames());
+            ISessionInfo info = service.createSession("mysession2", null, new NullProgressMonitor());
+            assertNotNull(info);
+            assertEquals("mysession2", info.getName());
+            assertNotNull(info.getSessionPath());
+            assertTrue(info.getSessionPath().contains("mysession2"));
+            assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
+    
+    public void testCreateSessionErrors() {
+        ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionErrors());
+        try {
+            service.createSession("alreadyExist", null, new NullProgressMonitor());
+            fail("No exeption thrown");
+        } catch (ExecutionException e) {
+            // success
+        }
+        
+        try {
+            service.createSession("wrongName", null, new NullProgressMonitor());
+            fail("No exeption thrown");
+        } catch (ExecutionException e) {
+            // success
+        } 
+
+        try {
+            service.createSession("wrongPath", "/home/user/hallo", new NullProgressMonitor());
+            fail("No exeption thrown");
+        } catch (ExecutionException e) {
+            // success
+        } 
+
+        try {
+            ISessionInfo info = service.createSession("session with spaces", null, new NullProgressMonitor());
+            assertNotNull(info);
+            assertEquals("session with spaces", info.getName());
+            assertNotNull(info.getSessionPath());
+            assertTrue(info.getSessionPath().contains("session with spaces"));
+            assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+            
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        } 
+
+        try {
+            ISessionInfo info = service.createSession("pathWithSpaces", "/home/user/hallo user/here", new NullProgressMonitor());
+            assertNotNull(info);
+            assertEquals("pathWithSpaces", info.getName());
+            assertNotNull(info.getSessionPath());
+            assertTrue(info.getSessionPath().contains("/home/user/hallo user/here"));
+            assertEquals(TraceSessionState.INACTIVE, info.getSessionState());
+            
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        } 
+    }
+
+    void testDestroySession() {
+        try {
+            ILttngControlService service = new LTTngControlService(fShellFactory.getShellForSessionErrors());
+            service.destroySession("mysession2", new NullProgressMonitor());
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        } 
+    }
+    
+//    public void testCreateChannel() {
+//        try {
+//            
+////            public void enableChannel(String sessionName, List<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());
+//        }
+//    }
+
+    
+    
 }
index 03679efec20767573ee006b25e178a559b629c11..c461ae6334ad724f80d5fae77671a9b7fde06836 100644 (file)
@@ -4,6 +4,7 @@ import org.eclipse.linuxtools.lttng.stubs.service.shells.GetSessionGarbageShell;
 import org.eclipse.linuxtools.lttng.stubs.service.shells.LttngNotExistsShell;
 import org.eclipse.linuxtools.lttng.stubs.service.shells.NoSessionNamesShell;
 import org.eclipse.linuxtools.lttng.stubs.service.shells.NoUstProviderShell;
+import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionCreationErrorsShell;
 import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNotExistsShell;
 import org.eclipse.linuxtools.lttng.stubs.service.shells.SessionNamesShell;
 import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
@@ -44,4 +45,8 @@ public class CommandShellFactory {
     public ICommandShell getShellForNoUstProvider() {
         return new NoUstProviderShell();
     }
+    
+    public ICommandShell getShellForSessionErrors() {
+        return new SessionCreationErrorsShell();
+    }
 }
index 92efecaf9a317435a622f83b7cb2d4075cddcc05..52ab21d45b3914b0be0ed3157d9599f9d3f0adc1 100644 (file)
@@ -2,7 +2,6 @@ package org.eclipse.linuxtools.lttng.stubs.service;
 
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.linuxtools.lttng.stubs.service.shells.TestCommandShell;
 import org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy;
 import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandShell;
 import org.eclipse.rse.core.model.IRSECallback;
@@ -10,6 +9,7 @@ import org.eclipse.rse.core.subsystems.ICommunicationsListener;
 import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.shells.IShellService;
 import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
 
 public class TestRemoteSystemProxy implements IRemoteSystemProxy {
 
@@ -32,6 +32,10 @@ public class TestRemoteSystemProxy implements IRemoteSystemProxy {
     public ISubSystem getTerminalServiceSubSystem() {
         return null;
     }
+    @Override
+    public IFileServiceSubSystem getFileServiceSubSystem() {
+        return null;
+    }
 
     @Override
     public void connect(IRSECallback callback) throws ExecutionException {
diff --git a/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java b/org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/service/shells/SessionCreationErrorsShell.java
new file mode 100644 (file)
index 0000000..32ff74c
--- /dev/null
@@ -0,0 +1,47 @@
+package org.eclipse.linuxtools.lttng.stubs.service.shells;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult;
+import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult;
+
+public class SessionCreationErrorsShell extends TestCommandShell {
+    @SuppressWarnings("nls")
+    @Override
+    public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException {
+        if ("lttng create alreadyExist".equals(command)) {
+            String[] output = new String[1];
+            //Error: Session name already exist
+            output[0] = String.valueOf("Error: Session name already exist");
+            return new CommandResult(1, output);
+        } else if("lttng create \"session with spaces\"".equals(command)) {
+            List<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);
+    }
+}
+
index 9d7a1dcd12e319f5920d36635d68ea76b4e36fed..173986dcae74954be9fd187b6e6b651e849add5a 100644 (file)
@@ -121,6 +121,15 @@ public class SessionNamesShell extends TestCommandShell {
             list.add("    Trace path: /home/user/lttng-traces/mysession1-20120203-133225");
             list.add("");
             return new CommandResult(0, list.toArray(new String[list.size()]));
+        } else if ("lttng create mysession2".equals(command)) {
+            List<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];
index a46de8491544e9b420f3ee31ef623c3e47891fa4..8abacaa6a19fb27e443174efe8befecb9ea63452 100644 (file)
@@ -77,17 +77,39 @@ commands.control.category=LTTng Trace Control Commands
 commands.control.category.description=LTTng Trace Control Commands
 
 commands.control.new=New Connection
-commands.control.new.description=New Connection To Target Node
+commands.control.new.description=New Connection to Target Node
 
 commands.control.connect=Connect
-commands.control.connect.description=Connect To Target Node
+commands.control.connect.description=Connect to Target Node
 
 commands.control.disconnect=Disconnect
-commands.control.discconnect.description=Disconnect To Target Node
+commands.control.discconnect.description=Disconnect to Target Node
 
 commands.control.delete=Delete
 commands.control.deleete.description=Delete Target Node
 
+commands.control.create.session=Create Session
+commands.control.create.session.description=Create a Trace Session
+
+commands.control.destroy.session=Destroy Session
+commands.control.destroy.session.description=Destroy a Trace Session
+
+commands.control.create.channel=Create Channel
+commands.control.create.channel.description=Create a Trace Channel
+
+commands.control.enable.channel=Enable Channel
+commands.control.enable.channel.description=Enable a Trace Channel
+
+commands.control.disable.channel=Disable Channel
+commands.control.disable.channel.description=Disable a Trace Channel
+
+commands.control.start=Start
+commands.control.start.description=Start Trace Session
+
+commands.control.stop=Stop
+commands.control.stop.description=Stop Trace Session
+
+
 # trace control (RSE) properties (LTTng 0.x)
 lttng.rse.subsystem.type.name=LTTng (v0.x)
 lttng.rse.subsystem.type.description=LTTng Trace Control (v0.x)
index 92886443811a032625ceedf1d156fc6ff982f93d..714dca90009e8252e78e71a0781840cdc67af8cd 100644 (file)
       <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>
 
     <!-- ======================================= -->
index eadbe596cb800e62e6191abb766e6df1c81a25ca..c801eb02ef9efa7d7269287365e941b0a6be9a3e 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.linuxtools.lttng.ui.views;
 
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
 import org.eclipse.linuxtools.lttng.ui.views.controlflow.ControlFlowView;
 import org.eclipse.linuxtools.lttng.ui.views.histogram.HistogramView;
 import org.eclipse.linuxtools.lttng.ui.views.resources.ResourcesView;
@@ -35,6 +36,7 @@ public class PerspectiveFactory implements IPerspectiveFactory {
     private static final String RESOURCES_VIEW_ID = ResourcesView.ID;
     private static final String STATISTICS_VIEW_ID = StatisticsView.ID;
     private static final String HISTOGRAM_VIEW_ID = HistogramView.ID;
+    private static final String CONTROL_VIEW_ID = ControlView.ID;
 
     // Standard Eclipse views
     private static final String PROJECT_VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
@@ -59,6 +61,7 @@ public class PerspectiveFactory implements IPerspectiveFactory {
         IFolderLayout topLeftFolder = layout.createFolder(
                 "topLeftFolder", IPageLayout.LEFT, 0.15f, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
         topLeftFolder.addView(PROJECT_VIEW_ID);
+        topLeftFolder.addView(CONTROL_VIEW_ID);
 
         // Create the top right folder
         IFolderLayout topRightFolder = layout.createFolder(
index f2ed3457be129c71dd757067949b6b5ec370ddd1..e5643d58c178a5f977cd145443e09873386aa69b 100644 (file)
@@ -82,7 +82,7 @@ public class ControlView extends ViewPart implements ITraceControlComponentChang
     @Override
     public void createPartControl(Composite parent) {
         // Create tree viewer
-        fTreeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+        fTreeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
         ColumnViewerToolTipSupport.enableFor(fTreeViewer);
 
         fTreeViewer.setContentProvider(new TraceControlContentProvider());
index 943cc2120372574c3e38e343e313565e2779f045..f54336e72c67e30caa0cb4121c5d0c3db8b65f1a 100644 (file)
@@ -33,12 +33,26 @@ final public class Messages extends NLS {
 
     public static String TraceControl_CommandShellError;
     public static String TraceControl_CommandError;
+    public static String TraceControl_UnexpectedCommnadOutputFormat;
+    public static String TraceControl_UnexpectedNameError;
+    public static String TraceControl_UnexpectedPathError;
     
     // Commands
     public static String TraceControl_RetrieveNodeConfigurationJob;
     public static String TraceControl_ListSessionFailure;
     public static String TraceControl_EclipseCommandFailure;
     public static String TraceControl_NewNodeCreationFailure;
+    public static String TraceControl_CreateSessionJob;
+    
+    public static String TraceControl_DestroySessionJob;
+    public static String TraceControl_DestroyConfirmationTitle;
+    public static String TraceControl_DestroyConfirmationMessage;
+
+    public static String TraceControl_EnableChannelJob;
+    public static String TraceControl_DisableChannelJob;
+
+    public static String TraceControl_StartSessionJob;
+    public static String TraceControl_StopSessionJob;
     
     // Dialogs
     public static String TraceControl_NewDialogTitle;
@@ -51,8 +65,43 @@ final public class Messages extends NLS {
     public static String TraceControl_NewNodeHostNameTooltip;
     public static String TraceControl_AlreadyExistsError;
     
+    public static String TraceControl_CreateSessionDialogTitle;
+    public static String TraceControl_CreateSessionNameLabel;
+    public static String TraceControl_CreateSessionNameTooltip;
+    public static String TraceControl_CreateSessionPathLabel;
+    public static String TraceControl_CreateSessionPathTooltip;
+    public static String TraceControl_InvalidSessionNameError;
+    public static String TraceControl_SessionAlreadyExistsError;
+    public static String TraceControl_SessionPathAlreadyExistsError;
+    public static String TraceControl_InvalidSessionPathError;
+    public static String TraceControl_FileSubSystemError;
+
+    
+    public static String TraceControl_EnableChannelDialogTitle;
+    public static String TraceControl_EnableChannelNameLabel;
+    public static String TraceControl_EnableChannelNameLabelTooltip;
+    public static String TraceControl_EnableChannelSubBufferSizeTooltip;
+    public static String TraceControl_EnableChannelNbSubBuffersTooltip;
+    public static String TraceControl_EnableChannelSwitchTimerTooltip;
+    public static String TraceControl_EnableChannelReadTimerTooltip;
+    public static String TraceControl_EnableChannelOutputTypeTooltip;
+    public static String TraceControl_EnableChannelOverwriteModeTooltip;
+    
+    public static String TraceControl_InvalidChannelNameError;
+    public static String TraceControl_ChannelAlreadyExistsError;
+    
+//    public static String TraceControl_CreateSessionNameTooltip;
+//    public static String TraceControl_CreateSessionPathLabel;
+//    public static String TraceControl_CreateSessionPathTooltip;
+//    public static String TraceControl_SessionAlreadyExistsError;
+//    public static String TraceControl_SessionPathAlreadyExistsError;
+//    public static String TraceControl_InvalidSessionPathError;
+//    public static String TraceControl_FileSubSystemError;
+
+    
     // Tree structure strings
     public static String TraceControl_KernelDomainDisplayName;
+    public static String TraceControl_UstDisplayName;
     public static String TraceControl_UstGlobalDomainDisplayName;
     public static String TraceControl_AllSessionsDisplayName;
     public static String TraceControl_SessionDisplayName;
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateChannelDialog.java
new file mode 100644 (file)
index 0000000..a27af85
--- /dev/null
@@ -0,0 +1,356 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.ChannelInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <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));
+        }
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/CreateSessionDialog.java
new file mode 100644 (file)
index 0000000..1a3073a
--- /dev/null
@@ -0,0 +1,245 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy;
+import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * <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();
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelDialog.java
new file mode 100644 (file)
index 0000000..26cd0ce
--- /dev/null
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
+
+/**
+ * <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();
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateChannelOnSessionDialog.java
new file mode 100644 (file)
index 0000000..f852159
--- /dev/null
@@ -0,0 +1,32 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+
+/**
+ * <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();
+
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/dialogs/ICreateSessionDialog.java
new file mode 100644 (file)
index 0000000..eb42ac2
--- /dev/null
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.dialogs;
+
+/**
+ * <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();
+}
index 5dc342b9a4ce2c604e5c3d1cd15e1f67e981834f..acdceac6e4cd4718ca7f84563add84bc1d19ecb4 100644 (file)
@@ -23,14 +23,14 @@ public interface INewConnectionDialog {
     // Accessors
     // ------------------------------------------------------------------------
     /**
-     * @return returns the node name (alias).
+     * @return the connection name (alias).
      */
-    public String getNodeName();
+    public String getConnectionName();
 
     /**
-     * @return returns the node address (IP address or DNS name)
+     * @return the host name (IP address or DNS name)
      */
-    public String getNodeAddress();
+    public String getHostName();
 
     // ------------------------------------------------------------------------
     // Operations
index 035c4153a0f1c0cc606dab13619fc92c078efc9f..0adec5e0f170597450455df0eaba1e906cdd81ca 100644 (file)
@@ -77,11 +77,11 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
     /**
      * The text widget for the node name (alias)
      */
-    private Text fNodeNameText = null;
+    private Text fConnectionNameText = null;
     /**
      * The text widget for the node address (IP or DNS name)
      */
-    private Text fNodeAddressText = null;
+    private Text fHostNameText = null;
     /**
      * The parent where the new node should be added.
      */
@@ -89,11 +89,11 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
     /**
      * The node name (alias) string.
      */
-    private String fNodeName = null;
+    private String fConnectionName = null;
     /**
      * The node address (IP or DNS name) string.
      */
-    private String fNodeAddress = null;
+    private String fHostName = null;
     
     /**
      * Input list of existing RSE hosts available for selection.
@@ -116,20 +116,20 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
     // ------------------------------------------------------------------------
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getNodeName()
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getConnectionName()
      */
     @Override
-    public String getNodeName() {
-        return fNodeName;
+    public String getConnectionName() {
+        return fConnectionName;
     }
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getNodeAddress()
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.dialogs.INewConnectionDialog#getHostName()
      */
     @Override
-    public String getNodeAddress() {
-        return fNodeAddress;
+    public String getHostName() {
+        return fHostName;
     }
 
     // ------------------------------------------------------------------------
@@ -190,17 +190,17 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
         fButton.setText(Messages.TraceControl_NewNodeEditButtonName);
         fButton.setEnabled(fExistingHosts.length > 0);
         
-        Label nodeNameLabel = new Label(fTextGroup, SWT.RIGHT);
-        nodeNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
-        fNodeNameText = new Text(fTextGroup, SWT.NONE);
-        fNodeNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
-        fNodeNameText.setEnabled(fExistingHosts.length == 0);
+        Label connectionNameLabel = new Label(fTextGroup, SWT.RIGHT);
+        connectionNameLabel.setText(Messages.TraceControl_NewNodeConnectionNameLabel);
+        fConnectionNameText = new Text(fTextGroup, SWT.NONE);
+        fConnectionNameText.setToolTipText(Messages.TraceControl_NewNodeConnectionNameTooltip);
+        fConnectionNameText.setEnabled(fExistingHosts.length == 0);
         
-        Label nodeAddressLabel = new Label(fTextGroup, SWT.RIGHT);
-        nodeAddressLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
-        fNodeAddressText = new Text(fTextGroup, SWT.NONE);
-        fNodeAddressText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
-        fNodeAddressText.setEnabled(fExistingHosts.length == 0);
+        Label hostNameLabel = new Label(fTextGroup, SWT.RIGHT);
+        hostNameLabel.setText(Messages.TraceControl_NewNodeHostNameLabel);
+        fHostNameText = new Text(fTextGroup, SWT.NONE);
+        fHostNameText.setToolTipText(Messages.TraceControl_NewNodeHostNameTooltip);
+        fHostNameText.setEnabled(fExistingHosts.length == 0);
 
         fButton.addSelectionListener(new SelectionListener() {
             @Override
@@ -208,12 +208,12 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
                 if (fButton.getSelection()) {
                     fExistingHostsCombo.deselectAll();
                     fExistingHostsCombo.setEnabled(false);
-                    fNodeNameText.setEnabled(true);
-                    fNodeAddressText.setEnabled(true);
+                    fConnectionNameText.setEnabled(true);
+                    fHostNameText.setEnabled(true);
                 } else {
                     fExistingHostsCombo.setEnabled(true);
-                    fNodeNameText.setEnabled(false);
-                    fNodeAddressText.setEnabled(false);
+                    fConnectionNameText.setEnabled(false);
+                    fHostNameText.setEnabled(false);
                 }             
             }
 
@@ -226,8 +226,8 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
             @Override
             public void widgetSelected(SelectionEvent e) {
                 int index = fExistingHostsCombo.getSelectionIndex();
-                fNodeNameText.setText(fExistingHosts[index].getAliasName());
-                fNodeAddressText.setText(fExistingHosts[index].getHostName());
+                fConnectionNameText.setText(fExistingHosts[index].getAliasName());
+                fHostNameText.setText(fExistingHosts[index].getHostName());
             }
 
             @Override
@@ -237,14 +237,14 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
         
         // layout widgets
         data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-        fNodeAddressText.setText("666.666.666.666"); //$NON-NLS-1$
-        Point minSize = fNodeAddressText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+        fHostNameText.setText("666.666.666.666"); //$NON-NLS-1$
+        Point minSize = fHostNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
         data.widthHint = minSize.x + 5;
         
-        fNodeNameText.setLayoutData(data);
-        fNodeAddressText.setLayoutData(data);
+        fConnectionNameText.setLayoutData(data);
+        fHostNameText.setLayoutData(data);
         
-        fNodeAddressText.setText(""); //$NON-NLS-1$
+        fHostNameText.setText(""); //$NON-NLS-1$
         
         return fDialogComposite;
     }
@@ -265,19 +265,19 @@ public class NewConnectionDialog extends Dialog implements INewConnectionDialog
     @Override
     protected void okPressed() {
         // Validate input data
-        fNodeName = fNodeNameText.getText();
-        fNodeAddress = fNodeAddressText.getText();
+        fConnectionName = fConnectionNameText.getText();
+        fHostName = fHostNameText.getText();
 
-        if (!"".equals(fNodeAddress)) { //$NON-NLS-1$
+        if (!"".equals(fHostName)) { //$NON-NLS-1$
             // If no node name is specified use the node address as name
-            if ("".equals(fNodeName)) { //$NON-NLS-1$
-                fNodeName = fNodeAddress;
+            if ("".equals(fConnectionName)) { //$NON-NLS-1$
+                fConnectionName = fHostName;
             }
             // Check if node with name already exists in parent
-            if(fParent.containsChild(fNodeName)) {
+            if(fParent.containsChild(fConnectionName)) {
                 MessageDialog.openError(getShell(),
                         Messages.TraceControl_NewDialogTitle,
-                        Messages.TraceControl_AlreadyExistsError + " (" + fNodeName + ")");  //$NON-NLS-1$//$NON-NLS-2$
+                        Messages.TraceControl_AlreadyExistsError + " (" + fConnectionName + ")");  //$NON-NLS-1$//$NON-NLS-2$
                 return;
             }
         }
index dc95d6b68feb03e76262fccf2c7b4abc28fecb73..feecfb3f6a9663f39aa3a27d4e1ba65d1f0856cc 100644 (file)
@@ -37,17 +37,6 @@ abstract public class BaseNodeHandler extends AbstractHandler {
      */
     protected TargetNodeComponent fTargetNode = null;
     
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-
-    // ------------------------------------------------------------------------
-    // Accessors
-    // ------------------------------------------------------------------------
-    public TargetNodeComponent getTargetNode() {
-        return fTargetNode;
-    }
-    
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -76,7 +65,7 @@ abstract public class BaseNodeHandler extends AbstractHandler {
             return false;
         }
 
-        // Check if a project is selected
+        // Check if the node component is selected
         ISelection selection = page.getSelection(ControlView.ID);
         if (selection instanceof StructuredSelection) {
             Object element = ((StructuredSelection) selection).getFirstElement();
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeChannelStateHandler.java
new file mode 100644 (file)
index 0000000..25bc176
--- /dev/null
@@ -0,0 +1,236 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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();
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/ChangeSessionStateHandler.java
new file mode 100644 (file)
index 0000000..08f28df
--- /dev/null
@@ -0,0 +1,153 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnDomainHandler.java
new file mode 100644 (file)
index 0000000..e66d1d0
--- /dev/null
@@ -0,0 +1,159 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateChannelOnSessionHandler.java
new file mode 100644 (file)
index 0000000..fd0262f
--- /dev/null
@@ -0,0 +1,160 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateChannelDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateChannelOnSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/CreateSessionHandler.java
new file mode 100644 (file)
index 0000000..e4347d9
--- /dev/null
@@ -0,0 +1,123 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.CreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.dialogs.ICreateSessionDialog;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DestroySessionHandler.java
new file mode 100644 (file)
index 0000000..62e04a4
--- /dev/null
@@ -0,0 +1,139 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
+import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
+import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionGroup;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * <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;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/DisableChannelHandler.java
new file mode 100644 (file)
index 0000000..1102844
--- /dev/null
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <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);
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/EnableChannelHandler.java
new file mode 100644 (file)
index 0000000..1264f91
--- /dev/null
@@ -0,0 +1,52 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
+
+/**
+ * <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);
+    }
+}
index 5e96e5f5acd91d33989260abea362dcb96c0a04a..c3bf8fdd58ff82b91dfe5a493a74b44f89206ad2 100644 (file)
@@ -81,8 +81,8 @@ public class NewConnectionHandler extends AbstractHandler {
 
         if (dialog.open() == Window.OK) {
 
-            String hostName = dialog.getNodeName(); 
-            String hostAddress = dialog.getNodeAddress();
+            String hostName = dialog.getConnectionName(); 
+            String hostAddress = dialog.getHostName();
 
             // get the singleton RSE registry
             IHost host = null;
@@ -97,7 +97,6 @@ public class NewConnectionHandler extends AbstractHandler {
             if (host == null) {
                 // if there's no host then we will create it
                 try {
-                    
                     // create the host object as an SSH Only connection
                     host = registry.createHost(
                             sysType,       //System Type Name
@@ -145,7 +144,7 @@ public class NewConnectionHandler extends AbstractHandler {
             return false;
         }
 
-        // Check if we are in the Project View
+        // Check if we are in the Control View
         IWorkbenchPage page = window.getActivePage();
         if (page == null) return false;
         IWorkbenchPart part = page.getActivePart();
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StartHandler.java
new file mode 100644 (file)
index 0000000..96d1869
--- /dev/null
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * <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);
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/control/handlers/StopHandler.java
new file mode 100644 (file)
index 0000000..de60178
--- /dev/null
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * Copyright (c) 2012 Ericsson
+ * 
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
+
+/**
+ * <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);
+    }
+}
index 9ff24f5087e0c27cb0362642fd2c61d3302c7454..be504a99b3c0bd7bcb3b18720a32735c0933a672 100644 (file)
@@ -5,14 +5,30 @@ TraceControl_ExecutionFailure=Command Execution failed
 TraceControl_ExecutionTimeout=Command Execution timed-out
 TraceControl_ShellNotConnected=Command shell not connected
 TraceControl_CommandShellError=Could not create HostShellProcessAdapter
-TraceControl_CommandError=Command failed! Command:
+TraceControl_CommandError=Command failed! Command: 
+TraceControl_UnexpectedCommnadOutputFormat=Unexpected command output
+TraceControl_UnexpectedNameError=Unexpected session name returned
+TraceControl_UnexpectedPathError=Unexpected session path returned
  
 # Commands 
 TraceControl_ListSessionFailure=List sessions failed
-TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration ...
+TraceControl_RetrieveNodeConfigurationJob=Retrieving Target Node Configuration...
 TraceControl_EclipseCommandFailure=Command failed
 TraceControl_NewNodeCreationFailure=Creation of new connection failed
+TraceControl_CreateSessionJob=Creating Session...
+
+TraceControl_DestroySessionJob=Destroying Session...
+TraceControl_DestroyConfirmationTitle=Destroy Confirmation
+TraceControl_DestroyConfirmationMessage=Do you want to delete all selected sessions?
+
+TraceControl_StartSessionJob=Starting Session...
+TraceControl_StopSessionJob=Stopping Session...
     
+TraceControl_EnableChannelJob=Enabling Channels...
+TraceControl_EnableChannelDialogTitle=Enable Channel
+TraceControl_DisableChannelJob=Disabling Channels...
+
+
 
 # Dialogs
 TraceControl_NewDialogTitle=New Connection
@@ -25,9 +41,34 @@ TraceControl_NewNodeHostNameLabel=Host Name
 TraceControl_NewNodeHostNameTooltip=IP Address or DNS name of node to connect to.
 TraceControl_AlreadyExistsError=Node name already exists in Control View
 
+TraceControl_CreateSessionDialogTitle=Create Session
+TraceControl_CreateSessionNameLabel=Session Name
+TraceControl_CreateSessionNameTooltip=The name of the session to be created.
+TraceControl_CreateSessionPathLabel=Session Path
+TraceControl_CreateSessionPathTooltip=The session path (keep empty for default location)
+TraceControl_InvalidSessionNameError=The session name is invalid
+TraceControl_SessionAlreadyExistsError=The session name already exists
+TraceControl_SessionPathAlreadyExistsError=Session path already exists
+TraceControl_InvalidSessionPathError=The session path is invalid
+TraceControl_FileSubSystemError=File subsystem error in session creation dialog.
+
+TraceControl_EnableChannelDialogTitle=Enable Channel
+TraceControl_EnableChannelNameLabel=Channel Name
+TraceControl_EnableChannelNameLabelTooltip=The name of the channel to be enabled.
+TraceControl_EnableChannelSubBufferSizeTooltip=The sub-buffers size of the channel.
+TraceControl_EnableChannelNbSubBuffersTooltip=The number of sub-buffers of the channel.
+TraceControl_EnableChannelSwitchTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelReadTimerTooltip=The switch timer interval in usec.
+TraceControl_EnableChannelOutputTypeTooltip=The output type of the channel.
+TraceControl_EnableChannelOverwriteModeTooltip=Select for overwrite mode (Flight recorder mode).
+
+TraceControl_InvalidChannelNameError=The channel name is invalid or empty
+TraceControl_ChannelAlreadyExistsError=Channel already exists
+
 # Tree structure strings
 TraceControl_KernelDomainDisplayName=Kernel
 TraceControl_UstGlobalDomainDisplayName=UST global
+TraceControl_UstDisplayName=UST
 TraceControl_AllSessionsDisplayName=Sessions
 TraceControl_SessionDisplayName=Session
 TraceControl_DomainDisplayName=Domain
index 7de4092a34f807c11c5190f658409d7240538153..9d7d37ba1a916ac0679de931dffa79b06c9bc06c 100644 (file)
@@ -21,6 +21,38 @@ import java.util.List;
  */
 public interface IChannelInfo extends ITraceInfo {
 
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+    /**
+     * Default value for overwrite mode.
+     */
+    public final static boolean DEFAULT_OVERWRITE_MODE = false;
+    /**
+     * Default value for sub-buffer size for a UST channel. 
+     */
+    public final static long DEFAULT_SUB_BUFFER_SIZE_UST = 4096L;
+    /**
+     * Default value for sub-buffer size for a Kernel channel. 
+     */
+    public final static long DEFAULT_SUB_BUFFER_SIZE_KERNEL = 262144L;
+    /**
+     * Default value for number of sub-buffer a UST channel. 
+     */
+    public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_UST = 8;
+    /**
+     * Default value for number of sub-buffer a Kernel channel. 
+     */
+    public final static int DEFAULT_NUMBER_OF_SUB_BUFFERS_KERNEL = 4;
+    /**
+     * Default value for number of the switch timer interval. 
+     */
+    public final static long DEFAULT_SWITCH_TIMER = 0;
+    /**
+     * Default value for number of the read timer interval. 
+     */
+    public final static long DEFAULT_READ_TIMER = 200;
+    
     /**
      * @return the overwrite mode value.
      */
index 9056c579631db92454fd77ba35f8537ee398b4f4..e7e20d7c1c0c94cc473f961d7cd2e195efb9e2eb 100644 (file)
@@ -38,5 +38,17 @@ public interface IDomainInfo extends ITraceInfo {
      * @param channel - channel information to add.
      */
     public void addChannel(IChannelInfo channel);
+    
+    /**
+     * @return true if domain is kernel, false for UST
+     */
+    public boolean isKernel();
+    
+    /**
+     * Sets whether domain is  Kernel domain or UST 
+     * @param isKernel true for kernel, false for UST
+     */
+    public void setIsKernel(boolean isKernel);
+
 
 }
index 1269b85ff5b43dbc9540005043806f203f57f7be..95c1d26366f3a6731937e183c00b78f7f6d92d48 100644 (file)
@@ -34,6 +34,7 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
      * The channels information of the domain.
      */
     private List<IChannelInfo> fChannels = new ArrayList<IChannelInfo>();
+    private boolean fIsKernel = false;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -59,6 +60,25 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
                 fChannels.add(other.fChannels.get(i));
             }
         }
+        fIsKernel = other.fIsKernel;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#isKernel()
+     */
+    @Override
+    public boolean isKernel() {
+        return fIsKernel;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo#setIsKernel(boolean)
+     */
+    @Override
+    public void setIsKernel(boolean isKernel) {
+        fIsKernel = isKernel;
     }
 
     // ------------------------------------------------------------------------
@@ -106,6 +126,7 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
             IChannelInfo channel = (IChannelInfo) iterator.next();
             result = 37 * result + channel.hashCode();
         }
+        result += 37 * result + (fIsKernel ? 1 : 0);
         return result;
     }
 
@@ -132,6 +153,10 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
                 return false;
             }
         }
+
+        if (fIsKernel != otherInfo.fIsKernel) {
+            return false;
+        }
         return true;
     }
     
@@ -154,6 +179,8 @@ public class DomainInfo extends TraceInfo implements IDomainInfo {
                     output.append(channel.toString());
                 }
             }
+            output.append(",isKernel=");
+            output.append(String.valueOf(fIsKernel));
             output.append(")]");
             return output.toString();
     }
index 650d6fa4ae22b804ac8ca9b7abea102c2db3e49d..5ef8b9627911a87dc96b448f7280e726a058072e 100644 (file)
@@ -175,10 +175,20 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu
         return null;
     } 
     
+    /**
+     * @return remote host name
+     */
     public String getHostName() {
         return fHost.getHostName();
     }
 
+    /**
+     * @return remote system proxy implementation
+     */
+    public IRemoteSystemProxy getRemoteSystemProxy() {
+        return fRemoteProxy;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
index f443d28d668735e04d2ad0dba020e6c2afd2ca5c..00311b745c165fb043085140ad198b5eed1bcbd0 100644 (file)
@@ -208,7 +208,20 @@ public class TraceChannelComponent extends TraceControlComponent {
         }
         return null;
     } 
-    
+
+    /**
+     * @return session name from parent
+     */
+    public String getSessionName() {
+       return ((TraceDomainComponent)getParent()).getSessionName(); 
+    }
+
+    /**
+     * @return if domain is kernel or UST
+     */
+    public boolean isKernel() {
+        return ((TraceDomainComponent)getParent()).isKernel();
+    }
     
     // ------------------------------------------------------------------------
     // Operations
index ec1febbde522fd6f8aa720e013b8345dcb994e96..8d88a69b23b25a42cd3e7abbb5804ef1c8ad640a 100644 (file)
  **********************************************************************/
 package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
 
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IDomainInfo;
@@ -39,7 +44,7 @@ public class TraceDomainComponent extends TraceControlComponent {
     /**
      * The domain information.
      */
-    private IDomainInfo fDomainInfo = null; 
+    private IDomainInfo fDomainInfo = null;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -84,8 +89,87 @@ public class TraceDomainComponent extends TraceControlComponent {
             return new TraceDomainPropertySource(this);
         }
         return null;
-    } 
+    }
+    
+    /**
+     * @return session name from parent
+     */
+    public String getSessionName() {
+        return ((TraceSessionComponent)getParent()).getName();
+    }
+    
+    /**
+     * @return true if domain is kernel, false for UST
+     */
+    public boolean isKernel() {
+        return fDomainInfo.isKernel();
+    }
+    
+    /**
+     * Sets whether domain is  Kernel domain or UST 
+     * @param isKernel true for kernel, false for UST
+     */
+    public void setIsKernel(boolean isKernel) {
+        fDomainInfo.setIsKernel(isKernel);
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
+    /**
+     * Retrieves the session configuration from the node. 
+     * @throws ExecutionException
+     */
+    public void getConfigurationFromNode() throws ExecutionException {
+        getConfigurationFromNode(new NullProgressMonitor());
+    }
+    /**
+     * Retrieves the session configuration from the node. 
+     * @param monitor - a progress monitor
+     * @throws ExecutionException
+     */
+    public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+        TraceSessionComponent session = (TraceSessionComponent) getParent();
+        session.getConfigurationFromNode(monitor);
+    }
+    /**
+     * Enables channels with given names which are part of this domain. If a given channel 
+     * doesn't exists it creates a new channel with the given parameters (or default values 
+     * if given parameter is null). 
+     * @param channelNames - a list of channel names to enable on this domain
+     * @param info - channel information to set for the channel (use null for default)
+     * @throws ExecutionException
+     */
+    public void enableChannels(List<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);
+    }
 }
index b7c29acaafa2d08b52d011077084f1f8c03e0a9a..4bcc4635d3ed38404c15e574b514e1c2a0207f1d 100644 (file)
@@ -105,14 +105,13 @@ public class TraceSessionComponent extends TraceControlComponent {
         return fActiveImage;
     }
 
-    
     /**
      * @return the whether the session is destroyed or not.
      */
     public boolean isDestroyed() {
         return fIsDestroyed;
     }
-    
+
     /**
      * Sets the session destroyed state to the given value.
      * @param destroyed - value to set.
@@ -120,7 +119,7 @@ public class TraceSessionComponent extends TraceControlComponent {
     public void setDestroyed(boolean destroyed) {
         fIsDestroyed = destroyed;
     }
-    
+
     /**
      * @return the session state state (active or inactive).
      */
@@ -135,7 +134,7 @@ public class TraceSessionComponent extends TraceControlComponent {
     public void setSessionState(TraceSessionState state) {
         fSessionInfo.setSessionState(state);
     }
-    
+
     /**
      * Sets the event state to the value specified by the given name.
      * @param stateName - state to set.
@@ -171,7 +170,7 @@ public class TraceSessionComponent extends TraceControlComponent {
         }
         return null;
     } 
-    
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -189,12 +188,48 @@ public class TraceSessionComponent extends TraceControlComponent {
      * @throws ExecutionException
      */
     public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
+        removeAllChildren();
         fSessionInfo = getControlService().getSession(getName(), monitor);
         IDomainInfo[] domains = fSessionInfo.getDomains();
         for (int i = 0; i < domains.length; i++) {
-            TraceDomainComponent domainComponenent = new TraceDomainComponent(domains[i].getName(), this);
-            addChild(domainComponenent);
-            domainComponenent.setDomainInfo(domains[i]);
+            TraceDomainComponent domainComponent = new TraceDomainComponent(domains[i].getName(), this);
+            addChild(domainComponent);
+            domainComponent.setDomainInfo(domains[i]);
         }
     }
+    
+    /**
+     * Starts the session. 
+     * throws ExecutionExecption
+     */
+    public void startSession() throws ExecutionException {
+        startSession(new NullProgressMonitor());
+    }
+    
+    /**
+     * Starts the session.
+     * @param monitor - a progress monitor
+     * throws ExecutionExecption
+     */
+    public void startSession(IProgressMonitor monitor) throws ExecutionException {
+        getControlService().startSession(getName(), monitor);
+    }
+    
+    /**
+     * Starts the session. 
+     * throws ExecutionExecption
+     */
+    public void stopSession() throws ExecutionException {
+        startSession(new NullProgressMonitor());
+    }
+    
+    /**
+     * Starts the session.
+     * @param monitor - a progress monitor
+     * throws ExecutionExecption
+     */
+    public void stopSession(IProgressMonitor monitor) throws ExecutionException {
+        getControlService().stopSession(getName(), monitor);
+    }
+
 }
index 105f76a73855226dc8d9b4d0bef3cb461b2c2c3a..e8ba69233573631daf30342f3a58a6736972c070 100644 (file)
@@ -14,6 +14,7 @@ package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
 
 /**
@@ -47,7 +48,7 @@ public class TraceSessionGroup extends TraceControlComponent {
         super(name, parent);
         setImage(TRACE_SESSIONS_ICON_FILE);
     }
-    
+
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
@@ -76,4 +77,54 @@ public class TraceSessionGroup extends TraceControlComponent {
             session.getConfigurationFromNode(monitor);
         }
     }
+
+    /**
+     * Creates a session with given session name and location. 
+     * @param sessionName - a session name to create
+     * @param sessionPath - a path for storing the traces (use null for default)
+     * @return the session information
+     * throws ExecutionExecption
+     */
+    public void createSession(final String sessionName, final String sessionPath) throws ExecutionException {
+        createSession(sessionName, sessionPath, new NullProgressMonitor());
+    }
+    
+    /**
+     * Creates a session with given session name and location. 
+     * @param sessionName - a session name to create
+     * @param sessionPath - a path for storing the traces (use null for default)
+     * @Param monitor - a progress monitor 
+     * @return the session information
+     * throws ExecutionExecption
+     */
+    public void createSession(final String sessionName, final String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+        ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
+        if (sessionInfo != null) {
+            TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
+            addChild(session);
+            session.getConfigurationFromNode(monitor);
+        }
+    }
+
+    /**
+     * Destroys a session with given session name. 
+     * @param sessionName - a session name to destroy
+     * throws ExecutionExecption
+     */
+    public void destroySession(final String sessionName) throws ExecutionException {
+        destroySession(sessionName, new NullProgressMonitor());
+    }
+    
+    /**
+     * Destroys a session with given session name. 
+     * @param sessionName - a session name to destroy
+     * @param monitor - a progress monitor
+     * throws ExecutionExecption
+     */
+    public void destroySession(final String sessionName, IProgressMonitor monitor) throws ExecutionException {
+        getControlService().destroySession(sessionName, monitor);
+        ITraceControlComponent session = getChild(sessionName);
+        session.removeAllChildren();
+        removeChild(session);
+    }
 }
index 97e941e38e854a1e3ff4d2f54287878a0065db41..ef2849d98c938970a02ea349e0002b4309f182a8 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.rse.core.subsystems.ICommunicationsListener;
 import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.shells.IShellService;
 import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
 
 /**
  * <b><u>IRemoteSystemProxy</u></b>
@@ -31,34 +32,40 @@ public interface IRemoteSystemProxy {
     // Operations
     // ------------------------------------------------------------------------
     /**
-     * Find the first shell service associated with the host.
+     * Find the first shell service.
      * 
      * @return shell service object, or <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. 
      * 
index 9d47cbfe89b0af12f44be410a4a692253262df2c..882c7a8221bf265bb2da0bc8050b69f4812b8067 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
 import org.eclipse.rse.services.IService;
 import org.eclipse.rse.services.shells.IShellService;
 import org.eclipse.rse.services.terminals.ITerminalService;
+import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
 
 /**
  * <b><u>RemoteSystemProxy</u></b>
@@ -36,7 +37,7 @@ public class RemoteSystemProxy implements IRemoteSystemProxy {
     // Attributes
     // ------------------------------------------------------------------------
     private IHost fHost;
-    
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -115,7 +116,24 @@ public class RemoteSystemProxy implements IRemoteSystemProxy {
         return null;
     }
 
-
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.remote.IRemoteSystemProxy#getFileServiceSubSystem()
+     */
+    @Override
+    public IFileServiceSubSystem getFileServiceSubSystem() {
+        if (fHost == null) {
+            return null;
+        }
+        ISubSystem[] subSystems = fHost.getSubSystems();
+        for (int i = 0; subSystems != null && i < subSystems.length; i++) {
+            if (subSystems[i] instanceof IFileServiceSubSystem) {
+                return (IFileServiceSubSystem)subSystems[i];
+            }
+        }
+        return null;
+    }
+    
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.lttng.ui.views.control.util.IRemoteSystemProxy#connect(org.eclipse.rse.core.model.IRSECallback)
      */
index 572c357434a75a9d21275125cb160215b86f99f6..8d1cc48bed407f16b3b1e530800bfcd3f65076dc 100644 (file)
@@ -16,6 +16,7 @@ import java.util.List;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.ISessionInfo;
 import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
 
@@ -26,12 +27,6 @@ import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo;
 * </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
@@ -40,14 +35,6 @@ public interface ILttngControlService {
      */
     public String[] getSessionNames(IProgressMonitor monitor) throws ExecutionException;
     
-    /**
-     * Retrieves the session information with the given name the node.
-     * @param sessionName - the session name 
-     * @return session information
-     * @throws ExecutionException
-     */
-    public ISessionInfo getSession(String sessionName) throws ExecutionException;
-    
     /**
      * Retrieves the session information with the given name the node.
      * @param sessionName - the session name
@@ -57,12 +44,6 @@ public interface ILttngControlService {
      */    
     public ISessionInfo getSession(String sessionName, IProgressMonitor monitor) throws ExecutionException;
     
-    /**
-     * Retrieves the kernel provider information (i.e. the kernel events)
-     * @return the list of existing kernel events.
-     * @throws ExecutionException
-     */
-    public List<IBaseEventInfo> getKernelProvider() throws ExecutionException;
     /**
      * Retrieves the kernel provider information (i.e. the kernel events)
      * @param monitor - a progress monitor 
@@ -80,8 +61,65 @@ public interface ILttngControlService {
     /**
      * Retrieves the UST provider information from the node.
      * @param monitor - a progress monitor 
-     * @return the UST provider information.
+     * @return the UST provider information.
      * @throws ExecutionException
      */
     public List<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;
+    
 }
index f26912f4bff88c06f52aed8575500024e57abb28..34fc55189f0f842d5b2e038a9b7b3c351cd2ccab 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.linuxtools.lttng.ui.views.control.service;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -60,7 +61,31 @@ public class LTTngControlService implements ILttngControlService {
     /**
      * Command to list user space trace information.
      */
-    private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u"; //$NON-NLS-1$
+    private final static String COMMAND_LIST_UST = COMMAND_LIST + "-u";  //$NON-NLS-1$
+    /**
+     * Command to create a session. 
+     */
+    private final static String COMMAND_CREATE_SESSION = CONTROL_COMMAND + " create "; //$NON-NLS-1$
+    /**
+     * Command to destroy a session. 
+     */
+    private final static String COMMAND_DESTROY_SESSION = CONTROL_COMMAND + " destroy "; //$NON-NLS-1$
+    /**
+     * Command to destroy a session. 
+     */
+    private final static String COMMAND_START_SESSION = CONTROL_COMMAND + " start "; //$NON-NLS-1$
+    /**
+     * Command to destroy a session. 
+     */
+    private final static String COMMAND_STOP_SESSION = CONTROL_COMMAND + " stop "; //$NON-NLS-1$
+    /**
+     * Command to enable a channel. 
+     */
+    private final static String COMMAND_ENABLE_CHANNEL = CONTROL_COMMAND + " enable-channel "; //$NON-NLS-1$
+    /**
+     * Command to destroy a session. 
+     */
+    private final static String COMMAND_DISABLE_CHANNEL = CONTROL_COMMAND + " disable-channel "; //$NON-NLS-1$
 
     // Parsing constants
     /**
@@ -154,7 +179,19 @@ public class LTTngControlService implements ILttngControlService {
      * Pattern to match for UST provider information (lttng list -u)
      */
     private final static Pattern UST_PROVIDER_PATTERN = Pattern.compile("\\s*PID\\:\\s+(\\d+)\\s+-\\s+Name\\:\\s+(.*)"); //$NON-NLS-1$
-
+    /**
+     * Pattern to match for session information (lttng create <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
     // ------------------------------------------------------------------------
@@ -181,18 +218,6 @@ public class LTTngControlService implements ILttngControlService {
     // Operations
     // ------------------------------------------------------------------------
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
-     * #getSessionNames()
-     */
-    @Override
-    public String[] getSessionNames() throws ExecutionException {
-        return getSessionNames(new NullProgressMonitor());
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -232,18 +257,6 @@ public class LTTngControlService implements ILttngControlService {
         return retArray.toArray(new String[retArray.size()]);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
-     * #getSession(java.lang.String)
-     */
-    @Override
-    public ISessionInfo getSession(String sessionName) throws ExecutionException {
-        return getSession(sessionName, new NullProgressMonitor());
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -300,6 +313,9 @@ public class LTTngControlService implements ILttngControlService {
 
                 // set channels
                 domainInfo.setChannels(channels);
+                
+                // set kernel flag
+                domainInfo.setIsKernel(true);
                 continue;
             }
 
@@ -308,12 +324,15 @@ public class LTTngControlService implements ILttngControlService {
                 IDomainInfo domainInfo = new DomainInfo(Messages.TraceControl_UstGlobalDomainDisplayName);
                 sessionInfo.addDomain(domainInfo);
 
-                // in domain kernel
+                // in domain UST
                 ArrayList<IChannelInfo> channels = new ArrayList<IChannelInfo>();
                 index = parseDomain(result.getOutput(), index, channels);
 
                 // set channels
                 domainInfo.setChannels(channels);
+                
+                // set kernel flag
+                domainInfo.setIsKernel(false);
                 continue;
             }
             index++;
@@ -321,18 +340,6 @@ public class LTTngControlService implements ILttngControlService {
         return sessionInfo;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService
-     * #getKernelProvider()
-     */
-    @Override
-    public List<IBaseEventInfo> getKernelProvider() throws ExecutionException {
-        return getKernelProvider(new NullProgressMonitor());
-    }
-
     /*
      * (non-Javadoc)
      * 
@@ -423,6 +430,236 @@ public class LTTngControlService implements ILttngControlService {
         return allProviders;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.lttng.ui.views.control.service.ILttngControlService#createSession(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+    public ISessionInfo createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
+
+        String newName = formatParameter(sessionName);
+        String newPath = formatParameter(sessionPath);
+
+        String command = COMMAND_CREATE_SESSION + newName;
+        if (newPath != null && !"".equals(newPath)) { //$NON-NLS-1$
+            command += " -o " + newPath; //$NON-NLS-1$
+        }
+
+        ICommandResult result = fCommandShell.executeCommand(command, monitor);
+        
+        if (isError(result)) {
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        //Session myssession2 created.
+        //Traces will be written in /home/user/lttng-traces/myssession2-20120209-095418
+        String[] output = result.getOutput();
+        
+        // Get and verify session name
+        Matcher matcher = CREATE_SESSION_NAME_PATTERN.matcher(output[0]);
+        String name = null;
+
+        if (matcher.matches()) {
+            name = String.valueOf(matcher.group(1).trim());
+        } else {
+            // Output format not expected
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ 
+                    Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$ 
+                    formatOutput(result.getOutput())); 
+        }
+
+        if ((name == null) || (!name.equals(sessionName))) {
+            // Unexpected name returned
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ 
+                    Messages.TraceControl_UnexpectedNameError + ": " + name); //$NON-NLS-1$ 
+        }
+        
+        // Get and verify session path
+        matcher = CREATE_SESSION_PATH_PATTERN.matcher(output[1]);
+        String path = null;
+        
+        if (matcher.matches()) {
+            path = String.valueOf(matcher.group(1).trim());
+        } else {
+            // Output format not expected
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ 
+                    Messages.TraceControl_UnexpectedCommnadOutputFormat + ":\n" + //$NON-NLS-1$ 
+                    formatOutput(result.getOutput())); 
+        }
+
+        if ((path == null) || ((sessionPath != null) && (!path.contains(sessionPath)))) {
+            // Unexpected path
+            throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + //$NON-NLS-1$ //$NON-NLS-2$ 
+                    Messages.TraceControl_UnexpectedPathError + ": " + name); //$NON-NLS-1$
+        }
+        
+        SessionInfo sessionInfo = new SessionInfo(name);
+        sessionInfo.setSessionPath(path);
+
+        return sessionInfo;
+    }
+    
+    @Override
+    public void destroySession(String sessionName, IProgressMonitor monitor) throws ExecutionException {
+        String newName = formatParameter(sessionName);
+        String command = COMMAND_DESTROY_SESSION + newName;
+
+        ICommandResult result = fCommandShell.executeCommand(command, monitor);
+        String[] output = result.getOutput();
+        
+        if (isError(result)) {
+            // In case "session not found" treat it as success 
+            if ((output == null) || (!SESSION_NOT_FOUND_ERROR_PATTERN.matcher(output[0]).matches())) {
+                throw new ExecutionException(Messages.TraceControl_CommandError + " " + command + "\n" + formatOutput(result.getOutput())); //$NON-NLS-1$ //$NON-NLS-2$
+            }
+        }
+        //Session <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
     // ------------------------------------------------------------------------
@@ -640,4 +877,22 @@ public class LTTngControlService implements ILttngControlService {
         return index;
     }
 
+    /**
+     * Formats a command parameter for the command execution i.e. adds quotes 
+     * at the beginning and end if necessary.
+     * @param parameter - parameter to format
+     * @return formated parameter
+     */
+    private String formatParameter(String parameter) {
+        if (parameter != null) {
+            String newString = String.valueOf(parameter);
+
+            if (parameter.contains(" ")) { //$NON-NLS-1$
+                newString = "\"" + newString + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+            }
+            return newString;
+        }
+        return null;
+    }
+    
 }
This page took 0.080859 seconds and 5 git commands to generate.