View | Details | Raw Unified | Return to bug 4922 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/ide/ChooseWorkspaceData.java (-3 / +63 lines)
Lines 69-75 Link Here
69
    /**
69
    /**
70
	 * This is the second version of the encode/decode protocol that uses the
70
	 * This is the second version of the encode/decode protocol that uses the
71
	 * confi area preferences store for persistence. This version is the same as
71
	 * confi area preferences store for persistence. This version is the same as
72
	 * the previous version except it uses a \n character to seperate the path
72
	 * the previous version except it uses a \n character to separate the path
73
	 * entries instead of commas. (see bug 98467)
73
	 * entries instead of commas. (see bug 98467)
74
	 * 
74
	 * 
75
	 * @since 3.3.1
75
	 * @since 3.3.1
Lines 83-88 Link Here
83
    private String selection;
83
    private String selection;
84
84
85
    private String[] recentWorkspaces;
85
    private String[] recentWorkspaces;
86
    
87
    /**
88
     * The port on which an instance of this configuration is already listening for remote communication.
89
     * This value is 0 if nobody is already listening.
90
     */
91
    private int port = 0;
92
    /**
93
     * An authorization integer that a client must provide when communication with
94
     * this application. This is a simple security measure to prevent a port scanner 
95
     * from executing commands in this application.
96
     */
97
    private int ipcAuth = 0;
86
98
87
    // xml tags
99
    // xml tags
88
    private static interface XML {
100
    private static interface XML {
Lines 101-107 Link Here
101
        public static final String MAX_LENGTH = "maxLength"; //$NON-NLS-1$
113
        public static final String MAX_LENGTH = "maxLength"; //$NON-NLS-1$
102
114
103
        public static final String PATH = "path"; //$NON-NLS-1$
115
        public static final String PATH = "path"; //$NON-NLS-1$
104
    }
116
117
        public static final String PORT= "port"; //$NON-NLS-1$
118
119
        public static final String IPC_AUTH= "ipcAuth"; //$NON-NLS-1$
120
}
105
121
106
    /**
122
    /**
107
     * Creates a new instance, loading persistent data if its found.
123
     * Creates a new instance, loading persistent data if its found.
Lines 151-156 Link Here
151
		}
167
		}
152
        initialDefault = dir;
168
        initialDefault = dir;
153
    }
169
    }
170
    
171
    /**
172
     * Sets the port on which an instance is listening for remote communication.
173
     * @param port The port, or 0 to indicate not listening.
174
     */
175
    public void setPort(int port) {
176
    	this.port = port;
177
    }
178
    
179
    /**
180
     * Sets an authorization integer that a client must provide to establish
181
     * remote communication.  This is used to prevent a port sniffer from
182
     * executing commands.
183
     */
184
    public void setIPCAuthorization(int auth) {
185
    	this.ipcAuth = auth;
186
    }
154
187
155
    /**
188
    /**
156
     * Return the currently selected workspace or null if nothing is selected.
189
     * Return the currently selected workspace or null if nothing is selected.
Lines 173-178 Link Here
173
    public String[] getRecentWorkspaces() {
206
    public String[] getRecentWorkspaces() {
174
        return recentWorkspaces;
207
        return recentWorkspaces;
175
    }
208
    }
209
    
210
    /**
211
     * Returns the port on which an instance of this same configuration is
212
     * already listening for remote communication, or 0 if nobody is listening.
213
     * @return The port number, or 0.
214
     */
215
    public int getPort() {
216
    	return port;
217
    }
218
    
219
    /**
220
     * Returns the authorization integer for establishing interprocess communication.
221
     * @return The authorization integer
222
     */
223
    public int getIPCAuthorization() {
224
    	return ipcAuth;
225
    }
176
226
177
    /**
227
    /**
178
     * The argument workspace has been selected, update the receiver.  Does not
228
     * The argument workspace has been selected, update the receiver.  Does not
Lines 230-237 Link Here
230
		// 5. store the protocol version used to encode the list
280
		// 5. store the protocol version used to encode the list
231
		node.putInt(IDE.Preferences.RECENT_WORKSPACES_PROTOCOL,
281
		node.putInt(IDE.Preferences.RECENT_WORKSPACES_PROTOCOL,
232
				PERS_ENCODING_VERSION_CONFIG_PREFS_NO_COMMAS);
282
				PERS_ENCODING_VERSION_CONFIG_PREFS_NO_COMMAS);
283
		
284
		// 6. store the interprocess communication data, if any
285
		if (port != 0) {
286
			node.putInt(XML.PORT, port);
287
			node.putInt(XML.IPC_AUTH, ipcAuth);
288
		}
233
289
234
		// 6. store the node
290
		// 7. store the node
235
		try {
291
		try {
236
			node.flush();
292
			node.flush();
237
		} catch (BackingStoreException e) {
293
		} catch (BackingStoreException e) {
Lines 405-410 Link Here
405
				.getString(IDE.Preferences.RECENT_WORKSPACES);
461
				.getString(IDE.Preferences.RECENT_WORKSPACES);
406
		recentWorkspaces = decodeStoredWorkspacePaths(protocol, max, workspacePathPref);
462
		recentWorkspaces = decodeStoredWorkspacePaths(protocol, max, workspacePathPref);
407
463
464
		// 5. load the interprocess communication data
465
		port = store.getInt(XML.PORT);
466
		ipcAuth = store.getInt(XML.IPC_AUTH);
467
		
408
		return true;
468
		return true;
409
	}
469
	}
410
470
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 13-19 Link Here
13
 org.eclipse.ui.navigator.resources;bundle-version="[3.2.100,4.0.0)",
13
 org.eclipse.ui.navigator.resources;bundle-version="[3.2.100,4.0.0)",
14
 org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)",
14
 org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)",
15
 org.eclipse.update.core;bundle-version="[3.1.100,4.0.0)",
15
 org.eclipse.update.core;bundle-version="[3.1.100,4.0.0)",
16
 com.ibm.icu;bundle-version="3.8.1"
16
 com.ibm.icu;bundle-version="3.8.1",
17
 org.eclipse.core.filesystem;bundle-version="1.2.0"
17
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
18
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
18
 org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true
19
 org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true
19
Bundle-RequiredExecutionEnvironment: J2SE-1.4
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/ui/internal/ide/application/IDEWorkbenchAdvisor.java (-227 / +130 lines)
Lines 10-43 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.ide.application;
11
package org.eclipse.ui.internal.ide.application;
12
12
13
import org.eclipse.ui.PartInitException;
14
15
import com.ibm.icu.text.Collator;
13
import java.lang.reflect.InvocationTargetException;
16
import java.lang.reflect.InvocationTargetException;
14
import java.net.URL;
17
import java.net.URL;
15
import java.util.ArrayList;
18
import java.util.*;
16
import java.util.Iterator;
19
import org.eclipse.core.filesystem.EFS;
17
import java.util.Map;
18
import java.util.TreeMap;
19
20
import org.eclipse.core.net.proxy.IProxyService;
20
import org.eclipse.core.net.proxy.IProxyService;
21
import org.eclipse.core.resources.IContainer;
21
import org.eclipse.core.resources.*;
22
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.runtime.*;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.resources.WorkspaceJob;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.FileLocator;
27
import org.eclipse.core.runtime.IAdaptable;
28
import org.eclipse.core.runtime.IBundleGroup;
29
import org.eclipse.core.runtime.IBundleGroupProvider;
30
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.MultiStatus;
33
import org.eclipse.core.runtime.Path;
34
import org.eclipse.core.runtime.Platform;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.core.runtime.jobs.Job;
37
import org.eclipse.jface.dialogs.ErrorDialog;
24
import org.eclipse.jface.dialogs.*;
38
import org.eclipse.jface.dialogs.IDialogSettings;
39
import org.eclipse.jface.dialogs.MessageDialog;
40
import org.eclipse.jface.dialogs.TrayDialog;
41
import org.eclipse.jface.operation.IRunnableWithProgress;
25
import org.eclipse.jface.operation.IRunnableWithProgress;
42
import org.eclipse.jface.preference.IPreferenceStore;
26
import org.eclipse.jface.preference.IPreferenceStore;
43
import org.eclipse.jface.resource.ImageDescriptor;
27
import org.eclipse.jface.resource.ImageDescriptor;
Lines 46-68 Link Here
46
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
47
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Display;
48
import org.eclipse.swt.widgets.Listener;
32
import org.eclipse.swt.widgets.Listener;
49
import org.eclipse.ui.PlatformUI;
33
import org.eclipse.ui.*;
50
import org.eclipse.ui.application.IWorkbenchConfigurer;
34
import org.eclipse.ui.application.*;
51
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
52
import org.eclipse.ui.application.WorkbenchAdvisor;
53
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
54
import org.eclipse.ui.ide.IDE;
35
import org.eclipse.ui.ide.IDE;
55
import org.eclipse.ui.internal.ISelectionConversionService;
36
import org.eclipse.ui.internal.*;
56
import org.eclipse.ui.internal.PluginActionBuilder;
37
import org.eclipse.ui.internal.ide.*;
57
import org.eclipse.ui.internal.Workbench;
58
import org.eclipse.ui.internal.ide.AboutInfo;
59
import org.eclipse.ui.internal.ide.IDEInternalPreferences;
60
import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
61
import org.eclipse.ui.internal.ide.IDESelectionConversionService;
62
import org.eclipse.ui.internal.ide.IDEWorkbenchActivityHelper;
63
import org.eclipse.ui.internal.ide.IDEWorkbenchErrorHandler;
64
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
65
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
66
import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
38
import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
67
import org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor;
39
import org.eclipse.ui.internal.ide.undo.WorkspaceUndoMonitor;
68
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
40
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
Lines 70-80 Link Here
70
import org.eclipse.ui.statushandlers.AbstractStatusHandler;
42
import org.eclipse.ui.statushandlers.AbstractStatusHandler;
71
import org.eclipse.ui.statushandlers.StatusManager;
43
import org.eclipse.ui.statushandlers.StatusManager;
72
import org.eclipse.update.core.SiteManager;
44
import org.eclipse.update.core.SiteManager;
73
import org.osgi.framework.Bundle;
45
import org.osgi.framework.*;
74
import org.osgi.framework.ServiceReference;
75
import org.osgi.framework.Version;
76
77
import com.ibm.icu.text.Collator;
78
46
79
/**
47
/**
80
 * IDE-specified workbench advisor which configures the workbench for use as an
48
 * IDE-specified workbench advisor which configures the workbench for use as an
Lines 128-134 Link Here
128
	private IDEIdleHelper idleHelper;
96
	private IDEIdleHelper idleHelper;
129
97
130
	private Listener settingsChangeListener;
98
	private Listener settingsChangeListener;
131
	
99
132
	/**
100
	/**
133
	 * Support class for monitoring workspace changes and periodically
101
	 * Support class for monitoring workspace changes and periodically
134
	 * validating the undo history
102
	 * validating the undo history
Lines 140-145 Link Here
140
	 */
108
	 */
141
	private AbstractStatusHandler ideWorkbenchErrorHandler;
109
	private AbstractStatusHandler ideWorkbenchErrorHandler;
142
110
111
	static IDEWorkbenchAdvisor getInstance() {
112
		return workbenchAdvisor;
113
	}
114
143
	/**
115
	/**
144
	 * Creates a new workbench advisor instance.
116
	 * Creates a new workbench advisor instance.
145
	 */
117
	 */
Lines 159-165 Link Here
159
	public void initialize(IWorkbenchConfigurer configurer) {
131
	public void initialize(IWorkbenchConfigurer configurer) {
160
132
161
		PluginActionBuilder.setAllowIdeLogging(true);
133
		PluginActionBuilder.setAllowIdeLogging(true);
162
		
134
163
		// make sure we always save and restore workspace state
135
		// make sure we always save and restore workspace state
164
		configurer.setSaveAndRestore(true);
136
		configurer.setSaveAndRestore(true);
165
137
Lines 186-192 Link Here
186
			}
158
			}
187
		}
159
		}
188
160
189
		// register shared images
190
		declareWorkbenchImages();
161
		declareWorkbenchImages();
191
162
192
		// initialize the activity helper
163
		// initialize the activity helper
Lines 194-200 Link Here
194
165
195
		// initialize idle handler
166
		// initialize idle handler
196
		idleHelper = new IDEIdleHelper(configurer);
167
		idleHelper = new IDEIdleHelper(configurer);
197
		
168
198
		// initialize the workspace undo monitor
169
		// initialize the workspace undo monitor
199
		workspaceUndoMonitor = WorkspaceUndoMonitor.getInstance();
170
		workspaceUndoMonitor = WorkspaceUndoMonitor.getInstance();
200
171
Lines 215-228 Link Here
215
		Job.getJobManager().suspend();
186
		Job.getJobManager().suspend();
216
187
217
		// Register the build actions
188
		// Register the build actions
218
		IProgressService service = PlatformUI.getWorkbench()
189
		IProgressService service = PlatformUI.getWorkbench().getProgressService();
219
				.getProgressService();
190
		ImageDescriptor newImage = IDEInternalWorkbenchImages.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC);
220
		ImageDescriptor newImage = IDEInternalWorkbenchImages
191
		service.registerIconForFamily(newImage, ResourcesPlugin.FAMILY_MANUAL_BUILD);
221
				.getImageDescriptor(IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC);
192
		service.registerIconForFamily(newImage, ResourcesPlugin.FAMILY_AUTO_BUILD);
222
		service.registerIconForFamily(newImage,
223
				ResourcesPlugin.FAMILY_MANUAL_BUILD);
224
		service.registerIconForFamily(newImage,
225
				ResourcesPlugin.FAMILY_AUTO_BUILD);
226
	}
193
	}
227
194
228
	/*
195
	/*
Lines 235-253 Link Here
235
			refreshFromLocal();
202
			refreshFromLocal();
236
			activateProxyService();
203
			activateProxyService();
237
			checkUpdates();
204
			checkUpdates();
238
			((Workbench) PlatformUI.getWorkbench()).registerService(
205
			((Workbench) PlatformUI.getWorkbench()).registerService(ISelectionConversionService.class, new IDESelectionConversionService());
239
					ISelectionConversionService.class,
240
					new IDESelectionConversionService());
241
206
242
			initializeSettingsChangeListener();
207
			initializeSettingsChangeListener();
243
			Display.getCurrent().addListener(SWT.Settings,
208
			Display.getCurrent().addListener(SWT.Settings, settingsChangeListener);
244
					settingsChangeListener);
209
			runStartupCommand(Platform.getCommandLineArgs());
245
		} finally {// Resume background jobs after we startup
210
		} finally {// Resume background jobs after we startup
246
			Job.getJobManager().resume();
211
			Job.getJobManager().resume();
247
		}
212
		}
248
	}
213
	}
249
214
250
	/**
215
	/**
216
	 * Runs a command specified on the command line, if any
217
	 */
218
	boolean runStartupCommand(String[] arguments) {
219
		if (arguments.length == 0)
220
			return false;
221
		//if the last command line argument is a file, open that file in an editor
222
		final IPath path = new Path(arguments[arguments.length - 1]);
223
		if (!path.toFile().exists())
224
			return false;
225
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
226
		if (window == null) {
227
			IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
228
			if (windows.length > 0)
229
				window = windows[0];
230
		}
231
		if (window == null)
232
			return false;
233
		final IWorkbenchPage page = window.getActivePage();
234
		if (page == null)
235
			return false;
236
		window.getShell().getDisplay().syncExec(new Runnable() {
237
			public void run() {
238
				try {
239
					IDE.openEditorOnFileStore(page, EFS.getLocalFileSystem().getStore(path));
240
				} catch (PartInitException e) {
241
					IDEWorkbenchPlugin.log("Error opening editor on path: " + path, e); //$NON-NLS-1$
242
				}
243
			}
244
		});
245
		return true;
246
	}
247
248
	/**
251
	 * Activate the proxy service by obtaining it.
249
	 * Activate the proxy service by obtaining it.
252
	 */
250
	 */
253
	private void activateProxyService() {
251
	private void activateProxyService() {
Lines 260-266 Link Here
260
		}
258
		}
261
		if (proxyService == null) {
259
		if (proxyService == null) {
262
			IDEWorkbenchPlugin.log("Proxy service could not be found."); //$NON-NLS-1$
260
			IDEWorkbenchPlugin.log("Proxy service could not be found."); //$NON-NLS-1$
263
		}	
261
		}
264
	}
262
	}
265
263
266
	/**
264
	/**
Lines 269-276 Link Here
269
	private void initializeSettingsChangeListener() {
267
	private void initializeSettingsChangeListener() {
270
		settingsChangeListener = new Listener() {
268
		settingsChangeListener = new Listener() {
271
269
272
			boolean currentHighContrast = Display.getCurrent()
270
			boolean currentHighContrast = Display.getCurrent().getHighContrast();
273
					.getHighContrast();
274
271
275
			public void handleEvent(org.eclipse.swt.widgets.Event event) {
272
			public void handleEvent(org.eclipse.swt.widgets.Event event) {
276
				if (Display.getCurrent().getHighContrast() == currentHighContrast)
273
				if (Display.getCurrent().getHighContrast() == currentHighContrast)
Lines 279-291 Link Here
279
				currentHighContrast = !currentHighContrast;
276
				currentHighContrast = !currentHighContrast;
280
277
281
				// make sure they really want to do this
278
				// make sure they really want to do this
282
				if (new MessageDialog(null,
279
				if (new MessageDialog(null, IDEWorkbenchMessages.SystemSettingsChange_title, null, IDEWorkbenchMessages.SystemSettingsChange_message, MessageDialog.QUESTION, new String[] {IDEWorkbenchMessages.SystemSettingsChange_yes, IDEWorkbenchMessages.SystemSettingsChange_no}, 1).open() == Window.OK) {
283
						IDEWorkbenchMessages.SystemSettingsChange_title, null,
284
						IDEWorkbenchMessages.SystemSettingsChange_message,
285
						MessageDialog.QUESTION, new String[] {
286
								IDEWorkbenchMessages.SystemSettingsChange_yes,
287
								IDEWorkbenchMessages.SystemSettingsChange_no },
288
						1).open() == Window.OK) {
289
					PlatformUI.getWorkbench().restart();
280
					PlatformUI.getWorkbench().restart();
290
				}
281
				}
291
			}
282
			}
Lines 322-329 Link Here
322
	 * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
313
	 * @see org.eclipse.ui.application.WorkbenchAdvisor#preShutdown()
323
	 */
314
	 */
324
	public boolean preShutdown() {
315
	public boolean preShutdown() {
325
		Display.getCurrent().removeListener(SWT.Settings,
316
		Display.getCurrent().removeListener(SWT.Settings, settingsChangeListener);
326
				settingsChangeListener);
327
		return super.preShutdown();
317
		return super.preShutdown();
328
	}
318
	}
329
319
Lines 332-339 Link Here
332
	 * 
322
	 * 
333
	 * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
323
	 * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
334
	 */
324
	 */
335
	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
325
	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
336
			IWorkbenchWindowConfigurer configurer) {
337
		return new IDEWorkbenchWindowAdvisor(this, configurer);
326
		return new IDEWorkbenchWindowAdvisor(this, configurer);
338
	}
327
	}
339
328
Lines 343-358 Link Here
343
	 * @return boolean
332
	 * @return boolean
344
	 */
333
	 */
345
	public boolean hasIntro() {
334
	public boolean hasIntro() {
346
		return getWorkbenchConfigurer().getWorkbench().getIntroManager()
335
		return getWorkbenchConfigurer().getWorkbench().getIntroManager().hasIntro();
347
				.hasIntro();
348
	}
336
	}
349
337
350
	private void refreshFromLocal() {
338
	private void refreshFromLocal() {
351
		String[] commandLineArgs = Platform.getCommandLineArgs();
339
		String[] commandLineArgs = Platform.getCommandLineArgs();
352
		IPreferenceStore store = IDEWorkbenchPlugin.getDefault()
340
		IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
353
				.getPreferenceStore();
341
		boolean refresh = store.getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
354
		boolean refresh = store
355
				.getBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP);
356
		if (!refresh) {
342
		if (!refresh) {
357
			return;
343
			return;
358
		}
344
		}
Lines 366-373 Link Here
366
352
367
		final IContainer root = ResourcesPlugin.getWorkspace().getRoot();
353
		final IContainer root = ResourcesPlugin.getWorkspace().getRoot();
368
		Job job = new WorkspaceJob(IDEWorkbenchMessages.Workspace_refreshing) {
354
		Job job = new WorkspaceJob(IDEWorkbenchMessages.Workspace_refreshing) {
369
			public IStatus runInWorkspace(IProgressMonitor monitor)
355
			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
370
					throws CoreException {
371
				root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
356
				root.refreshLocal(IResource.DEPTH_INFINITE, monitor);
372
				return Status.OK_STATUS;
357
				return Status.OK_STATUS;
373
			}
358
			}
Lines 381-394 Link Here
381
	 */
366
	 */
382
	private void disconnectFromWorkspace() {
367
	private void disconnectFromWorkspace() {
383
		// save the workspace
368
		// save the workspace
384
		final MultiStatus status = new MultiStatus(
369
		final MultiStatus status = new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH, 1, IDEWorkbenchMessages.ProblemSavingWorkbench, null);
385
				IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
386
				IDEWorkbenchMessages.ProblemSavingWorkbench, null);
387
		IRunnableWithProgress runnable = new IRunnableWithProgress() {
370
		IRunnableWithProgress runnable = new IRunnableWithProgress() {
388
			public void run(IProgressMonitor monitor) {
371
			public void run(IProgressMonitor monitor) {
389
				try {
372
				try {
390
					status.merge(ResourcesPlugin.getWorkspace().save(true,
373
					status.merge(ResourcesPlugin.getWorkspace().save(true, monitor));
391
							monitor));
392
				} catch (CoreException e) {
374
				} catch (CoreException e) {
393
					status.merge(e.getStatus());
375
					status.merge(e.getStatus());
394
				}
376
				}
Lines 397-418 Link Here
397
		try {
379
		try {
398
			new ProgressMonitorJobsDialog(null).run(true, false, runnable);
380
			new ProgressMonitorJobsDialog(null).run(true, false, runnable);
399
		} catch (InvocationTargetException e) {
381
		} catch (InvocationTargetException e) {
400
			status
382
			status.merge(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 1, IDEWorkbenchMessages.InternalError, e.getTargetException()));
401
					.merge(new Status(IStatus.ERROR,
402
							IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
403
							IDEWorkbenchMessages.InternalError, e
404
									.getTargetException()));
405
		} catch (InterruptedException e) {
383
		} catch (InterruptedException e) {
406
			status.merge(new Status(IStatus.ERROR,
384
			status.merge(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 1, IDEWorkbenchMessages.InternalError, e));
407
					IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
385
		}
408
					IDEWorkbenchMessages.InternalError, e));
386
		ErrorDialog.openError(null, IDEWorkbenchMessages.ProblemsSavingWorkspace, null, status, IStatus.ERROR | IStatus.WARNING);
409
		}
410
		ErrorDialog.openError(null,
411
				IDEWorkbenchMessages.ProblemsSavingWorkspace, null, status,
412
				IStatus.ERROR | IStatus.WARNING);
413
		if (!status.isOK()) {
387
		if (!status.isOK()) {
414
			IDEWorkbenchPlugin.log(
388
			IDEWorkbenchPlugin.log(IDEWorkbenchMessages.ProblemsSavingWorkspace, status);
415
					IDEWorkbenchMessages.ProblemsSavingWorkspace, status);
416
		}
389
		}
417
	}
390
	}
418
391
Lines 519-526 Link Here
519
	 */
492
	 */
520
	private Map createNewBundleGroupsMap() {
493
	private Map createNewBundleGroupsMap() {
521
		// retrieve list of installed bundle groups from last session
494
		// retrieve list of installed bundle groups from last session
522
		IDialogSettings settings = IDEWorkbenchPlugin.getDefault()
495
		IDialogSettings settings = IDEWorkbenchPlugin.getDefault().getDialogSettings();
523
				.getDialogSettings();
524
		String[] previousFeaturesArray = settings.getArray(INSTALLED_FEATURES);
496
		String[] previousFeaturesArray = settings.getArray(INSTALLED_FEATURES);
525
497
526
		// get a map of currently installed bundle groups and store it for next
498
		// get a map of currently installed bundle groups and store it for next
Lines 573-657 Link Here
573
545
574
		Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
546
		Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
575
547
576
		declareWorkbenchImage(ideBundle,
548
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
577
				IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL
549
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER, PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
578
						+ "build_exec.gif", false); //$NON-NLS-1$
550
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED, PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
579
		declareWorkbenchImage(ideBundle,
551
580
				IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
552
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
581
				PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
553
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER, PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
582
		declareWorkbenchImage(ideBundle,
554
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED, PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
583
				IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
555
584
				PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
556
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL + "next_nav.gif", false); //$NON-NLS-1$
585
557
586
		declareWorkbenchImage(ideBundle,
558
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$
587
				IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL
559
588
						+ "search_src.gif", false); //$NON-NLS-1$
560
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$
589
		declareWorkbenchImage(ideBundle,
561
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ, PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
590
				IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
562
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$
591
				PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
563
592
		declareWorkbenchImage(ideBundle,
564
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ, PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
593
				IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
565
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ, PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
594
				PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
566
595
567
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ, PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
596
		declareWorkbenchImage(ideBundle,
568
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ, PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
597
				IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
569
598
						+ "next_nav.gif", false); //$NON-NLS-1$
570
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
599
571
600
		declareWorkbenchImage(ideBundle,
572
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$
601
				IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL
573
602
						+ "prev_nav.gif", false); //$NON-NLS-1$
574
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$
603
575
604
		declareWorkbenchImage(ideBundle,
576
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
605
				IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN
577
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT + "cprj_obj.gif", true); //$NON-NLS-1$
606
						+ "newprj_wiz.png", false); //$NON-NLS-1$
578
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
607
		declareWorkbenchImage(ideBundle,
579
608
				IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
580
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED, PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
609
				PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
581
610
		declareWorkbenchImage(ideBundle,
582
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED, PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
611
				IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN
612
						+ "newfile_wiz.png", false); //$NON-NLS-1$
613
614
		declareWorkbenchImage(ideBundle,
615
				IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
616
				PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
617
		declareWorkbenchImage(ideBundle,
618
				IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
619
				PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
620
621
		declareWorkbenchImage(ideBundle,
622
				IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
623
				PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
624
		declareWorkbenchImage(ideBundle,
625
				IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
626
				PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
627
628
		declareWorkbenchImage(ideBundle,
629
				IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ,
630
				PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
631
632
		declareWorkbenchImage(ideBundle,
633
				IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN
634
						+ "saveas_wiz.png", false); //$NON-NLS-1$
635
636
		declareWorkbenchImage(ideBundle,
637
				IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN
638
						+ "quick_fix.png", false); //$NON-NLS-1$
639
640
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT,
641
				PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
642
		declareWorkbenchImage(ideBundle,
643
				IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
644
						+ "cprj_obj.gif", true); //$NON-NLS-1$
645
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER,
646
				PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
647
648
		declareWorkbenchImage(ideBundle,
649
				IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
650
				PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
651
652
		declareWorkbenchImage(ideBundle,
653
				IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
654
				PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
655
583
656
		// task objects
584
		// task objects
657
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
585
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
Lines 661-703 Link Here
661
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
589
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
662
		// PATH_OBJECT+"lprio_tsk.gif");
590
		// PATH_OBJECT+"lprio_tsk.gif");
663
591
664
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK,
592
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
665
				PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
593
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
666
		declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK,
594
667
				PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
595
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$
668
596
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$
669
		declareWorkbenchImage(ideBundle,
597
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$
670
				IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT
598
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$
671
						+ "complete_tsk.gif", true); //$NON-NLS-1$
599
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$
672
		declareWorkbenchImage(ideBundle,
600
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$
673
				IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT
601
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT + "info_tsk.gif", true); //$NON-NLS-1$
674
						+ "incomplete_tsk.gif", true); //$NON-NLS-1$
602
675
		declareWorkbenchImage(ideBundle,
603
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$
676
				IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT
604
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT, PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
677
						+ "welcome_item.gif", true); //$NON-NLS-1$
605
		declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY, PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
678
		declareWorkbenchImage(ideBundle,
606
679
				IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT
680
						+ "welcome_banner.gif", true); //$NON-NLS-1$
681
		declareWorkbenchImage(ideBundle,
682
				IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT
683
						+ "error_tsk.gif", true); //$NON-NLS-1$
684
		declareWorkbenchImage(ideBundle,
685
				IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT
686
						+ "warn_tsk.gif", true); //$NON-NLS-1$
687
		declareWorkbenchImage(ideBundle,
688
				IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
689
						+ "info_tsk.gif", true); //$NON-NLS-1$
690
691
		declareWorkbenchImage(ideBundle,
692
				IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL
693
						+ "flatLayout.gif", true); //$NON-NLS-1$
694
		declareWorkbenchImage(ideBundle,
695
				IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
696
				PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
697
		declareWorkbenchImage(ideBundle,
698
				IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
699
				PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
700
	
701
		// synchronization indicator objects
607
		// synchronization indicator objects
702
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
608
		// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_WBET_STAT,
703
		// PATH_OVERLAY+"wbet_stat.gif");
609
		// PATH_OVERLAY+"wbet_stat.gif");
Lines 728-735 Link Here
728
	 *            <code>false</code> if this is not a shared image
634
	 *            <code>false</code> if this is not a shared image
729
	 * @see IWorkbenchConfigurer#declareImage
635
	 * @see IWorkbenchConfigurer#declareImage
730
	 */
636
	 */
731
	private void declareWorkbenchImage(Bundle ideBundle, String symbolicName,
637
	private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) {
732
			String path, boolean shared) {
733
		URL url = FileLocator.find(ideBundle, new Path(path), null);
638
		URL url = FileLocator.find(ideBundle, new Path(path), null);
734
		ImageDescriptor desc = ImageDescriptor.createFromURL(url);
639
		ImageDescriptor desc = ImageDescriptor.createFromURL(url);
735
		getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
640
		getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
Lines 765-772 Link Here
765
				ArrayList list = new ArrayList(m.size());
670
				ArrayList list = new ArrayList(m.size());
766
				for (Iterator i = m.values().iterator(); i.hasNext();) {
671
				for (Iterator i = m.values().iterator(); i.hasNext();) {
767
					AboutInfo info = (AboutInfo) i.next();
672
					AboutInfo info = (AboutInfo) i.next();
768
					if (info != null && info.getWelcomePerspectiveId() != null
673
					if (info != null && info.getWelcomePerspectiveId() != null && info.getWelcomePageURL() != null) {
769
							&& info.getWelcomePageURL() != null) {
770
						list.add(info);
674
						list.add(info);
771
					}
675
					}
772
				}
676
				}
Lines 784-791 Link Here
784
	 */
688
	 */
785
	public AbstractStatusHandler getWorkbenchErrorHandler() {
689
	public AbstractStatusHandler getWorkbenchErrorHandler() {
786
		if (ideWorkbenchErrorHandler == null) {
690
		if (ideWorkbenchErrorHandler == null) {
787
			ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(
691
			ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(getWorkbenchConfigurer());
788
					getWorkbenchConfigurer());
789
		}
692
		}
790
		return ideWorkbenchErrorHandler;
693
		return ideWorkbenchErrorHandler;
791
	}
694
	}
(-)src/org/eclipse/ui/internal/ide/application/IDEApplication.java (-1 / +15 lines)
Lines 105-111 Link Here
105
                Platform.endSplash();
105
                Platform.endSplash();
106
                return EXIT_OK;
106
                return EXIT_OK;
107
            }
107
            }
108
108
            
109
            // create the workbench with this advisor and run it until it exits
109
            // create the workbench with this advisor and run it until it exits
110
            // N.B. createWorkbench remembers the advisor, and also registers
110
            // N.B. createWorkbench remembers the advisor, and also registers
111
            // the workbench globally so that all UI plug-ins can find it using
111
            // the workbench globally so that all UI plug-ins can find it using
Lines 217-222 Link Here
217
        // -data @noDefault or -data not specified, prompt and set
217
        // -data @noDefault or -data not specified, prompt and set
218
        ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc
218
        ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc
219
                .getDefault());
219
                .getDefault());
220
        
221
        //check if someone is listening that we can pass our command line to
222
        if (launchData.getPort() != 0) {
223
        	if (new IDECommunication().writeToPort(launchData.getPort(), launchData.getIPCAuthorization())) {
224
        		//we successfully punted this application's command line to another instance,
225
        		//so we can just shutdown this instance.
226
        		return false;
227
        	}
228
        }
220
229
221
        boolean force = false;
230
        boolean force = false;
222
        while (true) {
231
        while (true) {
Lines 233-238 Link Here
233
                // the operation will fail if the url is not a valid
242
                // the operation will fail if the url is not a valid
234
                // instance data area, so other checking is unneeded
243
                // instance data area, so other checking is unneeded
235
                if (instanceLoc.setURL(workspaceUrl, true)) {
244
                if (instanceLoc.setURL(workspaceUrl, true)) {
245
                    int[] ipcData = new IDECommunication().listen();
246
                    if (ipcData != null) {
247
                    	launchData.setPort(ipcData[0]);
248
                    	launchData.setIPCAuthorization(ipcData[1]);
249
                    }
236
                    launchData.writePersistedData();
250
                    launchData.writePersistedData();
237
                    writeWorkspaceVersion();
251
                    writeWorkspaceVersion();
238
                    return true;
252
                    return true;
(-)src/org/eclipse/ui/internal/ide/application/IDECommunication.java (+208 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 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
12
package org.eclipse.ui.internal.ide.application;
13
14
import java.security.SecureRandom;
15
16
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
17
18
import java.io.*;
19
import java.net.*;
20
import org.eclipse.core.runtime.*;
21
import org.eclipse.core.runtime.jobs.Job;
22
23
/**
24
 * A helper class that deals with interprocess communication between applications.
25
 * <p>
26
 * This class uses a socket connection on a random available port to establish
27
 * communication between applications. The client must provide an authorization
28
 * code to protect against communication from arbitrary port sniffing applications.
29
 * 
30
 * @since 3.5
31
 */
32
class IDECommunication {
33
	/**
34
	 * A job that listens on a socket for a command, and then invokes the
35
	 * workbench advisor to handle the command.
36
	 */
37
	class ListenJob extends Job {
38
		private ServerSocket server;
39
		private int auth;
40
41
		public ListenJob(ServerSocket server, int auth) {
42
			super("Listen"); //$NON-NLS-1$
43
			this.server = server;
44
			this.auth = auth;
45
			setSystem(true);
46
		}
47
48
		/* (non-Javadoc)
49
		 * @see org.eclipse.core.runtime.jobs.Job#canceling()
50
		 */
51
		protected void canceling() {
52
			try {
53
				server.close();
54
			} catch (IOException e) {
55
				//ignore
56
			}
57
		}
58
59
		/* (non-Javadoc)
60
		 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
61
		 */
62
		protected IStatus run(IProgressMonitor monitor) {
63
			if (server.isClosed())
64
				return Status.OK_STATUS;
65
			Socket client = null;
66
			DataInputStream in = null;
67
			DataOutputStream out = null;
68
			try {
69
				client = server.accept();
70
				in = new DataInputStream(client.getInputStream());
71
				out = new DataOutputStream(client.getOutputStream());
72
				//read the protocol version
73
				int version = in.readInt();
74
				String[] args = null;
75
				if (version == PROTOCOL_VERSION_ONE) {
76
					//read the authorization checksum
77
					int receivedAuth = in.readInt();
78
					//abort immediately if we failed to read the authorization integer
79
					if (receivedAuth != auth) {
80
						schedule(SCHEDULE_DELAY);
81
						return new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, "Connection from unauthorized client on port " + server.getLocalPort()); //$NON-NLS-1$
82
					}
83
					args = new String[in.readInt()];
84
					for (int i = 0; i < args.length; i++) {
85
						args[i] = in.readUTF();
86
					}
87
				}
88
				//pass the read arguments to the workbench advisor
89
				IDEWorkbenchAdvisor advisor = IDEWorkbenchAdvisor.getInstance();
90
				if (advisor != null && args != null) {
91
					if (advisor.runStartupCommand(args))
92
						out.writeUTF(OK);
93
					else
94
						out.writeUTF(FAIL);
95
				}
96
			} catch (IOException e) {
97
				IDEWorkbenchPlugin.log("Error communicating with client", e); //$NON-NLS-1$
98
			} finally {
99
				safeClose(in);
100
				safeClose(out);
101
				safeClose(client);
102
			}
103
			//reschedule
104
			schedule(SCHEDULE_DELAY);
105
			return Status.OK_STATUS;
106
		}
107
	}
108
109
	/**
110
	 * The first communication protocol version. This version contains an authorization
111
	 * integer followed by a list of command line arguments. The format is: int authorizationId, int N, String[N].
112
	 */
113
	private static final int PROTOCOL_VERSION_ONE = 1;
114
115
	private static final long SCHEDULE_DELAY = 1000;
116
117
	static final String OK = "OK"; //$NON-NLS-1$
118
	static final String FAIL = "FAIL"; //$NON-NLS-1$
119
120
	/**
121
	 * Start listening for commands.
122
	 * @return An integer array of size two. The first integer is the port
123
	 * number we are listening on, and the second integer is an authorization
124
	 * integer used to validate connections.  Returns <code>null</code> if
125
	 * there was a failure to establish communication
126
	 */
127
	public int[] listen() {
128
		try {
129
			ServerSocket server = new ServerSocket(0);
130
			int auth = new SecureRandom().nextInt();
131
			new ListenJob(server, auth).schedule(SCHEDULE_DELAY);
132
			return new int[] {server.getLocalPort(), auth};
133
		} catch (IOException e) {
134
			return null;
135
		}
136
	}
137
138
	/**
139
	 * Close the given stream and ignore secondary failures.
140
	 */
141
	void safeClose(DataInputStream in) {
142
		try {
143
			if (in != null)
144
				in.close();
145
		} catch (IOException e) {
146
			//ignore secondary failure while closing
147
		}
148
	}
149
150
	/**
151
	 * Close the given stream and ignore secondary failures.
152
	 */
153
	void safeClose(DataOutputStream out) {
154
		try {
155
			if (out != null)
156
				out.close();
157
		} catch (IOException e) {
158
			//ignore secondary failure while closing
159
		}
160
	}
161
162
	/**
163
	 * Close the given socket and ignore secondary failures.
164
	 */
165
	void safeClose(Socket socket) {
166
		try {
167
			if (socket != null)
168
				socket.close();
169
		} catch (IOException e) {
170
			//ignore secondary failure while closing
171
		}
172
	}
173
174
	/**
175
	 * Writes this application's command line arguments to the given port.
176
	 * 
177
	 * @param port The port to write data to
178
	 * @param auth The authorization integer
179
	 * @return <code>true</code> if written successfully, and <code>false</code> otherwise.
180
	 */
181
	public boolean writeToPort(int port, int auth) {
182
		Socket socket = null;
183
		DataOutputStream out = null;
184
		DataInputStream in = null;
185
		try {
186
			socket = new Socket("localhost", port);//$NON-NLS-1$
187
			out = new DataOutputStream(socket.getOutputStream());
188
			in = new DataInputStream(socket.getInputStream());
189
			out.writeInt(PROTOCOL_VERSION_ONE);
190
			out.writeInt(auth);
191
			String[] args = Platform.getCommandLineArgs();
192
			out.writeInt(args.length);
193
			for (int i = 0; i < args.length; i++)
194
				out.writeUTF(args[i]);
195
			//server will return OK or FAIL
196
			return in.readUTF().equals(OK);
197
		} catch (UnknownHostException e) {
198
			return false;
199
		} catch (IOException e) {
200
			return false;
201
		} finally {
202
			safeClose(socket);
203
			safeClose(out);
204
			safeClose(in);
205
		}
206
	}
207
208
}

Return to bug 4922