Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
14 |
import java.util.Iterator; |
14 |
import java.util.Iterator; |
|
|
15 |
import java.util.List; |
15 |
|
16 |
|
16 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
17 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
17 |
import org.eclipse.jface.viewers.IBaseLabelProvider; |
18 |
import org.eclipse.jface.viewers.IBaseLabelProvider; |
Lines 23-28
Link Here
|
23 |
import org.eclipse.jface.viewers.ViewerSorter; |
24 |
import org.eclipse.jface.viewers.ViewerSorter; |
24 |
import org.eclipse.swt.dnd.DND; |
25 |
import org.eclipse.swt.dnd.DND; |
25 |
import org.eclipse.swt.events.DisposeEvent; |
26 |
import org.eclipse.swt.events.DisposeEvent; |
|
|
27 |
import org.eclipse.swt.events.SelectionEvent; |
26 |
import org.eclipse.swt.widgets.Composite; |
28 |
import org.eclipse.swt.widgets.Composite; |
27 |
import org.eclipse.swt.widgets.Widget; |
29 |
import org.eclipse.swt.widgets.Widget; |
28 |
import org.eclipse.ui.PlatformUI; |
30 |
import org.eclipse.ui.PlatformUI; |
Lines 41-53
Link Here
|
41 |
* <p> |
43 |
* <p> |
42 |
* Clients may extend this class. |
44 |
* Clients may extend this class. |
43 |
* </p> |
45 |
* </p> |
44 |
* |
46 |
* <p> |
|
|
47 |
* Note that as of 3.2.1 and 3.3, the common viewer caches its selection. |
48 |
* Clients must not set the selection of the viewer's tree control directly. |
49 |
* </p> |
45 |
* |
50 |
* |
46 |
* @since 3.2 |
51 |
* @since 3.2 |
47 |
*/ |
52 |
*/ |
48 |
public class CommonViewer extends TreeViewer { |
53 |
public class CommonViewer extends TreeViewer { |
49 |
|
54 |
|
50 |
private final NavigatorContentService contentService; |
55 |
private final NavigatorContentService contentService; |
|
|
56 |
private ISelection cachedSelection; |
51 |
|
57 |
|
52 |
/** |
58 |
/** |
53 |
* <p> |
59 |
* <p> |
Lines 211-216
Link Here
|
211 |
if (contentService != null) { |
217 |
if (contentService != null) { |
212 |
contentService.dispose(); |
218 |
contentService.dispose(); |
213 |
} |
219 |
} |
|
|
220 |
clearSelectionCache(); |
214 |
} |
221 |
} |
215 |
|
222 |
|
216 |
/** |
223 |
/** |
Lines 346-351
Link Here
|
346 |
} |
353 |
} |
347 |
} |
354 |
} |
348 |
} |
355 |
} |
|
|
356 |
|
357 |
/* (non-Javadoc) |
358 |
* @see org.eclipse.jface.viewers.AbstractTreeViewer#setSelectionToWidget(java.util.List, boolean) |
359 |
*/ |
360 |
protected void setSelectionToWidget(List v, boolean reveal) { |
361 |
clearSelectionCache(); |
362 |
super.setSelectionToWidget(v, reveal); |
363 |
} |
364 |
|
365 |
/* (non-Javadoc) |
366 |
* @see org.eclipse.jface.viewers.AbstractTreeViewer#handleDoubleSelect(org.eclipse.swt.events.SelectionEvent) |
367 |
*/ |
368 |
protected void handleDoubleSelect(SelectionEvent event) { |
369 |
clearSelectionCache(); |
370 |
super.handleDoubleSelect(event); |
371 |
} |
372 |
|
373 |
/* (non-Javadoc) |
374 |
* @see org.eclipse.jface.viewers.StructuredViewer#handleOpen(org.eclipse.swt.events.SelectionEvent) |
375 |
*/ |
376 |
protected void handleOpen(SelectionEvent event) { |
377 |
clearSelectionCache(); |
378 |
super.handleOpen(event); |
379 |
} |
380 |
|
381 |
/* (non-Javadoc) |
382 |
* @see org.eclipse.jface.viewers.StructuredViewer#handlePostSelect(org.eclipse.swt.events.SelectionEvent) |
383 |
*/ |
384 |
protected void handlePostSelect(SelectionEvent e) { |
385 |
clearSelectionCache(); |
386 |
super.handlePostSelect(e); |
387 |
} |
388 |
|
389 |
/* (non-Javadoc) |
390 |
* @see org.eclipse.jface.viewers.StructuredViewer#handleSelect(org.eclipse.swt.events.SelectionEvent) |
391 |
*/ |
392 |
protected void handleSelect(SelectionEvent event) { |
393 |
clearSelectionCache(); |
394 |
super.handleSelect(event); |
395 |
} |
396 |
|
397 |
/** |
398 |
* Clears the selection cache. |
399 |
*/ |
400 |
private void clearSelectionCache() { |
401 |
cachedSelection = null; |
402 |
} |
403 |
|
404 |
/** |
405 |
* Returns the current selection. |
406 |
* <p> |
407 |
* Note that as of 3.2.1 and 3.3, the common viewer caches its selection. |
408 |
* Clients must not set the selection of the viewer's tree control directly. |
409 |
* </p> |
410 |
* |
411 |
* @see org.eclipse.jface.viewers.AbstractTreeViewer#getSelection() |
412 |
*/ |
413 |
public ISelection getSelection() { |
414 |
if (cachedSelection == null) { |
415 |
cachedSelection = super.getSelection(); |
416 |
} |
417 |
return cachedSelection; |
418 |
} |
349 |
|
419 |
|
350 |
/* |
420 |
/* |
351 |
* (non-Javadoc) |
421 |
* (non-Javadoc) |