Example usage for org.eclipse.jface.viewers ViewerCell getBounds

List of usage examples for org.eclipse.jface.viewers ViewerCell getBounds

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerCell getBounds.

Prototype

public Rectangle getBounds() 

Source Link

Document

Get the bounds of the cell.

Usage

From source file:org.eclipse.ui.internal.dialogs.cpd.ItemDetailToolTip.java

License:Open Source License

@Override
public Point getLocation(Point tipSize, Event event) {
    // try to position the tooltip at the bottom of the cell
    ViewerCell cell = v.getCell(new Point(event.x, event.y));

    if (cell != null) {
        return tree.toDisplay(event.x, cell.getBounds().y + cell.getBounds().height);
    }//from  w w w .  j  a v a 2s  . c  o  m

    return super.getLocation(tipSize, event);
}

From source file:org.eclipsetrader.ui.internal.views.WatchListViewCellLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    WatchListViewItem element = (WatchListViewItem) cell.getElement();

    IAdaptable adaptableValue = (IAdaptable) attributeMaps[0].get(element);
    WatchListViewCellAttribute attribute = (WatchListViewCellAttribute) attributeMaps[1].get(element);
    if (adaptableValue == null) {
        return;//from   w w  w  .  j a v  a 2  s.c o m
    }

    if (!objectEquals(adaptableValue, valueMap.get(element))) {
        String text = (String) adaptableValue.getAdapter(String.class);
        if (text == null) {
            text = ""; //$NON-NLS-1$
        }
        if (!text.equals(cell.getText())) {
            cell.setText(text);
        }

        cell.setForeground((Color) adaptableValue.getAdapter(Color.class));
        cell.setFont((Font) adaptableValue.getAdapter(Font.class));

        ImageData imageData = (ImageData) adaptableValue.getAdapter(ImageData.class);
        if (imageData != null) {
            imageData.transparentPixel = imageData.palette.getPixel(new RGB(255, 255, 255));
            Image newImage = new Image(Display.getDefault(), imageData);
            Image oldImage = cell.getImage();
            cell.setImage(newImage);
            if (oldImage != null) {
                oldImage.dispose();
            }
        } else {
            Image image = (Image) adaptableValue.getAdapter(Image.class);
            cell.setImage(image != null && image.isDisposed() ? null : image);
        }
        valueMap.put(element, adaptableValue);
    }

    if (!objectEquals(attribute, decoratorMap.get(element))) {
        if (ownerDrawEnabled) {
            cell.setBackground(null);
            Rectangle rect = cell.getBounds();
            cell.getControl().redraw(rect.x, rect.y, rect.width, rect.height, false);
        } else {
            if (attribute == null) {
                cell.setBackground(null);
            } else {
                TableItem tableItem = (TableItem) cell.getViewerRow().getItem();
                int rowIndex = tableItem.getParent().indexOf(tableItem);
                if ((rowIndex & 1) != 0) {
                    if (attribute.oddBackground == null || !attribute.oddBackground.isDisposed()) {
                        cell.setBackground(attribute.oddBackground);
                    }
                } else {
                    if (attribute.evenBackground == null || !attribute.evenBackground.isDisposed()) {
                        cell.setBackground(attribute.evenBackground);
                    }
                }
            }
        }
        decoratorMap.put(element, attribute);
    }
}

From source file:org.kalypso.contribs.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.FocusCellHighlighter#focusCellChanged(org.eclipse.jface.viewers.ViewerCell,
 *      org.eclipse.jface.viewers.ViewerCell)
 *///ww w . j a  v a 2 s.  c o m
@Override
protected void focusCellChanged(final ViewerCell cell, final ViewerCell oldCell2) {
    super.focusCellChanged(cell, m_oldCell);

    // Redraw new area
    if (cell != null) {
        final Rectangle rect = cell.getBounds();
        final int x = cell.getColumnIndex() == 0 ? 0 : rect.x;
        final int width = cell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width;
        // 1 is a fix for Linux-GTK
        cell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true);
    }

    if (m_oldCell != null) {
        final Rectangle rect = m_oldCell.getBounds();
        final int x = m_oldCell.getColumnIndex() == 0 ? 0 : rect.x;
        final int width = m_oldCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width;
        // 1 is a fix for Linux-GTK
        m_oldCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true);
    }

    m_oldCell = cell;
}