use of org.eclipse.swt.custom.StyleRange in project tdi-studio-se by Talend.
the class ReportMessageManager method setStartMessage.
public synchronized void setStartMessage(String content, Color foreground, Color background) {
messages.clear();
StyleRange styleRange = new StyleRange(0, content.length(), foreground, background);
messages.add(new ReportMessage(styleRange, content));
}
use of org.eclipse.swt.custom.StyleRange in project tdi-studio-se by Talend.
the class ProcessComposite method processMessage.
private boolean processMessage(StringBuffer consoleText, IProcessMessage message, int startLength, List<StyleRange> styles) {
String content = message.getContent();
int lengthBeforeAdd = consoleText.length();
//$NON-NLS-1$
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);
//$NON-NLS-1$
consoleText.append("\n");
}
}
boolean newStyle = false;
if (message.getType() != MsgType.STD_OUT) {
StyleRange style = new StyleRange();
style.start = startLength + lengthBeforeAdd;
style.length = content.length();
if (message.getType() == MsgType.CORE_OUT || message.getType() == MsgType.CORE_ERR) {
style.fontStyle = SWT.ITALIC;
}
Color color = getColor((MsgType) message.getType());
style.foreground = color;
if ((style.start + style.length) > (startLength + consoleText.length())) {
style.length = startLength + consoleText.length() - style.start;
}
styles.add(style);
newStyle = true;
}
return newStyle;
}
use of org.eclipse.swt.custom.StyleRange in project tesb-studio-se by Talend.
the class AnsiConsoleStyleListener method lineGetStyle.
@Override
public void lineGetStyle(LineStyleEvent event) {
if (event == null || event.lineText == null || event.lineText.length() == 0)
return;
StyleRange defStyle;
if (event.styles != null && event.styles.length > 0) {
defStyle = (StyleRange) event.styles[0].clone();
if (defStyle.background == null)
defStyle.background = AnsiConsoleUtils.getDebugConsoleBgColor();
} else {
defStyle = new StyleRange(1, lastRangeEnd, new Color(null, AnsiConsoleColorPalette.getColor(0)), new Color(null, AnsiConsoleColorPalette.getColor(15)), SWT.NORMAL);
}
lastRangeEnd = 0;
List<StyleRange> ranges = new ArrayList<StyleRange>();
String currentText = event.lineText;
Matcher matcher = pattern.matcher(currentText);
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
String theEscape = currentText.substring(matcher.start() + 2, matcher.end() - 1);
char code = currentText.charAt(matcher.end() - 1);
if (code == ESCAPE_SGR) {
// Select Graphic Rendition (SGR) escape sequence
List<Integer> nCommands = new ArrayList<Integer>();
for (String cmd : theEscape.split(";")) {
int nCmd = AnsiConsoleUtils.tryParseInteger(cmd);
if (nCmd != -1)
nCommands.add(nCmd);
}
if (nCommands.isEmpty())
nCommands.add(0);
interpretCommand(nCommands);
}
if (lastRangeEnd != start)
addRange(ranges, event.lineOffset + lastRangeEnd, start - lastRangeEnd, defStyle.foreground, false);
lastAttributes = currentAttributes.clone();
addRange(ranges, event.lineOffset + start, end - start, defStyle.foreground, true);
}
if (lastRangeEnd != currentText.length())
addRange(ranges, event.lineOffset + lastRangeEnd, currentText.length() - lastRangeEnd, defStyle.foreground, false);
lastAttributes = currentAttributes.clone();
if (!ranges.isEmpty())
event.styles = ranges.toArray(new StyleRange[ranges.size()]);
}
use of org.eclipse.swt.custom.StyleRange in project tesb-studio-se by Talend.
the class AnsiConsoleStyleListener method addRange.
private void addRange(List<StyleRange> ranges, int start, int length, Color foreground, boolean isCode) {
StyleRange range = new StyleRange(start, length, foreground, null);
AnsiConsoleAttributes.updateRangeStyle(range, lastAttributes);
if (isCode) {
range.metrics = new GlyphMetrics(0, 0, 0);
}
ranges.add(range);
lastRangeEnd = lastRangeEnd + range.length;
}
use of org.eclipse.swt.custom.StyleRange in project tesb-studio-se by Talend.
the class SearchCellLabelProvider method update.
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
final String text = getText(element);
cell.setText(text);
cell.setImage(getImage(element));
cell.setFont(getFont(element));
if (filterString != null && !filterString.isEmpty()) {
int filterIndex = text.indexOf(filterString);
StyleRange styleRange = new StyleRange(filterIndex, filterString.length(), null, hightLight);
cell.setStyleRanges(new StyleRange[] { styleRange });
} else {
cell.setStyleRanges(null);
}
}
Aggregations