Search in sources :

Example 21 with Color

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;
}
Also used : Color(org.eclipse.swt.graphics.Color)

Example 22 with 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();
}
Also used : Color(org.eclipse.swt.graphics.Color)

Example 23 with Color

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);
}
Also used : Color(org.eclipse.swt.graphics.Color)

Example 24 with Color

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);
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) Color(org.eclipse.swt.graphics.Color) MsgType(org.talend.designer.runprocess.ProcessMessage.MsgType) Point(org.eclipse.swt.graphics.Point)

Example 25 with Color

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Color(org.eclipse.swt.graphics.Color) StyleRange(org.eclipse.swt.custom.StyleRange) BufferedReader(java.io.BufferedReader) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

Color (org.eclipse.swt.graphics.Color)1008 Point (org.eclipse.swt.graphics.Point)145 RGB (org.eclipse.swt.graphics.RGB)127 GridData (org.eclipse.swt.layout.GridData)120 Composite (org.eclipse.swt.widgets.Composite)118 Rectangle (org.eclipse.swt.graphics.Rectangle)116 Image (org.eclipse.swt.graphics.Image)115 GridLayout (org.eclipse.swt.layout.GridLayout)99 Display (org.eclipse.swt.widgets.Display)97 Test (org.junit.Test)95 Font (org.eclipse.swt.graphics.Font)86 Label (org.eclipse.swt.widgets.Label)79 GC (org.eclipse.swt.graphics.GC)74 SelectionEvent (org.eclipse.swt.events.SelectionEvent)65 Shell (org.eclipse.swt.widgets.Shell)54 ArrayList (java.util.ArrayList)51 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)51 StyleRange (org.eclipse.swt.custom.StyleRange)49 TableItem (org.eclipse.swt.widgets.TableItem)48 Button (org.eclipse.swt.widgets.Button)45