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

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 868-873 Link Here
868
	public static String UnsupportedVM_message;
868
	public static String UnsupportedVM_message;
869
	
869
	
870
	public static String IDEWorkbenchActivityHelper_jobName;
870
	public static String IDEWorkbenchActivityHelper_jobName;
871
	
872
	public static String OpenDelayedFileAction_title;
873
	public static String OpenDelayedFileAction_message_errorOnOpen;
874
	public static String OpenDelayedFileAction_message_fileNotFound;
871
875
872
	static {
876
	static {
873
		// load message values from bundle file
877
		// load message values from bundle file
(-)src/org/eclipse/ui/internal/ide/messages.properties (-2 / +7 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
2
# Copyright (c) 2000, 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 881-884 Link Here
881
SystemSettingsChange_no = No
881
SystemSettingsChange_no = No
882
882
883
UnsupportedVM_message=GCJ has been detected as the current Java virtual machine.  Use of GCJ is untested and unsupported.  Please consult the documentation for more information.
883
UnsupportedVM_message=GCJ has been detected as the current Java virtual machine.  Use of GCJ is untested and unsupported.  Please consult the documentation for more information.
884
IDEWorkbenchActivityHelper_jobName=Update Capability Enablement for Natures
884
IDEWorkbenchActivityHelper_jobName=Update Capability Enablement for Natures
885
886
OpenDelayedFileAction_title = Open File
887
OpenDelayedFileAction_message_errorOnOpen = The file ''{0}'' could not be opened.\nSee log for details.
888
OpenDelayedFileAction_message_fileNotFound= The file ''{0}'' could not be found.
889
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 12-18 Link Here
12
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
12
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
13
 org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
14
 org.eclipse.ui.navigator.resources;bundle-version="[3.4.0,4.0.0)",
14
 org.eclipse.ui.navigator.resources;bundle-version="[3.4.0,4.0.0)",
15
 org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)"
15
 org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)",
16
 org.eclipse.core.filesystem;bundle-version="1.3.0"
16
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
17
Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true,
17
 org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true
18
 org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true
18
Import-Package: com.ibm.icu.text
19
Import-Package: com.ibm.icu.text
(-)src/org/eclipse/ui/internal/ide/application/DelayedEventsProcessor.java (+115 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 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.util.ArrayList;
15
16
import org.eclipse.core.filesystem.EFS;
17
import org.eclipse.core.filesystem.IFileInfo;
18
import org.eclipse.core.filesystem.IFileStore;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.jface.dialogs.MessageDialog;
21
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.swt.widgets.Event;
25
import org.eclipse.swt.widgets.Listener;
26
import org.eclipse.ui.IWorkbenchPage;
27
import org.eclipse.ui.IWorkbenchWindow;
28
import org.eclipse.ui.PartInitException;
29
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.ide.IDE;
31
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
32
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
33
34
/**
35
 * Helper class used to process delayed events.
36
 * Events currently supported:
37
 * <ul>
38
 * <li>SWT.OpenDoc</li>
39
 * </ul>
40
 * @since 3.3
41
 */
42
public class DelayedEventsProcessor implements Listener {
43
44
	private ArrayList filesToOpen = new ArrayList(1);
45
46
	/**
47
	 * Constructor.
48
	 * @param display display used as a source of event
49
	 */
50
	public DelayedEventsProcessor(Display display) {
51
		display.addListener(SWT.OpenDoc, this);
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
56
	 */
57
	public void handleEvent(Event event) {
58
		final String path = event.text;
59
		if (path == null)
60
			return;
61
		synchronized (filesToOpen) {
62
			filesToOpen.add(path);
63
		}
64
	}
65
	
66
	/**
67
	 * Process delayed events.
68
	 * @param display display associated with the workbench 
69
	 */
70
	public void catchUp(Display display) {
71
		if (filesToOpen.isEmpty()) // intentionally done outside of the sync block to improve performance
72
			return;
73
		// make a local copy of the list, clear it, and release the lock ASAP
74
		String[] filePaths;
75
		synchronized (filesToOpen) {
76
			filePaths = new String[filesToOpen.size()];
77
			filesToOpen.toArray(filePaths);
78
			filesToOpen.clear();
79
		}
80
		for(int i = 0; i < filePaths.length; i++) {
81
			openFile(display, filePaths[i]);
82
		}
83
	}
84
85
	private void openFile(Display display, final String path) {
86
		display.asyncExec(new Runnable() {
87
			public void run() {
88
				IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
89
				if (window == null)
90
					return;
91
				IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));
92
				IFileInfo fetchInfo = fileStore.fetchInfo();
93
				if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
94
					IWorkbenchPage page = window.getActivePage();
95
					try {
96
						IDE.openEditorOnFileStore(page, fileStore);
97
					} catch (PartInitException e) {
98
						String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_errorOnOpen,
99
										fileStore.getName());
100
						IDEWorkbenchPlugin.log(msg, e.getStatus());
101
						MessageDialog.open(MessageDialog.ERROR, window.getShell(),
102
								IDEWorkbenchMessages.OpenDelayedFileAction_title,
103
								msg, SWT.SHEET);
104
					}
105
				} else {
106
					String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_fileNotFound, path);
107
					MessageDialog.open(MessageDialog.ERROR, window.getShell(),
108
							IDEWorkbenchMessages.OpenDelayedFileAction_title,
109
							msg, SWT.SHEET);
110
				}
111
			}
112
		});
113
	}
114
115
}
(-)src/org/eclipse/ui/internal/ide/application/IDEApplication.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
2
 * Copyright (c) 2003, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 86-91 Link Here
86
     */
86
     */
87
    public Object start(IApplicationContext appContext) throws Exception {
87
    public Object start(IApplicationContext appContext) throws Exception {
88
        Display display = createDisplay();
88
        Display display = createDisplay();
89
        // processor must be created before we start event loop
90
        DelayedEventsProcessor processor = new DelayedEventsProcessor(display);
89
91
90
        try {
92
        try {
91
93
Lines 111-117 Link Here
111
            // the workbench globally so that all UI plug-ins can find it using
113
            // the workbench globally so that all UI plug-ins can find it using
112
            // PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
114
            // PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
113
            int returnCode = PlatformUI.createAndRunWorkbench(display,
115
            int returnCode = PlatformUI.createAndRunWorkbench(display,
114
                    new IDEWorkbenchAdvisor());
116
            		new IDEWorkbenchAdvisor(processor));
115
117
116
            // the workbench doesn't support relaunch yet (bug 61809) so
118
            // the workbench doesn't support relaunch yet (bug 61809) so
117
            // for now restart is used, and exit data properties are checked
119
            // for now restart is used, and exit data properties are checked
(-)src/org/eclipse/ui/internal/ide/application/IDEWorkbenchAdvisor.java (+23 lines)
Lines 144-149 Link Here
144
	private AbstractStatusHandler ideWorkbenchErrorHandler;
144
	private AbstractStatusHandler ideWorkbenchErrorHandler;
145
145
146
	/**
146
	/**
147
	 * Helper class used to process delayed events.
148
	 */
149
	private DelayedEventsProcessor delayedEventsProcessor;
150
151
	/**
147
	 * Creates a new workbench advisor instance.
152
	 * Creates a new workbench advisor instance.
148
	 */
153
	 */
149
	public IDEWorkbenchAdvisor() {
154
	public IDEWorkbenchAdvisor() {
Lines 154-159 Link Here
154
		workbenchAdvisor = this;
159
		workbenchAdvisor = this;
155
	}
160
	}
156
161
162
	/**
163
	 * Creates a new workbench advisor instance supporting delayed file open.
164
	 * @param processor helper class used to process delayed events
165
	 */
166
	public IDEWorkbenchAdvisor(DelayedEventsProcessor processor) {
167
		this();
168
		this.delayedEventsProcessor = processor;
169
	}
170
157
	/*
171
	/*
158
	 * (non-Javadoc)
172
	 * (non-Javadoc)
159
	 * 
173
	 * 
Lines 852-855 Link Here
852
		}
866
		}
853
		return ideWorkbenchErrorHandler;
867
		return ideWorkbenchErrorHandler;
854
	}
868
	}
869
870
	/* (non-Javadoc)
871
	 * @see org.eclipse.ui.application.WorkbenchAdvisor#eventLoopIdle(org.eclipse.swt.widgets.Display)
872
	 */
873
	public void eventLoopIdle(Display display) {
874
		if (delayedEventsProcessor != null)
875
			delayedEventsProcessor.catchUp(display);
876
		super.eventLoopIdle(display);
877
	}
855
}
878
}

Return to bug 4922