KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > splash > EclipseSplashHandler


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.splash;
12
13 import org.eclipse.core.runtime.IProduct;
14 import org.eclipse.core.runtime.Platform;
15 import org.eclipse.jface.resource.StringConverter;
16 import org.eclipse.swt.events.PaintEvent;
17 import org.eclipse.swt.events.PaintListener;
18 import org.eclipse.swt.graphics.Point;
19 import org.eclipse.swt.graphics.RGB;
20 import org.eclipse.swt.graphics.Rectangle;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.branding.IProductConstants;
23 import org.eclipse.ui.internal.util.PrefUtil;
24 import org.eclipse.ui.splash.BasicSplashHandler;
25
26 /**
27  * Parses the well known product constants and constructs a splash handler
28  * accordingly.
29  */

30 public class EclipseSplashHandler extends BasicSplashHandler {
31
32     public void init(Shell splash) {
33         super.init(splash);
34         String JavaDoc progressRectString = null;
35         String JavaDoc messageRectString = null;
36         String JavaDoc foregroundColorString = null;
37         IProduct product = Platform.getProduct();
38         if (product != null) {
39             progressRectString = product
40                     .getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
41             messageRectString = product
42                     .getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
43             foregroundColorString = product
44                     .getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
45         }
46         Rectangle progressRect = StringConverter.asRectangle(
47                 progressRectString, new Rectangle(10, 10, 300, 15));
48         setProgressRect(progressRect);
49
50         Rectangle messageRect = StringConverter.asRectangle(messageRectString,
51                 new Rectangle(10, 35, 300, 15));
52         setMessageRect(messageRect);
53
54         int foregroundColorInteger;
55         try {
56             foregroundColorInteger = Integer
57                     .parseInt(foregroundColorString, 16);
58         } catch (Exception JavaDoc ex) {
59             foregroundColorInteger = 0xD2D7FF; // off white
60
}
61
62         setForeground(new RGB((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 JavaDoc 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 JavaDoc buildIdLocString = product.getProperty("buildIdLocation"); //$NON-NLS-1$
73
final Point buildIdPoint = StringConverter.asPoint(buildIdLocString,
74                     new Point(322, 190));
75             getContent().addPaintListener(new PaintListener() {
76
77                 public void paintControl(PaintEvent e) {
78                     e.gc.setForeground(getForeground());
79                     e.gc.drawText(buildId, buildIdPoint.x, buildIdPoint.y, true);
80                 }
81             });
82         }
83         else {
84             getContent(); // ensure creation of the progress
85
}
86     }
87 }
88
Popular Tags