Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 25637 Details for
Bug 7022
[Workbench] Splash screen with progress bar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch to org.eclipse.ui.workbench
patch.txt (text/plain), 14.57 KB, created by
Boris Bokowski
on 2005-08-03 16:43:03 EDT
(
hide
)
Description:
patch to org.eclipse.ui.workbench
Filename:
MIME Type:
Creator:
Boris Bokowski
Created:
2005-08-03 16:43:03 EDT
Size:
14.57 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/branding/IProductConstants.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/branding/IProductConstants.java,v >retrieving revision 1.8 >diff -u -r1.8 IProductConstants.java >--- Eclipse UI/org/eclipse/ui/branding/IProductConstants.java 25 Feb 2005 20:52:32 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/branding/IProductConstants.java 3 Aug 2005 20:41:21 -0000 >@@ -123,4 +123,53 @@ > * </p> > */ > public static final String WELCOME_PAGE = "welcomePage"; //$NON-NLS-1$ >+ >+ /** >+ * The rectangle relative to the splash image's top left corner where >+ * the progress bar for reporting progress at startup should be shown. >+ * Products designed to run "headless" typically would not define this >+ * property. >+ * <p> >+ * The value is a comma-separated list of four integer values, specifying >+ * x, y, width, and height of the rectangle in pixel coordinates. >+ * </p> >+ * <p>This property is still experimental and may be renamed or removed >+ * during the development of Eclipse 3.2. >+ * </p> >+ * @since 3.2 <b>EXPERIMENTAL</b> >+ */ >+ public static final String STARTUP_PROGRESS_RECT = "startupProgressRect"; //$NON-NLS-1$ >+ >+ /** >+ * The rectangle relative to the splash image's top left corner where >+ * messages for reporting progress at startup should be shown. >+ * Products designed to run "headless" typically would not define this >+ * property. >+ * <p> >+ * The value is a comma-separated list of four integer values, specifying >+ * x, y, width, and height of the rectangle in pixel coordinates. >+ * </p> >+ * <p>This property is still experimental and may be renamed or removed >+ * during the development of Eclipse 3.2. >+ * </p> >+ * @since 3.2 <b>EXPERIMENTAL</b> >+ */ >+ public static final String STARTUP_MESSAGE_RECT = "startupMessageRect"; //$NON-NLS-1$ >+ >+ /** >+ * The foreground color to be used when reporting progress at startup. >+ * Products designed to run "headless" typically would not define this >+ * property. >+ * <p> >+ * The value is a six-digit hexadecimal number. The first two digits >+ * specify the red component of the color, the next two digits the >+ * green component, and the last two digits the blue component. >+ * </p> >+ * <p>This property is still experimental and may be renamed or removed >+ * during the development of Eclipse 3.2. >+ * </p> >+ * @since 3.2 <b>EXPERIMENTAL</b> >+ */ >+ public static final String STARTUP_FOREGROUND_COLOR = "startupForegroundColor"; //$NON-NLS-1$ >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/Workbench.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java,v >retrieving revision 1.344 >diff -u -r1.344 Workbench.java >--- Eclipse UI/org/eclipse/ui/internal/Workbench.java 2 Aug 2005 17:40:40 -0000 1.344 >+++ Eclipse UI/org/eclipse/ui/internal/Workbench.java 3 Aug 2005 20:41:21 -0000 >@@ -1242,39 +1242,74 @@ > } > } > >- private void runStartupWithProgress(final int expectedProgressCount, final Runnable runnable) throws InvocationTargetException, InterruptedException { >+ private void runStartupWithProgress(final int expectedProgressCount, >+ final Runnable runnable) throws InvocationTargetException, >+ InterruptedException { > progressCount = 0; > final double cutoff = 0.95; > >- Shell shell = new Shell(Display.getCurrent(), SWT.NONE); >- try { >- >- final StartupProgressMonitorDialog progressMonitorDialog = new StartupProgressMonitorDialog(shell); >- >- SynchronousBundleListener bundleListener = new StartupProgressBundleListener(progressMonitorDialog.getProgressMonitor(), (int) (expectedProgressCount * cutoff)); >+ IProgressMonitor progressMonitor = StartupProgressMonitor.getInstance(); >+ if (progressMonitor != null) { >+ progressMonitor.beginTask("", expectedProgressCount); //$NON-NLS-1$ >+ SynchronousBundleListener bundleListener = new StartupProgressBundleListener( >+ progressMonitor, (int) (expectedProgressCount * cutoff)); > WorkbenchPlugin.getDefault().addBundleListener(bundleListener); >- > try { >- progressMonitorDialog.run(false, false, new IRunnableWithProgress() { >- >- public void run(IProgressMonitor monitor) { >- monitor.beginTask("", expectedProgressCount); //$NON-NLS-1$ >- >- runnable.run(); >- >- monitor.subTask(WorkbenchMessages.Startup_Done); >- int remainingWork = expectedProgressCount - Math.min(progressCount, (int)(expectedProgressCount * cutoff)); >- monitor.worked(remainingWork); >- Display.getCurrent().update(); >- monitor.done(); >- }}); >+ runnable.run(); >+ progressMonitor.subTask(WorkbenchMessages.Startup_Done); >+ int remainingWork = expectedProgressCount >+ - Math.min(progressCount, >+ (int) (expectedProgressCount * cutoff)); >+ progressMonitor.worked(remainingWork); >+ progressMonitor.done(); > } finally { >- WorkbenchPlugin.getDefault().removeBundleListener(bundleListener); >+ WorkbenchPlugin.getDefault().removeBundleListener( >+ bundleListener); > } >- >- } finally { >- shell.dispose(); >- } >+ } else { >+ Shell shell = new Shell(Display.getCurrent(), SWT.NONE); >+ try { >+ >+ final StartupProgressMonitorDialog progressMonitorDialog = new StartupProgressMonitorDialog( >+ shell); >+ >+ SynchronousBundleListener bundleListener = new StartupProgressBundleListener( >+ progressMonitorDialog.getProgressMonitor(), >+ (int) (expectedProgressCount * cutoff)); >+ WorkbenchPlugin.getDefault().addBundleListener(bundleListener); >+ >+ try { >+ progressMonitorDialog.run(false, false, >+ new IRunnableWithProgress() { >+ >+ public void run(IProgressMonitor monitor) { >+ monitor >+ .beginTask( >+ "", expectedProgressCount); //$NON-NLS-1$ >+ >+ runnable.run(); >+ >+ monitor >+ .subTask(WorkbenchMessages.Startup_Done); >+ int remainingWork = expectedProgressCount >+ - Math >+ .min( >+ progressCount, >+ (int) (expectedProgressCount * cutoff)); >+ monitor.worked(remainingWork); >+ Display.getCurrent().update(); >+ monitor.done(); >+ } >+ }); >+ } finally { >+ WorkbenchPlugin.getDefault().removeBundleListener( >+ bundleListener); >+ } >+ >+ } finally { >+ shell.dispose(); >+ } >+ } > } > > private void doOpenFirstTimeWindow() { >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java,v >retrieving revision 1.132 >diff -u -r1.132 WorkbenchPlugin.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java 24 May 2005 20:04:10 -0000 1.132 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java 3 Aug 2005 20:41:21 -0000 >@@ -11,6 +11,7 @@ > > package org.eclipse.ui.internal; > >+import java.io.OutputStream; > import java.text.MessageFormat; > import java.util.Locale; > >@@ -66,6 +67,8 @@ > import org.osgi.framework.Bundle; > import org.osgi.framework.BundleContext; > import org.osgi.framework.BundleListener; >+import org.osgi.framework.InvalidSyntaxException; >+import org.osgi.framework.ServiceReference; > > /** > * This class represents the TOP of the workbench UI world >@@ -971,4 +974,27 @@ > /* package */ int getBundleCount() { > return bundleContext.getBundles().length; > } >+ >+ /* package */ OutputStream getSplashStream() { >+ // assumes the output stream is available as a service >+ // see EclipseStarter.publishSplashScreen >+ ServiceReference[] ref; >+ try { >+ ref = bundleContext.getServiceReferences(OutputStream.class.getName(), null); >+ } catch (InvalidSyntaxException e) { >+ return null; >+ } >+ if(ref==null) >+ return null; >+ for (int i = 0; i < ref.length; i++) { >+ String name = (String) ref[i].getProperty("name"); //$NON-NLS-1$ >+ if (name != null && name.equals("splashstream")) { //$NON-NLS-1$ >+ Object result = bundleContext.getService(ref[i]); >+ bundleContext.ungetService(ref[i]); >+ return (OutputStream) result; >+ } >+ } >+ return null; >+ } >+ > } >Index: Eclipse UI/org/eclipse/ui/internal/StartupProgressMonitor.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/StartupProgressMonitor.java >diff -N Eclipse UI/org/eclipse/ui/internal/StartupProgressMonitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/StartupProgressMonitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,205 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ui.internal; >+ >+import java.io.OutputStream; >+import java.io.PrintStream; >+import java.util.LinkedList; >+ >+import org.eclipse.core.runtime.IProduct; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.ui.branding.IProductConstants; >+ >+/* package */class StartupProgressMonitor implements IProgressMonitor { >+ >+ // this class prints to the output stream and calls flush() >+ // on it in a separate thread so that the main thread will >+ // not block if the other end of the stream (the executable >+ // that displays the splash screen) misbehaves. >+ private class AsynchronousPrinter extends Thread { >+ private PrintStream printStream; >+ >+ // this list holds strings to print. The empty string is >+ // added to the list if the output stream should be flushed. >+ // If the output stream should be closed, null is added >+ // to this list. >+ private LinkedList tasks = new LinkedList(); >+ >+ private AsynchronousPrinter(OutputStream stream) { >+ this.printStream = new PrintStream(stream, false); >+ setName("Startup Progress Printer"); //$NON-NLS-1$ >+ } >+ >+ public void run() { >+ while (true) { >+ Object task; >+ synchronized (tasks) { >+ while (tasks.isEmpty()) { >+ try { >+ tasks.wait(); >+ } catch (InterruptedException e) { >+ return; >+ } >+ } >+ task = tasks.removeFirst(); >+ } >+ if (task == null) { >+ printStream.close(); >+ return; >+ } else if ("".equals(task)) { //$NON-NLS-1$ >+ printStream.flush(); >+ } else { >+ printStream.print(task.toString() + "\n"); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ private void addTask(Object o) { >+ synchronized (tasks) { >+ tasks.addLast(o); >+ tasks.notifyAll(); >+ } >+ } >+ >+ void println(String string) { >+ addTask(string); >+ } >+ >+ void flush() { >+ addTask(""); //$NON-NLS-1$ >+ } >+ >+ void close() { >+ addTask(null); >+ } >+ } >+ >+ private static boolean progressMonitorReturned = false; >+ >+ /** >+ * Returns a progress monitor to report startup progress, or >+ * <code>null</code> if progress cannot be reported. This method will >+ * return <code>null</code> if called more than once. >+ * >+ * @return a progress monitor, or null >+ */ >+ /* package */static IProgressMonitor getInstance() { >+ if (!progressMonitorReturned) { >+ OutputStream outputStream = WorkbenchPlugin.getDefault() >+ .getSplashStream(); >+ if (outputStream != null) { >+ progressMonitorReturned = true; >+ return new StartupProgressMonitor(outputStream); >+ } >+ } >+ return null; >+ } >+ >+ private double sumWorked = 0; >+ >+ private int totalWork; >+ >+ private int lastReportedWork = -1; >+ >+ private AsynchronousPrinter printer; >+ >+ private StartupProgressMonitor(OutputStream os) { >+ printer = new AsynchronousPrinter(os); >+ } >+ >+ private void reportWork(int value) { >+ if (lastReportedWork != value) { >+ printer.println("value=" + value); //$NON-NLS-1$ >+ printer.flush(); >+ lastReportedWork = value; >+ } >+ } >+ >+ public void beginTask(String name, int total) { >+ this.totalWork = total; >+ printer.start(); >+ printInitializationData(); >+ } >+ >+ private void printInitializationData() { >+ String progressRect = null; >+ String messageRect = null; >+ String foregroundColor = null; >+ IProduct product = Platform.getProduct(); >+ if (product != null) { >+ progressRect = product >+ .getProperty(IProductConstants.STARTUP_PROGRESS_RECT); >+ messageRect = product >+ .getProperty(IProductConstants.STARTUP_MESSAGE_RECT); >+ foregroundColor = product >+ .getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR); >+ } >+ if (progressRect == null) >+ progressRect = "10,10,300,15"; //$NON-NLS-1$ >+ if (messageRect == null) >+ messageRect = "10,35,300,15"; //$NON-NLS-1$ >+ int foregroundColorInteger; >+ try { >+ foregroundColorInteger = Integer.parseInt(foregroundColor, 16); >+ } catch (Exception ex) { >+ foregroundColorInteger = 13817855; // D2D7FF=white >+ } >+ printer.println("foreground=" + foregroundColorInteger); //$NON-NLS-1$ >+ printer.println("messageRect=" + messageRect); //$NON-NLS-1$ >+ printer.println("progressRect=" + progressRect); //$NON-NLS-1$ >+ printer.println("maximum=" + totalWork); //$NON-NLS-1$ >+ printer.flush(); >+ } >+ >+ public void done() { >+ if (lastReportedWork < totalWork) { >+ reportWork(totalWork); >+ } >+ printer.close(); >+ } >+ >+ public void internalWorked(double work) { >+ if (work == 0) { >+ return; >+ } >+ sumWorked += work; >+ if (sumWorked > totalWork) { >+ sumWorked = totalWork; >+ } >+ if (sumWorked < 0) { >+ sumWorked = 0; >+ } >+ reportWork((int) sumWorked); >+ } >+ >+ public boolean isCanceled() { >+ return false; >+ } >+ >+ public void setCanceled(boolean value) { >+ // cannot cancel >+ } >+ >+ public void setTaskName(String name) { >+ // ignore, this does not change anything in the splash screen >+ } >+ >+ public void subTask(String name) { >+ printer.println("message=" + name.replace('\n', ' ')); //$NON-NLS-1$ >+ printer.flush(); >+ } >+ >+ public void worked(int work) { >+ internalWorked(work); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 7022
:
22858
| 25637 |
25638