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); } }
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); } }
@Override public void update(ViewerCell cell) { Object obj = cell.getElement(); StyledString str = getStyledText(obj); cell.setText(str.toString()); cell.setStyleRanges(str.getStyleRanges()); cell.setImage(getImage(obj)); }
// Column for the link TableViewerColumn col2 = createTableViewerColumn("Link", 100, 1, viewer); col2.setLabelProvider(new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { Object element = cell.getElement(); if(element instanceof Person) { Person person = (Person) cell.getElement(); /* make text look like a link */ StyledString text = new StyledString(); StyleRange myStyledRange = new StyleRange(0, person.getLocation().length(), Display.getCurrent().getSystemColor(SWT.COLOR_BLUE), null); myStyledRange.underline = true; text.append(person.getLocation(), StyledString.DECORATIONS_STYLER); cell.setText(text.toString()); StyleRange[] range = { myStyledRange }; cell.setStyleRanges(range); super.update(cell); } } });
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof AbstractNode) { StyledString styledString = getStyledString((AbstractNode) element); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(getIcon((AbstractNode) element))); } }
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString styledString = getStyledString(element); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(element)); super.update(cell); }
@Override public void update(ViewerCell cell) { StyledString string = getStyledText(cell.getElement()); cell.setText(string.getString()); cell.setStyleRanges(string.getStyleRanges()); cell.setImage(getImage(cell.getElement())); super.update(cell); }
public void update(ViewerCell cell) { StyledString string = getStyledText(cell.getElement()); cell.setText(string.getString()); cell.setStyleRanges(string.getStyleRanges()); cell.setImage(getImage(cell.getElement())); super.update(cell); }
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof WorkbenchPartReference) { WorkbenchPartReference ref = (WorkbenchPartReference) element; String text = getWorkbenchPartReferenceText(ref); cell.setText(text); cell.setImage(ref.getTitleImage()); // get the model to define the style MPart model = ref.getModel(); // build the style range StyleRange style = new StyleRange(); style.start = 0; style.length = cell.getText().length(); // if hidden use the bold font, if active italic style.font = getFont(isHiddenEditor(model), isActiveEditor(model)); cell.setStyleRanges(new StyleRange[] { style }); } }
@Override public void update(ViewerCell cell) { StyledString string = getStyledText(cell.getElement()); cell.setText(string.getString()); cell.setStyleRanges(string.getStyleRanges()); cell.setImage(getImage(cell.getElement())); super.update(cell); }
@Override public void update(ViewerCell cell) { StyledString string = getStyledText(cell.getElement()); cell.setText(string.getString()); cell.setStyleRanges(string.getStyleRanges()); cell.setImage(getImage(cell.getElement())); super.update(cell); }
@Override public void update(ViewerCell cell) { final Object element = cell.getElement(); ITargetDefinition targetDef = (ITargetDefinition) element; ITargetHandle targetHandle = targetDef.getHandle(); String name = targetDef.getName(); if (name == null || name.length() == 0) { name = targetHandle.toString(); } StyledString styledString = new StyledString(name); if (targetHandle instanceof WorkspaceFileTargetHandle) { IFile file = ((WorkspaceFileTargetHandle) targetHandle).getTargetFile(); String location = " - " + file.getFullPath(); //$NON-NLS-1$ styledString.append(location, StyledString.DECORATIONS_STYLER); } else if (targetHandle instanceof ExternalFileTargetHandle) { URI uri = ((ExternalFileTargetHandle) targetHandle).getLocation(); String location = " - " + uri.toASCIIString(); //$NON-NLS-1$ styledString.append(location, StyledString.DECORATIONS_STYLER); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(targetDef)); super.update(cell); }
@Override public void update ( final ViewerCell cell ) { final Object ele = cell.getElement (); if ( ele instanceof GroupEntry ) { cell.setText ( String.format ( Messages.FlagsDetailsPart_GroupSumFormat, ( (GroupEntry)ele ).getActiveCount (), ( (GroupEntry)ele ).getCount () ) ); } else if ( ele instanceof AttributeEntry ) { final StyledString str = new StyledString (); if ( ( (AttributeEntry)ele ).isActive () ) { str.append ( Messages.FlagsDetailsPart_ActiveMarker, this.activeStyler ); } else { str.append ( Messages.FlagsDetailsPart_InactiveMarker, this.inactiveStyler ); } cell.setText ( str.getString () ); cell.setStyleRanges ( str.getStyleRanges () ); } }
public void update(ViewerCell cell) { Object e = cell.getElement(); if( e instanceof YAMLOutlineElement ){ YAMLOutlineElement element = (YAMLOutlineElement) e; StyledString styledString = new StyledString( elementLabel(element), TEXT_STYLER ); boolean showTags = Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_SHOW_TAGS ); if( showTags ){ styledString.append( " " + element.node.getTag(), TAG_STYLER ); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage( element ) ); } super.update(cell); }
@Override public void update ( final ViewerCell cell ) { final Object ele = cell.getElement (); if ( ele instanceof GroupEntry ) { cell.setText ( String.format ( Messages.FlagsDetailsPart_GroupSumFormat, ( (GroupEntry)ele ).getActiveCount (), ( (GroupEntry)ele ).getCount () ) ); } else if ( ele instanceof AttributeEntry ) { final StyledString str = new StyledString (); if ( ( (AttributeEntry)ele ).isActive () ) { str.append ( Messages.FlagsDetailsPart_ActiveMarker, this.activeStyler ); } else { str.append ( Messages.FlagsDetailsPart_InactiveMarker, this.inactiveStyler ); } cell.setText ( str.getString () ); cell.setStyleRanges ( str.getStyleRanges () ); } }
@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. }
@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. }
@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 = new StyledString(); if (element instanceof ImportPackageSpecification) { ImportPackageSpecification spec = (ImportPackageSpecification) element; styledString.append(spec.getName()); ExportPackageDescription supplier = (ExportPackageDescription) spec.getSupplier(); if (isJREPackage(supplier)) { styledString.append(PDEUIMessages.StateViewPage_suppliedByJRE); } else { styledString.append(PDEUIMessages.StateViewPage_suppliedBy); getElementString(supplier.getSupplier(), styledString, false); } } else { getElementString(element, styledString, true); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(element)); super.update(cell); }
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (!(element instanceof ItemsListSeparator) && provider instanceof IStyledLabelProvider) { IStyledLabelProvider styledLabelProvider = (IStyledLabelProvider) provider; StyledString styledString = getStyledText(element, styledLabelProvider); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(styledLabelProvider.getImage(element)); } else { cell.setText(getText(element)); cell.setImage(getImage(element)); } cell.setFont(getFont(element)); cell.setForeground(getForeground(element)); cell.setBackground(getBackground(element)); super.update(cell); }