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