List of usage examples for org.eclipse.jface.viewers StyledString toString
@Override
public String toString()
From source file:bndtools.editor.components.ComponentSvcRefTableLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { ComponentSvcReference svcRef = (ComponentSvcReference) cell.getElement(); int columnIndex = cell.getColumnIndex(); StyledString styledString; switch (columnIndex) { case 0:// w ww.j a v a 2 s .co m styledString = new StyledString(svcRef.getName()); String bind = svcRef.getBind(); String unbind = svcRef.getUnbind(); if (bind != null) { StringBuilder buffer = new StringBuilder(); buffer.append(" {").append(bind).append('/'); if (unbind != null) { buffer.append(unbind); } buffer.append('}'); styledString.append(buffer.toString(), StyledString.DECORATIONS_STYLER); } cell.setImage(svcRef.isDynamic() ? dynamicImg : staticImg); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 1: styledString = new StyledString(svcRef.getServiceClass(), StyledString.QUALIFIER_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 2: char[] cardinality = new char[] { svcRef.isOptional() ? '0' : '1', '.', '.', svcRef.isMultiple() ? 'n' : '1' }; styledString = new StyledString(new String(cardinality), StyledString.COUNTER_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); break; case 3: String target = svcRef.getTargetFilter(); cell.setText(target != null ? target : ""); break; } }
From source file:com.dubture.symfony.ui.views.ServiceLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); Styler style = null;/*from w w w . j a va 2s . co m*/ if (element instanceof IProject) { IProject project = (IProject) element; StyledString styledString = new StyledString(project.getName(), style); cell.setText(styledString.toString()); cell.setImage(PHPPluginImages.get(PHPPluginImages.IMG_OBJS_PHP_PROJECT)); } else if (element instanceof Service) { Service service = (Service) element; String name = service.getClassName() != null ? service.getClassName() : service.getId(); StyledString styledString = new StyledString(name, style); String decoration = MessageFormat.format(" [{0}]", new Object[] { service.getId() }); //$NON-NLS-1$ styledString.append(decoration, StyledString.DECORATIONS_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); if (service.isPublic()) { cell.setImage(SymfonyPluginImages.get(SymfonyPluginImages.IMG_OBJS_SERVICE_PUBLIC)); } else { cell.setImage(SymfonyPluginImages.get(SymfonyPluginImages.IMG_OBJS_SERVICE_PRIVATE)); } } else if (element instanceof Bundle) { Bundle bundle = (Bundle) element; StyledString styledString = new StyledString(bundle.getElementName(), style); cell.setText(styledString.toString()); cell.setImage(SymfonyPluginImages.get(SymfonyPluginImages.IMG_OBJS_BUNDLE2)); } }
From source file:com.google.gapid.widgets.MeasuringViewLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { // Adjusted from the DelegatingStyledCellLabelProvider implementation. StyledString styledString = format(cell.getItem(), cell.getElement(), LinkableStyledString.ignoring(theme)) .getString();/*from w ww . j a v a2 s.co m*/ String newText = styledString.toString(); StyleRange[] oldStyleRanges = cell.getStyleRanges(); StyleRange[] newStyleRanges = styledString.getStyleRanges(); if (!Arrays.equals(oldStyleRanges, newStyleRanges)) { cell.setStyleRanges(newStyleRanges); if (cell.getText().equals(newText)) { cell.setText(""); } } Color bgcolor = getBackgroundColor(cell.getElement()); if (bgcolor != null) { cell.setBackground(bgcolor); } cell.setImage(getImage(cell.getElement())); cell.setText(newText); }
From source file:com.google.gapid.widgets.MeasuringViewLabelProvider.java
License:Apache License
private void updateLayout(ViewerCell cell, StyledString string) { // Adjusted from similar method from super class. layout.setStyle(null, 0, Integer.MAX_VALUE); layout.setText(string.toString()); for (StyleRange range : cell.getStyleRanges()) { layout.setStyle(range, range.start, range.start + range.length - 1); }//from w ww .j a v a 2s . co m }
From source file:com.hydra.project.myplugin_nebula.xviewer.XViewerStyledTextLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString styledString = getStyledText(element, cell.getColumnIndex()); 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 w w w .j a v a 2 s . c o m cell.setText(newText); cell.setImage(getColumnImage(element, cell.getColumnIndex())); cell.setFont(getFont(element, cell.getColumnIndex())); cell.setForeground(getForeground(element, cell.getColumnIndex())); cell.setBackground(getBackground(element, cell.getColumnIndex())); // no super call required. changes on item will trigger the refresh. }
From source file:com.kdmanalytics.toif.report.internal.providers.ReportLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { Object element = cell.getElement(); final StyledString styledString = new StyledString(getColumnText(element, cell.getColumnIndex())); if (element instanceof IFindingEntry) { final IFindingEntry entry = (IFindingEntry) element; if (Citing.UNKNOWN == entry.isOk()) { cell.setForeground(colorReg.get(FOREGROUND_BLACK)); cell.setBackground(colorReg.get(BLUE)); } else {//from w w w. ja v a 2s. c o m cell.setForeground(Citing.TRUE == entry.isOk() ? colorReg.get(FOREGROUND_GREEN) : colorReg.get(FOREGROUND_RED)); cell.setBackground(Citing.TRUE == entry.isOk() ? colorReg.get(GREEN) : colorReg.get(RED)); } } else if (element instanceof IFileGroup) { cell.setFont(getFont(element)); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(cell.getColumnIndex() > 0 ? null : getImage(element)); }
From source file:com.kdmanalytics.toif.report.internal.providers.ReportStyledCellLabelProvider.java
License:Open Source License
@Override public void update(final ViewerCell cell) { final IToifReportEntry entry = (IToifReportEntry) cell.getElement(); final StyledString styledString = new StyledString(getColumnText(entry, cell.getColumnIndex())); final IFindingEntry findingEntry = entry.getFindingEntry(); if (Citing.UNKNOWN == findingEntry.isOk()) { cell.setForeground(FOREGROUND_BLACK); cell.setBackground(WHITE);//from w ww . jav a 2 s . co m } else { cell.setForeground(Citing.TRUE == findingEntry.isOk() ? FOREGROUND_RED : FOREGROUND_GREEN); cell.setBackground(Citing.TRUE == findingEntry.isOk() ? RED : GREEN); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(entry, cell.getColumnIndex())); }
From source file:com.kdmanalytics.toif.ui.views.DefectDescStyledLabelProvider.java
License:Open Source License
public void update(final ViewerCell cell) { final DefectNode entry = (DefectNode) cell.getElement(); int index = cell.getColumnIndex(); final StyledString styledString = new StyledString(getColumnText(entry, index)); String desc = entry.getDescription(); if (desc.startsWith("http://") || desc.startsWith("https://")) { cell.setForeground(FOREGROUND_BLUE); }/*ww w . ja va 2 s . c o m*/ String text = styledString.toString(); // This removed code is used to split the string into a number of separate // lines suitable for wrapping. // // // // How many characters will we allow per line? // Tree tree = (Tree)cell.getControl(); // // // Use the client area minus the first column to see how much room we have // // for text. // Rectangle area = viewer.getTree().getClientArea(); // TreeColumn column = tree.getColumn(0); // int width = area.width - column.getWidth(); // if (width < 50) width = 50; // width -= 10; // GC gc = new GC(tree); // FontMetrics fm = gc.getFontMetrics(); // int charWidth = fm.getAverageCharWidth(); // int charCount = width / charWidth; // if (charCount < 10) charCount = 10; // // List<String> lines = new LinkedList<String>(); // // while (text.length() > 0) { // // Break at space // int lastSpace = text.lastIndexOf(' ', charCount); // if (lastSpace > 10) { // lines.add(text.substring(0, lastSpace)); // text = text.substring(lastSpace + 1); // continue; // } // // // Break at next space // int nextSpace = text.indexOf(' ', charCount); // if (nextSpace > 10) { // lines.add(text.substring(0, nextSpace)); // text = text.substring(nextSpace + 1); // continue; // } // // // Just use whole string // lines.add(text); // text = ""; // } // // // Add in \n characters // StringBuilder sb = new StringBuilder(); // for (int i = 0; i < lines.size(); i++) { // if (i > 0) sb.append("\n"); // sb.append(lines.get(i)); // } // // cell.setText(sb.toString()); cell.setText(text); cell.setStyleRanges(styledString.getStyleRanges()); }
From source file:com.kdmanalytics.toif.ui.views.FindingStyledLabelProvider.java
License:Open Source License
public void update(final ViewerCell cell) { final IFindingEntry entry = (IFindingEntry) cell.getElement(); int index = cell.getColumnIndex(); String text = getColumnText(entry, index); if (text == null) { text = ""; }//from w ww. ja v a 2 s.c o m final StyledString styledString = new StyledString(text); Boolean citing = entry.getCiting(); if (citing != null) { if (citing) { cell.setForeground(FOREGROUND_RED); cell.setBackground(RED); } else { cell.setForeground(FOREGROUND_GREEN); cell.setBackground(GREEN); } } else { cell.setForeground(FOREGROUND_BLACK); cell.setBackground(WHITE); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(entry, cell.getColumnIndex())); }
From source file:com.netxforge.netxstudio.screens.LoadingLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof String) { // Do some styling on our loading string. . StyledString styledString = new StyledString(); styledString.append((String) element, StyledString.COUNTER_STYLER); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); }/*from w w w . j a va2 s . co m*/ // We only support String (for now). super.update(cell); }