List of usage examples for org.eclipse.jface.viewers ViewerCell setBackground
public void setBackground(Color background)
From source file:org.eclipse.emf.ecp.edit.internal.swt.controls.ECPFocusCellDrawHighlighter.java
License:Open Source License
private void removeSelectionInformation(Event event, ViewerCell cell) { // GC gc = event.gc; // gc.setBackground(cell.getViewerRow().getBackground( // cell.getColumnIndex())); // gc.setForeground(cell.getViewerRow().getForeground( // cell.getColumnIndex())); // gc.fillRectangle(cell.getBounds()); // event.detail &= ~SWT.SELECTED; Color cellBackground = null;/*ww w . j av a 2 s .c o m*/ Color cellForeground = null; final CellLabelProvider labelProvider = viewer.getLabelProvider(cell.getColumnIndex()); if (labelProvider instanceof IColorProvider) { final IColorProvider columnLabelProvider = (IColorProvider) labelProvider; cellBackground = columnLabelProvider.getBackground(cell.getElement()); cellForeground = columnLabelProvider.getForeground(cell.getElement()); } cell.setBackground(cellBackground); cell.setForeground(cellForeground); }
From source file:org.eclipse.jubula.client.ui.provider.DecoratingCellLabelProvider.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . java 2 s .c o m*/ */ public void update(ViewerCell cell) { ViewerLabel label = new ViewerLabel(cell.getText(), cell.getImage()); // Set up the initial settings from the label provider label.setBackground(getBackground(cell.getElement())); label.setForeground(getForeground(cell.getElement())); label.setFont(getFont(cell.getElement())); updateLabel(label, cell.getElement()); cell.setBackground(label.getBackground()); cell.setForeground(label.getForeground()); cell.setFont(label.getFont()); if (label.hasNewText()) { cell.setText(label.getText()); } if (label.hasNewImage()) { cell.setImage(label.getImage()); } }
From source file:org.eclipse.linuxtools.dataviewers.abstractviewers.STOwnerDrawLabelProvider.java
License:Open Source License
public void update(ViewerCell cell) { if (fields.getSpecialDrawer(cell.getElement()) == null) { Object element = cell.getElement(); cell.setText(getText(element));//from ww w. j a v a 2 s .c o m cell.setImage(getImage(element)); cell.setForeground(getForeground(element)); cell.setBackground(getBackground(element)); } }
From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaSeeAlsoAttributeEditor.java
License:Open Source License
private void createSeeAlsoTable(FormToolkit toolkit, final Composite seeAlsoComposite) { seeAlsoTable = toolkit.createTable(seeAlsoComposite, SWT.MULTI | SWT.FULL_SELECTION); seeAlsoTable.setLinesVisible(true);//from ww w .ja va 2 s. c om seeAlsoTable.setHeaderVisible(true); seeAlsoTable.setLayout(new GridLayout()); seeAlsoTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); for (int i = 0; i < seeAlsoColumns.length; i++) { TableColumn column = new TableColumn(seeAlsoTable, SWT.LEFT, i); column.setText(seeAlsoColumns[i]); column.setWidth(seeAlsoColumnWidths[i]); column.setMoveable(true); } seeAlsoViewer = new TableViewer(seeAlsoTable); seeAlsoViewer.setUseHashlookup(true); seeAlsoViewer.setColumnProperties(seeAlsoColumns); ColumnViewerToolTipSupport.enableFor(seeAlsoViewer, ToolTip.NO_RECREATE); seeAlsoViewer.setContentProvider(new ArrayContentProvider()); seeAlsoViewer.addOpenListener(new IOpenListener() { public void open(OpenEvent event) { openseeAlso(event); } private void openseeAlso(OpenEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); for (String item : (List<String>) selection.toList()) { BrowserUtil.openUrl(item); } } }); seeAlsoViewer.setLabelProvider(new ColumnLabelProvider() { public Image getColumnImage(Object element, int columnIndex) { String value = (String) element; if (columnIndex == 0) { if (value.contains("/r/#/c/") || value.contains("git.eclipse.org/r/")) { //$NON-NLS-1$ //$NON-NLS-2$ return CommonImages.getImage(BugzillaImages.GERRIT); } else if (value.contains("/commit/?id=")) { //$NON-NLS-1$ return CommonImages.getImage(BugzillaImages.GIT); } else { return CommonImages.getImage(BugzillaImages.BUG); } } return null; } public String getColumnText(Object element, int columnIndex) { String value = (String) element; switch (columnIndex) { case 0: return null; case 1: return attrRemoveSeeAlso.getValues().contains(value) ? Messages.BugzillaSeeAlsoAttributeEditor_Yes : Messages.BugzillaSeeAlsoAttributeEditor_No; default: return value; } } @Override public void update(ViewerCell cell) { Object element = cell.getElement(); cell.setText(getColumnText(element, cell.getColumnIndex())); Image image = getColumnImage(element, cell.getColumnIndex()); cell.setImage(image); cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); } }); seeAlsoViewer.setInput(getTaskAttribute().getValues().toArray()); GC gc = new GC(seeAlsoComposite); int maxSize = 0; for (String string : getTaskAttribute().getValues()) { Point size = gc.textExtent(string); if (size.x > maxSize) { maxSize = size.x; } } if (maxSize == 0) { maxSize = 100; } seeAlsoTable.getColumn(2).setWidth(maxSize); MenuManager menuManager = new MenuManager(); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { manager.add(openAction); manager.add(copyURLToClipAction); manager.add(toggelRemoveStateAction); } }); Menu menu = menuManager.createContextMenu(seeAlsoTable); seeAlsoTable.setMenu(menu); }
From source file:org.eclipse.mylyn.internal.github.ui.gist.GistAttachmentTableLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); cell.setText(getColumnText(element, cell.getColumnIndex())); Image image = getColumnImage(element, cell.getColumnIndex()); cell.setImage(image);/*from w w w . j a va 2 s. co m*/ cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); }
From source file:org.eclipse.paho.mqtt.ui.support.provider.PropertyCellLabelProvider.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from w w w .j a v a 2 s . c o m*/ public void update(ViewerCell cell) { super.update(cell); Object value = Beans.readProperty(cell.getElement(), descriptor); if (value == null) { // SWT.COLOR_GRAY cell.setBackground(Colors.getColor("BFC1C0")); //$NON-NLS-1$ cell.setText(null); return; } String text = String.valueOf(value); if (valueFormatter != null && value != null) { text = valueFormatter.format((T) value); } cell.setText(text); }
From source file:org.eclipse.ptp.internal.rm.jaxb.control.ui.providers.ViewerDataCellLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { int index = cell.getColumnIndex(); Object element = cell.getElement(); Color color = getBackground(element, index); if (color != null) { cell.setBackground(color); }/*from w w w.j a v a 2s . c o m*/ color = getForeground(element, index); if (color != null) { cell.setForeground(color); } else { /* * If foreground color is not specified, then we use the edit status of the * cell to determine the color. We save the default foreground color to use * when the cell is editable. */ if (foregroundColor == null) { foregroundColor = cell.getForeground(); } if (!canEdit(element)) { cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY)); } else { cell.setForeground(foregroundColor); } } Font font = getFont(element, index); if (font != null) { cell.setFont(font); } Image img = getColumnImage(element, index); if (img != null) { cell.setImage(img); } cell.setText(getColumnText(element, index)); }
From source file:org.eclipse.ptp.rm.jaxb.control.ui.providers.ViewerDataCellLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { int index = cell.getColumnIndex(); Object element = cell.getElement(); Color color = getBackground(element, index); if (color != null) { cell.setBackground(color); }//from www .jav a 2 s . c o m color = getForeground(element, index); if (color != null) { cell.setBackground(color); } Font font = getFont(element, index); if (font != null) { cell.setFont(font); } Image img = getColumnImage(element, index); if (img != null) { cell.setImage(img); } cell.setText(getColumnText(element, index)); }
From source file:org.eclipse.rcptt.verifications.tree.ui.VerificationTreeLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { if (cell.getElement() instanceof Row) { Row row = (Row) cell.getElement(); int ind = cell.getColumnIndex(); if (row.getValues().size() > ind) { Cell cellValue = row.getValues().get(ind); ItemData cellData = cellValue.getData(); if (ignoreStyle) { cell.setStyleRanges(null); cell.setText(cellData.getText()); } else { StyleRange[] ranges = RangeUtils.fromEMF(cellValue.getStyle(), cell.getItem().getDisplay()); if (skipStyledText) { cell.setStyleRanges(null); cell.setText(StyleRangeUtils.getNonStyledText(ranges, cellData.getText())); } else { cell.setStyleRanges(ranges); cell.setText(cellData.getText()); }/* ww w . j av a 2s. c o m*/ } cell.setBackground( RangeUtils.colorFromEMF(cellData.getBackgroundColor(), cell.getItem().getDisplay())); cell.setForeground( RangeUtils.colorFromEMF(cellData.getForegroundColor(), cell.getItem().getDisplay())); if (drawIcons) { String imgPath = TreeVerificationUtils.getDecoratedImagePath(cellData.getImage()); if (images.containsKey(imgPath)) { cell.setImage(images.get(imgPath)); } } else { cell.setImage(null); } } } }
From source file:org.eclipse.scada.ca.ui.editor.factory.FactoryCellLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { final ConfigurationDescriptor cfg = (ConfigurationDescriptor) cell.getElement(); switch (cell.getColumnIndex()) { case 0:// www . ja va 2 s . c o m cell.setText(cfg.getConfigurationInformation().getId()); break; case 1: cell.setText("" + cfg.getConfigurationInformation().getState()); break; } if (cfg.getConfigurationInformation().getErrorInformation() != null) { cell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } else { cell.setBackground(null); } super.update(cell); }