List of usage examples for org.eclipse.jface.viewers ViewerCell setText
public void setText(String text)
From source file:bndtools.editor.common.PropertiesTableLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { ColumnViewer viewer = getViewer();/*from w w w . j a va2 s . co m*/ @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) viewer.getInput(); String key = (String) cell.getElement(); if (cell.getColumnIndex() == 0) { cell.setText(key); } else if (cell.getColumnIndex() == 1) { cell.setText(map.get(key)); } }
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;//w w w.ja v a 2s . co m switch (columnIndex) { case 0: 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:bndtools.editor.components.MethodProposalLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { StyledString styledString = getStyledString(cell.getElement()); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }
From source file:bndtools.editor.pkgpatterns.HeaderClauseLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { @SuppressWarnings("unchecked") C clause = (C) cell.getElement();//from www.j a va 2s . c om cell.setImage(packageImg); StyledString styledString = new StyledString(clause.getName()); String version = clause.getAttribs().get(org.osgi.framework.Constants.VERSION_ATTRIBUTE); if (version != null) { styledString.append(": " + version, StyledString.COUNTER_STYLER); } decorate(styledString, clause); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }
From source file:bndtools.editor.pkgpatterns.PkgPatternsLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { HeaderClause clause = (HeaderClause) cell.getElement(); cell.setImage(packageImg);/* w w w . j av a 2 s. c o m*/ StyledString styledString = new StyledString(clause.getName()); String resolution = clause.getAttribs().get(Constants.RESOLUTION_DIRECTIVE); if (org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution)) { styledString.append(" <optional>", UIConstants.ITALIC_QUALIFIER_STYLER); } String version = clause.getAttribs().get(org.osgi.framework.Constants.VERSION_ATTRIBUTE); if (version != null) { styledString.append(": " + version, StyledString.COUNTER_STYLER); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); }
From source file:bndtools.model.importanalysis.ImportsExportsTreeLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { if (IMPORTS_PLACEHOLDER.equals(cell.getElement())) { if (cell.getColumnIndex() == 0) { cell.setImage(pkgFolderImg); cell.setText("Import Packages"); }//from ww w . j ava2 s.c o m } else if (EXPORTS_PLACEHOLDER.equals(cell.getElement())) { if (cell.getColumnIndex() == 0) { cell.setImage(pkgFolderImg); cell.setText("Export Packages"); } } else if (REQUIRED_PLACEHOLDER.equals(cell.getElement())) { if (cell.getColumnIndex() == 0) { cell.setImage(bundleFolderImg); cell.setText("Required Bundles"); } } else if (cell.getElement() instanceof ImportUsedByPackage) { if (cell.getColumnIndex() == 0) { StyledString styledString = new StyledString("Used By: ", UIConstants.ITALIC_QUALIFIER_STYLER); styledString.append(((ImportUsedByPackage) cell.getElement()).usedByName); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); } } else if (cell.getElement() instanceof ImportUsedByClass) { if (cell.getColumnIndex() == 0) { ImportUsedByClass importUsedBy = (ImportUsedByClass) cell.getElement(); String fqn = importUsedBy.clazz.getFQN(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); cell.setText(className); cell.setImage(classImg); } } else if (cell.getElement() instanceof ExportUsesPackage) { if (cell.getColumnIndex() == 0) { StyledString styledString = new StyledString("Uses: ", UIConstants.ITALIC_QUALIFIER_STYLER); styledString.append(((ExportUsesPackage) cell.getElement()).name); cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); } } else if (cell.getElement() instanceof RequiredBundle) { RequiredBundle rb = (RequiredBundle) cell.getElement(); switch (cell.getColumnIndex()) { case 0: StyledString label; if (rb.isSatisfied()) label = new StyledString(rb.getName(), StyledString.QUALIFIER_STYLER); else label = new StyledString(rb.getName()); String version = rb.getAttribs().get(Constants.BUNDLE_VERSION_ATTRIBUTE); if (version != null) label.append(" " + version, StyledString.COUNTER_STYLER); String resolution = rb.getAttribs().get(Constants.RESOLUTION_DIRECTIVE); boolean optional = org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution); if (resolution != null) label.append(" <" + resolution + ">", UIConstants.ITALIC_QUALIFIER_STYLER); cell.setText(label.getString()); cell.setStyleRanges(label.getStyleRanges()); if (optional) cell.setImage(requiredBundleOptImg); else if (rb.isSatisfied()) cell.setImage(requiredBundleSatisfiedImg); else cell.setImage(requiredBundleImg); break; case 1: cell.setText(formatAttribs(rb.getAttribs())); break; default: break; } } else if (cell.getElement() instanceof ImportPackage || cell.getElement() instanceof ExportPackage) { HeaderClause entry = (HeaderClause) cell.getElement(); switch (cell.getColumnIndex()) { case 0: boolean selfImport = false; if (entry instanceof ImportPackage) { selfImport = ((ImportPackage) entry).isSelfImport(); } StyledString styledString; if (selfImport) { styledString = new StyledString(entry.getName(), StyledString.QUALIFIER_STYLER); } else { styledString = new StyledString(entry.getName()); } String version = entry.getAttribs().get(Constants.VERSION_ATTRIBUTE); if (version != null) styledString.append(" " + version, StyledString.COUNTER_STYLER); String resolution = entry.getAttribs().get(Constants.RESOLUTION_DIRECTIVE); boolean optional = org.osgi.framework.Constants.RESOLUTION_OPTIONAL.equals(resolution); if (resolution != null) { styledString.append(" <" + resolution + ">", UIConstants.ITALIC_QUALIFIER_STYLER); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); if (optional) { cell.setImage(packageOptImg); } else if (selfImport) { cell.setImage(packageImpExpImg); } else { cell.setImage(packageImg); } break; case 1: cell.setText(formatAttribs(entry.getAttribs())); break; default: break; } } }
From source file:bndtools.utils.ClassPathLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { IPath path = (IPath) cell.getElement(); cell.setText(path.toString()); if (path.hasTrailingSeparator()) cell.setImage(folderImg);/*w ww .java 2 s . c o m*/ else cell.setImage(jarImg); }
From source file:ca.uvic.chisel.javasketch.ui.internal.search.TraceSearchResultLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); int columnIndex = cell.getColumnIndex(); cell.setImage(getColumnImage(element, columnIndex)); if (element instanceof Match) { String text = ""; switch (columnIndex) { case 0:/* w w w. j a v a 2 s . co m*/ setMatchText(cell); break; case 1: ITraceModelProxy mElement = (ITraceModelProxy) ((Match) element).getElement(); switch (mElement.getKind()) { case ITraceModel.ACTIVATION: text = "Activation"; break; case ITraceModel.TRACE_CLASS: text = "Class"; break; case ITraceModel.TRACE_CLASS_METHOD: text = "Method"; break; case ITraceModel.THREAD: text = "Thread"; break; case ITraceModel.TRACE: text = "Trace"; break; } if ((mElement.getKind() & ITraceModel.MESSAGE) == ITraceModel.MESSAGE) { text = "Message"; } cell.setText(text); } } else { cell.setText(getColumnText(element, columnIndex)); } }
From source file:ca.uvic.chisel.javasketch.ui.internal.search.TraceSearchResultLabelProvider.java
License:Open Source License
/** * @param cell//from ww w.j a v a 2 s .c o m */ private void setMatchText(ViewerCell cell) { Match match = (Match) cell.getElement(); ITraceModelProxy proxy = (ITraceModelProxy) match.getElement(); IProgramSketch sketch = SketchPlugin.getDefault().getSketch(proxy.getTrace()); PresentationData pd = PresentationData.connect(sketch); try { String annotation = pd.getAnnotation(proxy.getElementId()); if (annotation != null) { annotation = annotation.replaceAll("\\s+", " "); if (annotation.length() >= match.getOffset() + match.getLength()) { int summaryOffset = 0; String summary = annotation.substring(match.getOffset(), match.getOffset() + match.getLength()); StringBuilder builder = new StringBuilder(summary); int wordCount = 0; int index = match.getOffset() - 1; while (wordCount < 3 && index >= 0) { char c = annotation.charAt(index); if (Character.isWhitespace(c)) { wordCount++; if (wordCount > 3) { break; } } builder.insert(0, c); summaryOffset++; index--; } if (index >= 0) { builder.insert(0, "..."); summaryOffset += 3; } index = match.getOffset() + match.getLength(); wordCount = 0; while (wordCount < 3 && index < annotation.length()) { char c = annotation.charAt(index); if (Character.isWhitespace(c)) { wordCount++; if (wordCount > 3) { break; } } builder.append(c); index++; } if (index < annotation.length()) { builder.append("..."); } cell.setText(builder.toString()); Color fg = cell.getForeground(); Color bg = cell.getFont().getDevice().getSystemColor(SWT.COLOR_YELLOW); StyleRange range = new StyleRange(summaryOffset, match.getLength(), fg, bg); cell.setStyleRanges(new StyleRange[] { range }); } } } finally { pd.disconnect(); } }
From source file:ca.uvic.chisel.javasketch.ui.internal.views.TraceNavigatorLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); IProgramSketch sketch = null;// w w w. j a v a 2 s . c o m Image image = null; if (element instanceof IProgramSketch) { sketch = (IProgramSketch) element; } else if (element instanceof IThread) { IThread thread = (IThread) element; sketch = SketchPlugin.getDefault().getSketch(thread); } switch (cell.getColumnIndex()) { case TraceNavigator.ACTIVE_TRACE_COLUMN: if (sketch != null) { if (sketch.equals(SketchPlugin.getDefault().getActiveSketch())) { cell.setImage(SketchPlugin.getDefault().getImageRegistry() .get(ISketchImageConstants.ICON_TRACE_ACTIVE)); } else { cell.setImage(SketchPlugin.getDefault().getImageRegistry() .get(ISketchImageConstants.ICON_TRACE_INACTIVE)); } } break; case TraceNavigator.LABEL_COLUMN: cell.setText(getText(element)); cell.setImage(getImage(element)); break; case TraceNavigator.VISIBLE_TRACE_COLUMN: if (sketch != null) { IDegreeOfInterest doi = SketchPlugin.getDefault().getDOI(); IProgramSketch activeSketch = SketchPlugin.getDefault().getActiveSketch(); if (activeSketch != null) { if (activeSketch.getTracedLaunchConfiguration().equals(sketch.getTracedLaunchConfiguration())) { TraceNavigator navigator = (TraceNavigator) PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().findView(TraceNavigator.VIEW_ID); if (navigator != null) { if (doi.isSketchHidden(sketch)) { image = SketchPlugin.getDefault().getImageRegistry() .get(ISketchImageConstants.ICON_ELEMENT_FILTERED); } else { image = SketchPlugin.getDefault().getImageRegistry() .get(ISketchImageConstants.ICON_ELEMENT_VISIBLE); } } } } } cell.setImage(image); break; } }