1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.model
.config
;
15 import org
.eclipse
.jface
.viewers
.ILabelProviderListener
;
16 import org
.eclipse
.jface
.viewers
.ITableLabelProvider
;
17 import org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.config
.TraceChannel
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.LTTngUiPlugin
;
19 import org
.eclipse
.swt
.graphics
.Image
;
22 * <b><u>TraceChannelTableLabelProvider</u></b>
24 * ITableLabelProvider implementation for TableViewers in order to provide the labels of a table
25 * used for displaying and configuring trace channel information.
28 public class TraceChannelTableLabelProvider
implements ITableLabelProvider
{
30 // ------------------------------------------------------------------------
32 // -----------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 // -----------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 // -----------------------------------------------------------------------
44 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
47 public void addListener(ILabelProviderListener listener
) {
52 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
55 public void dispose() {
60 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
63 public boolean isLabelProperty(Object element
, String property
) {
69 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
72 public void removeListener(ILabelProviderListener listener
) {
77 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
80 public Image
getColumnImage(Object element
, int columnIndex
) {
81 if (element
instanceof TraceChannel
) {
82 TraceChannel chan
= (TraceChannel
) element
;
83 switch (columnIndex
) {
85 return getImage(chan
.isEnabled() && chan
.isEnabledStatusKnown());
87 return getImage(chan
.isChannelOverride() && chan
.isChannelOverrideStatusKnown());
96 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
99 public String
getColumnText(Object element
, int columnIndex
) {
100 if (element
instanceof TraceChannel
) {
101 TraceChannel chan
= (TraceChannel
) element
;
102 switch (columnIndex
) {
104 return chan
.getName();
106 if (!chan
.isEnabledStatusKnown()) {
107 return TraceChannel
.UNKNOWN_STRING
;
111 if (!chan
.isChannelOverrideStatusKnown()) {
112 return TraceChannel
.UNKNOWN_STRING
;
116 if (chan
.getSubbufNum() == TraceChannel
.UNKNOWN_VALUE
) {
117 return TraceChannel
.UNKNOWN_STRING
;
119 return String
.valueOf(chan
.getSubbufNum());
121 if (chan
.getSubbufSize() == TraceChannel
.UNKNOWN_VALUE
) {
122 return TraceChannel
.UNKNOWN_STRING
;
124 return String
.valueOf(chan
.getSubbufSize());
126 if (chan
.getTimer() == TraceChannel
.UNKNOWN_VALUE
) {
127 return TraceChannel
.UNKNOWN_STRING
;
129 return String
.valueOf(chan
.getTimer());
138 * Gets the checked or unchecked image.
140 private Image
getImage(boolean isSelected
) {
142 return LTTngUiPlugin
.getDefault().getImage(LTTngUiPlugin
.ICON_ID_CHECKED
);
144 return LTTngUiPlugin
.getDefault().getImage(LTTngUiPlugin
.ICON_ID_UNCHECKED
);