Lines 55-65
Link Here
|
55 |
private Hashtable perPartTrackers; |
55 |
private Hashtable perPartTrackers; |
56 |
|
56 |
|
57 |
/** |
57 |
/** |
|
|
58 |
* Caches the selection last seen from the active part. May be null if the selection is not yet cached. |
59 |
*/ |
60 |
private ISelection cachedSelection; |
61 |
|
62 |
/** |
58 |
* The JFace selection listener to hook on the active part's selection provider. |
63 |
* The JFace selection listener to hook on the active part's selection provider. |
59 |
*/ |
64 |
*/ |
60 |
private ISelectionChangedListener selListener = new ISelectionChangedListener() { |
65 |
private ISelectionChangedListener selListener = new ISelectionChangedListener() { |
61 |
public void selectionChanged(SelectionChangedEvent event) { |
66 |
public void selectionChanged(SelectionChangedEvent event) { |
62 |
fireSelection(activePart, event.getSelection()); |
67 |
cachedSelection = event.getSelection(); |
|
|
68 |
fireSelection(activePart, cachedSelection); |
63 |
} |
69 |
} |
64 |
}; |
70 |
}; |
65 |
|
71 |
|
Lines 68-74
Link Here
|
68 |
*/ |
74 |
*/ |
69 |
private ISelectionChangedListener postSelListener = new ISelectionChangedListener() { |
75 |
private ISelectionChangedListener postSelListener = new ISelectionChangedListener() { |
70 |
public void selectionChanged(SelectionChangedEvent event) { |
76 |
public void selectionChanged(SelectionChangedEvent event) { |
71 |
firePostSelection(activePart, event.getSelection()); |
77 |
cachedSelection = event.getSelection(); |
|
|
78 |
firePostSelection(activePart, cachedSelection); |
72 |
} |
79 |
} |
73 |
}; |
80 |
}; |
74 |
|
81 |
|
Lines 217-223
Link Here
|
217 |
*/ |
224 |
*/ |
218 |
public ISelection getSelection() { |
225 |
public ISelection getSelection() { |
219 |
if (activeProvider != null) { |
226 |
if (activeProvider != null) { |
220 |
return activeProvider.getSelection(); |
227 |
if (cachedSelection == null) { |
|
|
228 |
cachedSelection = activeProvider.getSelection(); |
229 |
} |
230 |
return cachedSelection; |
221 |
} else { |
231 |
} else { |
222 |
return null; |
232 |
return null; |
223 |
} |
233 |
} |
Lines 243-248
Link Here
|
243 |
return; |
253 |
return; |
244 |
} |
254 |
} |
245 |
|
255 |
|
|
|
256 |
cachedSelection = null; |
257 |
|
246 |
ISelectionProvider selectionProvider = null; |
258 |
ISelectionProvider selectionProvider = null; |
247 |
|
259 |
|
248 |
if (newPart != null) { |
260 |
if (newPart != null) { |
Lines 278-292
Link Here
|
278 |
activeProvider = selectionProvider; |
290 |
activeProvider = selectionProvider; |
279 |
// Fire an event if there's an active provider |
291 |
// Fire an event if there's an active provider |
280 |
activeProvider.addSelectionChangedListener(selListener); |
292 |
activeProvider.addSelectionChangedListener(selListener); |
281 |
ISelection sel = activeProvider.getSelection(); |
293 |
cachedSelection = activeProvider.getSelection(); |
282 |
fireSelection(newPart, sel); |
294 |
fireSelection(newPart, cachedSelection); |
283 |
if (activeProvider instanceof IPostSelectionProvider) { |
295 |
if (activeProvider instanceof IPostSelectionProvider) { |
284 |
((IPostSelectionProvider) activeProvider) |
296 |
((IPostSelectionProvider) activeProvider) |
285 |
.addPostSelectionChangedListener(postSelListener); |
297 |
.addPostSelectionChangedListener(postSelListener); |
286 |
} else { |
298 |
} else { |
287 |
activeProvider.addSelectionChangedListener(postSelListener); |
299 |
activeProvider.addSelectionChangedListener(postSelListener); |
288 |
} |
300 |
} |
289 |
firePostSelection(newPart, sel); |
301 |
firePostSelection(newPart, cachedSelection); |
290 |
} else { |
302 |
} else { |
291 |
fireSelection(null, null); |
303 |
fireSelection(null, null); |
292 |
firePostSelection(null, null); |
304 |
firePostSelection(null, null); |