List of usage examples for org.eclipse.jface.viewers ViewerCell setForeground
public void setForeground(Color foreground)
From source file:org.eclipse.babel.tapiji.tools.core.ui.widgets.provider.ResKeyTreeLabelProvider.java
License:Open Source License
private void updateCell(ViewerCell cell) { Object element = cell.getElement(); int columnIndex = cell.getColumnIndex(); if (isSearchEnabled(element)) { if (isMatchingToPattern(element, columnIndex)) { List<StyleRange> styleRanges = new ArrayList<StyleRange>(); FilterInfo filterInfo = (FilterInfo) ((IValuedKeyTreeNode) element).getInfo(); if (columnIndex > 0) { for (Region reg : filterInfo.getFoundInLocaleRanges(locales.get(columnIndex - 1))) { styleRanges//www . j a v a2 s .co m .add(new StyleRange(reg.getOffset(), reg.getLength(), black, info_color, SWT.BOLD)); } } else { // check if the pattern has been found within the key // section if (filterInfo.isFoundInKey()) { for (Region reg : filterInfo.getKeyOccurrences()) { StyleRange sr = new StyleRange(reg.getOffset(), reg.getLength(), black, info_color, SWT.BOLD); styleRanges.add(sr); } } } cell.setStyleRanges(styleRanges.toArray(new StyleRange[styleRanges.size()])); } else { cell.setForeground(gray); } } else if (columnIndex == 0) { super.update(cell); } }
From source file:org.eclipse.cdt.debug.internal.ui.views.executables.SourceFilesLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { super.update(cell); SourceFilesViewer.TranslationUnitInfo tuInfo = null; Object element = cell.getElement(); if (element instanceof ITranslationUnit) { tuInfo = SourceFilesViewer.fetchTranslationUnitInfo((Executable) viewer.getInput(), element); }/* w w w. java 2 s .c o m*/ int orgColumnIndex = cell.getColumnIndex(); if (orgColumnIndex == 0) { if (element instanceof String) { cell.setText((String) element); Font italicFont = resourceManager .createFont(FontDescriptor.createFrom(viewer.getTree().getFont()).setStyle(SWT.ITALIC)); cell.setFont(italicFont); } else { cell.setFont(viewer.getTree().getFont()); } } else if (orgColumnIndex == 1) { cell.setText(null); if (tuInfo != null) { if (tuInfo.location != null) { cell.setText(tuInfo.location.toOSString()); if (tuInfo.exists) cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); else cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); } } cell.setImage(null); } else if (orgColumnIndex == 2) { cell.setText(null); if (tuInfo != null && tuInfo.originalLocation != null) { cell.setText(tuInfo.originalLocation.toOSString()); if (tuInfo.originalExists) cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); else cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); } cell.setImage(null); } else if (orgColumnIndex == 3) { cell.setText(null); if (tuInfo != null) { if (tuInfo.exists) { cell.setText(Long.toString(tuInfo.fileLength)); } } cell.setImage(null); } else if (orgColumnIndex == 4) { cell.setText(null); if (tuInfo != null) { if (tuInfo.exists) { String dateTimeString = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) .format(new Date(tuInfo.lastModified)); cell.setText(dateTimeString); } } cell.setImage(null); } else if (orgColumnIndex == 5) { cell.setText(null); if (tuInfo != null) { if (tuInfo.location != null) { String fileExtension = tuInfo.location.getFileExtension(); if (fileExtension != null) cell.setText(fileExtension.toLowerCase()); } } cell.setImage(null); } }
From source file:org.eclipse.e4.tools.emf.ui.internal.ObservableColumnLabelProvider.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public void update(ViewerCell cell) { M element = (M) cell.getElement();/* w w w . ja va 2 s . c o m*/ cell.setText(getText(element)); cell.setImage(getImage(element)); cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); }
From source file:org.eclipse.eatop.examples.graphicaleditor.depd.features.views.RequirementsLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof SafetyGoal) { SafetyGoal safetyGoal = (SafetyGoal) element; text.append(safetyGoal.getShortName() + "[" + ((EObject) safetyGoal).eClass().getName() + "]"); cell.setImage(GraphitiUi.getImageService().getPlatformImageForId(DEPDImageProvider.IMAGE_SAFETY_GOAL)); text.append(" (" + safetyGoal.getRequirement().size() + ") ", StyledString.COUNTER_STYLER); }/*w w w . j a v a 2s .c om*/ if (element instanceof QualityRequirement) { QualityRequirement qr = (QualityRequirement) element; text.append(qr.getShortName() + "[" + ((EObject) qr).eClass().getName() + "]"); cell.setImage(GraphitiUi.getImageService() .getPlatformImageForId(DEPDImageProvider.IMAGE_QUALITY_REQUIREMENT)); } List<Requirement> reqs = new ArrayList<Requirement>(); if (element instanceof Requirement && !(element instanceof QualityRequirement)) { Requirement requirement = (Requirement) element; reqs = getAllRequirementsInSatisfies(safetyGoal); if (reqs.isEmpty()) { cell.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } for (Requirement req : reqs) { if (req.equals(requirement)) { cell.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GREEN)); break; } else { cell.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } } text.append(requirement.getShortName() + "[" + ((EObject) requirement).eClass().getName() + "]"); cell.setImage(GraphitiUi.getImageService().getPlatformImageForId(DEPDImageProvider.IMAGE_REQUIREMENT)); } if (element instanceof Identifiable) { if (element instanceof AnalysisFunctionPrototype) { text.append(((Identifiable) element).getShortName() + "[" + ((EObject) element).eClass().getName() + "]"); cell.setImage(GraphitiUi.getImageService() .getPlatformImageForId(DEPDImageProvider.IMAGE_ANALYSIS_FUNCTION_PROTOTYPE)); } if (element instanceof DesignFunctionPrototype) { text.append(((Identifiable) element).getShortName() + "[" + ((EObject) element).eClass().getName() + "]"); cell.setImage(GraphitiUi.getImageService() .getPlatformImageForId(DEPDImageProvider.IMAGE_DESIGN_FUNCTION_PROTOTYPE)); } } cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); super.update(cell); }
From source file:org.eclipse.emf.ecp.edit.internal.swt.controls.ECPFocusCellDrawHighlighter.java
License:Open Source License
private void markFocusedCell(Event event, ViewerCell cell) { Color background = cell.getControl().isFocusControl() ? getSelectedCellBackgroundColor(cell) : getSelectedCellBackgroundColorNoFocus(cell); Color foreground = cell.getControl().isFocusControl() ? getSelectedCellForegroundColor(cell) : getSelectedCellForegroundColorNoFocus(cell); if (foreground != null || background != null || onlyTextHighlighting(cell)) { // GC gc = event.gc; if (background == null) { background = cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); }/*from ww w .java2s .c o m*/ if (foreground == null) { foreground = cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); } // gc.setBackground(background); // gc.setForeground(foreground); // // if (onlyTextHighlighting(cell)) { // Rectangle area = event.getBounds(); // Rectangle rect = cell.getTextBounds(); // if( rect != null ) { // area.x = rect.x; // } // gc.fillRectangle(area); // } else { // gc.fillRectangle(event.getBounds()); // } cell.setBackground(background); cell.setForeground(foreground); // event.detail &= ~SWT.SELECTED; } }
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;/*from w ww . j a va 2s . 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}// w ww .j av a 2 s . co 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 w ww .j a va2 s .com*/ 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 w w w . j ava 2 s . co m 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);/*ww w.ja va 2 s .c o m*/ cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); }