~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnData.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.views.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 1.0
 
23
 * @author Mathieu Denis
 
24
 */
 
25
public class TmfBaseColumnData implements ITmfStatisticsColumnData {
 
26
 
 
27
    /**
 
28
     * Name of the column.
 
29
     */
 
30
    protected final String fHeader;
 
31
    /**
 
32
     * Width of the column.
 
33
     */
 
34
    protected final int fWidth;
 
35
    /**
 
36
     * Alignment of the column.
 
37
     */
 
38
    protected final int fAlignment;
 
39
    /**
 
40
     * Tooltip of the column.
 
41
     */
 
42
    protected final String fTooltip;
 
43
    /**
 
44
     * Adapts a StatisticsTreeNode into the content of it's corresponding cell for that column.
 
45
     */
 
46
    protected final ColumnLabelProvider fLabelProvider;
 
47
    /**
 
48
     * Used to sort elements of this column. Can be null.
 
49
     */
 
50
    protected final ViewerComparator fComparator;
 
51
    /**
 
52
     * Used to draw bar charts in this column. Can be null.
 
53
     */
 
54
    protected final ITmfColumnPercentageProvider fPercentageProvider;
 
55
 
 
56
    /**
 
57
     * Used to draw bar charts in columns.
 
58
     */
 
59
    public interface ITmfColumnPercentageProvider {
 
60
        public double getPercentage(TmfStatisticsTreeNode node);
 
61
    }
 
62
 
 
63
    /**
 
64
     * Constructor with parameters
 
65
     *
 
66
     * @param h header of the column. The name will be shown at the top of the column.
 
67
     * @param w width of the column.
 
68
     * @param a alignment of the text
 
69
     * @param t text to shown as a tooltip when the cursor comes over the header
 
70
     * @param l provide all the column element
 
71
     * @param c used to compare element between them to be able to classify the content of the columns
 
72
     * @param p provide the percentage of a specific element
 
73
     */
 
74
    public TmfBaseColumnData(String h, int w, int a, String t, ColumnLabelProvider l, ViewerComparator c, ITmfColumnPercentageProvider p) {
 
75
        fHeader = h;
 
76
        fWidth = w;
 
77
        fAlignment = a;
 
78
        fTooltip = t;
 
79
        fLabelProvider = l;
 
80
        fComparator = c;
 
81
        fPercentageProvider = p;
 
82
    }
 
83
 
 
84
    /*
 
85
     * (non-Javadoc)
 
86
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getHeader()
 
87
     */
 
88
    @Override
 
89
    public String getHeader() {
 
90
        return fHeader;
 
91
    }
 
92
 
 
93
    /*
 
94
     * (non-Javadoc)
 
95
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getWidth()
 
96
     */
 
97
    @Override
 
98
    public int getWidth() {
 
99
        return fWidth;
 
100
    }
 
101
 
 
102
    /*
 
103
     * (non-Javadoc)
 
104
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getAlignment()
 
105
     */
 
106
    @Override
 
107
    public int getAlignment() {
 
108
        return fAlignment;
 
109
    }
 
110
 
 
111
    /*
 
112
     * (non-Javadoc)
 
113
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getTooltip()
 
114
     */
 
115
    @Override
 
116
    public String getTooltip() {
 
117
        return fTooltip;
 
118
    }
 
119
 
 
120
    /*
 
121
     * (non-Javadoc)
 
122
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getLabelProvider()
 
123
     */
 
124
    @Override
 
125
    public ColumnLabelProvider getLabelProvider() {
 
126
        return fLabelProvider;
 
127
    }
 
128
 
 
129
    /*
 
130
     * (non-Javadoc)
 
131
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getComparator()
 
132
     */
 
133
    @Override
 
134
    public ViewerComparator getComparator() {
 
135
        return fComparator;
 
136
    }
 
137
 
 
138
    /*
 
139
     * (non-Javadoc)
 
140
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getPercentageProvider()
 
141
     */
 
142
    @Override
 
143
    public ITmfColumnPercentageProvider getPercentageProvider() {
 
144
        return fPercentageProvider;
 
145
    }
 
146
}