Commit | Line | Data |
---|---|---|
e8d771d5 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011 Ericsson | |
3 | * | |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | * | |
12 | *******************************************************************************/ | |
638eac44 | 13 | package org.eclipse.linuxtools.internal.lttng.ui.tracecontrol.model.config; |
e8d771d5 BH |
14 | |
15 | import org.eclipse.jface.viewers.ILabelProviderListener; | |
16 | import org.eclipse.jface.viewers.ITableLabelProvider; | |
5945cec9 | 17 | import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config.TraceChannel; |
0977b009 | 18 | import org.eclipse.linuxtools.internal.lttng.ui.Activator; |
e8d771d5 BH |
19 | import org.eclipse.swt.graphics.Image; |
20 | ||
21 | /** | |
22 | * <b><u>TraceChannelTableLabelProvider</u></b> | |
23 | * <p> | |
24 | * ITableLabelProvider implementation for TableViewers in order to provide the labels of a table | |
25 | * used for displaying and configuring trace channel information. | |
26 | * </p> | |
27 | */ | |
28 | public class TraceChannelTableLabelProvider implements ITableLabelProvider { | |
29 | ||
30 | // ------------------------------------------------------------------------ | |
31 | // Attributes | |
32 | // ----------------------------------------------------------------------- | |
33 | ||
34 | // ------------------------------------------------------------------------ | |
35 | // Constructors | |
36 | // ----------------------------------------------------------------------- | |
37 | ||
38 | // ------------------------------------------------------------------------ | |
39 | // Operations | |
40 | // ----------------------------------------------------------------------- | |
41 | ||
42 | /* | |
43 | * (non-Javadoc) | |
44 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) | |
45 | */ | |
46 | @Override | |
47 | public void addListener(ILabelProviderListener listener) { | |
48 | } | |
49 | ||
50 | /* | |
51 | * (non-Javadoc) | |
52 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() | |
53 | */ | |
54 | @Override | |
55 | public void dispose() { | |
56 | } | |
57 | ||
58 | /* | |
59 | * (non-Javadoc) | |
60 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) | |
61 | */ | |
62 | @Override | |
63 | public boolean isLabelProperty(Object element, String property) { | |
64 | return false; | |
65 | } | |
66 | ||
67 | /* | |
68 | * (non-Javadoc) | |
69 | * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) | |
70 | */ | |
71 | @Override | |
72 | public void removeListener(ILabelProviderListener listener) { | |
73 | } | |
74 | ||
75 | /* | |
76 | * (non-Javadoc) | |
77 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) | |
78 | */ | |
79 | @Override | |
80 | public Image getColumnImage(Object element, int columnIndex) { | |
81 | if (element instanceof TraceChannel) { | |
82 | TraceChannel chan = (TraceChannel) element; | |
83 | switch (columnIndex) { | |
84 | case 1: | |
85 | return getImage(chan.isEnabled() && chan.isEnabledStatusKnown()); | |
86 | case 2: | |
87 | return getImage(chan.isChannelOverride() && chan.isChannelOverrideStatusKnown()); | |
88 | default: | |
89 | } | |
90 | } | |
91 | return null; | |
92 | } | |
93 | ||
94 | /* | |
95 | * (non-Javadoc) | |
96 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) | |
97 | */ | |
98 | @Override | |
99 | public String getColumnText(Object element, int columnIndex) { | |
100 | if (element instanceof TraceChannel) { | |
101 | TraceChannel chan = (TraceChannel) element; | |
102 | switch (columnIndex) { | |
103 | case 0: | |
104 | return chan.getName(); | |
105 | case 1: | |
106 | if (!chan.isEnabledStatusKnown()) { | |
107 | return TraceChannel.UNKNOWN_STRING; | |
108 | } | |
109 | break; | |
110 | case 2: | |
111 | if (!chan.isChannelOverrideStatusKnown()) { | |
112 | return TraceChannel.UNKNOWN_STRING; | |
113 | } | |
114 | break; | |
115 | case 3: | |
116 | if (chan.getSubbufNum() == TraceChannel.UNKNOWN_VALUE) { | |
117 | return TraceChannel.UNKNOWN_STRING; | |
118 | } | |
119 | return String.valueOf(chan.getSubbufNum()); | |
120 | case 4: | |
121 | if (chan.getSubbufSize() == TraceChannel.UNKNOWN_VALUE) { | |
122 | return TraceChannel.UNKNOWN_STRING; | |
123 | } | |
124 | return String.valueOf(chan.getSubbufSize()); | |
125 | case 5: | |
126 | if (chan.getTimer() == TraceChannel.UNKNOWN_VALUE) { | |
127 | return TraceChannel.UNKNOWN_STRING; | |
128 | } | |
129 | return String.valueOf(chan.getTimer()); | |
130 | default: | |
131 | // fall through | |
132 | } | |
133 | } | |
134 | return null; | |
135 | } | |
136 | ||
137 | /* | |
138 | * Gets the checked or unchecked image. | |
139 | */ | |
140 | private Image getImage(boolean isSelected) { | |
141 | if (isSelected) { | |
638eac44 | 142 | return Activator.getDefault().getImage(Activator.ICON_ID_CHECKED); |
e8d771d5 | 143 | } |
638eac44 | 144 | return Activator.getDefault().getImage(Activator.ICON_ID_UNCHECKED); |
e8d771d5 BH |
145 | } |
146 | } |