Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / viewers / statistics / model / TmfBaseColumnData.java
CommitLineData
79e08fd0 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2011, 2014 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
2bdf0193 14package org.eclipse.tracecompass.tmf.ui.viewers.statistics.model;
79e08fd0 15
b3a26928 16import org.eclipse.jdt.annotation.Nullable;
79e08fd0
BH
17import org.eclipse.jface.viewers.ColumnLabelProvider;
18import org.eclipse.jface.viewers.ViewerComparator;
19
20/**
21 * Contains all the information necessary to build a column of the table.
013a5f1c 22 *
b544077e 23 * @author Mathieu Denis
79e08fd0 24 */
b3a26928 25public class TmfBaseColumnData {
013a5f1c 26
b544077e
BH
27 /**
28 * Name of the column.
29 */
b3a26928 30 private final String fHeader;
09667aa4 31
b544077e
BH
32 /**
33 * Width of the column.
34 */
b3a26928 35 private final int fWidth;
09667aa4 36
b544077e
BH
37 /**
38 * Alignment of the column.
39 */
b3a26928 40 private final int fAlignment;
09667aa4 41
b544077e
BH
42 /**
43 * Tooltip of the column.
44 */
b3a26928 45 private 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 */
b3a26928 51 private final ColumnLabelProvider fLabelProvider;
09667aa4 52
b544077e
BH
53 /**
54 * Used to sort elements of this column. Can be null.
55 */
b3a26928 56 private final @Nullable ViewerComparator fComparator;
09667aa4 57
b544077e
BH
58 /**
59 * Used to draw bar charts in this column. Can be null.
60 */
b3a26928 61 private final @Nullable 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
b3a26928
AM
111 /**
112 * Return the column name.
113 *
114 * @return the name of the column.
115 */
79e08fd0
BH
116 public String getHeader() {
117 return fHeader;
118 }
119
b3a26928
AM
120 /**
121 * Return the width of the column at the creation.
122 *
123 * @return the width of the column.
124 */
79e08fd0
BH
125 public int getWidth() {
126 return fWidth;
127 }
128
b3a26928
AM
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 */
79e08fd0
BH
135 public int getAlignment() {
136 return fAlignment;
137 }
138
b3a26928
AM
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 */
79e08fd0
BH
145 public String getTooltip() {
146 return fTooltip;
147 }
148
b3a26928
AM
149 /**
150 * Return the labelProvider which provides the information to put in column
151 * cells.
152 *
153 * @return a ColumnLabelProvider.
154 */
79e08fd0
BH
155 public ColumnLabelProvider getLabelProvider() {
156 return fLabelProvider;
157 }
158
b3a26928
AM
159 /**
160 * Return a ViewerComparator used to sort viewer's contents.
161 *
162 * @return the comparator.
163 */
79e08fd0
BH
164 public ViewerComparator getComparator() {
165 return fComparator;
166 }
167
b3a26928
AM
168 /**
169 * Return the provider of the percentage. Used to draw bar charts in
170 * columns.
171 *
172 * @return the percentageProvider.
173 */
79e08fd0
BH
174 public ITmfColumnPercentageProvider getPercentageProvider() {
175 return fPercentageProvider;
176 }
177}
This page took 0.076709 seconds and 5 git commands to generate.