Example usage for org.eclipse.jface.resource StringConverter asRectangle

List of usage examples for org.eclipse.jface.resource StringConverter asRectangle

Introduction

In this page you can find the example usage for org.eclipse.jface.resource StringConverter asRectangle.

Prototype

public static Rectangle asRectangle(String value) throws DataFormatException 

Source Link

Document

Converts the given value into an SWT rectangle.

Usage

From source file:org.bonitasoft.studio.application.splash.BOSSplashHandler.java

License:Open Source License

@Override
public void init(Shell splash) {
    super.init(splash);
    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    IProduct product = Platform.getProduct();
    if (product != null) {
        progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
        messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
        foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }//w w  w.  j  a va  2  s. c  om

    Rectangle progressRect = StringConverter.asRectangle(progressRectString);
    setProgressRect(progressRect);

    Rectangle messageRect = StringConverter.asRectangle(messageRectString);
    setMessageRect(messageRect);

    int foregroundColorInteger;
    try {
        foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
    } catch (Exception ex) {
        foregroundColorInteger = 0xD2D7FF; // off white
    }

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    // the following code will be removed for release time
    if (PrefUtil.getInternalPreferenceStore().getBoolean("SHOW_BUILDID_ON_STARTUP")) { //$NON-NLS-1$
        final String buildId = System.getProperty("eclipse.buildId", "Unknown Build"); //$NON-NLS-1$ //$NON-NLS-2$
        // find the specified location.  Not currently API
        // hardcoded to be sensible with our current splash Graphic
        String buildIdLocString = product.getProperty("buildIdLocation"); //$NON-NLS-1$
        final Point buildIdPoint = StringConverter.asPoint(buildIdLocString, new Point(322, 190));
        getContent().addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                e.gc.setForeground(getForeground());
                e.gc.setBackground(getForeground());
                e.gc.drawText(buildId, buildIdPoint.x, buildIdPoint.y, true);
            }
        });
    } else {
        getContent(); // ensure creation of the progress
    }
}