01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.splash;
11:
12: import org.eclipse.core.runtime.IProduct;
13: import org.eclipse.core.runtime.Platform;
14: import org.eclipse.jface.resource.StringConverter;
15: import org.eclipse.swt.events.PaintEvent;
16: import org.eclipse.swt.events.PaintListener;
17: import org.eclipse.swt.graphics.Point;
18: import org.eclipse.swt.graphics.RGB;
19: import org.eclipse.swt.graphics.Rectangle;
20: import org.eclipse.swt.widgets.Shell;
21: import org.eclipse.ui.branding.IProductConstants;
22: import org.eclipse.ui.internal.util.PrefUtil;
23: import org.eclipse.ui.splash.BasicSplashHandler;
24:
25: /**
26: * Parses the well known product constants and constructs a splash handler
27: * accordingly.
28: */
29: public class EclipseSplashHandler extends BasicSplashHandler {
30:
31: public void init(Shell splash) {
32: super .init(splash);
33: String progressRectString = null;
34: String messageRectString = null;
35: String foregroundColorString = null;
36: IProduct product = Platform.getProduct();
37: if (product != null) {
38: progressRectString = product
39: .getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
40: messageRectString = product
41: .getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
42: foregroundColorString = product
43: .getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
44: }
45: Rectangle progressRect = StringConverter.asRectangle(
46: progressRectString, new Rectangle(10, 10, 300, 15));
47: setProgressRect(progressRect);
48:
49: Rectangle messageRect = StringConverter.asRectangle(
50: messageRectString, new Rectangle(10, 35, 300, 15));
51: setMessageRect(messageRect);
52:
53: int foregroundColorInteger;
54: try {
55: foregroundColorInteger = Integer.parseInt(
56: foregroundColorString, 16);
57: } catch (Exception ex) {
58: foregroundColorInteger = 0xD2D7FF; // off white
59: }
60:
61: setForeground(new RGB(
62: (foregroundColorInteger & 0xFF0000) >> 16,
63: (foregroundColorInteger & 0xFF00) >> 8,
64: foregroundColorInteger & 0xFF));
65: // the following code will be removed for release time
66: if (PrefUtil.getInternalPreferenceStore().getBoolean(
67: "SHOW_BUILDID_ON_STARTUP")) { //$NON-NLS-1$
68: final String buildId = System.getProperty(
69: "eclipse.buildId", "Unknown Build"); //$NON-NLS-1$ //$NON-NLS-2$
70: // find the specified location. Not currently API
71: // hardcoded to be sensible with our current Europa Graphic
72: String buildIdLocString = product
73: .getProperty("buildIdLocation"); //$NON-NLS-1$
74: final Point buildIdPoint = StringConverter.asPoint(
75: buildIdLocString, new Point(322, 190));
76: getContent().addPaintListener(new PaintListener() {
77:
78: public void paintControl(PaintEvent e) {
79: e.gc.setForeground(getForeground());
80: e.gc.drawText(buildId, buildIdPoint.x,
81: buildIdPoint.y, true);
82: }
83: });
84: } else {
85: getContent(); // ensure creation of the progress
86: }
87: }
88: }
|