Java Code Examples for org.eclipse.jface.viewers.StyledString#getString()

The following examples show how to use org.eclipse.jface.viewers.StyledString#getString() . 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: TypeScriptCompletionProposalWithExtension7.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
public StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider) {
	// Highlight matched prefix
	StyledString styledDisplayString = new StyledString();
	styledDisplayString.append(getStyledDisplayString());

	String pattern = getPatternToEmphasizeMatch(document, offset);
	if (pattern != null && pattern.length() > 0) {
		String displayString = styledDisplayString.getString();
		int[] bestSequence = getMatcher().bestSubsequence(displayString, pattern);
		int highlightAdjustment = 0;
		for (int index : bestSequence) {
			styledDisplayString.setStyle(index + highlightAdjustment, 1, boldStylerProvider.getBoldStyler());
		}
	}
	return styledDisplayString;
}
 
Example 2
Source File: Strings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds special marks so that that the given styled string is readable in a BiDi environment.
 * 
 * @param styledString the styled string
 * @return the processed styled string
 * @since 3.4
 */
public static StyledString markLTR(StyledString styledString) {
	
	/*
	 * NOTE: For performance reasons we do not call  markLTR(styledString, null)
	 */
	
	if (!USE_TEXT_PROCESSOR)
		return styledString;

	String inputString= styledString.getString();
	String string= TextProcessor.process(inputString);
	if (string != inputString)
		insertMarks(styledString, inputString, string);
	return styledString;
}
 
Example 3
Source File: DiffStyle.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
void applyTo(StyledString styled, String otherText, Site site, ActionType action) {
	String text = styled.getString();
	if (text.isEmpty())
		return;
	styled.setStyle(0, text.length(), defaultStyler);
	LinkedList<Diff> diffs = getDiffs(text, otherText, site, action);
	boolean showDelete = doShowDelete(site, action);
	boolean showInsert = doShowInsert(site, action);
	int index = 0;
	for (Diff diff : diffs) {
		if (showDelete && diff.operation == Operation.DELETE) {
			styled.setStyle(index, diff.text.length(), deleteStyler);
			index += diff.text.length();
		} else if (showInsert && diff.operation == Operation.INSERT) {
			styled.setStyle(index, diff.text.length(), insertStyler);
			index += diff.text.length();
		} else if (diff.operation == Operation.EQUAL) {
			index += diff.text.length();
		}
	}
}
 
Example 4
Source File: Strings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds special marks so that that the given styled Java element label is readable in a BiDi
 * environment.
 * 
 * @param styledString the styled string
 * @return the processed styled string
 * @since 3.6
 */
public static StyledString markJavaElementLabelLTR(StyledString styledString) {
	if (!USE_TEXT_PROCESSOR)
		return styledString;

	String inputString= styledString.getString();
	String string= TextProcessor.process(inputString, JAVA_ELEMENT_DELIMITERS);
	if (string != inputString)
		insertMarks(styledString, inputString, string);
	return styledString;
}
 
Example 5
Source File: Strings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds special marks so that that the given styled string is readable in a BiDi environment.
 * 
 * @param styledString the styled string
 * @param delimiters the additional delimiters
 * @return the processed styled string
 * @since 3.4
 */
public static StyledString markLTR(StyledString styledString, String delimiters) {
	if (!USE_TEXT_PROCESSOR)
		return styledString;

	String inputString= styledString.getString();
	String string= TextProcessor.process(inputString, delimiters);
	if (string != inputString)
		insertMarks(styledString, inputString, string);
	return styledString;
}
 
Example 6
Source File: TextSearchLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected final StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
	String name= coloredName.getString();
	String decorated= getLabelWithCounts(element, name);
	if (decorated.length() > name.length()) {
		StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.COUNTER_STYLER, coloredName);
	}
	return coloredName;
}
 
Example 7
Source File: SearchLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected final StyledString getColoredLabelWithCounts(Object element, StyledString coloredName) {
	String name= coloredName.getString();
	String decorated= getLabelWithCounts(element, name);
	if (decorated.length() > name.length()) {
		StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.COUNTER_STYLER, coloredName);
	}
	return coloredName;
}
 
Example 8
Source File: AbstractLangLabelProvider.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getText(Object element) {
	StyledString styledText = getStyledText(element);
	if(styledText != null) {
		return styledText.getString();
	}
	return null;
}
 
Example 9
Source File: AbstractLangLabelProvider.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getDescription(Object anElement) {
	
	StyledString styledText = getStyledText(anElement);
	if(styledText != null) {
		return styledText.getString();
	}
	return null;
}
 
Example 10
Source File: ApplicationFileStoreLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private String appendAppTokens(final ApplicationFileStore fileStore, final StyledString styledString)
        throws ReadFileStoreException {
    styledString.append("  ");
    List<ApplicationNode> applications = fileStore.getContent().getApplications();
    styledString.append(
            applications.stream()
                    .map(application -> "../apps/" + application.getToken())
                    .collect(Collectors.joining(", ")),
            StyledString.COUNTER_STYLER);
    return styledString.getString();
}
 
Example 11
Source File: LabelStyle.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
void applyTo(StyledString styled, JsonNode node) {
	String s = styled.getString();
	int colon = s.indexOf(':');
	apply(styled, propertyStyle, 0, colon + 1);
	if (node.readOnly)
		apply(styled, readOnlyStyle);
	if (node.hasEqualValues())
		return;
	if (colon != -1) {
		apply(styled, diffStyle, colon + 2, s.length() - colon - 2);
	} else {
		apply(styled, diffStyle);
	}
}
 
Example 12
Source File: LabelStyle.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void apply(StyledString styled, ColorStyler styler, int start, int length) {
	String s = styled.getString();
	if (start >= s.length())
		return;
	if (length < 1) {
		length = s.length();
	} else if (length > s.length() - start)
		length = s.length() - start;
	styled.setStyle(start, length, styler);
}