Commit | Line | Data |
---|---|---|
79e08fd0 | 1 | /******************************************************************************* |
b544077e | 2 | * Copyright (c) 2011, 2012 Ericsson |
013a5f1c | 3 | * |
79e08fd0 BH |
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 | |
013a5f1c | 8 | * |
79e08fd0 | 9 | * Contributors: |
09667aa4 | 10 | * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial Implementation |
013a5f1c | 11 | * Bernd Hufmann - Added Annotations |
79e08fd0 BH |
12 | *******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.tmf.ui.views.statistics.model; | |
15 | ||
16 | import org.eclipse.jface.viewers.ColumnLabelProvider; | |
17 | import org.eclipse.jface.viewers.ViewerComparator; | |
18 | ||
19 | /** | |
20 | * Contains all the information necessary to build a column of the table. | |
013a5f1c AM |
21 | * |
22 | * @version 1.0 | |
b544077e | 23 | * @author Mathieu Denis |
79e08fd0 BH |
24 | */ |
25 | public class TmfBaseColumnData implements ITmfStatisticsColumnData { | |
013a5f1c | 26 | |
b544077e BH |
27 | /** |
28 | * Name of the column. | |
29 | */ | |
66711dc8 | 30 | protected final String fHeader; |
09667aa4 | 31 | |
b544077e BH |
32 | /** |
33 | * Width of the column. | |
34 | */ | |
66711dc8 | 35 | protected final int fWidth; |
09667aa4 | 36 | |
b544077e BH |
37 | /** |
38 | * Alignment of the column. | |
39 | */ | |
66711dc8 | 40 | protected final int fAlignment; |
09667aa4 | 41 | |
b544077e BH |
42 | /** |
43 | * Tooltip of the column. | |
44 | */ | |
66711dc8 | 45 | protected final String fTooltip; |
09667aa4 | 46 | |
b544077e | 47 | /** |
09667aa4 MD |
48 | * Adapts a StatisticsTreeNode into the content of it's corresponding cell |
49 | * for that column. | |
b544077e | 50 | */ |
66711dc8 | 51 | protected final ColumnLabelProvider fLabelProvider; |
09667aa4 | 52 | |
b544077e BH |
53 | /** |
54 | * Used to sort elements of this column. Can be null. | |
55 | */ | |
66711dc8 | 56 | protected final ViewerComparator fComparator; |
09667aa4 | 57 | |
b544077e BH |
58 | /** |
59 | * Used to draw bar charts in this column. Can be null. | |
60 | */ | |
66711dc8 | 61 | protected final ITmfColumnPercentageProvider fPercentageProvider; |
013a5f1c | 62 | |
b544077e BH |
63 | /** |
64 | * Used to draw bar charts in columns. | |
65 | */ | |
79e08fd0 | 66 | public interface ITmfColumnPercentageProvider { |
20ff3b75 AM |
67 | |
68 | /** | |
69 | * Percentage provider | |
70 | * | |
71 | * @param node | |
72 | * The statistics tree node | |
73 | * @return The value as a percentage | |
74 | */ | |
79e08fd0 BH |
75 | public double getPercentage(TmfStatisticsTreeNode node); |
76 | } | |
77 | ||
78 | /** | |
79 | * Constructor with parameters | |
013a5f1c | 80 | * |
20ff3b75 AM |
81 | * @param h |
82 | * header of the column. The name will be shown at the top of the | |
83 | * column. | |
84 | * @param w | |
85 | * width of the column. | |
86 | * @param a | |
87 | * alignment of the text | |
88 | * @param t | |
89 | * text to shown as a tooltip when the cursor comes over the | |
90 | * header | |
91 | * @param l | |
92 | * provide all the column element | |
93 | * @param c | |
94 | * used to compare element between them to be able to classify | |
95 | * the content of the columns | |
96 | * @param p | |
97 | * provide the percentage of a specific element | |
79e08fd0 | 98 | */ |
20ff3b75 AM |
99 | public TmfBaseColumnData(String h, int w, int a, String t, |
100 | ColumnLabelProvider l, ViewerComparator c, | |
101 | ITmfColumnPercentageProvider p) { | |
79e08fd0 BH |
102 | fHeader = h; |
103 | fWidth = w; | |
104 | fAlignment = a; | |
105 | fTooltip = t; | |
106 | fLabelProvider = l; | |
107 | fComparator = c; | |
108 | fPercentageProvider = p; | |
109 | } | |
013a5f1c | 110 | |
79e08fd0 BH |
111 | /* |
112 | * (non-Javadoc) | |
113 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getHeader() | |
114 | */ | |
115 | @Override | |
116 | public String getHeader() { | |
117 | return fHeader; | |
118 | } | |
119 | ||
120 | /* | |
121 | * (non-Javadoc) | |
122 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getWidth() | |
123 | */ | |
124 | @Override | |
125 | public int getWidth() { | |
126 | return fWidth; | |
127 | } | |
128 | ||
129 | /* | |
130 | * (non-Javadoc) | |
131 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getAlignment() | |
132 | */ | |
133 | @Override | |
134 | public int getAlignment() { | |
135 | return fAlignment; | |
136 | } | |
137 | ||
138 | /* | |
139 | * (non-Javadoc) | |
140 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getTooltip() | |
141 | */ | |
142 | @Override | |
143 | public String getTooltip() { | |
144 | return fTooltip; | |
145 | } | |
146 | ||
147 | /* | |
148 | * (non-Javadoc) | |
149 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getLabelProvider() | |
150 | */ | |
151 | @Override | |
152 | public ColumnLabelProvider getLabelProvider() { | |
153 | return fLabelProvider; | |
154 | } | |
155 | ||
156 | /* | |
157 | * (non-Javadoc) | |
158 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getComparator() | |
159 | */ | |
160 | @Override | |
161 | public ViewerComparator getComparator() { | |
162 | return fComparator; | |
163 | } | |
164 | ||
165 | /* | |
166 | * (non-Javadoc) | |
167 | * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getPercentageProvider() | |
168 | */ | |
169 | @Override | |
170 | public ITmfColumnPercentageProvider getPercentageProvider() { | |
171 | return fPercentageProvider; | |
172 | } | |
173 | } |