use of org.eclipse.swt.custom.StyleRange in project dbeaver by serge-rider.
the class HexEditControl method mergeRanges.
/**
* Merge ranges of changes in file with ranges of highlighted elements.
* Finds lowest range border, finds next lowest range border. That's the first result. Keeps going
* until last range border.
*
* @return list of StyleRanges, each with a style of type 'changed', 'highlighted', or both.
*/
List<StyleRange> mergeRanges(List<Long> changeRanges, List<Integer> highlightRanges) {
if (!mergerInit(changeRanges, highlightRanges)) {
return null;
}
List<StyleRange> result = new ArrayList<>();
mergerNext();
int start = mergeRangesPosition;
boolean blue = mergeRangesIsBlue;
boolean highlight = mergeRangesIsHighlight;
while (mergerNext()) {
if (blue || highlight) {
result.add(new StyleRange(start, mergeRangesPosition - start, blue ? COLOR_BLUE : null, highlight ? colorHighlight : null));
}
start = mergeRangesPosition;
blue = mergeRangesIsBlue;
highlight = mergeRangesIsHighlight;
}
return result;
}
use of org.eclipse.swt.custom.StyleRange in project cubrid-manager by CUBRID.
the class QueryExecuter method updateStyledLogTextForPlan.
private void updateStyledLogTextForPlan(StyledText messageText) {
String text = messageText.getText();
final String[] titleString = { "Join graph segments (f indicates final):", "Join graph nodes:", "Join graph equivalence classes:", "Join graph edges:", "Join graph terms:", "Query plan:", "Query stmt:" };
for (int i = 0, sp = -1, ep = 0, len = titleString.length; i < len; i++) {
sp = text.indexOf(titleString[i], ep);
if (sp != -1) {
StyleRange eachStyle = new StyleRange();
eachStyle.start = sp;
eachStyle.length = titleString[i].length();
eachStyle.fontStyle = SWT.BOLD;
eachStyle.foreground = ResourceManager.getColor(SWT.COLOR_BLUE);
messageText.setStyleRange(eachStyle);
}
ep = sp + 1;
}
}
use of org.eclipse.swt.custom.StyleRange in project tdi-studio-se by Talend.
the class ProcessComposite method doAppendToConsole.
private void doAppendToConsole(Collection<IProcessMessage> messages) {
if (consoleText == null || consoleText.isDisposed()) {
return;
}
int linesLimit = getConsoleRowLimit();
int currentLines = consoleText.getLineCount();
if (linesLimit > 0 && currentLines > linesLimit) {
return;
}
List<StyleRange> styles = new ArrayList<StyleRange>();
StringBuffer consoleMsgText = new StringBuffer();
int startLength = consoleText.getText().length();
for (StyleRange curStyle : consoleText.getStyleRanges()) {
styles.add(curStyle);
}
boolean newStyle = false;
for (IProcessMessage message : messages) {
if (message.getType() == MsgType.STD_OUT) {
//$NON-NLS-1$
String[] splitLines = message.getContent().split("\n");
for (String lineContent : splitLines) {
if (linesLimit > 0 && currentLines > linesLimit) {
return;
}
currentLines++;
IProcessMessage lineMsg = new ProcessMessage(getLog4jMsgType(MsgType.STD_OUT, lineContent), lineContent);
newStyle = newStyle | processMessage(consoleMsgText, lineMsg, startLength, styles);
}
} else {
if (linesLimit > 0 && currentLines > linesLimit) {
return;
}
currentLines++;
// count as only one line for the error, to avoid the error to be cut from original
newStyle = newStyle | processMessage(consoleMsgText, message, startLength, styles);
}
}
if (messages.size() > 1) {
consoleText.setText(consoleText.getText() + consoleMsgText);
} else {
consoleText.append(consoleMsgText.toString());
}
if (newStyle) {
consoleText.setStyleRanges(styles.toArray(new StyleRange[0]));
}
}
use of org.eclipse.swt.custom.StyleRange in project tdi-studio-se by Talend.
the class TraceDebugProcessComposite method doAppendToConsole.
private void doAppendToConsole(final IProcessMessage message) {
if (consoleText.isDisposed()) {
return;
}
// see feature 0004895: Font size of the output console are very small
setConsoleFont();
//$NON-NLS-1$
String[] rows = message.getContent().split("\n");
int rowLimit = getConsoleRowLimit();
String content = null;
if (rowLimit != SWT.DEFAULT) {
int currentRows = consoleText.getLineCount();
// if (consoleText.getText().equals("")) {
currentRows--;
// }
if (currentRows >= rowLimit) {
return;
} else if (currentRows + rows.length <= rowLimit) {
content = message.getContent();
} else {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < rowLimit - currentRows; i++) {
//$NON-NLS-1$
sb.append(rows[i]).append("\n");
}
content = sb.toString();
}
}
if (content == null) {
content = message.getContent();
}
StyleRange style = new StyleRange();
style.start = consoleText.getText().length();
String[] contents = content.split("\n");
for (String content2 : contents) {
if (isPattern(content2) || isPatternFor(content2)) {
//$NON-NLS-1$
consoleText.append("");
//$NON-NLS-1$
content = "";
} else {
consoleText.append(content2);
consoleText.append("\n");
}
}
style.length = content.length();
if (message.getType() == MsgType.CORE_OUT || message.getType() == MsgType.CORE_ERR) {
style.fontStyle = SWT.ITALIC;
}
Color color;
switch((MsgType) message.getType()) {
case CORE_OUT:
color = getDisplay().getSystemColor(SWT.COLOR_BLUE);
break;
case CORE_ERR:
color = getDisplay().getSystemColor(SWT.COLOR_DARK_RED);
break;
case STD_ERR:
color = getDisplay().getSystemColor(SWT.COLOR_RED);
break;
case STD_OUT:
default:
color = getDisplay().getSystemColor(SWT.COLOR_BLACK);
break;
}
style.foreground = color;
// added by hyWang for bug 0007411
if ((style.start + style.length) > consoleText.getCharCount()) {
style.length = consoleText.getCharCount() - style.start;
}
consoleText.setStyleRange(style);
}
use of org.eclipse.swt.custom.StyleRange in project tesb-studio-se by Talend.
the class SpringConfigurationStyledText method updateStyledRanges.
private void updateStyledRanges(ExtendedModifyEvent event) {
StyledText st = (StyledText) event.widget;
int start = event.start;
int length = event.length;
String replacedText = event.replacedText;
String textRange = st.getTextRange(start, length);
/*
* if no real change
* then return
*/
if ("".equals(textRange.trim()) && "".equals(replacedText.trim())) {
return;
}
List<StyleRange> styles = new ArrayList<StyleRange>();
scanner.setRange(st.getText());
int token = scanner.nextToken();
while (token != EOF) {
int startOffset = scanner.getStartOffset();
int tokenLength = scanner.getLength();
String tokenText = st.getTextRange(startOffset, tokenLength).trim();
for (String s : fgKeywords) {
if (s.equals(tokenText)) {
token = KEY;
break;
}
}
Color color = getColor(token);
StyleRange style = new StyleRange(startOffset, tokenLength, color, null);
if (token == KEY) {
style.fontStyle = SWT.BOLD;
}
styles.add(style);
token = scanner.nextToken();
}
st.setStyleRanges(styles.toArray(new StyleRange[0]));
}
Aggregations