org.eclipse.jface.viewers.StyledString.Styler Java Examples
The following examples show how to use
org.eclipse.jface.viewers.StyledString.Styler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: N4JSProjectExplorerHelper.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * @return a styled string for a given external project. Respects name, type, version, and information about * shadowing and whether it is available in the xtext index */ public StyledString getStyledTextForExternalProject(final IN4JSProject project, N4JSProjectName overrideProjectName) { N4JSProjectName name = (overrideProjectName == null) ? project.getProjectName() : overrideProjectName; ProjectType type = project.getProjectType(); // for better visual representation MyProject @1.2.3 -> MyProject v1.2.3 String version = SemverSerializer.serialize(project.getVersion()).replaceFirst("@", "v"); String typeLabel = getProjectTypeLabel(type); boolean inIndex = project.isExternal() && indexSynchronizer.isInIndex((FileURI) project.getProjectDescriptionLocation()); String rootLocationName = getRootLocationName(project); Styler stylerName = inIndex ? null : StyledString.QUALIFIER_STYLER; Styler stylerType = inIndex ? StyledString.DECORATIONS_STYLER : StyledString.QUALIFIER_STYLER; StyledString string = new StyledString(name + " " + version, stylerName); string.append(typeLabel, stylerType); if (rootLocationName != null) { string.append(rootLocationName, StyledString.COUNTER_STYLER); } return string; }
Example #2
Source File: HierarchyLabelProvider.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public StyledString getStyledText(Object element) { if (element instanceof DataAndImageTreeNode) { @SuppressWarnings("rawtypes") DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element; Object data = treeNode.data; if (data instanceof HierarchyNodeModel) { HierarchyNodeModel model = (HierarchyNodeModel) data; String spaces = " "; StyledString styledString = new StyledString(model.name + spaces); if (model.moduleName != null && model.moduleName.trim().length() > 0) { Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, null); styledString.append("(" + model.moduleName + ")", styler); } return styledString; } return new StyledString(data.toString()); } return new StyledString(element == null ? "" : element.toString()); }
Example #3
Source File: WorkbenchLabelProvider.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * The default implementation of this returns the styled text label for the given element. * @param element * the element to evaluate the styled string for * @return the styled string. * @since 3.7 */ public StyledString getStyledText(Object element) { IWorkbenchAdapter3 adapter = getAdapter3(element); if (adapter == null) { // If adapter class doesn't implement IWorkbenchAdapter3 than use // StyledString with text of element. Since the output of getText is // already decorated, so we don't need to call decorateText again // here. return new StyledString(getText(element)); } StyledString styledString = adapter.getStyledText(element); // Now, re-use any existing decorateText implementation, to decorate // this styledString. String decorated = decorateText(styledString.getString(), element); Styler styler = getDecorationStyle(element); return StyledCellLabelProvider.styleDecoratedString(decorated, styler, styledString); }
Example #4
Source File: WorkbenchLabelProvider.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * The default implementation of this returns the styled text label for the given element. * @param element * the element to evaluate the styled string for * @return the styled string. * @since 3.7 */ public StyledString getStyledText(Object element) { IWorkbenchAdapter3 adapter = getAdapter3(element); if (adapter == null) { // If adapter class doesn't implement IWorkbenchAdapter3 than use // StyledString with text of element. Since the output of getText is // already decorated, so we don't need to call decorateText again // here. return new StyledString(getText(element)); } StyledString styledString = adapter.getStyledText(element); // Now, re-use any existing decorateText implementation, to decorate // this styledString. String decorated = decorateText(styledString.getString(), element); Styler styler = getDecorationStyle(element); return StyledCellLabelProvider.styleDecoratedString(decorated, styler, styledString); }
Example #5
Source File: SelectModulaSourceFileDialog.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private void markMatchingRegions(StyledString string, ArrayList<Integer> intervals, Styler styler) { if (intervals != null) { int offset= -1; int length= 0; for (int i= 0; i + 1 < intervals.size(); i= i + 2) { int beg = intervals.get(i); int len = intervals.get(i+1) - beg; if (offset == -1) { offset = beg; } // Concatenate adjacent regions if (i + 2 < intervals.size() && beg+len == intervals.get(i + 2)) { length= length + len; } else { string.setStyle(offset, length + len, styler); offset= -1; length= 0; } } } }
Example #6
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) { if (matchingRegions != null) { int offset= -1; int length= 0; for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) { if (offset == -1) offset= index + matchingRegions[i]; // Concatenate adjacent regions if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) { length= length + matchingRegions[i + 1]; } else { string.setStyle(offset, length + matchingRegions[i + 1], styler); offset= -1; length= 0; } } } }
Example #7
Source File: CallHierarchyLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public StyledString getStyledText(Object element) { if (isNormalMethodWrapper(element)) { MethodWrapper wrapper= (MethodWrapper)element; String decorated= getElementLabel(wrapper); StyledString styledLabel= super.getStyledText(wrapper.getMember()); StyledString styledDecorated= StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.COUNTER_STYLER, styledLabel); if (isSpecialConstructorNode(wrapper)) { decorated= Messages.format(CallHierarchyMessages.CallHierarchyLabelProvider_constructor_label, decorated); styledDecorated= StyledCellLabelProvider.styleDecoratedString(decorated, ColoringLabelProvider.INHERITED_STYLER, styledDecorated); } return styledDecorated; } String specialLabel= getSpecialLabel(element); Styler styler= element instanceof RealCallers ? ColoringLabelProvider.INHERITED_STYLER : null; return new StyledString(specialLabel, styler); }
Example #8
Source File: N4JSProjectExplorerLabelProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public StyledString getStyledText(final Object element) { if (element instanceof WorkingSet) { return WorkingSetLabelProvider.INSTANCE.getStyledText(element); } if (element instanceof IFolder) { IFolder folder = (IFolder) element; N4JSExternalProject npmProject = helper.getNodeModulesNpmProjectOrNull(folder); if (npmProject != null) { IN4JSProject iNpmProject = npmProject.getIProject(); return helper.getStyledTextForExternalProject(iNpmProject, new N4JSProjectName(folder.getName())); } else if (Files.isSymbolicLink(folder.getLocation().toFile().toPath())) { // might be a project from workspace N4JSProjectName n4jsProjectName = new PlatformResourceURI(folder).getProjectName(); String eclipseProjectName = n4jsProjectName.toEclipseProjectName().getRawName(); IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(eclipseProjectName); if (iProject != null && iProject.exists()) { Styler stylerName = StyledString.QUALIFIER_STYLER; if (iProject.isAccessible()) { IN4JSEclipseProject n4jsProject = n4jsCore.create(iProject).orNull(); if (n4jsProject.isExternal()) { stylerName = null; } } StyledString string = new StyledString(folder.getName(), stylerName); return string; } } return new StyledString(folder.getName()); } return workbenchLabelProvider.getStyledText(element); }
Example #9
Source File: DataStyledTreeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void initStyle() { imageProvider = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)) ; italicGrey = new StyledString.Styler() { @Override public void applyStyles(TextStyle textStyle) { textStyle.font = BonitaStudioFontRegistry.getTransientDataFont(); textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR); } }; }
Example #10
Source File: DatabaseDriversLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public DatabaseDriversLabelProvider(){ super(); boldgreen = new StyledString.Styler(){ @Override public void applyStyles(TextStyle textStyle) { textStyle.font = BonitaStudioFontRegistry.getActiveFont(); textStyle.foreground = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN); } }; }
Example #11
Source File: StylerBuilder.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public Styler create() { return new Styler() { @Override public void applyStyles(TextStyle textStyle) { color.ifPresent(c -> textStyle.foreground = c); font.ifPresent(f -> textStyle.font = f); } }; }
Example #12
Source File: SARLUIStrings.java From sarl with Apache License 2.0 | 5 votes |
/** Format the parameters. * * @param elements the list of the formal parameters. * @param isVarArgs indicates if the function has var args. * @param includeName indicates if the names are included in the replied valued. * @param keywords the keyword provider. * @param annotationFinder the finder of attached annotations. * @param utils the utility. * @return the string representation of the parameters. * @since 0.6 */ public static StyledString getParameterStyledString(Iterable<? extends JvmFormalParameter> elements, boolean isVarArgs, boolean includeName, SARLGrammarKeywordAccess keywords, AnnotationLookup annotationFinder, UIStrings utils) { final StyledString result = new StyledString(); boolean needsSeparator = false; final Iterator<? extends JvmFormalParameter> iterator = elements.iterator(); while (iterator.hasNext()) { final JvmFormalParameter parameter = iterator.next(); if (needsSeparator) { result.append(keywords.getCommaKeyword()).append(" "); //$NON-NLS-1$ } needsSeparator = true; final boolean isDefaultValued = annotationFinder.findAnnotation(parameter, DefaultValue.class) != null; final Styler styler; if (isDefaultValued) { styler = OPTIONAL_ELEMENT_STYLER; result.append(keywords.getLeftSquareBracketKeyword(), styler); } else { styler = null; } if (includeName) { result.append(parameter.getName(), styler).append(" ", styler); //$NON-NLS-1$ result.append(keywords.getColonKeyword(), styler).append(" ", styler); //$NON-NLS-1$ } JvmTypeReference typeRef = parameter.getParameterType(); if (isVarArgs && !iterator.hasNext() && typeRef instanceof JvmGenericArrayTypeReference) { typeRef = ((JvmGenericArrayTypeReference) typeRef).getComponentType(); result.append(utils.referenceToString(typeRef, NULL_TYPE), styler); result.append(keywords.getWildcardAsteriskKeyword(), styler); } else { result.append(utils.referenceToString(typeRef, NULL_TYPE), styler); } if (isDefaultValued) { result.append(keywords.getRightSquareBracketKeyword(), styler); } } return result; }
Example #13
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Styler createBoldQualifierStyler() { return new Styler() { @Override public void applyStyles(TextStyle textStyle) { StyledString.QUALIFIER_STYLER.applyStyles(textStyle); textStyle.font= getBoldFont(); } }; }
Example #14
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Styler createBoldStyler() { return new Styler() { @Override public void applyStyles(TextStyle textStyle) { textStyle.font= getBoldFont(); } }; }
Example #15
Source File: SnippetsCompletionProcessor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private Styler getStyler() { if (textFontStyler == null) { textFontStyler = new TextFontStyler(); } return textFontStyler; }
Example #16
Source File: BlockControlImage.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public BlockControlImage ( final ControlImage controlImage, final int style, final RegistrationManager registrationManager ) { super ( controlImage.getClientSpace (), style ); this.controlImage = controlImage; this.registrationManager = registrationManager; setLayout ( new FillLayout () ); this.icon = new Label ( this, SWT.NONE ); this.icon.setImage ( getEmptyImage () ); this.icon.addMouseListener ( new MouseAdapter () { @Override public void mouseUp ( final MouseEvent e ) { toggleBlock (); } } ); this.registrationManager.addListener ( this ); final LocalResourceManager resources = new LocalResourceManager ( JFaceResources.getResources (), this.icon ); this.boldFont = resources.createFont ( JFaceResources.getDefaultFontDescriptor ().withStyle ( SWT.BOLD ) ); this.boldStyler = new Styler () { @Override public void applyStyles ( final TextStyle textStyle ) { textStyle.font = BlockControlImage.this.boldFont; } }; }
Example #17
Source File: XtextLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
StyledString text(ParserRule parserRule) { if (GrammarUtil.isDatatypeRule(parserRule)) { Styler xtextStyleAdapterStyler = stylerFactory.createXtextStyleAdapterStyler(semanticHighlightingConfiguration .dataTypeRule()); return new StyledString(parserRule.getName(), xtextStyleAdapterStyler); } return convertToStyledString(parserRule.getName()); }
Example #18
Source File: TmfOnDemandAnalysisElement.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public @Nullable Styler getStyler() { if (!fCanRun) { return STRIKED_OUT_STYLER; } return null; }
Example #19
Source File: TmfAnalysisElement.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public Styler getStyler() { if (!canExecute()) { return ANALYSIS_CANT_EXECUTE_STYLER; } return null; }
Example #20
Source File: SelectModulaSourceFileDialog.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public StyledDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) { super(provider, decorator); boldStyler = new Styler() { @Override public void applyStyles(TextStyle textStyle) { textStyle.font= getBoldFont(); } }; }
Example #21
Source File: ModulaSearchLabelProvider.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public M2LabelProvider(ModulaSearchResultPage resultPage, ResourceRegistry resourceRegistry) { this.resultPage = resultPage; this.resourceRegistry = resourceRegistry; this.dlgFont = resultPage.getControl().getFont(); fLabelProvider= new WorkbenchLabelProvider(); positionStyler = new Styler() { @Override public void applyStyles(TextStyle textStyle) { textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR); textStyle.font= getItalicFont(dlgFont); } }; }
Example #22
Source File: ImportModelStyler.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public Styler createNotImportedStyler() { return new NotImportedStyler(); }
Example #23
Source File: OutlineStyledLabelProvider.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 4 votes |
public Styler getTagStyler() { return TAG_STYLER; }
Example #24
Source File: ImportModelStyler.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public Styler createSameContentStyler() { return new SameContentStyler(); }
Example #25
Source File: StylerFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @return {@link DefaultFontStyler} */ public Styler createStyler(String foregroundColorName, String backgroundColorName) { return new DefaultFontStyler(null, foregroundColorName, backgroundColorName); }
Example #26
Source File: StylerHelpers.java From goclipse with Eclipse Public License 1.0 | 4 votes |
public BoldStyler(Styler parentStyler) { super(parentStyler); }
Example #27
Source File: StylerHelpers.java From goclipse with Eclipse Public License 1.0 | 4 votes |
public ItalicStyler(Styler parentStyler) { super(parentStyler); }
Example #28
Source File: StylerHelpers.java From goclipse with Eclipse Public License 1.0 | 4 votes |
public FontStyler(Styler parentStyler) { this.parentStyler = parentStyler; }
Example #29
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void setStyle(int offset, int length, Styler styler) { fStyledString.setStyle(offset, length, styler); }
Example #30
Source File: JavaElementLabelComposer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void setStyle(int offset, int length, Styler styler) { // no style }