ctf: Re-enable the CTF parser unit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceSessionComponent.java
index e8cffe2da5218c0ebee7783a628d3f0dc4827558..7fec67c21e650dddbc35e6f9b418ebf47d1ea541 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
@@ -16,24 +16,26 @@ 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.internal.lttng2.core.control.model.IChannelInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IChannelInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.IDomainInfo;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ISessionInfo;
+import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.views.properties.IPropertySource;
 
 /**
- * <b><u>TraceSessionComponent</u></b>
  * <p>
  * Implementation of the trace session component.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 public class TraceSessionComponent extends TraceControlComponent {
 
@@ -77,10 +79,10 @@ public class TraceSessionComponent extends TraceControlComponent {
     // Constructors
     // ------------------------------------------------------------------------
     /**
-     * Constructor 
+     * Constructor
      * @param name - the name of the component.
      * @param parent - the parent of this component.
-     */    
+     */
     public TraceSessionComponent(String name, ITraceControlComponent parent) {
         super(name, parent);
         setImage(TRACE_SESSION_ICON_FILE_INACTIVE);
@@ -106,7 +108,7 @@ public class TraceSessionComponent extends TraceControlComponent {
         if (fSessionInfo.getSessionState() == TraceSessionState.INACTIVE) {
             return super.getImage();
         }
-        
+
         return fActiveImage;
     }
 
@@ -157,7 +159,7 @@ public class TraceSessionComponent extends TraceControlComponent {
 
     /**
      * Sets the path string (where session is located) to the given value.
-     * @param path - session path to set.
+     * @param sessionPath - session path to set.
      */
     public void setSessionPath(String sessionPath) {
         fSessionInfo.setSessionPath(sessionPath);
@@ -167,142 +169,212 @@ public class TraceSessionComponent extends TraceControlComponent {
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
      */
-    @SuppressWarnings("rawtypes")
     @Override
     public Object getAdapter(Class adapter) {
         if (adapter == IPropertySource.class) {
             return new TraceSessionPropertySource(this);
         }
         return null;
-    } 
+    }
 
     /**
      * @return all available domains of this session.
      */
     public TraceDomainComponent[] getDomains() {
         List<ITraceControlComponent> sessions = getChildren(TraceDomainComponent.class);
-        return (TraceDomainComponent[])sessions.toArray(new TraceDomainComponent[sessions.size()]);
+        return sessions.toArray(new TraceDomainComponent[sessions.size()]);
     }
-    
+
     /**
      * @return the parent target node
      */
     public TargetNodeComponent getTargetNode() {
         return ((TraceSessionGroup)getParent()).getTargetNode();
     }
-    
+
+    /**
+     * Returns whether the kernel provider is available or not
+     * @return <code>true</code> if kernel provide is available or <code>false</code>
+     */
+    public boolean hasKernelProvider() {
+        List<ITraceControlComponent> providerGroups = getTargetNode().getChildren(TraceProviderGroup.class);
+        return (!providerGroups.isEmpty() ? ((TraceProviderGroup) providerGroups.get(0)).hasKernelProvider() : false);
+    }
+
+    /**
+     * Returns if node supports filtering of events
+     * @return <code>true</code> if node supports filtering else <code>false</code>
+     */
+    public boolean isEventFilteringSupported() {
+        return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported();
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
+
     /**
-     * Retrieves the session configuration from the node. 
+     * Retrieves the session configuration from the node.
+     *
      * @throws ExecutionException
+     *             If the command fails
      */
     public void getConfigurationFromNode() throws ExecutionException {
         getConfigurationFromNode(new NullProgressMonitor());
     }
 
     /**
-     * Retrieves the session configuration from the node. 
-     * @param monitor - a progress monitor
+     * Retrieves the session configuration from the node.
+     *
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void getConfigurationFromNode(IProgressMonitor monitor) 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 domainComponent = new TraceDomainComponent(domains[i].getName(), this);
+            TraceDomainComponent domainComponent = new TraceDomainComponent(
+                    domains[i].getName(), this);
             addChild(domainComponent);
             domainComponent.setDomainInfo(domains[i]);
         }
     }
-    
+
     /**
-     * Starts the session. 
-     * throws ExecutionExecption
+     * Starts the session.
+     *
+     * @throws ExecutionException
+     *             If the command fails
      */
     public void startSession() throws ExecutionException {
         startSession(new NullProgressMonitor());
     }
-    
+
     /**
      * Starts the session.
-     * @param monitor - a progress monitor
-     * throws ExecutionExecption
+     *
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
      */
-    public void startSession(IProgressMonitor monitor) throws ExecutionException {
+    public void startSession(IProgressMonitor monitor)
+            throws ExecutionException {
         getControlService().startSession(getName(), monitor);
     }
-    
+
     /**
-     * Starts the session. 
-     * throws ExecutionExecption
+     * Starts the session.
+     *
+     * @throws ExecutionException
+     *             If the command fails
      */
     public void stopSession() throws ExecutionException {
         startSession(new NullProgressMonitor());
     }
-    
+
     /**
      * Starts the session.
-     * @param monitor - a progress monitor
-     * throws ExecutionExecption
+     *
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
      */
     public void stopSession(IProgressMonitor monitor) throws ExecutionException {
         getControlService().stopSession(getName(), 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)
-     * @param isKernel -  a flag for indicating kernel or UST.
+     * 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 isKernel
+     *            - a flag for indicating kernel or UST.
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableChannels(List<String> channelNames, IChannelInfo info, boolean isKernel) throws ExecutionException {
+    public void enableChannels(List<String> channelNames, IChannelInfo info,
+            boolean isKernel) throws ExecutionException {
         enableChannels(channelNames, info, isKernel, 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 isKernel -  a flag for indicating kernel or UST.
-     * @param monitor - a progress 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)
+     * @param isKernel
+     *            - a flag for indicating kernel or UST.
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableChannels(List<String> channelNames, IChannelInfo info, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableChannels(getName(), channelNames, isKernel, info, monitor);
+    public void enableChannels(List<String> channelNames, IChannelInfo info,
+            boolean isKernel, IProgressMonitor monitor)
+            throws ExecutionException {
+        getControlService().enableChannels(getName(), channelNames, isKernel,
+                info, monitor);
     }
-    
+
     /**
      * Enables a list of events with no additional parameters.
-     * @param eventNames - a list of event names to enabled.
-     * @param isKernel -  a flag for indicating kernel or UST.
+     *
+     * @param eventNames
+     *            - a list of event names to enabled.
+     * @param isKernel
+     *            - a flag for indicating kernel or UST.
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableEvent(List<String> eventNames, boolean isKernel) throws ExecutionException {
-        enableEvents(eventNames, isKernel, new NullProgressMonitor());
+    public void enableEvent(List<String> eventNames, boolean isKernel, String filterExpression)
+            throws ExecutionException {
+        enableEvents(eventNames, isKernel, filterExpression, new NullProgressMonitor());
     }
 
     /**
      * Enables a list of events with no additional parameters.
-     * @param eventNames - a list of event names to enabled.
-     * @param isKernel -  a flag for indicating kernel or UST.
-     * @param monitor - a progress monitor
+     *
+     * @param eventNames
+     *            - a list of event names to enabled.
+     * @param isKernel
+     *            - a flag for indicating kernel or UST.
+     * @param filterExpression
+     *            - a filter expression
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableEvents(getName(), null, eventNames, isKernel, monitor);
+    public void enableEvents(List<String> eventNames, boolean isKernel,
+            String filterExpression, IProgressMonitor monitor) throws ExecutionException {
+        getControlService().enableEvents(getName(), null, eventNames, isKernel,
+                filterExpression, monitor);
     }
 
     /**
      * Enables all syscalls (for kernel domain)
+     *
      * @throws ExecutionException
+     *             If the command fails
      */
     public void enableSyscalls() throws ExecutionException {
         enableSyscalls(new NullProgressMonitor());
@@ -310,56 +382,119 @@ public class TraceSessionComponent extends TraceControlComponent {
 
     /**
      * Enables all syscalls (for kernel domain)
-     * @param monitor - a progress monitor
+     *
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
+    public void enableSyscalls(IProgressMonitor monitor)
+            throws ExecutionException {
         getControlService().enableSyscalls(getName(), null, monitor);
     }
 
     /**
      * Enables a dynamic probe (for kernel domain)
-     * @param eventName - event name for probe
-     * @param isFunction - true for dynamic function entry/return probe else false
-     * @param probe - the actual probe
+     *
+     * @param eventName
+     *            - event name for probe
+     * @param isFunction
+     *            - true for dynamic function entry/return probe else false
+     * @param probe
+     *            - the actual probe
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException {
+    public void enableProbe(String eventName, boolean isFunction, String probe)
+            throws ExecutionException {
         enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
     }
-    
+
     /**
      * Enables a dynamic probe (for kernel domain)
-     * @param eventName - event name for probe
-     * @param isFunction - true for dynamic function entry/return probe else false
-     * @param probe - the actual probe
-     * @param monitor - a progress monitor
+     *
+     * @param eventName
+     *            - event name for probe
+     * @param isFunction
+     *            - true for dynamic function entry/return probe else false
+     * @param probe
+     *            - the actual probe
+     * @param monitor
+     *            - a progress monitor
      * @throws ExecutionException
+     *             If the command fails
      */
-   public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableProbe(getName(), null, eventName, isFunction, probe, monitor);
+    public void enableProbe(String eventName, boolean isFunction, String probe,
+            IProgressMonitor monitor) throws ExecutionException {
+        getControlService().enableProbe(getName(), null, eventName, isFunction,
+                probe, monitor);
     }
-    
+
     /**
      * Enables events using log level.
-     * @param eventName - a event name
-     * @param logLevelType - a log level type 
-     * @param level - a log level 
+     *
+     * @param eventName
+     *            - a event name
+     * @param logLevelType
+     *            - a log level type
+     * @param level
+     *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException {
-        enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
+    public void enableLogLevel(String eventName, LogLevelType logLevelType,
+            TraceLogLevel level, String filterExpression) throws ExecutionException {
+        enableLogLevel(eventName, logLevelType, level, filterExpression,
+                new NullProgressMonitor());
     }
 
     /**
      * Enables events using log level.
-     * @param eventName - a event name
-     * @param logLevelType - a log level type 
-     * @param level - a log level 
-     * @param monitor - a progress monitor  
+     *
+     * @param eventName
+     *            - a event name
+     * @param logLevelType
+     *            - a log level type
+     * @param level
+     *            - a log level
+     * @param filterExpression
+     *            - a filter expression
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void enableLogLevel(String eventName, LogLevelType logLevelType,
+            TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
+            throws ExecutionException {
+        getControlService().enableLogLevel(getName(), null, eventName,
+                logLevelType, level, null, monitor);
+    }
+
+    /**
+     * Gets all available contexts to be added to channels/events.
+     *
+     * @return the list of available contexts
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public List<String> getContextList() throws ExecutionException {
+        return getContextList(new NullProgressMonitor());
+    }
+
+    /**
+     * Gets all available contexts to be added to channels/events.
+     *
+     * @param monitor
+     *            The monitor that will indicate the progress
+     * @return the list of available contexts
      * @throws ExecutionException
+     *             If the command fails
      */
-    public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableLogLevel(getName(), null, eventName, logLevelType, level, monitor);
+    public List<String> getContextList(IProgressMonitor monitor)
+            throws ExecutionException {
+        return getControlService().getContextList(monitor);
     }
 }
This page took 0.043661 seconds and 5 git commands to generate.