Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d9293494927b51c7df4ca9814b46b75e0304d0bd (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
/*******************************************************************************
 * Copyright (c) 2009, 2010 Wind River Systems and others.
 * 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:
 *     Wind River Systems - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model;

import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IStateUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewerFilter;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;

/** 
 * {@link TreeModelViewer} content provider interface.
 *  
 * @since 3.5
 */
public interface ITreeModelContentProvider extends ILazyTreePathContentProvider {

    /**
     * Bit-mask which allows all possible model delta flags.
     * 
     * @since 3.6
     * @see #setModelDeltaMask(int)
     */
    public static final int ALL_MODEL_DELTA_FLAGS = ~0; 

    /**
     * Bit-mask which allows only flags which control selection and expansion. 
     * 
     * @since 3.6
     * @see #setModelDeltaMask(int)
     */
    public static final int CONTROL_MODEL_DELTA_FLAGS = 
        IModelDelta.EXPAND | IModelDelta.COLLAPSE | IModelDelta.SELECT | IModelDelta.REVEAL | IModelDelta.FORCE;

    /**
     * Bit-mask which allows only flags which update viewer's information
     * about the model.
     * 
     * @since 3.6
     * @see #setModelDeltaMask(int)
     */
    public static final int UPDATE_MODEL_DELTA_FLAGS = 
        IModelDelta.ADDED | IModelDelta.CONTENT | IModelDelta.INSERTED | IModelDelta.INSTALL | IModelDelta.REMOVED |
        IModelDelta.REPLACED | IModelDelta.STATE | IModelDelta.UNINSTALL;

    /**
     * Translates and returns the given child index from the viewer coordinate
     * space to the model coordinate space.
     *  
     * @param parentPath path to parent element
     * @param index index of child element in viewer (filtered) space
     * @return index of child element in model (raw) space
     */
    public int viewToModelIndex(TreePath parentPath, int index);
    
    /**
     * Translates and returns the given child count from the viewer coordinate
     * space to the model coordinate space.
     *  
     * @param parentPath path to parent element
     * @param count number of child elements in viewer (filtered) space
     * @return number of child elements in model (raw) space
     */
    public int viewToModelCount(TreePath parentPath, int count);
    
    /**
     * Translates and returns the given child index from the model coordinate
     * space to the viewer coordinate space.
     *  
     * @param parentPath path to parent element
     * @param index index of child element in model (raw) space
     * @return index of child element in viewer (filtered) space or -1 if filtered
     */
    public int modelToViewIndex(TreePath parentPath, int index);

    /**
     * Returns whether the children of given element should be filtered.
     * <p>This method is used to determine whether any of the registered filters
     * that extend {@link TreeModelViewerFilter} are applicable to the given 
     * element.  If so, then children of given element should be filtered 
     * prior to populating them in the viewer.  
     * 
     * @param parentElement
     *            the parent element 
     * @return whether there are any {@link TreeModelViewerFilter} filters 
     * applicable to given parent
     */
    public boolean areTreeModelViewerFiltersApplicable(Object parentElement);        
    
    /**
     * Returns whether the given element is filtered.
     * 
     * @param parentElementOrTreePath
     *            the parent element or path
     * @param element
     *            the child element
     * @return whether to filter the element
     */
    public boolean shouldFilter(Object parentElementOrTreePath, Object element);   

    /**
     * Notification the given element is being unmapped.
     * 
     * @param path Path to unmap
     */
    public void unmapPath(TreePath path);

    /**
     * Sets the bit mask which will be used to filter the {@link IModelDelta}
     * coming from the model.  Any delta flags which are hidden by the mask
     * will be ignored.
     *  
     * @param mask for <code>IModelDelta</code> flags
     * 
     * @since 3.6
     */
    public void setModelDeltaMask(int mask);
    
    /**
     * Returns the current model delta mask.
     * 
     * @return bit mask used to filter model delta events.
     * 
     * @see #setModelDeltaMask(int)
     * @since 3.6
     */
    public int getModelDeltaMask();
    
    /**
     * Translates and returns the given child count from the model coordinate
     * space to the viewer coordinate space.
     *  
     * @param parentPath path to parent element
     * @param count child count element in model (raw) space
     * @return child count in viewer (filtered) space
     */
    public int modelToViewChildCount(TreePath parentPath, int count);

    /**
     * Registers the specified listener for view update notifications.
     * @param listener Listener to add
     */
    public void addViewerUpdateListener(IViewerUpdateListener listener);
    
    /**
     * Removes the specified listener from update notifications.
     * @param listener Listener to remove
     */
    public void removeViewerUpdateListener(IViewerUpdateListener listener);
    
    /**
     * Registers the given listener for model delta notification.
     * This listener is called immediately after the viewer processes
     * the delta.  
     * @param listener Listener to add
     */
    public void addModelChangedListener(IModelChangedListener listener);
    
    /**
     * Removes the given listener from model delta notification.
     * @param listener Listener to remove
     */
    public void removeModelChangedListener(IModelChangedListener listener);
    
    /**
     * Causes the content provider to save the expansion and selection state
     * of given element.  The state is then restored as the tree is lazily
     * re-populated.
     * @param path Path of the element to save.
     */
    public void preserveState(TreePath path);

    /**
     * Registers the specified listener for state update notifications.
     * @param listener Listener to add
     * @since 3.6
     */
    public void addStateUpdateListener(IStateUpdateListener listener);

    /**
     * Removes the specified listener from state update notifications.
     * @param listener Listener to remove
     * @since 3.6
     */
    public void removeStateUpdateListener(IStateUpdateListener listener);

    /**
     * Instructs the content provider to process the given model delta.  This
     * mechanism can be used to control the view's layout (expanding, selecting
     * , etc.) 
     * 
     * @param delta The model delta to process.
     * @param mask Mask that can be used to suppress processing of some of the 
     * delta flags
     * 
     * @since 3.6
     */
    public void updateModel(IModelDelta delta, int mask);

    /**
     * Instructs the content provider to cancel any pending state changes 
     * (i.e. SELECT, REVEAL, EXPAND, COLLAPSE) for the given path.  Pending
     * state changes are changes the the viewer plans to re-apply to the 
     * viewer following a refresh.  If the user changes viewer state while
     * the viewer is being refreshed, user's change should override the 
     * previous state. 
     * 
     * @param path Path of the element for which to cancel pending changes.
     * @param flags Flags indicating the changes to cancel.
     */
    public void cancelRestore(TreePath path, int flags);
    
    /**
     * Notifies the content provider that a client called {@link Viewer#setInput(Object)}, 
     * and the viewer input is changed. 
     * This method is guaranteed to be called after {@link IContentProvider#inputChanged(Viewer, Object, Object)} 
     *  
     * @param viewer The viewer that uses this content provider.
     * @param oldInput Old input object.
     * @param newInput New input object.
     * 
     * @since 3.8
     */
    public void postInputChanged(IInternalTreeModelViewer viewer, Object oldInput, Object newInput);
    
    /**
     * Notifies the receiver that the given element has had its 
     * checked state modified in the viewer.
     * 
     * @param path Path of the element that had its checked state changed
     * @param checked The new checked state of the element
     * @return false if the check state should not change
     */
    public boolean setChecked(TreePath path, boolean checked);
}

Back to the top