Beispiel #1
0
 private String getToolTipText(final GridItem item, final int column) {
   String result = null;
   final IBaseLabelProvider labelProvider = getTableViewer().getLabelProvider();
   if (labelProvider != null) {
     final Object element = item.getData();
     result = ((TableRidgetLabelProvider) labelProvider).getToolTipText(element, column);
   }
   if (result == null) {
     result = item.getText(column);
   }
   return result;
 }
Beispiel #2
0
  private ViewerRow getRowBelow() {
    int index = item.getParent().indexOf(item) + 1;

    if (index < item.getParent().getItemCount()) {
      GridItem tmp = item.getParent().getItem(index);
      // Maybe this is a dummy item!!

      if (tmp != null && !tmp.isDisposed() && tmp.isVisible() && tmp.getData() != null) {
        return new GridViewerRow(tmp);
      }
    }

    return null;
  }
Beispiel #3
0
  @Override
  public void testAddClickListener() {
    final ITableRidget ridget = getRidget();
    ridget.updateFromModel();
    final Grid control = getWidget();
    final RowData rowData = new RowData();
    rowData.width = 300;
    rowData.height = 300;
    control.setLayoutData(rowData);
    control.getColumn(0).setWidth(100);
    control.getColumn(1).setWidth(100);
    control.getShell().pack();
    control.getParent().update();

    try {
      ridget.addClickListener(null);
      fail();
    } catch (final RuntimeException npe) {
      ok();
    }

    final FTClickListener listener1 = new FTClickListener();
    ridget.addClickListener(listener1);

    final FTClickListener listener2 = new FTClickListener();
    ridget.addClickListener(listener2);
    ridget.addClickListener(listener2);

    final Event mdEvent = new Event();
    mdEvent.widget = control;
    mdEvent.type = SWT.MouseDown;
    mdEvent.button = 2;
    final GridItem row2 = control.getItem(2);
    mdEvent.item = row2;
    mdEvent.x = row2.getBounds(0).x + 1;
    mdEvent.y = row2.getBounds(0).y + 1;
    control.notifyListeners(SWT.MouseDown, mdEvent);

    assertEquals(0, listener1.getCount());
    assertEquals(0, listener2.getCount());

    mdEvent.type = SWT.MouseUp;
    control.notifyListeners(SWT.MouseUp, mdEvent);

    assertEquals(1, listener1.getCount());
    assertEquals(1, listener2.getCount());

    final ClickEvent event = listener2.getEvent();
    assertEquals(ridget, event.getSource());
    assertEquals(2, event.getButton());
    assertEquals(0, event.getColumnIndex());
    assertEquals(row2.getData(), event.getRow());

    ridget.removeClickListener(listener1);

    mdEvent.type = SWT.MouseDown;
    control.notifyListeners(SWT.MouseDown, mdEvent);
    mdEvent.type = SWT.MouseUp;
    control.notifyListeners(SWT.MouseUp, mdEvent);

    assertEquals(1, listener1.getCount());
  }
Beispiel #4
0
 /** {@inheritDoc} */
 @Override
 public Object getElement() {
   return item.getData();
 }
Beispiel #5
0
 /** {@inheritDoc} */
 @Override
 public TreePath getTreePath() {
   return new TreePath(new Object[] {item.getData()});
 }