List of usage examples for org.eclipse.jface.viewers StyledString getStyleRanges
public StyleRange[] getStyleRanges()
From source file:at.bestsolution.eclipse.properties.PropertyContentOutlinePage.java
License:Open Source License
@Override public void createControl(Composite parent) { super.createControl(parent); TreeViewer viewer = getTreeViewer(); viewer.setLabelProvider(new StyledCellLabelProvider() { @Override//from w ww.j av a 2s. co m public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof PropertyGroup) { cell.setText(((PropertyGroup) element).name); cell.setImage(Activator.getDefault().getImageRegistry().get(Activator.GROUP_ICON)); cell.setStyleRanges(null); } else if (element instanceof Property) { cell.setImage(Activator.getDefault().getImageRegistry().get(Activator.KEY_ICON)); StyledString s = new StyledString(((Property) element).pair.key); String text = ((Property) element).pair.value; if (text.length() > 20) { text = text.substring(0, 20) + "..."; } s.append(" : " + text, StyledString.DECORATIONS_STYLER); cell.setStyleRanges(s.getStyleRanges()); cell.setText(s.getString()); } super.update(cell); } }); viewer.setContentProvider(new HierarchicalContentProvider()); if (isSorted()) { setSorted(true); } createHierarchicalStructure(); if (isHierarchical()) { viewer.setInput(hierarchicalStructure); } else { viewer.setInput(flatStructure); } }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.outline.PropertyContentOutlinePage.java
License:Open Source License
@Override public void createControl(Composite parent) { super.createControl(parent); TreeViewer viewer = getTreeViewer(); viewer.setLabelProvider(new StyledCellLabelProvider() { @Override/*from w ww . ja va 2 s . c o m*/ public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof PropertyGroup) { cell.setText(((PropertyGroup) element).name); cell.setImage(JavaFXUIPlugin.getDefault().getImageRegistry().get(JavaFXUIPlugin.GROUP_ICON)); cell.setStyleRanges(null); } else if (element instanceof Property) { cell.setImage(JavaFXUIPlugin.getDefault().getImageRegistry().get(JavaFXUIPlugin.KEY_ICON)); StyledString s = new StyledString(((Property) element).pair.key); String text = ((Property) element).pair.value; if (text.length() > 20) { text = text.substring(0, 20) + "..."; } s.append(" : " + text, StyledString.DECORATIONS_STYLER); cell.setStyleRanges(s.getStyleRanges()); cell.setText(s.getString()); } super.update(cell); } }); viewer.setContentProvider(new HierarchicalContentProvider()); if (isSorted()) { setSorted(true); } createHierarchicalStructure(); if (isHierarchical()) { viewer.setInput(hierarchicalStructure); } else { viewer.setInput(flatStructure); } }
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:/*from ww w . 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: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 w ww . j a v a 2 s .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);/*from w w w. j av a 2 s.com*/ 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"); }/*w w w. j ava 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:com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposalPopup.java
License:Open Source License
private void handleSetData(Event event) { TableItem item = (TableItem) event.item; int index = fProposalTable.indexOf(item); if (0 <= index && index < fFilteredProposals.length) { ICompletionProposal current = fFilteredProposals[index]; String displayString;// www. j av a 2s .c o m StyleRange[] styleRanges = null; if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension6) { StyledString styledString = ((ICompletionProposalExtension6) current).getStyledDisplayString(); displayString = styledString.getString(); styleRanges = styledString.getStyleRanges(); } else displayString = current.getDisplayString(); item.setText(displayString); if (fIsColoredLabelsSupportEnabled) TableOwnerDrawSupport.storeStyleRanges(item, 0, styleRanges); item.setImage(current.getImage()); item.setData(current); } else { // this should not happen, but does on win32 } }
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;// w w w . j a v a 2s . c o 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 ww w . j ava2s. c o 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); }