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

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

Introduction

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

Prototype

public void setBackground(Color background) 

Source Link

Document

Set the background color of the cell.

Usage

From source file:com.magicparser.net.packet.reader.ColorPartReader.java

License:Open Source License

@Override
public Widget getWidget(IntegerPart part, Display display, ViewerCell cell) {
    //final Composite composite = new Composite(parent, SWT.NONE);

    int r = (part.getValue()) & 0xFF;
    int g = (part.getValue() >> 8) & 0xFF;
    int b = (part.getValue() >> 16) & 0xFF;

    cell.setBackground(new Color(display, r, g, b));
    return null;//  www  .  ja  v  a2s  .c  om
}

From source file:com.matlab.eclipse.mconsole.views.CommandHistoryLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof CommandHistoryEntry) {
        ThemeWrapper theme = MConsolePlugin.getDefault().getCurrentTheme();
        CommandHistoryEntry commandHistoryEntry = (CommandHistoryEntry) cell.getElement();

        String entry = commandHistoryEntry.getName();
        if (entry.contains(System.getProperty("line.separator"))) {
            cell.setText(/*w  ww. j  a  v  a  2  s  .  c o m*/
                    commandHistoryEntry.toString().replaceAll(System.getProperty("line.separator"), "\\\\n"));
        } else {
            cell.setText(commandHistoryEntry.toString());
        }
        try {
            if (commandHistoryEntry.getName().startsWith("%")) {
                cell.setForeground(theme.getColor(ThemeConstants.COMMANDHISTORY_DATE_COLOR));
            } else
                cell.setForeground(theme.getColor(ThemeConstants.COMMANDHISTORY_FOREGROUND_COLOR));
            cell.setBackground(theme.getColor(ThemeConstants.COMMANDHISTORY_BACKGROUND_COLOR));
            cell.setFont(theme.getFont(ThemeConstants.COMMANDHISTORY_FONT));

        } catch (Exception e) {

        }
    }

}

From source file:com.motorola.studio.android.emulator.core.emulationui.AbstractEmuLabelProvider.java

License:Apache License

/**
 * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
 *//*from  w  w w.  j a  va2s  .c  om*/
@Override
public void update(ViewerCell cell) {
    // The instance column index is set with the current cell column index, as the logic
    // contained in this class depends on this information. Then after the cell is 
    // updated according to the standard procedure, the column index field is reset so that
    // it does not interfere with subsequent updates. 
    columnIndex = cell.getColumnIndex();
    super.update(cell);
    columnIndex = firstColumnIndex;

    // Checks if the cell needs to be highlighted. This will be true if the values of
    // alternativeColorHost and alternativeColorBeanId are different from null and -1
    if ((alternativeColorHost != null) && (alternativeColorBeanId != -1)) {

        Object element = cell.getElement();
        // Only leaf nodes can be highlighted
        if (element instanceof EmuViewerLeafNode) {
            // The next lines are used to check if the current element is the one to be
            // highlighted. For that, the host and bean id needs to be compared to the
            // alternativeColorHost and alternativeColorBeanId instance field values
            EmuViewerLeafNode node = (EmuViewerLeafNode) element;
            long beanId = node.getBeanId();
            EmuViewerRootNode root = (EmuViewerRootNode) node.getParent().getParent();
            String host = root.getEmulatorIdentifier();

            if ((beanId == alternativeColorBeanId) && (host.equals(alternativeColorHost))) {
                // Highlighting the node

                cell.setBackground(alternativeColor);

                // Putting the node at the visible part of the tree

                ViewerRow highlightedRow = cell.getViewerRow();
                TreeItem highlightedItem = (TreeItem) highlightedRow.getItem();
                Tree tree = (Tree) cell.getControl();
                tree.showItem(highlightedItem);
            }
        }

    }
}

From source file:com.netxforge.netxstudio.screens.f1.support.MonitoringTreeLabelProvider.java

License:Open Source License

private void backGroundForRag(ViewerCell cell, int ragValue, String symbolicName) {
    // Determine if R, A or G from the RAG status, set the styler.
    if (ragValue > 0) {
        // remember the previous background.
        cell.setBackground(JFaceResources.getColorRegistry().get(symbolicName));
    } else {//from ww w.j  av a 2 s  .  c  om
        cell.setBackground(null);
    }
}

From source file:com.nextep.designer.sqlclient.ui.jface.SQLResultLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    final Object elt = cell.getElement();
    final int colIndex = cell.getColumnIndex();
    final String text = getColumnText(elt, colIndex);
    cell.setText(text);//from w ww .  j  a va  2  s .  c  o  m
    final Image img = getColumnImage(elt, colIndex);
    cell.setImage(img);
    final Color background = getBackground(elt, colIndex);
    cell.setBackground(background);
}

From source file:cop.swt.widgets.viewers.table.columns.settings.ColorColumn.java

License:LGPL

@Override
public void update(ViewerCell cell, T item) throws Exception {
    cell.setBackground(getColor((RGB) invoke(item)));
}

From source file:de.fips.plugin.tinyaudioplayer.view.playlist.PlaylistItemLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    val item = (PlaylistItem) cell.getElement();
    cell.setText(item.getDisplayableName());
    if (player != null) {
        val playlist = player.getPlaylist();
        if (!playlist.isEmpty() && (item.equals(playlist.getCurrentTrack()))) {
            cell.setBackground(new Color(null, GREY));
        } else {/*  w  w w  . ja  v a2 s  . com*/
            cell.setBackground(new Color(null, WHITE));
        }
    }
}

From source file:de.instanttouch.ui.scaffolding.swt.viewer.lazy.SnakeLazyTableViewer.java

License:Open Source License

private void handleStateMarker(ViewerCell cell, SnakeType dataItem, SnakeMarker marker) {
    SnakeStateMarker stateMarker = (SnakeStateMarker) marker;

    String backColorStr = stateMarker.getStateColor(dataItem);
    if (backColorStr != null) {
        Color stateBackground = SnakeSwtUtils.createFromHexString(backColorStr);
        cell.setBackground(stateBackground);
    }//from  w ww .  ja va  2  s .  c  o  m
}

From source file:de.instanttouch.ui.scaffolding.swt.viewer.lazy.SnakeLazyTableViewer.java

License:Open Source License

private void handleValidationMarker(ViewerCell cell, SnakeType dataItem, SnakeMarker marker) {
    SnakeValidationMarker validationMarker = (SnakeValidationMarker) marker;
    if (!validationMarker.isValid(dataItem)) {

        String backColorStr = validationMarker.getBackgroundColor();
        Color validationBackground = SnakeSwtUtils.createFromHexString(backColorStr);

        cell.setBackground(validationBackground);
    }/* w w w .j a v a 2  s  .com*/
}

From source file:es.uah.aut.srg.micobs.util.impl.MICOBSAdapterFactoryLabelProvider.java

License:Open Source License

public void update(ViewerCell cell) {
    Object element = cell.getElement();

    StyledString styledString = getStyledText(element);
    String newText = styledString.toString();

    StyleRange[] oldStyleRanges = cell.getStyleRanges();
    StyleRange[] newStyleRanges = isOwnerDrawEnabled() ? styledString.getStyleRanges() : null;

    if (!Arrays.equals(oldStyleRanges, newStyleRanges)) {
        cell.setStyleRanges(newStyleRanges);
        if (cell.getText().equals(newText)) {
            // make sure there will be a refresh from a change
            cell.setText(""); //$NON-NLS-1$
        }//from   ww  w.  ja  v  a 2  s.c  o  m
    }

    cell.setText(newText);
    cell.setImage(getImage(element));
    cell.setFont(getFont(element));
    cell.setForeground(getForeground(element));
    cell.setBackground(getBackground(element));

    // no super call required. changes on item will trigger the refresh.
}