~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« 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: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

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
 
 
61
 
        /**
62
 
         * Percentage provider
63
 
         *
64
 
         * @param node
65
 
         *            The statistics tree node
66
 
         * @return The value as a percentage
67
 
         */
68
 
        public double getPercentage(TmfStatisticsTreeNode node);
69
 
    }
70
 
 
71
 
    /**
72
 
     * Constructor with parameters
73
 
     *
74
 
     * @param h
75
 
     *            header of the column. The name will be shown at the top of the
76
 
     *            column.
77
 
     * @param w
78
 
     *            width of the column.
79
 
     * @param a
80
 
     *            alignment of the text
81
 
     * @param t
82
 
     *            text to shown as a tooltip when the cursor comes over the
83
 
     *            header
84
 
     * @param l
85
 
     *            provide all the column element
86
 
     * @param c
87
 
     *            used to compare element between them to be able to classify
88
 
     *            the content of the columns
89
 
     * @param p
90
 
     *            provide the percentage of a specific element
91
 
     */
92
 
    public TmfBaseColumnData(String h, int w, int a, String t,
93
 
            ColumnLabelProvider l, ViewerComparator c,
94
 
            ITmfColumnPercentageProvider p) {
95
 
        fHeader = h;
96
 
        fWidth = w;
97
 
        fAlignment = a;
98
 
        fTooltip = t;
99
 
        fLabelProvider = l;
100
 
        fComparator = c;
101
 
        fPercentageProvider = p;
102
 
    }
103
 
 
104
 
    /*
105
 
     * (non-Javadoc)
106
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getHeader()
107
 
     */
108
 
    @Override
109
 
    public String getHeader() {
110
 
        return fHeader;
111
 
    }
112
 
 
113
 
    /*
114
 
     * (non-Javadoc)
115
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getWidth()
116
 
     */
117
 
    @Override
118
 
    public int getWidth() {
119
 
        return fWidth;
120
 
    }
121
 
 
122
 
    /*
123
 
     * (non-Javadoc)
124
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getAlignment()
125
 
     */
126
 
    @Override
127
 
    public int getAlignment() {
128
 
        return fAlignment;
129
 
    }
130
 
 
131
 
    /*
132
 
     * (non-Javadoc)
133
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getTooltip()
134
 
     */
135
 
    @Override
136
 
    public String getTooltip() {
137
 
        return fTooltip;
138
 
    }
139
 
 
140
 
    /*
141
 
     * (non-Javadoc)
142
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getLabelProvider()
143
 
     */
144
 
    @Override
145
 
    public ColumnLabelProvider getLabelProvider() {
146
 
        return fLabelProvider;
147
 
    }
148
 
 
149
 
    /*
150
 
     * (non-Javadoc)
151
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getComparator()
152
 
     */
153
 
    @Override
154
 
    public ViewerComparator getComparator() {
155
 
        return fComparator;
156
 
    }
157
 
 
158
 
    /*
159
 
     * (non-Javadoc)
160
 
     * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getPercentageProvider()
161
 
     */
162
 
    @Override
163
 
    public ITmfColumnPercentageProvider getPercentageProvider() {
164
 
        return fPercentageProvider;
165
 
    }
166
 
}