下面列出了怎么用org.eclipse.ui.branding.IProductConstants的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void init(Shell splash) {
super.init(splash);
String progressString = null;
// Try to get the progress bar and message updater.
IProduct product = Platform.getProduct();
if (product != null) {
progressString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
}
Rectangle progressRect = StringConverter.asRectangle(progressString, PROCESS_BAR_RECTANGLE);
setProgressRect(progressRect);
// Set font color.
setForeground(FOREGROUND_COLOR);
// Set the software version.
getContent().addPaintListener(e -> {
e.gc.setForeground(getForeground());
e.gc.drawText(
NLS.bind(Messages.SplahScreen_VersionString,
TracingRcpPlugin.getDefault().getBundle().getVersion().toString()),
VERSION_LOCATION.x, VERSION_LOCATION.y, true);
});
}
@Override
public void init(Shell splash) {
super.init(splash);
String progressRectString = null;
String messageRectString = null;
String foregroundColorString = null;
String versionColorString = null;
String buildIdLocationString = 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);
versionColorString = product.getProperty("versionForegroundColor");
buildIdLocationString = product.getProperty("versionRect");
}
Rectangle progressRect = StringConverter.asRectangle(progressRectString, new Rectangle(10, 10, 300, 15));
setProgressRect(progressRect);
Rectangle messageRect = StringConverter.asRectangle(messageRectString, new Rectangle(10, 35, 300, 15));
setMessageRect(messageRect);
int foregroundColorInteger;
int versionColorInteger;
try {
foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
versionColorInteger = Integer.parseInt(versionColorString, 16);
}
catch (Exception ex) {
foregroundColorInteger = 0xD2D7FF; // off white
versionColorInteger = 0xD2D7FF; // off white
}
setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8,
foregroundColorInteger & 0xFF));
final Color versionColor = new Color(getSplash().getShell().getDisplay(),
new RGB((versionColorInteger & 0xFF0000) >> 16, (versionColorInteger & 0xFF00) >> 8,
versionColorInteger & 0xFF));
// add Version number at custom location
final String version = getVersionString();
final Point versionPoint = StringConverter.asPoint(buildIdLocationString, new Point(322, 190));
getContent().addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setForeground(versionColor);
// This is needed to right align the text to the given location
Point p = e.gc.textExtent(version);
e.gc.drawText(version, versionPoint.x - p.x, versionPoint.y, true);
}
});
}
@Override
public void init(final Shell splash) {
super.init(splash);
String progressRectString = null;
String messageRectString = null;
String foregroundColorString = null;
final 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);
}
final Rectangle progressRect = StringConverter.asRectangle(progressRectString);
setProgressRect(progressRect);
final Rectangle messageRect = StringConverter.asRectangle(messageRectString);
setMessageRect(messageRect);
int foregroundColorInteger;
try {
foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
} catch (final 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
final 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(final 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
}
}