示例#1
0
  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;
  }
示例#2
0
  @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);
  }
示例#3
0
  /** 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));
  }