Java Code Examples for org.eclipse.jface.viewers.StyledString#append()
The following examples show how to use
org.eclipse.jface.viewers.StyledString#append() .
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: 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 2
Source File: XtypeProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void appendParameters(StyledString result, JvmExecutable executable, int insignificantParameters, LightweightTypeReferenceFactory ownedConverter) { List<JvmFormalParameter> declaredParameters = executable.getParameters(); List<JvmFormalParameter> relevantParameters = declaredParameters.subList(Math.min(insignificantParameters, declaredParameters.size()), declaredParameters.size()); for(int i = 0; i < relevantParameters.size(); i++) { JvmFormalParameter parameter = relevantParameters.get(i); if (i != 0) result.append(", "); if (i == relevantParameters.size() - 1 && executable.isVarArgs() && parameter.getParameterType() instanceof JvmGenericArrayTypeReference) { JvmGenericArrayTypeReference parameterType = (JvmGenericArrayTypeReference) parameter.getParameterType(); result.append(ownedConverter.toLightweightReference(parameterType.getComponentType()).getHumanReadableName()); result.append("..."); } else { if (parameter.getParameterType()!= null) { String simpleName = ownedConverter.toLightweightReference(parameter.getParameterType()).getHumanReadableName(); if (simpleName != null) // is null if the file is not on the class path result.append(simpleName); } } result.append(' '); result.append(notNull(parameter.getName())); } }
Example 3
Source File: AppEngineLabelProvider.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@VisibleForTesting static StyledString getAppEngineProjectText(IProject project) { try { AppEngineProjectElement projectElement = AppEngineContentProvider.loadRepresentation(project); StyledString result = new StyledString(project.getName()); String qualifier = getVersionTuple(projectElement); if (qualifier.length() > 0) { result.append(" [", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ result.append(qualifier.toString(), StyledString.QUALIFIER_STYLER); result.append("]", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$ } return result; } catch (AppEngineException ex) { // ignore } return null; // carry onto the next label provider }
Example 4
Source File: PromptParameterDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
public StyledString getStyledText( Object element ) { String value = null; if ( element instanceof IAmbiguousParameterNode ) { value = ( (IAmbiguousParameterNode) element ).getOdaDataSetParameterHandle( ) .getName( ); } else if ( element instanceof IAmbiguousAttribute ) { value = ( (IAmbiguousAttribute) element ).getAttributeName( ); } if ( value == null ) value = ""; //$NON-NLS-1$ StyledString styledString = new StyledString( ); styledString.append( value ); return styledString; }
Example 5
Source File: AdditionalResourcesPropertySection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private StyledString getStyledLabel(AdditionalResource additionalResource) { StyledString styledString = new StyledString(additionalResource.getName()); if (!Strings.isNullOrEmpty(additionalResource.getDescription())) { styledString.append(" - ", descriptionStyler); styledString.append(additionalResource.getDescription(), descriptionStyler); } return styledString; }
Example 6
Source File: UiToIdeContentProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected StyledString getDisplayString(ContentAssistEntry entry) { StyledString result = new StyledString(entry.getLabel() != null ? entry.getLabel() : entry.getProposal()); if (!Strings.isNullOrEmpty(entry.getDescription())) { result.append(new StyledString(" \u2013 " + entry.getDescription(), StyledString.QUALIFIER_STYLER)); } return result; }
Example 7
Source File: XtextCallHierarchyLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected StyledString _getStyledText(XtextCallHierarchyNode hierarchyNode) { if (hierarchyNode.getElement() == null) { return hierarchyLabelProvider.getStyledText(hierarchyNode); } StyledString styledString = new StyledString("" + hierarchyNode.getElement().getQualifiedName()); if (hierarchyNode.getGrammarDescription() == null) { return styledString; } return styledString .append(new StyledString(" - " + hierarchyNode.getGrammarDescription().getQualifiedName(), StyledString.QUALIFIER_STYLER)); }
Example 8
Source File: DecoratedXdsElementLabelProvider.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public StyledString getStyledText(Object element) { StyledString styledString = new StyledString(); String text = decoratedLabelProvider.getText(element); styledString.append(text != null ? text : ""); //$NON-NLS-1$ if (element instanceof IXdsRecordVariant) { IXdsRecordVariant xdsRecordVariant = (IXdsRecordVariant) element; if (xdsRecordVariant.isElseVariant()) { appendStringDecoration(styledString, "", " ELSE"); //$NON-NLS-1$ //$NON-NLS-2$ } else { Collection<IXdsRecordVariantLabel> labels = xdsRecordVariant.getLabels(); String separator = " | "; //$NON-NLS-1$ String decoration = ""; //$NON-NLS-1$ for (IXdsRecordVariantLabel label : labels) { decoration += separator + label.getElementName(); separator = ", "; //$NON-NLS-1$ } appendStringDecoration(styledString, "", decoration); //$NON-NLS-1$ } } else if (element instanceof IXdsSetElement) { } else if (element instanceof IXdsElementWithSymbol) { IModulaSymbol symbol = ((IXdsElementWithSymbol)element).getSymbol(); if (element instanceof IXdsAliasQualifiedImportElement) symbol = ((IXdsAliasQualifiedImportElement)element).getAliasSymbol(); appendStringDecoration(styledString, "", ModulaSymbolDescriptions.getSymbolDescription(symbol)); } if (element instanceof IXdsProcedure) { IXdsProcedure xdsProcedure = (IXdsProcedure) element; if (xdsProcedure.isForwardDeclaration()) { appendStringDecoration(styledString, "", " FORWARD"); //$NON-NLS-1$ } } return styledString; }
Example 9
Source File: TypeScriptSearchLabelProvider.java From typescript.java with MIT License | 5 votes |
private StyledString getLineElementLabel(LineElement lineElement) { int lineNumber= lineElement.getLine(); String lineNumberString= Messages.format(SearchMessages.FileLabelProvider_line_number, new Integer(lineNumber)); StyledString str= new StyledString(lineNumberString, StyledString.QUALIFIER_STYLER); Match[] matches= lineElement.getMatches(fPage.getInput()); Arrays.sort(matches, fMatchComparator); String content= lineElement.getContents(); int pos= evaluateLineStart(matches, content, lineElement.getOffset()); int length= content.length(); int charsToCut= getCharsToCut(length, matches); // number of characters to leave away if the line is too long for (int i= 0; i < matches.length; i++) { TypeScriptMatch match= (TypeScriptMatch) matches[i]; int start= Math.max(match.getOriginalOffset() - lineElement.getOffset(), 0); // append gap between last match and the new one if (pos < start) { if (charsToCut > 0) { charsToCut= appendShortenedGap(content, pos, start, charsToCut, i == 0, str); } else { str.append(content.substring(pos, start)); } } // append match int end= Math.min(match.getOriginalOffset() + match.getOriginalLength() - lineElement.getOffset(), lineElement.getLength()); str.append(content.substring(start, end), DecoratingTypeScriptSearchLabelProvider.HIGHLIGHT_STYLE); pos= end; } // append rest of the line if (charsToCut > 0) { appendShortenedGap(content, pos, length, charsToCut, false, str); } else { str.append(content.substring(pos)); } return str; }
Example 10
Source File: DataStyledTreeLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void update(ViewerCell cell) { if (cell.getElement() instanceof Data) { Data d = (Data) cell.getElement(); StyledString styledString = new StyledString(); String decoration = " -- " + getTypeLabel(d); if (d.isTransient()) { styledString.append(d.getName(), italicGrey); } else { styledString.append(d.getName(), null); } styledString.append(decoration, StyledString.DECORATIONS_STYLER); if(d.getDefaultValue() != null && d.getDefaultValue().getName() != null && !d.getDefaultValue().getName().isEmpty()){ String content = d.getDefaultValue().getName(); content = Messages.defaultValue+": " + content.replaceAll("\n", " ") ; if(content.length() > 150) { content = content.substring(0, 150) + "..."; } styledString.append(" -- ",StyledString.DECORATIONS_STYLER) ; styledString.append(content, StyledString.QUALIFIER_STYLER); } cell.setText(styledString.getString()); cell.setImage(getImage(d)) ; cell.setStyleRanges(styledString.getStyleRanges()); } }
Example 11
Source File: RepositoryLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void update(final ViewerCell cell) { final IRepository element = (IRepository) cell.getElement(); final StyledString styledString = new StyledString(); styledString.append(getText(element), null); if (RepositoryManager.getInstance().getCurrentRepository().equals(element)) { styledString.append(" -- ", StyledString.QUALIFIER_STYLER); styledString.append(Messages.current, StyledString.DECORATIONS_STYLER); } cell.setForeground(getForeground(element)); cell.setText(styledString.getString()); cell.setImage(getImage(element)); cell.setStyleRanges(styledString.getStyleRanges()); }
Example 12
Source File: ZeroMatchedStatementsPreconditionViolation.java From JDeodorant with MIT License | 5 votes |
@Override public StyledString getStyledViolation() { StyledString styledString = new StyledString(); NormalStyler normalStyler = new NormalStyler(); styledString.append("The refactoring of the clones is infeasible, because the number of macthed statements is equal to zero", normalStyler); return styledString; }
Example 13
Source File: CompletionProposalLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
StyledString createOverrideMethodProposalLabel(CompletionProposal methodProposal) { StyledString nameBuffer= new StyledString(); // method name nameBuffer.append(methodProposal.getName()); // parameters nameBuffer.append('('); appendUnboundedParameterList(nameBuffer, methodProposal); nameBuffer.append(')'); nameBuffer.append(RETURN_TYPE_SEPARATOR); // return type // TODO remove SignatureUtil.fix83600 call when bugs are fixed char[] returnType= createTypeDisplayName(SignatureUtil.getUpperBound(Signature.getReturnType(SignatureUtil.fix83600(methodProposal.getSignature())))); nameBuffer.append(returnType); // declaring type nameBuffer.append(QUALIFIER_SEPARATOR, StyledString.QUALIFIER_STYLER); String declaringType= extractDeclaringTypeFQN(methodProposal); declaringType= Signature.getSimpleName(declaringType); nameBuffer.append(Messages.format(JavaTextMessages.ResultCollector_overridingmethod, BasicElementLabels.getJavaElementName(declaringType)), StyledString.QUALIFIER_STYLER); return nameBuffer; }
Example 14
Source File: AbapGitStagingLabelProvider.java From ADT_Frontend with MIT License | 5 votes |
private void updateFileCell(ViewerCell cell, IAbapGitFile file) { StyledString text = new StyledString(); if (file.eContainer().eContainer() instanceof IIgnoredObjects) { //Ignored files will be shown as greyed out text.append(file.getName().toLowerCase(Locale.ENGLISH), this.grayStyler); } else { text.append(file.getName().toLowerCase(Locale.ENGLISH)); } text.append(DASH, this.grayStyler).append(file.getPath(), this.grayStyler); cell.setText(text.getString()); cell.setStyleRanges(text.getStyleRanges()); cell.setImage(getFileImage(file)); }
Example 15
Source File: XtypeProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected StyledString getStyledDisplayString(JvmFeature feature, boolean withParents, int insignificantParameters, String qualifiedNameAsString, String shortName, LightweightTypeReferenceFactory converter) { StyledString result = new StyledString(shortName); if (feature instanceof JvmOperation) { JvmOperation operation = (JvmOperation) feature; if (withParents) { result.append('('); appendParameters(result, (JvmExecutable)feature, insignificantParameters, converter); result.append(')'); } JvmTypeReference returnType = operation.getReturnType(); if (returnType != null && returnType.getSimpleName() != null) { result.append(" : "); result.append(converter.toLightweightReference(returnType).getHumanReadableName()); } result.append(" - ", StyledString.QUALIFIER_STYLER); result.append(converter.toPlainTypeReference(feature.getDeclaringType()).getHumanReadableName(), StyledString.QUALIFIER_STYLER); if (!withParents) { result.append(".", StyledString.QUALIFIER_STYLER); result.append(feature.getSimpleName(), StyledString.QUALIFIER_STYLER); result.append("()", StyledString.QUALIFIER_STYLER); } } else if (feature instanceof JvmField) { JvmField field = (JvmField) feature; result.append(" : "); if (field.getType() != null) { String fieldType = converter.toLightweightReference(field.getType()).getHumanReadableName(); if (fieldType != null) result.append(fieldType); } result.append(" - ", StyledString.QUALIFIER_STYLER); result.append(converter.toPlainTypeReference(feature.getDeclaringType()).getHumanReadableName(), StyledString.QUALIFIER_STYLER); } else if (feature instanceof JvmConstructor) { if (withParents) { result.append('('); appendParameters(result, (JvmExecutable)feature, insignificantParameters, converter); result.append(')'); } } return result; }
Example 16
Source File: ActiveCodeContentAssistProcessor.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
private void addProposal(List<ICompletionProposal> completionProposals, Set<ICompletionProposal> proposalsSet, IModulaSymbol s) { String proposalText = s.getName(); StyledString sstring = new StyledString(proposalText); sstring.append(ModulaSymbolDescriptions.getSymbolDescription(s), StyledString.DECORATIONS_STYLER); String replacementString; if (s instanceof IProcedureSymbol && context.getRegionType() != RegionType.IMPORT_STATEMENT) { replacementString = createReplacementStringFromProcedureSymbol((IProcedureSymbol) s); } else { StringBuilder sb = new StringBuilder(); if (context.getRegionType() == RegionType.IMPORT_STATEMENT) { if (ContentAssistUtils.tokenType(context.getPreviousNonSpaceToken()) == ModulaTokenTypes.IDENTIFIER) { sb.append(','); } } sb.append(s.getName()); if (context.getRegionType() == RegionType.IMPORT_STATEMENT) { if (ContentAssistUtils.tokenType(context.getNextNonSpaceToken()) == ModulaTokenTypes.IDENTIFIER) { sb.append(','); } } replacementString = sb.toString(); } int cursorPosition = Math.max(context.getReplacementLength(), replacementString.length()); //XXX ?? ICompletionProposal proposal = new ModulaContextualCompletionProposal( replacementString, context.getReplacementOffset(), context.getReplacementLength(), cursorPosition, ModulaSymbolImages.getImage(s), sstring, null, ""); //$NON-NLS-1$ if (!proposalsSet.contains(proposal)) { proposalsSet.add(proposal); completionProposals.add(proposal); } }
Example 17
Source File: ExpressionLabelProvider.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public StyledString getStyledString(org.bonitasoft.studio.model.expression.Expression expression) { final StyledString styledString = new StyledString(expression.getName()); styledString.append(" -- "); styledString.append(new StyledString(expression.getReturnType(), StyledString.DECORATIONS_STYLER)); return styledString; }
Example 18
Source File: LangCompletionProposal.java From goclipse with Eclipse Public License 1.0 | 4 votes |
protected void getStyledDisplayString_TypeLabel(StyledString styledString) { if(proposal.getTypeLabel() != null) { styledString.append(new StyledString(" " + proposal.getTypeLabel(), StyledString.DECORATIONS_STYLER)); } }
Example 19
Source File: UserElement.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public StyledString getStyledText() { StyledString text = new StyledString(); /* * Blank space in the front for the highlighting color square, see * saros.ui.widgets.viewer.session.UserElementDecorator * * ColorSquare [HOST] Alice [following] */ text.append(" "); if (user.isHost()) { text.append(Messages.UserElement_host, StyledString.COUNTER_STYLER); } text.append(CoreUtils.determineUserDisplayName(user)); /* * Right level */ if (user.hasReadOnlyAccess()) { text.append(" "); text.append(Messages.UserElement_read_only, StyledString.COUNTER_STYLER); } /* * Follow Mode: Who am I following? If this equals the user element we * are looking at, append the follow information to the user. Don't * append this info for any other users, because they have a * FollowModeTreeElement for this. */ User followee = editorManager.getFollowedUser(); if (!user.equals(followee)) return text; final String followModeState = collector.isActiveEditorShared(user) ? Messages.UserElement_following : Messages.UserElement_following_paused; text.append(" "); text.append(followModeState, SWTBoldStyler.STYLER); return text; }
Example 20
Source File: SARLLabelProvider.java From sarl with Apache License 2.0 | 2 votes |
/** Create a string representation of a signature without the return type. * * @param simpleName the action name. * @param element the executable element. * @return the signature. */ protected StyledString signatureWithoutReturnType(StyledString simpleName, JvmExecutable element) { return simpleName.append(this.uiStrings.styledParameters(element)); }