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