public static IViewerToolBar addToolBar(IViewerBinding viewer, int style) { IViewerToolBar bb = viewer.getService(IViewerToolBar.class); if (bb != null) return bb; bb = new ViewerToolBar(viewer, style); return bb; }
@Test public void filterExists() { Listener[] listeners = myFilter.getListeners(SWT.Modify); assertNotNull(listeners); assertEquals(0, listeners.length); IFilteringTableAdapter.Factory.adapt(myViewer, myFilter); assertTrue(myViewer.getService(IFilteringTableAdapter.class) != null); listeners = myFilter.getListeners(SWT.Modify); assertNotNull(listeners); assertEquals(1, listeners.length); }
/** Tests that all listeners are removed on dispose */ @Test public void disposeTest() { final Listener[] filterKeyDownListeners = myFilter.getListeners(SWT.KeyDown); final Listener[] filterSelectionListeners = myFilter.getListeners(SWT.Selection); final Listener[] filterFocusInListeners = myFilter.getListeners(SWT.FocusIn); final Listener[] tableKeyDownListeners = myTable.getListeners(SWT.KeyDown); final Listener[] tableDisposeListeners = myTable.getListeners(SWT.Dispose); final IFilteringTableAdapter adapter = IFilteringTableAdapter.Factory.adapt(myViewer, myFilter); adapter.dispose(); assertEquals(null, myViewer.getService(IFilteringTableAdapter.class)); assertArrayEquals(filterKeyDownListeners, myFilter.getListeners(SWT.KeyDown)); assertArrayEquals(filterSelectionListeners, myFilter.getListeners(SWT.Selection)); assertArrayEquals(filterFocusInListeners, myFilter.getListeners(SWT.FocusIn)); assertArrayEquals(tableKeyDownListeners, myTable.getListeners(SWT.KeyDown)); assertArrayEquals(tableDisposeListeners, myTable.getListeners(SWT.Dispose)); }