@Test public void testToggleSelection() { final BasicEventList<String> list = new BasicEventList<>(); final Table table = new Table(getShell(), SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); final EventTableViewer<String> viewer = new EventTableViewer<>(list, table, new SimpleTableFormat()); list.addAll(GlazedListsTests.delimitedStringToList("A B C D E F")); assertEquals(Collections.EMPTY_LIST, viewer.getSelected()); assertEquals(Collections.EMPTY_LIST, viewer.getTogglingSelected()); assertEquals(list, viewer.getDeselected()); assertEquals(list, viewer.getTogglingDeselected()); assertEquals(0, table.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, table.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 2, 3, 5}, table.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, table.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0}, table.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, table.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 2, 3, 5}, table.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, table.getSelectionCount()); assertTrue(Arrays.equals(new int[] {2}, table.getSelectionIndices())); list.remove("C"); list.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, table.getSelectionCount()); list.add("E"); list.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, table.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, table.getSelectionCount()); assertTrue(Arrays.equals(new int[] {0, 1, 2, 3, 4, 5}, table.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, table.getSelectionCount()); viewer.dispose(); }
@Override public void dispose() { if (swtThreadSource != null) swtThreadSource.dispose(); super.dispose(); swtThreadSource = null; }
EventTableViewer extends DefaultEventTableViewer<E> { @Override public void dispose() { if (swtThreadSource != null) swtThreadSource.dispose(); super.dispose(); swtThreadSource = null; } }
EventTableViewer extends DefaultEventTableViewer<E> { @Override public void dispose() { if (swtThreadSource != null) swtThreadSource.dispose(); super.dispose(); swtThreadSource = null; } @Deprecated  EventTableViewer(EventList<E> source, Table table, String[] propertyNames, String[] columnLabels);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); private  EventTableViewer(EventList<E> source, EventList<E> swtProxySource, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); }
EventTableViewer extends DefaultEventTableViewer<E> { @Override public void dispose() { if (swtThreadSource != null) swtThreadSource.dispose(); super.dispose(); swtThreadSource = null; } @Deprecated  EventTableViewer(EventList<E> source, Table table, String[] propertyNames, String[] columnLabels);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); private  EventTableViewer(EventList<E> source, EventList<E> swtProxySource, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); @Override void dispose(); }
EventTableViewer extends DefaultEventTableViewer<E> { @Override public void dispose() { if (swtThreadSource != null) swtThreadSource.dispose(); super.dispose(); swtThreadSource = null; } @Deprecated  EventTableViewer(EventList<E> source, Table table, String[] propertyNames, String[] columnLabels);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat);  EventTableViewer(EventList<E> source, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); private  EventTableViewer(EventList<E> source, EventList<E> swtProxySource, Table table, TableFormat<? super E> tableFormat,
            TableItemConfigurer<? super E> tableItemConfigurer); @Override void dispose();  }