@Test public void testToggleSelection() { final BasicEventList<String> source = new BasicEventList<>(); final List list = new List(getShell(), SWT.MULTI); final EventListViewer<String> viewer = new EventListViewer<>(source, list); source.addAll(GlazedListsTests.delimitedStringToList("A B C D E F")); assertEquals(Collections.EMPTY_LIST, viewer.getSelected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingSelected()); assertEquals(source, viewer.getDeselected()); assertEquals(source, viewer.getTogglingDeselected()); assertEquals(0, list.getSelectionCount()); viewer.getTogglingDeselected().remove("A"); viewer.getTogglingDeselected().remove(1); viewer.getTogglingDeselected().removeAll(GlazedListsTests.delimitedStringToList("F D")); assertEquals(GlazedListsTests.delimitedStringToList("B E"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("B E"), viewer.getTogglingDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A C D F"), viewer.getSelected()); assertEquals(GlazedListsTests.delimitedStringToList("A C D F"), viewer.getTogglingSelected()); assertEquals(4, list.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 2, 3, 5}, list.getSelectionIndices())); viewer.getTogglingDeselected().add("F"); viewer.getTogglingDeselected().addAll(GlazedListsTests.delimitedStringToList("C D")); assertEquals(GlazedListsTests.delimitedStringToList("B C D E F"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("B C D E F"), viewer.getTogglingDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A"), viewer.getSelected()); assertEquals(GlazedListsTests.delimitedStringToList("A"), viewer.getTogglingSelected()); assertEquals(1, list.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0}, list.getSelectionIndices())); viewer.getTogglingSelected().add("F"); viewer.getTogglingSelected().addAll(GlazedListsTests.delimitedStringToList("C D")); assertEquals(GlazedListsTests.delimitedStringToList("B E"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("B E"), viewer.getTogglingDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A C D F"), viewer.getSelected()); assertEquals(GlazedListsTests.delimitedStringToList("A C D F"), viewer.getTogglingSelected()); assertEquals(4, list.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 2, 3, 5}, list.getSelectionIndices())); viewer.getTogglingSelected().remove("A"); viewer.getTogglingSelected().remove(1); viewer.getTogglingSelected().removeAll(GlazedListsTests.delimitedStringToList("F")); assertEquals(GlazedListsTests.delimitedStringToList("A B D E F"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A B D E F"), viewer.getTogglingDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("C"), viewer.getSelected()); assertEquals(GlazedListsTests.delimitedStringToList("C"), viewer.getTogglingSelected()); assertEquals(1, list.getSelectionCount()); assertTrue(Arrays.equals(new int[] {2}, list.getSelectionIndices())); source.remove("C"); source.removeAll(GlazedListsTests.delimitedStringToList("B E")); assertEquals(GlazedListsTests.delimitedStringToList("A D F"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A D F"), viewer.getTogglingDeselected()); assertEquals(Collections.EMPTY_LIST, viewer.getSelected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingSelected()); assertEquals(0, list.getSelectionCount()); source.add("E"); source.addAll(GlazedListsTests.delimitedStringToList("C B")); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getTogglingDeselected()); assertEquals(Collections.EMPTY_LIST, viewer.getSelected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingSelected()); assertEquals(0, list.getSelectionCount()); viewer.getTogglingDeselected().clear(); assertEquals(Collections.EMPTY_LIST, viewer.getDeselected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getSelected()); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getTogglingSelected()); assertEquals(6, list.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 1, 2, 3, 4, 5}, list.getSelectionIndices())); viewer.getTogglingSelected().clear(); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getDeselected()); assertEquals(GlazedListsTests.delimitedStringToList("A D F E C B"), viewer.getTogglingDeselected()); assertEquals(Collections.EMPTY_LIST, viewer.getSelected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingSelected()); assertEquals(0, list.getSelectionCount()); viewer.dispose(); }
@Override public void dispose() { if (disposeSource) source.dispose(); super.dispose(); }
EventListViewer extends DefaultEventListViewer<E> { @Override public void dispose() { if (disposeSource) source.dispose(); super.dispose(); } }
EventListViewer extends DefaultEventListViewer<E> { @Override public void dispose() { if (disposeSource) source.dispose(); super.dispose(); } EventListViewer(EventList<E> source, List list);  EventListViewer(EventList<E> source, List list, ItemFormat<? super E> itemFormat); }
EventListViewer extends DefaultEventListViewer<E> { @Override public void dispose() { if (disposeSource) source.dispose(); super.dispose(); } EventListViewer(EventList<E> source, List list);  EventListViewer(EventList<E> source, List list, ItemFormat<? super E> itemFormat); @Override void dispose(); }
EventListViewer extends DefaultEventListViewer<E> { @Override public void dispose() { if (disposeSource) source.dispose(); super.dispose(); } EventListViewer(EventList<E> source, List list);  EventListViewer(EventList<E> source, List list, ItemFormat<? super E> itemFormat); @Override void dispose();  }