Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 109290 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPlugin.java (-2 / +78 lines)
Lines 12-18 Link Here
12
package org.eclipse.ui.internal;
12
package org.eclipse.ui.internal;
13
13
14
import java.io.OutputStream;
14
import java.io.OutputStream;
15
import java.util.*;
15
import java.lang.reflect.InvocationTargetException;
16
import java.lang.reflect.Method;
17
import java.util.Collection;
18
import java.util.HashSet;
19
import java.util.Locale;
16
20
17
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IConfigurationElement;
Lines 28-33 Link Here
28
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
29
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.custom.BusyIndicator;
34
import org.eclipse.swt.custom.BusyIndicator;
35
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IEditorRegistry;
37
import org.eclipse.ui.IEditorRegistry;
32
import org.eclipse.ui.IElementFactory;
38
import org.eclipse.ui.IElementFactory;
33
import org.eclipse.ui.IPerspectiveRegistry;
39
import org.eclipse.ui.IPerspectiveRegistry;
Lines 63-69 Link Here
63
import org.eclipse.ui.presentations.AbstractPresentationFactory;
69
import org.eclipse.ui.presentations.AbstractPresentationFactory;
64
import org.eclipse.ui.views.IViewRegistry;
70
import org.eclipse.ui.views.IViewRegistry;
65
import org.eclipse.ui.wizards.IWizardRegistry;
71
import org.eclipse.ui.wizards.IWizardRegistry;
66
import org.osgi.framework.*;
72
import org.osgi.framework.Bundle;
73
import org.osgi.framework.BundleContext;
74
import org.osgi.framework.BundleEvent;
75
import org.osgi.framework.BundleListener;
76
import org.osgi.framework.InvalidSyntaxException;
77
import org.osgi.framework.ServiceReference;
78
import org.osgi.framework.SynchronousBundleListener;
67
79
68
import com.ibm.icu.text.MessageFormat;
80
import com.ibm.icu.text.MessageFormat;
69
81
Lines 88-93 Link Here
88
 */
100
 */
89
public class WorkbenchPlugin extends AbstractUIPlugin {
101
public class WorkbenchPlugin extends AbstractUIPlugin {
90
	
102
	
103
	/**
104
	 * The OSGi splash property.
105
	 * 
106
	 * @sicne 3.4
107
	 */
108
	private static final String PROP_SPLASH_HANDLE = "org.eclipse.equinox.launcher.splash.handle"; //$NON-NLS-1$
109
	
91
	private static final String LEFT_TO_RIGHT = "ltr"; //$NON-NLS-1$
110
	private static final String LEFT_TO_RIGHT = "ltr"; //$NON-NLS-1$
92
	private static final String RIGHT_TO_LEFT = "rtl";//$NON-NLS-1$
111
	private static final String RIGHT_TO_LEFT = "rtl";//$NON-NLS-1$
93
	private static final String ORIENTATION_COMMAND_LINE = "-dir";//$NON-NLS-1$
112
	private static final String ORIENTATION_COMMAND_LINE = "-dir";//$NON-NLS-1$
Lines 1210-1214 Link Here
1210
			return startingBundles.contains(bundle);
1229
			return startingBundles.contains(bundle);
1211
		}
1230
		}
1212
	}
1231
	}
1232
1233
	/**
1234
	 * Return whether or not the OSGi framework has specified the handle of a splash shell.
1235
	 * 
1236
	 * @return whether or not the OSGi framework has specified the handle of a splash shell
1237
	 * @since 3.4
1238
	 */
1239
	public static boolean isSplashHandleSpecified() {
1240
		return System.getProperty(PROP_SPLASH_HANDLE) != null;
1241
	}
1213
	
1242
	
1243
	/**
1244
	 * Get the splash shell for this workbench instance, if any. This will find
1245
	 * the splash created by the launcher (native) code and wrap it in a SWT
1246
	 * shell.
1247
1248
	 * @param display the display to parent the shell on 
1249
	 * 
1250
	 * @return the splash shell or <code>null</code>
1251
	 * @throws InvocationTargetException 
1252
	 * @throws IllegalAccessException 
1253
	 * @throws IllegalArgumentException 
1254
	 * @throws NumberFormatException 
1255
	 * @since 3.4
1256
	 */
1257
	public static Shell getSplashShell(Display display)
1258
			throws NumberFormatException, IllegalArgumentException,
1259
			IllegalAccessException, InvocationTargetException {
1260
		String splashHandle = System.getProperty(PROP_SPLASH_HANDLE);
1261
		if (splashHandle == null) {
1262
			return null;
1263
		}
1264
		Shell splashShell = null;
1265
		// look for the 32 bit internal_new shell method
1266
		try {
1267
			Method method = Shell.class.getMethod(
1268
					"internal_new", new Class[] { Display.class, int.class }); //$NON-NLS-1$
1269
			// we're on a 32 bit platform so invoke it with splash
1270
			// handle as an int
1271
			splashShell = (Shell) method.invoke(null, new Object[] { display,
1272
					new Integer(splashHandle) });
1273
		} catch (NoSuchMethodException e) {
1274
			// look for the 64 bit internal_new shell method
1275
			try {
1276
				Method method = Shell.class
1277
						.getMethod(
1278
								"internal_new", new Class[] { Display.class, long.class }); //$NON-NLS-1$
1279
1280
				// we're on a 64 bit platform so invoke it with a long
1281
				splashShell = (Shell) method.invoke(null, new Object[] {
1282
						display, new Long(splashHandle) });
1283
			} catch (NoSuchMethodException e2) {
1284
				// cant find either method - don't do anything.
1285
			}
1286
		}
1287
1288
		return splashShell;
1289
	}
1214
}
1290
}
(-)Eclipse UI/org/eclipse/ui/internal/Workbench.java (-28 / +3 lines)
Lines 20-26 Link Here
20
import java.io.InputStream;
20
import java.io.InputStream;
21
import java.io.InputStreamReader;
21
import java.io.InputStreamReader;
22
import java.io.OutputStreamWriter;
22
import java.io.OutputStreamWriter;
23
import java.lang.reflect.Method;
24
import java.util.ArrayList;
23
import java.util.ArrayList;
25
import java.util.Arrays;
24
import java.util.Arrays;
26
import java.util.Dictionary;
25
import java.util.Dictionary;
Lines 533-540 Link Here
533
		SafeRunnable run = new SafeRunnable() {
532
		SafeRunnable run = new SafeRunnable() {
534
533
535
			public void run() throws Exception {
534
			public void run() throws Exception {
536
				String splashHandle = System.getProperty("org.eclipse.equinox.launcher.splash.handle"); //$NON-NLS-1$
535
				if (! WorkbenchPlugin.isSplashHandleSpecified()) {
537
				if (splashHandle == null) {
538
					createSplash = false;
536
					createSplash = false;
539
					return;
537
					return;
540
				}
538
				}
Lines 547-577 Link Here
547
				}
545
				}
548
				
546
				
549
				Shell splashShell = splash.getSplash();
547
				Shell splashShell = splash.getSplash();
550
				if (splashShell == null) {
548
				if (splashShell == null) {					
551
					// look for the 32 bit internal_new shell method
549
					splashShell = WorkbenchPlugin.getSplashShell(display);
552
					try {
553
						Method method = Shell.class
554
								.getMethod(
555
										"internal_new", new Class[] { Display.class, int.class }); //$NON-NLS-1$
556
						// we're on a 32 bit platform so invoke it with splash
557
						// handle as an int
558
						splashShell = (Shell) method.invoke(null, new Object[] {
559
								display, new Integer(splashHandle) });
560
					} catch (NoSuchMethodException e) {
561
						// look for the 64 bit internal_new shell method
562
						try {
563
							Method method = Shell.class
564
									.getMethod(
565
											"internal_new", new Class[] { Display.class, long.class }); //$NON-NLS-1$
566
567
							// we're on a 64 bit platform so invoke it with a long
568
							splashShell = (Shell) method.invoke(null,
569
									new Object[] { display,
570
											new Long(splashHandle) });
571
						} catch (NoSuchMethodException e2) {
572
							// cant find either method - don't do anything.
573
						}
574
					}
575
					
550
					
576
					if (splashShell == null)
551
					if (splashShell == null)
577
						return;
552
						return;
(-)src/org/eclipse/ui/internal/ide/application/IDEApplication.java (-8 / +15 lines)
Lines 35-40 Link Here
35
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.swt.widgets.Shell;
36
import org.eclipse.ui.IWorkbench;
36
import org.eclipse.ui.IWorkbench;
37
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
38
import org.eclipse.ui.internal.WorkbenchPlugin;
38
import org.eclipse.ui.internal.ide.ChooseWorkspaceData;
39
import org.eclipse.ui.internal.ide.ChooseWorkspaceData;
39
import org.eclipse.ui.internal.ide.ChooseWorkspaceDialog;
40
import org.eclipse.ui.internal.ide.ChooseWorkspaceDialog;
40
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
41
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
Lines 86-95 Link Here
86
        Display display = createDisplay();
87
        Display display = createDisplay();
87
88
88
        try {
89
        try {
89
            Shell shell = new Shell(display, SWT.ON_TOP);
90
        	boolean parentChooserOnShell = true;
91
        	Shell shell = WorkbenchPlugin.getSplashShell(display);
92
        	if (shell == null) {
93
        		shell = new Shell(display, SWT.ON_TOP);
94
        		parentChooserOnShell = false;
95
        	}
90
96
91
            try {
97
            try {
92
                if (!checkInstanceLocation(shell)) {
98
                if (!checkInstanceLocation(shell, parentChooserOnShell)) {
93
                    Platform.endSplash();
99
                    Platform.endSplash();
94
                    return EXIT_OK;
100
                    return EXIT_OK;
95
                }
101
                }
Lines 147-157 Link Here
147
    /**
153
    /**
148
     * Return true if a valid workspace path has been set and false otherwise.
154
     * Return true if a valid workspace path has been set and false otherwise.
149
     * Prompt for and set the path if possible and required.
155
     * Prompt for and set the path if possible and required.
156
     * @param parentChooserOnShell whether the workspace chooser should be parented on this shell 
150
     * 
157
     * 
151
     * @return true if a valid instance location has been set and false
158
     * @return true if a valid instance location has been set and false
152
     *         otherwise
159
     *         otherwise
153
     */
160
     */
154
    private boolean checkInstanceLocation(Shell shell) {
161
    private boolean checkInstanceLocation(Shell shell, boolean parentChooserOnShell) {
155
        // -data @none was specified but an ide requires workspace
162
        // -data @none was specified but an ide requires workspace
156
        Location instanceLoc = Platform.getInstanceLocation();
163
        Location instanceLoc = Platform.getInstanceLocation();
157
        if (instanceLoc == null) {
164
        if (instanceLoc == null) {
Lines 213-219 Link Here
213
220
214
        boolean force = false;
221
        boolean force = false;
215
        while (true) {
222
        while (true) {
216
            URL workspaceUrl = promptForWorkspace(shell, launchData, force);
223
            URL workspaceUrl = promptForWorkspace(shell, launchData, force, parentChooserOnShell);
217
            if (workspaceUrl == null) {
224
            if (workspaceUrl == null) {
218
				return false;
225
				return false;
219
			}
226
			}
Lines 257-272 Link Here
257
     * @param force
264
     * @param force
258
     *            setting to true makes the dialog open regardless of the
265
     *            setting to true makes the dialog open regardless of the
259
     *            showDialog value
266
     *            showDialog value
267
     * @param parentChooserOnShell whether the chooser should be parented on the provided shell or not
260
     * @return An URL storing the selected workspace or null if the user has
268
     * @return An URL storing the selected workspace or null if the user has
261
     *         canceled the launch operation.
269
     *         canceled the launch operation.
262
     */
270
     */
263
    private URL promptForWorkspace(Shell shell, ChooseWorkspaceData launchData,
271
    private URL promptForWorkspace(Shell shell, ChooseWorkspaceData launchData,
264
            boolean force) {
272
            boolean force, boolean parentChooserOnShell) {
265
        URL url = null;
273
        URL url = null;
266
        do {
274
        do {
267
        	// don't use the parent shell to make the dialog a top-level
275
        	// okay to use the shell now - this is the splash shell
268
        	// shell. See bug 84881.
276
            new ChooseWorkspaceDialog(parentChooserOnShell ? shell : null, launchData, false, true).prompt(force);
269
            new ChooseWorkspaceDialog(null, launchData, false, true).prompt(force);
270
            String instancePath = launchData.getSelection();
277
            String instancePath = launchData.getSelection();
271
            if (instancePath == null) {
278
            if (instancePath == null) {
272
				return null;
279
				return null;

Return to bug 109290