Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ca162aef0af2d1e912d3b97932eaf5acad327e99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*******************************************************************************
 * Copyright (c) 2009, 2018 STMicroelectronics and others.
 * 
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.dataviewers.abstractviewers;

import org.eclipse.linuxtools.dataviewers.listeners.ISpecialDrawerListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

/**
 * This class defines how the data is displayed for a given column. This renderer is on charge of providing several
 * things:
 * <ul>
 * <li>the name of the column header
 * <li>the tooltip of the column header
 * <li>It computes the label to display for each object given by the {@link org.eclipse.jface.viewers.ITreeContentProvider}
 * <li>It computes the tooltip to display for each object given by the {@link org.eclipse.jface.viewers.ITreeContentProvider}
 * <li>It computes the background and foreground color to display for each object given by the
 * {@link org.eclipse.jface.viewers.ITreeContentProvider}
 * <li>It computes the image to display for each object given by the {@link org.eclipse.jface.viewers.ITreeContentProvider}
 * <li>It provides a comparator, used to compare objects given by the {@link org.eclipse.jface.viewers.ITreeContentProvider}
 * <li>It allows a "custom rendering", for example if you want to display percentages as progress bars or to display
 * hyperlink as underlined text
 * </ul>
 */
public interface ISTDataViewersField {
    /**
     * @return String the description of the field.
     */
    String getDescription();

    /**
     * @return the image associated with the description of the field or <code>null</code>.
     */
    Image getDescriptionImage();

    /**
     * @return The text to be displayed in the column header for this field.
     */
    String getColumnHeaderText();

    /**
     * @return The tooltip to be displayed in the column header for this field.
     */
    String getColumnHeaderTooltip();

    /**
     * @return The image to be displayed in the column header for this field or <code>null</code>.
     */
    Image getColumnHeaderImage();

    /**
     * @param obj The object whose image is asked for.
     * @return The String value of the object for this particular field displayed to the user.
     */
    String getValue(Object obj);

    /**
     * @param obj The object whose image is asked for.
     * @return The image value of the object for this particular field displayed to the user or <code>null</code>.
     */
    Image getImage(Object obj);

    /**
     * Compares the given objects.
     *
     * Returns a negative number if the value of obj1 is less than the value of obj2 for this field,
     * <code>0</code> if the value of obj1 and the value of obj2 are equal for this field or a positive number
     * if the value of obj1 is greater than the value of obj2 for this field.
     *
     * @param obj1 The first object to compare.
     * @param obj2 The second object to compare.
     * @return The result of the comparison.
     */
    int compare(Object obj1, Object obj2);

    /**
     * Get the default direction for the receiver. Return either {@link STDataViewersComparator#ASCENDING } or
     * {@link STDataViewersComparator#DESCENDING }
     * @return int
     */
    int getDefaultDirection();

    /**
     * Get the preferred width of the receiver.
     * @return int
     */
    int getPreferredWidth();

    /**
     * Return whether the receiver is showing or not by default.
     * @return boolean
     * @since 5.0
     */
    boolean isShowingByDefault();

    /**
     * Returns special drawer, typically used paint percentages paint hyperlink.
     *
     * @param element The element whose special drawer is needed.
     * @return A special drawer.
     */
    ISpecialDrawerListener getSpecialDrawer(Object element);

    /**
     * @param element The element whose tooltip is needed.
     * @return the tooltip to display this particular element.
     */
    String getToolTipText(Object element);

    /**
     * @param element The element whose background is needed.
     * @return the background color for the given element
     */
    Color getBackground(Object element);

    /**
     * @param element The element whose foreground is needed.
     * @return the foreground color for the given element
     */
    Color getForeground(Object element);

    /**
     * Customize the horizontal alignment of the columns.
     * @return one of: SWT.LEFT, SWT.RIGHT, SWT.CENTER, SWT.NONE. Note that SWT.NONE is equivalent to SWT.LEFT
     */
    int getAlignment();
}

Back to the top