lttng: Fix ControlViewTest
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / TraceSessionComponent.java
index 5a6fa47add7a1ea023e243f75558e017f4a1a81e..98286e1ebccd0f4c926a9bc2e8fbe7d13b0f99e1 100644 (file)
@@ -22,8 +22,9 @@ import org.eclipse.tracecompass.internal.lttng2.control.core.model.IChannelInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IDomainInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISnapshotInfo;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
-import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceLogLevel;
+import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo;
 import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
@@ -108,13 +109,32 @@ public class TraceSessionComponent extends TraceControlComponent {
     }
 
     private void copyLiveInfo(ISessionInfo sessionInfo) {
-        // Since we can't retrieve this information from the node, we copy it over
+        /*
+         * Since we can't retrieve this live port and URL from the node, we
+         * copy it over. Note that this information gets lost when the user
+         * presses the refresh button or restarts or Trace Compass.
+         */
         if (sessionInfo.getLivePort() != null) {
             fSessionInfo.setLivePort(sessionInfo.getLivePort());
         }
         if (sessionInfo.getLiveUrl() != null) {
             fSessionInfo.setLiveUrl(sessionInfo.getLiveUrl());
         }
+
+        /*
+         * Live streaming has been added in 2.4.x. Since we can't retrieve
+         * whether a session is live or not from a 2.4.x node, we copy it over.
+         * Note that this information gets lost when the user presses the
+         * refresh button or restarts or Trace Compass.
+         *
+         * For LTTng 2.5.0 and later it's possible to retrieve this information.
+         * So we don't need to copy this over be set here. This will make sure
+         * that the session is recognized as live after a Trace Compass restart
+         * or a refresh.
+         */
+        if (!getTargetNode().isVersionSupported("2.5.0")) { //$NON-NLS-1$
+            fSessionInfo.setLive(sessionInfo.isLive());
+        }
     }
 
     // ------------------------------------------------------------------------
@@ -220,9 +240,9 @@ public class TraceSessionComponent extends TraceControlComponent {
     }
 
     @Override
-    public Object getAdapter(Class adapter) {
+    public <T> T getAdapter(Class<T> adapter) {
         if (adapter == IPropertySource.class) {
-            return new TraceSessionPropertySource(this);
+            return adapter.cast(new TraceSessionPropertySource(this));
         }
         return null;
     }
@@ -253,10 +273,11 @@ public class TraceSessionComponent extends TraceControlComponent {
 
     /**
      * Returns if node supports filtering of events
+     * @param domain - the domain type ({@link TraceDomainType})
      * @return <code>true</code> if node supports filtering else <code>false</code>
      */
-    public boolean isEventFilteringSupported() {
-        return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported();
+    public boolean isEventFilteringSupported(TraceDomainType domain) {
+        return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported(domain);
     }
 
     /**
@@ -291,8 +312,7 @@ public class TraceSessionComponent extends TraceControlComponent {
 
             IDomainInfo[] domains = fSessionInfo.getDomains();
             for (int i = 0; i < domains.length; i++) {
-                TraceDomainComponent domainComponent = new TraceDomainComponent(
-                        domains[i].getName(), this);
+                TraceDomainComponent domainComponent = new TraceDomainComponent(domains[i].getName(), this);
                 addChild(domainComponent);
                 domainComponent.setDomainInfo(domains[i]);
             }
@@ -334,17 +354,17 @@ public class TraceSessionComponent extends TraceControlComponent {
      * @param info
      *            - channel information to set for the channel (use null for
      *            default)
-     * @param isKernel
-     *            - a flag for indicating kernel or UST.
+     * @param domain
+     *            - indicate the domain type ({@link TraceDomainType})
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableChannels(List<String> channelNames, IChannelInfo info,
-            boolean isKernel, IProgressMonitor monitor)
+            TraceDomainType domain, IProgressMonitor monitor)
             throws ExecutionException {
-        getControlService().enableChannels(getName(), channelNames, isKernel,
+        getControlService().enableChannels(getName(), channelNames, domain,
                 info, monitor);
     }
 
@@ -353,32 +373,36 @@ public class TraceSessionComponent extends TraceControlComponent {
      *
      * @param eventNames
      *            - a list of event names to enabled.
-     * @param isKernel
-     *            - a flag for indicating kernel or UST.
+     * @param domain
+     *            - the type of the domain type ({@link TraceDomainType})
      * @param filterExpression
      *            - a filter expression
+     * @param excludedEvents
+     *            - a list of events to exclude.
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
-    public void enableEvents(List<String> eventNames, boolean isKernel,
-            String filterExpression, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableEvents(getName(), null, eventNames, isKernel,
-                filterExpression, monitor);
+    public void enableEvents(List<String> eventNames, TraceDomainType domain,
+            String filterExpression, List<String> excludedEvents, IProgressMonitor monitor) throws ExecutionException {
+        getControlService().enableEvents(getName(), null, eventNames, domain,
+                filterExpression, excludedEvents, monitor);
     }
 
     /**
      * Enables all syscalls (for kernel domain)
      *
+     * @param syscallNames
+     *            - a list of syscall names to be enabled
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
-    public void enableSyscalls(IProgressMonitor monitor)
+    public void enableSyscalls(List<String> syscallNames, IProgressMonitor monitor)
             throws ExecutionException {
-        getControlService().enableSyscalls(getName(), null, monitor);
+        getControlService().enableSyscalls(getName(), null, syscallNames, monitor);
     }
 
     /**
@@ -404,24 +428,27 @@ public class TraceSessionComponent extends TraceControlComponent {
     /**
      * Enables events using log level.
      *
-     * @param eventName
-     *            - a event name
+     * @param eventNames
+     *            - a list of event names
      * @param logLevelType
      *            - a log level type
      * @param level
      *            - a log level
      * @param filterExpression
      *            - a filter expression
+     * @param domain
+     *            - the domain type ({@link TraceDomainType})
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
-    public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
+    public void enableLogLevel(List<String> eventNames, LogLevelType logLevelType,
+            ITraceLogLevel level, String filterExpression,
+            TraceDomainType domain, IProgressMonitor monitor)
             throws ExecutionException {
-        getControlService().enableLogLevel(getName(), null, eventName,
-                logLevelType, level, null, monitor);
+        getControlService().enableLogLevel(getName(), null, eventNames,
+                logLevelType, level, null, domain, monitor);
     }
 
     /**
@@ -450,6 +477,24 @@ public class TraceSessionComponent extends TraceControlComponent {
         getControlService().recordSnapshot(getName(), monitor);
     }
 
+    /**
+     * Save all or a given session.
+     *
+     * @param session
+     *            a session name to save or null for all
+     * @param outputPath
+     *            a path to save session or null for default location
+     * @param isForce
+     *            flag whether to overwrite existing or not
+     * @param monitor
+     *            a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void saveSession(String session, String outputPath, boolean isForce, IProgressMonitor monitor) throws ExecutionException {
+        getControlService().saveSession(session, outputPath, isForce, monitor);
+    }
+
     /**
      * Returns if session is live.
      * @return <code>true</code> if session if live else <code>false</code>
This page took 0.033579 seconds and 5 git commands to generate.