List of usage examples for org.eclipse.jface.viewers StyledString DECORATIONS_STYLER
Styler DECORATIONS_STYLER
To view the source code for org.eclipse.jface.viewers StyledString DECORATIONS_STYLER.
Click Source Link
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 ww w .j a va2 s . c o 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.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
@Override public void completeResourceValueProperty_Value(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (!model.eResource().getContents().isEmpty()) { Model m = (Model) model.eResource().getContents().get(0); if (m.getComponentDef() != null) { if (m.getComponentDef().getPreviewResourceBundle() != null) { File f = RelativeFileLocator.locateFile(model.eResource().getURI(), m.getComponentDef().getPreviewResourceBundle()); Properties p = null; if (f != null) { FileInputStream fi = null; try { fi = new FileInputStream(f); p = new Properties(); p.load(fi);/*from www . j av a 2 s .com*/ } catch (FileNotFoundException e) { LOGGER.warn("Unable to load resource bundle", e); } catch (IOException e) { LOGGER.warn("Unable to load resource bundle", e); } finally { if (fi != null) { try { fi.close(); } catch (IOException e) { LOGGER.error("Unable to close resource filehandle", e); } } } } if (p != null) { for (String k : p.stringPropertyNames()) { StyledString s = new StyledString(k); s.append(" - " + p.getProperty(k), StyledString.DECORATIONS_STYLER); acceptor.accept(createCompletionProposal("\"" + k + "\"", s, IconKeys.getIcon(IconKeys.EXTERNALIZED_STRING_KEY), context)); } } } } } }
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.contentassist.FXGraphProposalProvider.java
License:Open Source License
@Override public void completeBindValueProperty_ElementReference(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { TreeIterator<EObject> it = model.eResource().getAllContents(); while (it.hasNext()) { EObject o = it.next();/*from www . j av a2 s. c om*/ if (o instanceof Element) { Element e = (Element) o; if (e.getName() != null && e.getName().trim().length() > 0) { StyledString s = new StyledString(e.getName()); s.append(" - " + e.getType().getQualifiedName(), StyledString.DECORATIONS_STYLER); acceptor.accept(createCompletionProposal(e.getName(), s, IconKeys.getIcon(IconKeys.CLASS_KEY), context)); } } } }
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/* w w w. j ava 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;/*from w ww .jav a2 s .c o 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:com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode.java
License:Open Source License
/** * Computes a styled string describing the UI node suitable for tree views. * Similar to {@link #getShortDescription()} but styles the Strings. * * @return A styled string describing the UI node suitable for tree views. *//*from w w w .j a v a 2s. c o m*/ public StyledString getStyledDescription() { String uiName = mDescriptor.getUiName(); // Special case: for <view>, show the class attribute value instead. // This is done here rather than in the descriptor since this depends on // node instance data. if (SdkConstants.VIEW_TAG.equals(uiName) && mXmlNode instanceof Element) { Element element = (Element) mXmlNode; String cls = element.getAttribute(ATTR_CLASS); if (cls != null) { uiName = cls.substring(cls.lastIndexOf('.') + 1); } } StyledString styledString = new StyledString(); String attr = getDescAttribute(); if (attr != null) { // Don't append the two when it's a repeat, e.g. Button01 (Button), // only when the ui name is not part of the attribute if (attr.toLowerCase(Locale.US).indexOf(uiName.toLowerCase(Locale.US)) == -1) { styledString.append(attr); styledString.append(String.format(" (%1$s)", uiName), StyledString.DECORATIONS_STYLER); } else { styledString.append(attr); } } if (styledString.length() == 0) { styledString.append(uiName); } return styledString; }
From source file:com.android.ide.eclipse.auidt.internal.editors.uimodel.UiElementNode.java
License:Open Source License
/** * Computes a styled string describing the UI node suitable for tree views. * Similar to {@link #getShortDescription()} but styles the Strings. * * @return A styled string describing the UI node suitable for tree views. *//*from w w w .ja v a 2 s. c o m*/ public StyledString getStyledDescription() { String uiName = mDescriptor.getUiName(); // Special case: for <view>, show the class attribute value instead. // This is done here rather than in the descriptor since this depends on // node instance data. if (LayoutDescriptors.VIEW_VIEWTAG.equals(uiName) && mXmlNode instanceof Element) { Element element = (Element) mXmlNode; String cls = element.getAttribute(ATTR_CLASS); if (cls != null) { uiName = cls.substring(cls.lastIndexOf('.') + 1); } } StyledString styledString = new StyledString(); String attr = getDescAttribute(); if (attr != null) { // Don't append the two when it's a repeat, e.g. Button01 (Button), // only when the ui name is not part of the attribute if (attr.toLowerCase(Locale.US).indexOf(uiName.toLowerCase(Locale.US)) == -1) { styledString.append(attr); styledString.append(String.format(" (%1$s)", uiName), StyledString.DECORATIONS_STYLER); } else { styledString.append(attr); } } if (styledString.length() == 0) { styledString.append(uiName); } return styledString; }
From source file:com.appnativa.studio.editors.SDFCompletionItem.java
License:Open Source License
@Override public StyledString getStyledDisplayString() { if (styledString == null) { styledString = new StyledString(); styledString.append(text, StyledString.QUALIFIER_STYLER); if (right != null) { styledString.append(" - "); styledString.append(text, StyledString.DECORATIONS_STYLER); }//from w w w . j av a 2s.c o m } return styledString; }
From source file:com.contrastsecurity.ide.eclipse.ui.internal.model.VulnerabilityLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof Trace) { int index = cell.getColumnIndex(); switch (index) { case 0:/*from w ww . j ava 2 s. com*/ case 3: Image image = getImage(element, index); cell.setImage(image); break; case 1: String title = getText(element, index); if (title.startsWith(UNLICENSED_PREFIX)) { StyledString text = new StyledString(); StyleRange range = new StyleRange(0, UNLICENSED_PREFIX.length(), Constants.UNLICENSED_COLOR, null); text.append(title, StyledString.DECORATIONS_STYLER); StyleRange[] ranges = { range }; cell.setStyleRanges(ranges); } cell.setText(title); break; case 2: String appName = ((Trace) element).getApplication().getName(); cell.setText(appName); break; default: break; } if (index == 0) { } } super.update(cell); }
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;//ww w .j av a 2s . c om 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)); } }