1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson
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
10 * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial Implementation
11 * Bernd Hufmann - Added Annotations
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.viewers
.statistics
.model
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
18 import org
.eclipse
.jface
.viewers
.ViewerComparator
;
21 * Contains all the information necessary to build a column of the table.
23 * @author Mathieu Denis
25 public class TmfBaseColumnData
{
30 private final String fHeader
;
33 * Width of the column.
35 private final int fWidth
;
38 * Alignment of the column.
40 private final int fAlignment
;
43 * Tooltip of the column.
45 private final String fTooltip
;
48 * Adapts a StatisticsTreeNode into the content of it's corresponding cell
51 private final ColumnLabelProvider fLabelProvider
;
54 * Used to sort elements of this column. Can be null.
56 private final @Nullable ViewerComparator fComparator
;
59 * Used to draw bar charts in this column. Can be null.
61 private final @Nullable ITmfColumnPercentageProvider fPercentageProvider
;
64 * Used to draw bar charts in columns.
66 public interface ITmfColumnPercentageProvider
{
72 * The statistics tree node
73 * @return The value as a percentage
75 public double getPercentage(TmfStatisticsTreeNode node
);
79 * Constructor with parameters
82 * header of the column. The name will be shown at the top of the
85 * width of the column.
87 * alignment of the text
89 * text to shown as a tooltip when the cursor comes over the
92 * provide all the column element
94 * used to compare element between them to be able to classify
95 * the content of the columns
97 * provide the percentage of a specific element
99 public TmfBaseColumnData(String h
, int w
, int a
, String t
,
100 ColumnLabelProvider l
, ViewerComparator c
,
101 ITmfColumnPercentageProvider p
) {
108 fPercentageProvider
= p
;
112 * Return the column name.
114 * @return the name of the column.
116 public String
getHeader() {
121 * Return the width of the column at the creation.
123 * @return the width of the column.
125 public int getWidth() {
130 * Return the alignment of the column.
132 * @see org.eclipse.swt.SWT
133 * @return an integer representing the alignment inside the column.
135 public int getAlignment() {
140 * Provide the text to show in the tooltip when the cursor comes over the
143 * @return text to show in the tooltip
145 public String
getTooltip() {
150 * Return the labelProvider which provides the information to put in column
153 * @return a ColumnLabelProvider.
155 public ColumnLabelProvider
getLabelProvider() {
156 return fLabelProvider
;
160 * Return a ViewerComparator used to sort viewer's contents.
162 * @return the comparator.
164 public ViewerComparator
getComparator() {
169 * Return the provider of the percentage. Used to draw bar charts in
172 * @return the percentageProvider.
174 public ITmfColumnPercentageProvider
getPercentageProvider() {
175 return fPercentageProvider
;