lttng: Disallow adding contexts on events for v2.2 or later (419455)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceEventComponent.java
index f67b3cff0c999cba0627f28d0e8d351e94995de1..31ce99c81c3694540104a9d787e0ab64aa06bc96 100644 (file)
@@ -1,33 +1,40 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
- * 
+ * Copyright (c) 2012, 2013 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
+ *   Bernd Hufmann - Updated for support of LTTng Tools 2.1
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
 
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
 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.IEventInfo;
+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.TraceEnablement;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceEventType;
-import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceEventPropertySource;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.views.properties.IPropertySource;
 
 
 /**
- * <b><u>TraceEventComponent</u></b>
  * <p>
  * Implementation of the trace channel component.
  * </p>
+ *
+ * @author Bernd Hufmann
  */
 public class TraceEventComponent extends TraceControlComponent {
     // ------------------------------------------------------------------------
@@ -41,7 +48,7 @@ public class TraceEventComponent extends TraceControlComponent {
      * Path to icon file for this component (disabled state).
      */
     public static final String TRACE_EVENT_ICON_FILE_DISABLED = "icons/obj16/event_disabled.gif"; //$NON-NLS-1$
-    
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -53,15 +60,15 @@ public class TraceEventComponent extends TraceControlComponent {
      * The image to be displayed when in disabled state.
      */
     private Image fDisabledImage = null;
-    
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
     /**
-     * Constructor 
+     * Constructor
      * @param name - the name of the component.
      * @param parent - the parent of this component.
-     */    
+     */
     public TraceEventComponent(String name, ITraceControlComponent parent) {
         super(name, parent);
         setImage(TRACE_EVENT_ICON_FILE_ENABLED);
@@ -69,14 +76,11 @@ public class TraceEventComponent extends TraceControlComponent {
         fEventInfo = new EventInfo(name);
         fDisabledImage = Activator.getDefault().loadIcon(TRACE_EVENT_ICON_FILE_DISABLED);
     }
-    
+
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
-     */
+
     @Override
     public Image getImage() {
         if (fEventInfo.getState() == TraceEnablement.DISABLED) {
@@ -84,7 +88,7 @@ public class TraceEventComponent extends TraceControlComponent {
         }
         return super.getImage();
     }
-    
+
     /**
      * Sets the event information.
      * @param eventInfo - the event information to set.
@@ -92,25 +96,25 @@ public class TraceEventComponent extends TraceControlComponent {
     public void setEventInfo(IEventInfo eventInfo) {
         fEventInfo = eventInfo;
     }
-    
+
     /**
      * @return the trace event type
      */
     public TraceEventType getEventType() {
         return fEventInfo.getEventType();
     }
-    
+
     /**
-     * Sets the trace event type to the given type 
+     * Sets the trace event type to the given type
      * @param type - type to set
      */
     public void setEventType(TraceEventType type) {
         fEventInfo.setEventType(type);
     }
-    
+
     /**
      * Sets the trace event type to the type specified by the given name.
-     * @param type - event type name
+     * @param typeName - event type name
      */
     public void setEventType(String typeName) {
         fEventInfo.setEventType(typeName);
@@ -122,7 +126,7 @@ public class TraceEventComponent extends TraceControlComponent {
     public TraceEnablement getState() {
         return fEventInfo.getState();
     }
-    
+
     /**
      * Sets the event state (enablement) to the given value.
      * @param state - state to set.
@@ -130,7 +134,7 @@ public class TraceEventComponent extends TraceControlComponent {
     public void setState(TraceEnablement state) {
         fEventInfo.setState(state);
     }
-    
+
     /**
      * Sets the event state (enablement) to the value specified by the given name.
      * @param stateName - state to set.
@@ -145,15 +149,15 @@ public class TraceEventComponent extends TraceControlComponent {
     public TraceLogLevel getLogLevel() {
         return fEventInfo.getLogLevel();
     }
-    
+
     /**
-     * Sets the trace event log level to the given level 
+     * Sets the trace event log level to the given level
      * @param level - event log level to set
      */
     public void setLogLevel(TraceLogLevel level) {
         fEventInfo.setLogLevel(level);
     }
-    
+
     /**
      * Sets the trace event log level to the level specified by the given name.
      * @param levelName - event log level name
@@ -161,32 +165,57 @@ public class TraceEventComponent extends TraceControlComponent {
     public void setLogLevel(String levelName) {
         fEventInfo.setLogLevel(levelName);
     }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
+
+    /**
+     * Returns filter expression.
+     * @return filter expression
+     */
+    public String getFilterExpression() {
+        return fEventInfo.getFilterExpression();
+    }
+
+    /**
+     * Sets the filter expression.
+     * @param filter The filter expression to set
      */
-    @SuppressWarnings("rawtypes")
+    public void setFilterExpression(String filter) {
+        fEventInfo.setFilterExpression(filter);
+    }
+
     @Override
     public Object getAdapter(Class adapter) {
         if (adapter == IPropertySource.class) {
             return new TraceEventPropertySource(this);
         }
         return null;
-    } 
-    
+    }
+
+    /**
+     * @return target node component.
+     */
+    public TargetNodeComponent getTargetNode() {
+        return ((TraceChannelComponent)getParent()).getTargetNode();
+    }
+
     /**
      * @return session name from parent
      */
     public String getSessionName() {
-       return ((TraceChannelComponent)getParent()).getSessionName(); 
+       return ((TraceChannelComponent)getParent()).getSessionName();
+    }
+
+    /**
+     * @return session from parent
+     */
+    public TraceSessionComponent getSession() {
+       return ((TraceChannelComponent)getParent()).getSession();
     }
 
     /**
      * @return channel name from parent
      */
     public String getChannelName() {
-        return getParent().getName(); 
+        return getParent().getName();
     }
 
     /**
@@ -199,4 +228,20 @@ public class TraceEventComponent extends TraceControlComponent {
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
+
+    /**
+     * Add contexts to given channels and or events
+     *
+     * @param contexts
+     *            - a list of contexts to add
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void addContexts(List<String> contexts, IProgressMonitor monitor)
+            throws ExecutionException {
+        getControlService().addContexts(getSessionName(), getChannelName(),
+                getName(), isKernel(), contexts, monitor);
+    }
 }
This page took 0.027144 seconds and 5 git commands to generate.