Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.ViewerCell


  }

  @Test
  public void updateShouldSetTheCellColorUsingTheGivenColorProvider()
      throws Exception {
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(TRUE);

    Display display = PlatformUI.getWorkbench().getDisplay();
    Color foreground = display.getSystemColor(SWT.COLOR_CYAN);
    Color background = display.getSystemColor(SWT.COLOR_BLUE);
    IColorProvider colors = mock(IColorProvider.class);
    given(colors.getForeground(cell.getElement())).willReturn(foreground);
    given(colors.getBackground(cell.getElement())).willReturn(background);

    TreePathDurationLabelProvider labelProvider =
        new TreePathDurationLabelProvider(valueProvider, colors);

    labelProvider.update(cell);
    assertThat(cell.getForeground(), is(foreground));
    assertThat(cell.getBackground(), is(background));
  }
View Full Code Here


  }

  @Test
  public void updateShouldSetTheCellTextToBlankIfThePathShouldNotBePainted()
      throws Exception {
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(FALSE);
    given(valueProvider.getValue(cell.getViewerRow().getTreePath()))
        .willReturn(Long.valueOf(1024));

    TreePathDurationLabelProvider labelProvider =
        new TreePathDurationLabelProvider(valueProvider);

    labelProvider.update(cell);
    assertThat(nullToEmpty(cell.getText()), is(""));
  }
View Full Code Here

  @Test
  public void updateShouldSetTheCellTextToTheValueOfThePathIfThePathIsToBePainted()
      throws Exception {
    long value = 1024;
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(TRUE);
    given(valueProvider.getValue(cell.getViewerRow().getTreePath()))
        .willReturn(value);

    TreePathDurationLabelProvider labelProvider =
        new TreePathDurationLabelProvider(valueProvider);

    labelProvider.update(cell);
    assertThat(cell.getText(), is(DurationFormat.format(value)));
  }
View Full Code Here

  }

  @Test
  public void updateShouldSetTheCellColorUsingTheGivenColorProvider()
      throws Exception {
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(TRUE);

    Display display = PlatformUI.getWorkbench().getDisplay();
    Color foreground = display.getSystemColor(SWT.COLOR_CYAN);
    Color background = display.getSystemColor(SWT.COLOR_BLUE);
    IColorProvider colors = mock(IColorProvider.class);
    given(colors.getForeground(cell.getElement())).willReturn(foreground);
    given(colors.getBackground(cell.getElement())).willReturn(background);

    TreePathIntLabelProvider labelProvider =
        new TreePathIntLabelProvider(valueProvider, colors);

    labelProvider.update(cell);
    assertThat(cell.getForeground(), is(foreground));
    assertThat(cell.getBackground(), is(background));
  }
View Full Code Here

  }

  @Test
  public void updateShouldSetTheCellTextToBlankIfThePathShouldNotBePainted()
      throws Exception {
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(FALSE);
    given(valueProvider.getValue(cell.getViewerRow().getTreePath()))
        .willReturn(Long.valueOf(1024));

    TreePathIntLabelProvider labelProvider =
        new TreePathIntLabelProvider(valueProvider);

    labelProvider.update(cell);
    assertThat(nullToEmpty(cell.getText()), is(""));
  }
View Full Code Here

  @Test
  public void updateShouldSetTheCellTextToTheValueOfThePathIfThePathIsToBePainted()
      throws Exception {
    long value = 1024;
    ViewerCell cell = newCell(0, new Object());

    IValueProvider valueProvider = mock(IValueProvider.class);
    given(valueProvider.shouldPaint(cell.getElement())).willReturn(TRUE);
    given(valueProvider.getValue(cell.getViewerRow().getTreePath()))
        .willReturn(value);

    TreePathIntLabelProvider labelProvider =
        new TreePathIntLabelProvider(valueProvider);

    labelProvider.update(cell);
    assertThat(cell.getText(), is(String.valueOf(value)));
  }
View Full Code Here

            TableViewer viewer = (TableViewer)event.getViewer();
            logger.trace("viewer: " + viewer);

            logger.trace("source: " + event.getSource());

            ViewerCell vc = (ViewerCell)viewer.getData("selectedCell");
            logger.trace("selectedCell: " + vc);

            viewer.editElement(item, vc.getColumnIndex());
        }
View Full Code Here

      public void mouseDown(MouseEvent e) {
      }

      @Override
      public void mouseDoubleClick(MouseEvent e) {
        ViewerCell selectedCell = browserTableViewer.getCell(new Point(e.x, e.y));
        if (selectedCell == null) {
          return;
        }
        Object element = selectedCell.getElement();
        if (element == null || !(element instanceof File)) {
          return;
        }
        File clickedFile = (File) element;
        if (clickedFile.isDirectory()) {
View Full Code Here

        this.viewer = viewer1;
        viewer1.getControl().addMouseTrackListener(new MouseTrackAdapter() {
            @Override
            public void mouseHover(MouseEvent e) {
                String tooltip = "";
                ViewerCell cell = viewer.getCell(new Point(e.x, e.y));
                if(cell != null) {
                    tooltip = labelProvider.getToolTip(cell.getElement());
                }
                viewer.getControl().setToolTipText(tooltip);
            }
            @Override
            public void mouseExit(MouseEvent e) {
View Full Code Here

  /* (non-Javadoc)
   * @see net.sf.logsaw.ui.editors.ILogViewEditor#getFocusCellLogEntryField()
   */
  @Override
  public ALogEntryField<?, ?> getFocusCellLogEntryField() {
    ViewerCell cell = focusCellManager.getFocusCell();
    if ((cell != null) && (cell.getColumnIndex() > 0)) {
      return columnConfig.getFields().get(cell.getColumnIndex() - 1);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.ViewerCell

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.