Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2b2e49c7708ac261d9cae4f9df0dc19fd412e9a3 (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
138
139
/*******************************************************************************
 * Copyright (c) 2009 STMicroelectronics.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Marzia Maugeri <marzia.maugeri@st.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.dataviewers.abstractviewers;

import org.eclipse.jface.viewers.ITreeContentProvider;
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 ITreeContentProvider}
 * <li>It computes the tooltip to display for each object given by the {@link ITreeContentProvider}
 * <li>It computes the background & foreground color to display for each object given by the
 * {@link ITreeContentProvider}
 * <li>It computes the image to display for each object given by the {@link ITreeContentProvider}
 * <li>It provides a comparator, used to compare objects given by the {@link 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>
 * Three abstract implementations are available: {@link AbstractSTDataViewersField} for default rendering
 * {@link AbstractPercentageDrawerField} for displaying percentages as progress bars
 * {@link STDataViewersHyperLinkDrawerField} for displaying hyperlinks as underlined text
 */
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
     * @return The String value of the object for this particular field displayed to the user.
     */
    String getValue(Object obj);

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

    /**
     * @param obj1
     * @param obj2
     * @return Either: <li>a negative number if the value of obj1 is less than the value of obj2 for this field. <li>
     *         <code>0</code> if the value of obj1 and the value of obj2 are equal for this field. <li>a positive number
     *         if the value of obj1 is greater than the value of obj2 for this field.
     */
    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 to: paint percentages paint hyperlink
     * @return a special drawer
     */
    ISpecialDrawerListener getSpecialDrawer(Object element);

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

    /**
     * @param element
     * @return the background color for the given element
     */
    Color getBackground(Object element);

    /**
     * @param element
     * @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();

    /**
     * Indicates if the given element is a hyperlink to something as a view, editor, dialog,etc...
     */
    boolean isHyperLink(Object element);

}

Back to the top