use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.
the class ColorProviderMapper method getColor.
public static Color getColor(ColorInfo colorInfo) {
Color colorFromCache = colorsCache.get(colorInfo);
if (colorFromCache != null) {
return colorFromCache;
}
Color color = new Color(Display.getCurrent(), colorInfo.getRed(), colorInfo.getGreen(), colorInfo.getBlue());
colorsCache.put(colorInfo, color);
return color;
}
use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.
the class ColorProviderMapper method releaseColors.
/**
* DOC amaumont Comment method "release".
*/
public static void releaseColors() {
Collection<Color> colors = colorsCache.values();
for (Color color : colors) {
if (!color.isDisposed()) {
color.dispose();
}
}
colorsCache.clear();
}
use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.
the class ColorProviderMapper method releaseColor.
public static void releaseColor(ColorInfo colorInfo) {
Color color = colorsCache.get(colorInfo);
if (!color.isDisposed()) {
color.dispose();
}
colorsCache.remove(colorInfo);
}
use of org.eclipse.swt.graphics.Color in project tdi-studio-se by Talend.
the class DebugProcessTosComposite 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.graphics.Color in project tdi-studio-se by Talend.
the class ExpressionTestMain method feedBackTestResult.
/**
* yzhang Comment method "feedBackTestResult".
*/
private void feedBackTestResult() {
StringBuffer testResult = new StringBuffer();
try {
// Thread.sleep(500);
BufferedReader readerOut = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader readerError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
Thread.sleep(500);
boolean ready = readerOut.ready();
// System.out.println(ready);
if (ready) {
//$NON-NLS-1$
testResult.append(readerOut.readLine() + "\n");
}
Thread.sleep(500);
text.setText(testResult.toString());
if (readerError.ready()) {
//$NON-NLS-1$
testResult.append(readerError.readLine() + "\n");
text.setText(testResult.toString());
Color red = new Color(text.getDisplay(), new RGB(255, 0, 0));
StyleRange style = new StyleRange(0, testResult.length(), red, null, SWT.NORMAL);
text.setStyleRange(style);
}
} catch (Exception e) {
RuntimeExceptionHandler.process(e);
}
}
Aggregations