private synchronized MultiSelection<Object> getMixedSelection() {
   if (mixedSelection == null) {
     mixedSelection =
         MultiSelection.from(
             Object.class,
             new ObservableSet<Object>() {
               @Override
               protected ImmutableSet<Object> compute() {
                 if (tv != null) {
                   ISelection s = tv.getSelection();
                   if (s instanceof IStructuredSelection) {
                     Object[] elements = ((IStructuredSelection) s).toArray();
                     return ImmutableSet.copyOf(elements);
                   }
                 }
                 return ImmutableSet.of();
               }
             });
     debug("mixedSelection", mixedSelection.getElements());
   }
   if (tv != null) {
     addViewerSelectionListener();
   }
   return mixedSelection;
 }
 @Override
 public synchronized MultiSelection<BootDashElement> getSelection() {
   if (selection == null) {
     selection = getMixedSelection().filter(BootDashElement.class);
     debug("selection", selection.getElements());
   }
   return selection;
 }
 private void addViewerSelectionListener() {
   tv.setSelection(new StructuredSelection(Arrays.asList(mixedSelection.getValue().toArray())));
   tv.addSelectionChangedListener(
       new ISelectionChangedListener() {
         public void selectionChanged(SelectionChangedEvent event) {
           mixedSelection.getElements().refresh();
         }
       });
 }
 public AbstractBootDashAction(MultiSelection<BootDashElement> selection, UserInteractions ui) {
   this.selection = selection;
   this.ui = ui;
   selection
       .getElements()
       .addListener(
           new ValueListener<Set<BootDashElement>>() {
             public void gotValue(
                 LiveExpression<Set<BootDashElement>> exp, Set<BootDashElement> selecteds) {
               updateEnablement();
             }
           });
 }
 protected BootDashElement getSingleSelectedElement() {
   return selection.getSingle();
 }
 protected Collection<BootDashElement> getSelectedElements() {
   return selection.getValue();
 }
Пример #7
0
 public static <T> MultiSelection<T> union(MultiSelection<T> a, MultiSelection<T> b) {
   Assert.isLegal(a.getElementType().equals(b.getElementType()));
   return from(a.getElementType(), LiveSets.union(a.getElements(), b.getElements()));
 }