|
Lines 18-23
Link Here
|
| 18 |
import org.eclipse.jface.internal.databinding.internal.viewers.SelectionProviderSingleSelectionObservableValue; |
18 |
import org.eclipse.jface.internal.databinding.internal.viewers.SelectionProviderSingleSelectionObservableValue; |
| 19 |
import org.eclipse.jface.viewers.ISelectionProvider; |
19 |
import org.eclipse.jface.viewers.ISelectionProvider; |
| 20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
|
21 |
import org.eclipse.jface.viewers.Viewer; |
| 21 |
import org.eclipse.swt.widgets.Display; |
22 |
import org.eclipse.swt.widgets.Display; |
| 22 |
|
23 |
|
| 23 |
/** |
24 |
/** |
|
Lines 70-73
Link Here
|
| 70 |
selectionProvider, Object.class); |
71 |
selectionProvider, Object.class); |
| 71 |
} |
72 |
} |
| 72 |
|
73 |
|
|
|
74 |
/** |
| 75 |
* Returns an observable value that tracks the current selection of the |
| 76 |
* given viewer. The IViewerObservableValue exposes the viewer. If the |
| 77 |
* selection provider provides selections of type |
| 78 |
* {@link IStructuredSelection}, the observable value will be the first |
| 79 |
* element of the structured selection as returned by |
| 80 |
* {@link IStructuredSelection#getFirstElement()}. |
| 81 |
* |
| 82 |
* @param viewer |
| 83 |
* @return the observable value tracking the (single) selection of the given |
| 84 |
* selection provider |
| 85 |
*/ |
| 86 |
public static IViewerObservableValue observeSingleSelection(Viewer viewer) { |
| 87 |
return new SelectionProviderSingleSelectionObservableValue( |
| 88 |
SWTObservables.getRealm(Display.getDefault()), viewer); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Returns an observable value that tracks the current selection of the |
| 93 |
* given viewer. The IViewerObservableList exposes the viewer. Assumes that |
| 94 |
* the selection provider provides selections of type |
| 95 |
* {@link IStructuredSelection}. Note that the observable list will not |
| 96 |
* honor the full contract of <code>java.util.List</code> in that it may |
| 97 |
* delete or reorder elements based on what the selection provider returns |
| 98 |
* from {@link ISelectionProvider#getSelection()} after having called |
| 99 |
* {@link ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)} |
| 100 |
* based on the requested change to the observable list. The affected |
| 101 |
* methods are <code>add</code>, <code>addAll</code>, and |
| 102 |
* <code>set</code>. |
| 103 |
* |
| 104 |
* @param viewer |
| 105 |
* @return the observable value tracking the (multi) selection of the given |
| 106 |
* selection provider |
| 107 |
* |
| 108 |
* @since 1.2 |
| 109 |
*/ |
| 110 |
public static IViewerObservableList observeMultiSelection( |
| 111 |
Viewer viewer) { |
| 112 |
return new SelectionProviderMultipleSelectionObservableList( |
| 113 |
SWTObservables.getRealm(Display.getDefault()), viewer, |
| 114 |
Object.class); |
| 115 |
} |
| 116 |
|
| 73 |
} |
117 |
} |