Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / viewers / statistics / model / TmfBaseColumnData.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 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.tracecompass.tmf.ui.viewers.statistics.model;
15
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.jface.viewers.ColumnLabelProvider;
18 import org.eclipse.jface.viewers.ViewerComparator;
19
20 /**
21 * Contains all the information necessary to build a column of the table.
22 *
23 * @author Mathieu Denis
24 */
25 public class TmfBaseColumnData {
26
27 /**
28 * Name of the column.
29 */
30 private final String fHeader;
31
32 /**
33 * Width of the column.
34 */
35 private final int fWidth;
36
37 /**
38 * Alignment of the column.
39 */
40 private final int fAlignment;
41
42 /**
43 * Tooltip of the column.
44 */
45 private final String fTooltip;
46
47 /**
48 * Adapts a StatisticsTreeNode into the content of it's corresponding cell
49 * for that column.
50 */
51 private final ColumnLabelProvider fLabelProvider;
52
53 /**
54 * Used to sort elements of this column. Can be null.
55 */
56 private final @Nullable ViewerComparator fComparator;
57
58 /**
59 * Used to draw bar charts in this column. Can be null.
60 */
61 private final @Nullable ITmfColumnPercentageProvider fPercentageProvider;
62
63 /**
64 * Used to draw bar charts in columns.
65 */
66 public interface ITmfColumnPercentageProvider {
67
68 /**
69 * Percentage provider
70 *
71 * @param node
72 * The statistics tree node
73 * @return The value as a percentage
74 */
75 public double getPercentage(TmfStatisticsTreeNode node);
76 }
77
78 /**
79 * Constructor with parameters
80 *
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
98 */
99 public TmfBaseColumnData(String h, int w, int a, String t,
100 ColumnLabelProvider l, ViewerComparator c,
101 ITmfColumnPercentageProvider p) {
102 fHeader = h;
103 fWidth = w;
104 fAlignment = a;
105 fTooltip = t;
106 fLabelProvider = l;
107 fComparator = c;
108 fPercentageProvider = p;
109 }
110
111 /**
112 * Return the column name.
113 *
114 * @return the name of the column.
115 */
116 public String getHeader() {
117 return fHeader;
118 }
119
120 /**
121 * Return the width of the column at the creation.
122 *
123 * @return the width of the column.
124 */
125 public int getWidth() {
126 return fWidth;
127 }
128
129 /**
130 * Return the alignment of the column.
131 *
132 * @see org.eclipse.swt.SWT
133 * @return an integer representing the alignment inside the column.
134 */
135 public int getAlignment() {
136 return fAlignment;
137 }
138
139 /**
140 * Provide the text to show in the tooltip when the cursor comes over the
141 * column header.
142 *
143 * @return text to show in the tooltip
144 */
145 public String getTooltip() {
146 return fTooltip;
147 }
148
149 /**
150 * Return the labelProvider which provides the information to put in column
151 * cells.
152 *
153 * @return a ColumnLabelProvider.
154 */
155 public ColumnLabelProvider getLabelProvider() {
156 return fLabelProvider;
157 }
158
159 /**
160 * Return a ViewerComparator used to sort viewer's contents.
161 *
162 * @return the comparator.
163 */
164 public ViewerComparator getComparator() {
165 return fComparator;
166 }
167
168 /**
169 * Return the provider of the percentage. Used to draw bar charts in
170 * columns.
171 *
172 * @return the percentageProvider.
173 */
174 public ITmfColumnPercentageProvider getPercentageProvider() {
175 return fPercentageProvider;
176 }
177 }
This page took 0.034493 seconds and 5 git commands to generate.