Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c713621681e4373e976f2d44b990ca98c100669e (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
/*******************************************************************************
 * Copyright (c) 2011 Wind River Systems and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Wind River Systems - initial API and implementation
 *     IBM Corporation - ongoing bug fixes and enhancements
 *******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model;

import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;

/**
 * This interface must be implemented by the viewer which uses the
 * {@link TreeModelContentProvider} content provider.  It allows the content
 * provider to update the viewer with information retrieved from the
 * content, proxy, memento, and other element-based providers.
 *
 * @since 3.8
 */
public interface IInternalTreeModelViewer extends ITreeModelViewer {

    /**
     * Returns this viewer's filters.
     *
     * @return an array of viewer filters
     * @see org.eclipse.jface.viewers.StructuredViewer#setFilters(ViewerFilter[])
     */
    @Override ViewerFilter[] getFilters();

    /**
     * Reveals the given element in the viewer.
     * @param path Path to the element's parent.
     * @param index Index of the element to be revealed.
     */
    void reveal(TreePath path, int index);

    /**
     * Triggers an update of the given element's state.  If multiple instances
     * of the given element are found in the tree, they will all be updated.
     *
     * @param element Element to update.
     */
    void update(Object element);

    /**
     * Sets the given object to be the element at the given index of the given parent.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param parentOrTreePath Parent object, or a tree path of the parent element.
     * @param index Index at which to set the new element.
     * @param element Element object.
     * @noreference This method is not intended to be referenced by clients.
     */
    void replace(Object parentOrTreePath, final int index, Object element);

    /**
     * Set the number of children of the given element or tree path. To set the
     * number of children of the invisible root of the tree, you can pass the
     * input object or an empty tree path.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param elementOrTreePath The element, or tree path.
     * @param count new value
     * @noreference This method is not intended to be referenced by clients.
     */
    void setChildCount(final Object elementOrTreePath, final int count);

    /**
     * Inform the viewer about whether the given element or tree path has
     * children. Avoid calling this method if the number of children has
     * already been set.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param elementOrTreePath the element, or tree path
     * @param hasChildren new value.
     * @noreference This method is not intended to be referenced by clients.
     */
    void setHasChildren(final Object elementOrTreePath, final boolean hasChildren);

    /**
     * Performs auto expand on an element at the specified path if the auto expand
     * level dictates the element should be expanded.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param elementPath tree path to element to consider for expansion
     * @noreference This method is not intended to be referenced by clients.
     */
    void autoExpand(TreePath elementPath);

    /**
     * Sets whether the node corresponding to the given element or tree path is
     * expanded or collapsed.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param elementOrTreePath
     *            the element, or the tree path to the element
     * @param expanded
     *            <code>true</code> if the node is expanded, and
     *            <code>false</code> if collapsed
     *
     * @noreference This method is not intended to be referenced by clients.
     */
    void setExpandedState(Object elementOrTreePath, boolean expanded);

    /**
     * Expands all ancestors of the given element or tree path so that the given
     * element becomes visible in this viewer's tree control, and then expands
     * the subtree rooted at the given element to the given level.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param elementOrTreePath
     *            the element
     * @param level
     *            non-negative level, or <code>ALL_LEVELS</code> to expand all
     *            levels of the tree
     *
     * @noreference This method is not intended to be referenced by clients.
     */
    void expandToLevel(Object elementOrTreePath, int level);

    /**
     * Removes the given element from the viewer. The selection is updated if
     * necessary.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     * @param elementOrTreePath the element, or the tree path to the element
     * @noreference This method is not intended to be referenced by clients.
     */
    void remove(Object elementOrTreePath);

    /**
     * Removes the element at the specified index of the parent.  The selection is updated if required.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param parentOrTreePath the parent element, the input element, or a tree path to the parent element
     * @param index child index
     * @noreference This method is not intended to be referenced by clients.
     */
    void remove(Object parentOrTreePath, final int index);

    /**
     * Inserts the given element as a new child element of the given parent
     * element at the given position. If this viewer has a sorter, the position
     * is ignored and the element is inserted at the correct position in the
     * sort order.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     * @param parentOrTreePath the parent element, or the tree path to the parent
     *
     * @param element the element
     * @param position a 0-based position relative to the model, or -1 to indicate
     * the last position
     * @noreference This method is not intended to be referenced by clients.
     */
    void insert(Object parentOrTreePath, Object element, int position);

    /**
     * Returns whether the candidate selection should override the current
     * selection.
     * @param current Current selection in viewer.
     * @param candidate Proposed new selection.
     * @return whether new selection should override the current
     */
    boolean overrideSelection(ISelection current, ISelection candidate);

    /**
     * Returns whether the node corresponding to the given element or tree path
     * is expanded or collapsed.
     *
     * @param elementOrTreePath
     *            the element
     * @return <code>true</code> if the node is expanded, and
     *         <code>false</code> if collapsed
     */
    boolean getExpandedState(Object elementOrTreePath);

    /**
     * Returns whether the node corresponding to the given element or tree path
     * has any child elements.
     *
     * @param elementOrTreePath Path to element
     * @return Returns whether the given element has children.
     */
    boolean getHasChildren(Object elementOrTreePath);

    /**
     * Returns the child count of the element at the given path. <br>
     * Note: The child count may be incorrect if the element is not
     * expanded in the tree.
     *
     * @param path Path to get count for.
     * @return The child count.
     */
    int getChildCount(TreePath path);

    /**
     * Returns the element which is a child of the element at the
     * given path, with the given index.
     *
     * @param path Path to parent element.
     * @param index Index of child element.
     * @return Child element.
     */
    Object getChildElement(TreePath path, int index);

    /**
     * Returns the tree path of the element that is at the top of the
     * viewer.
     *
     * @return the tree path of the element at the top of the
     * viewer.
     */
    TreePath getTopElementPath();

    /**
     * Finds the index of the given element with a parent of given path.
     *
     * @param parentPath Path of parent element.
     * @param element Element to find.
     *
     * @return The element's index, or -1 if not found.
     */
    int findElementIndex(TreePath parentPath, Object element);

    /**
     * Returns a boolean indicating whether all the child elements of the
     * given parent have been realized already.
     *
     * @param parentPath Path of parent element.
     * @return true if all children realized
     */
    boolean getElementChildrenRealized(TreePath parentPath);

    /**
     * Clears the selection in the viewer, if any, without firing
     * selection change notification. This is only to be used by
     * the platform.
     */
    void clearSelectionQuiet();

    /**
     * Sets the element's display information.
     * <p>
     * This method should only be called by the viewer framework.
     * </p>
     *
     * @param path Element path.
     * @param numColumns Number of columns in the data.
     * @param labels Array of labels.  The array cannot to be
     * <code>null</code>, but values within the array may be.
     * @param images Array of image descriptors, may be <code>null</code>.
     * @param fontDatas Array of fond data objects, may be <code>null</code>.
     * @param foregrounds Array of RGB values for foreground colors, may be
     * <code>null</code>.
     * @param backgrounds Array of RGB values for background colors, may be
     * <code>null</code>.
     * @noreference This method is not intended to be referenced by clients.
     */
    void setElementData(TreePath path, int numColumns, String[] labels, ImageDescriptor[] images, FontData[] fontDatas, RGB[] foregrounds, RGB[] backgrounds);

    /**
     * Returns identifiers of the visible columns in this viewer, or <code>null</code>
     * if there is currently no column presentation.
     *
     * @return visible columns or <code>null</code>
     */
    String[] getVisibleColumns();

    /**
     * Sets the element check state data.
     *
     * @param path Path of element to check.
     * @param checked if true, item will be checked
     * @param grayed if true item will be grayed
     */
    void setElementChecked(TreePath path, boolean checked, boolean grayed);

    /**
     * Retrieves the element check state.
     *
     * @param path Path of element to return check state for.
     * @return the element checked state
     */
    boolean getElementChecked(TreePath path);

    /**
     * Retrieves the element's check box grayed state.
     *
     * @param path Path of element to return grayed state for.
     * @return the element grayed state
     */
    boolean getElementGrayed(TreePath path);
}

Back to the top