List of usage examples for org.eclipse.jface.viewers ViewerCell getElement
public Object getElement()
From source file:bndtools.editor.BndEditorContentOutlineLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof String) { // Top-level placeholder if (BndEditor.BUILD_PAGE.equals(element)) { cell.setText("Build"); } else if (BndEditor.PROJECT_RUN_PAGE.equals(element)) { cell.setText("Run"); } else if (BndEditorContentOutlineProvider.EXPORTS.equals(element)) { cell.setText("Exports"); } else if (BndEditorContentOutlineProvider.PRIVATE_PKGS.equals(element)) { cell.setText("Private Packages"); } else if (BndEditorContentOutlineProvider.IMPORT_PATTERNS.equals(element)) { cell.setText("Import Patterns"); } else if (BndEditor.SOURCE_PAGE.equals(element)) { cell.setText("Source"); } else if (BndEditorContentOutlineProvider.PLUGINS.equals(element)) { cell.setText("Plugins"); }//w ww. j a v a2s . c o m cell.setImage(pageImg); } else if (element instanceof ExportedPackage) { cell.setText(((ExportedPackage) element).getName()); cell.setImage(packageImg); } else if (element instanceof ImportPattern) { cell.setText(((ImportPattern) element).getName()); cell.setImage(packageImg); } else if (element instanceof PrivatePkg) { cell.setText(((PrivatePkg) element).pkg); cell.setImage(packageImg); } else if (element instanceof PluginClause) { cell.setText(((PluginClause) element).header.getName()); cell.setImage(pluginImg); } }
From source file:bndtools.editor.common.PropertiesTableLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { ColumnViewer viewer = getViewer();/* w w w . j a v a 2s. com*/ @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;//from w ww . j a v a 2 s .c om 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(); cell.setImage(packageImg);/*w w w . j av a2 s . com*/ 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 a v a 2 s.c om*/ 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 a va 2 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());//from w ww .java 2 s .c om if (path.hasTrailingSeparator()) cell.setImage(folderImg); 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://from w w w . java 2s .c om 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/* w w w .j av a 2s . com*/ */ 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(); } }