@Override public void update(ViewerCell cell) { switch (cell.getColumnIndex()) { case COLUMN_FEATURE_NAME : StyledString label = getStyledText(cell.getElement()); cell.setStyleRanges(label.getStyleRanges()); cell.setText(label.toString()); cell.setImage(getColumnImage(cell.getElement(), COLUMN_FEATURE_NAME)); break; case COLUMN_PLUGIN_RESOLUTION : cell.setText(getColumnText(cell.getElement(), COLUMN_PLUGIN_RESOLUTION)); cell.setImage(getColumnImage(cell.getElement(), COLUMN_PLUGIN_RESOLUTION)); break; } super.update(cell); }
@Override 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$ } } 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. }
public void update(ViewerCell cell) { TableItem item = (TableItem) cell.getItem(); Button button; if(buttons.containsKey(cell.getElement())) button = buttons.get(cell.getElement()); button = new Button((Composite) cell.getViewerRow().getControl(),SWT.NONE); button.setText("Remove"); buttons.put(cell.getElement(), button); editor.setEditor(button , item, cell.getColumnIndex()); editor.layout();
@Override public void update(final ViewerCell cell) { cell.setText(cell.getElement().toString()); } }
public class ColorColumnLabelProvider extends ColumnLabelProvider { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); if(element instanceof AplotResultsDataModel.ResultsData) { AplotResultsDataModel.ResultsData p = (AplotResultsDataModel.ResultsData) element; cell.setForeground(YOUR_COLOR); switch(cell.getColumnIndex()) { case 0: cell.setText(p.YOUR_FIRST_TEXT); break; case 1: cell.setText(p.YOUR_SECOND_TEXT); break; case ... } } } }
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); cell.setText(getText(element)); Image image = getImage(element); cell.setImage(image); cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); }
public void update(ViewerCell cell) { Object element = cell.getElement(); if(viewerLabelProvider == null && treePathLabelProvider == null){ cell.setText(getText(element)); Image image = getImage(element); cell.setImage(image); if (colorProvider != null) { cell.setBackground(getBackground(element)); cell.setForeground(getForeground(element)); cell.setFont(getFont(element)); ViewerLabel label = new ViewerLabel(cell.getText(), cell.getImage()); TreePath treePath = cell.getViewerRow().getTreePath();
public class MyStyledLabelProvider extends StyledCellLabelProvider { private Styler defaultStyler; public MyStyledLabelProvider () { defaultStyler = new Styler() { @Override public void applyStyles(TextStyle textStyle) { textStyle.strikeout = true; } }; } @Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString styledString = getStyledString(element); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); super.update(cell); } @SuppressWarnings("unchecked") private StyledString getStyledString(Object element) { return new StyledString("Cell string", defaultStyler); } }
/** * Update the contents of the cell. * * @param cell */ public void update(ViewerCell cell) { cell.setText(getValue((MarkerItem) cell.getElement())); cell.setImage(null); }
public void update(ViewerCell cell) { provider.update(cell); if (cell.getStyleRanges() == null) { cell.setStyleRanges(styleRanges); if (cell.getElement() instanceof IValidable) { IValidable model = (IValidable) cell.getElement(); if (!ControllerRegistry.getCurrentViolations().getViolations(model.getModelId(), propertyName).isEmpty()) { if (cell.getText().isEmpty()) { cell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); cell.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } else { if (styleRanges[0].length < cell.getText().length()) { styleRanges[0].length = cell.getText().length(); if (cell.getImage() != null) { cell.setImage(null); cell.setStyleRanges(null);
@Override public void update(ViewerCell cell) { cell.setText(getText(cell.getElement())); Color color = getForeground(cell.getElement()); if (color != null) { cell.setForeground(color); } } }
@Override public void update ( final ViewerCell cell ) { final ConfigurationDescriptor cfg = (ConfigurationDescriptor)cell.getElement (); switch ( cell.getColumnIndex () ) { case 0: 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 ); }
@Override public void update ( final ViewerCell cell ) { final Map.Entry<?, ?> cfg = (Map.Entry<?, ?>)cell.getElement (); switch ( cell.getColumnIndex () ) { case 0: cell.setText ( "" + cfg.getKey () ); break; case 1: cell.setText ( "" + cfg.getValue () ); break; } super.update ( cell ); } }
@Override public void update(ViewerCell cell) { super.update(cell); cell.setImage(getImage(cell.getElement())); } }
private boolean isCellEditable(ColumnViewer viewer, ViewerCell cell) { ViewerColumn column = viewer.getViewerColumn(cell.getColumnIndex()); return column != null && column.getEditingSupport() != null && column.getEditingSupport().canEdit(cell.getElement()); }
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; Color cellForeground = null; CellLabelProvider labelProvider = viewer.getLabelProvider( cell.getColumnIndex() ); if( labelProvider instanceof ColumnLabelProvider ) { ColumnLabelProvider columnLabelProvider = ( ColumnLabelProvider )labelProvider; cellBackground = columnLabelProvider.getBackground( cell.getElement() ); cellForeground = columnLabelProvider.getForeground( cell.getElement() ); } cell.setBackground( cellBackground ); cell.setForeground( cellForeground ); }
private boolean waitForPendingDecoration(ViewerCell cell) { if (this.decorator == null) return false; Object element = cell.getElement(); String oldText = cell.getText(); boolean isDecorationPending = false; if (this.decorator instanceof LabelDecorator) { isDecorationPending = !((LabelDecorator) this.decorator) .prepareDecoration(element, oldText, getDecorationContext()); } else if (this.decorator instanceof IDelayedLabelDecorator) { isDecorationPending = !((IDelayedLabelDecorator) this.decorator) .prepareDecoration(element, oldText); } if (isDecorationPending && oldText.length() == 0) { // item is empty: is shown for the first time: don't wait return false; } return isDecorationPending; }
public void keyTraversed(TraverseEvent e) { if ((feature & DEFAULT) != DEFAULT && e.doit) { processTraverseEvent(cell.getColumnIndex(), viewer.getViewerRowFromItem(cell .getItem()), e); } } };
private void handleSelection(Event event) { if ((event.detail & SWT.CHECK) == 0 && focusCell != null && focusCell.getItem() != event.item && event.item != null && ! event.item.isDisposed() ) { ViewerRow row = viewer.getViewerRowFromItem(event.item); Assert .isNotNull(row, "Internal Structure invalid. Row item has no row ViewerRow assigned"); //$NON-NLS-1$ ViewerCell tmp = row.getCell(focusCell.getColumnIndex()); if (!focusCell.equals(tmp)) { setFocusCell(tmp); } } }
@Override public void getName(AccessibleEvent event) { ViewerCell cell = getFocusCell(); if (cell == null) return; ViewerRow row = cell.getViewerRow(); if (row == null) return; ViewerColumn viewPart = viewer.getViewerColumn(cell .getColumnIndex()); if (viewPart == null) return; CellLabelProvider labelProvider = viewPart .getLabelProvider(); if (labelProvider == null) return; labelProvider.update(cell); event.result = cell.getText(); } });