SwtRx { public static <T> RxBox<T> combo(Combo combo, ImmutableList<T> values, Function<T, String> converter) { RxBox<T> box = RxBox.of(values.get(Math.max(0, combo.getSelectionIndex()))); combo(combo, values, converter, box); return box; }  static @SwtThread Observable<Event> addListener(Widget widget, int... events); static @SwtThread Observable<Event> addListener(Widget widget, Collection<Integer> events); static @SwtThread Observable<Event> addListener(Widget widget, Stream<Integer> events); static @SwtThread Observable<Point> rightClickGlobal(Control ctl); static @SwtThread Observable<Point> rightClickLocal(Control ctl); static @SwtThread RxBox<String> textImmediate(Text text); static @SwtThread RxBox<String> textConfirmed(Text text); static RxBox<Boolean> toggle(Button btn); static RxBox<T> combo(Combo combo, ImmutableList<T> values, Function<T, String> converter); static void combo(Combo combo, ImmutableList<T> values, Function<T, String> converter, RxBox<T> box); static Chit chit(ControlWrapper wrapper); static Chit chit(Widget guard);  }
@Test public void testComboAsBox() { InteractiveTest.testCoat("The two combos should stay in sync.", cmp -> { ImmutableList<TestEnum> values = ImmutableList.copyOf(TestEnum.class.getEnumConstants()); Supplier<Combo> creator = () -> { Combo combo = new Combo(cmp, SWT.DROP_DOWN); values.forEach(value -> combo.add(value.name())); combo.select(0); return combo; }; Layouts.setGrid(cmp).numColumns(2); Combo comboA = creator.get(); RxBox<TestEnum> boxA = SwtRx.combo(comboA, values, Enum::name); Combo comboB = creator.get(); RxBox<TestEnum> boxB = SwtRx.combo(comboB, values, Enum::name); Rx.subscribe(boxA, boxB); Rx.subscribe(boxB, boxA); }); }