### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.ide.application Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.ide.application/META-INF/MANIFEST.MF,v retrieving revision 1.14 diff -u -r1.14 MANIFEST.MF --- META-INF/MANIFEST.MF 1 Sep 2009 04:32:22 -0000 1.14 +++ META-INF/MANIFEST.MF 20 Jan 2010 17:48:54 -0000 @@ -12,7 +12,8 @@ org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.navigator.resources;bundle-version="[3.4.0,4.0.0)", - org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)" + org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)", + org.eclipse.core.filesystem;bundle-version="1.3.0" Export-Package: org.eclipse.ui.internal.ide.application;x-internal:=true, org.eclipse.ui.internal.ide.application.dialogs;x-internal:=true Import-Package: com.ibm.icu.text Index: src/org/eclipse/ui/internal/ide/application/IDEApplication.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java,v retrieving revision 1.7 diff -u -r1.7 IDEApplication.java --- src/org/eclipse/ui/internal/ide/application/IDEApplication.java 3 Jun 2008 17:56:02 -0000 1.7 +++ src/org/eclipse/ui/internal/ide/application/IDEApplication.java 20 Jan 2010 17:48:54 -0000 @@ -19,9 +19,13 @@ import java.net.URL; import java.util.Properties; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.app.IApplication; @@ -32,10 +36,16 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.WorkbenchPlugin; import org.eclipse.ui.internal.ide.ChooseWorkspaceData; import org.eclipse.ui.internal.ide.ChooseWorkspaceDialog; @@ -85,8 +95,10 @@ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext context) */ public Object start(IApplicationContext appContext) throws Exception { - Display display = createDisplay(); + final Display display = createDisplay(); + hookOpenDocListener(display); + try { // look and see if there's a splash shell we can parent off of @@ -134,6 +146,53 @@ } } + /** + * @param display + */ + protected void hookOpenDocListener(final Display display) { + display.addListener(SWT.OpenDoc, new Listener() { + public void handleEvent(Event event) { + final String path = event.text; + if (path == null) { + return; + } + display.asyncExec(new Runnable() { + public void run() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { + return; + } + IFileStore fileStore = EFS.getLocalFileSystem() + .getStore(new Path(path)); + IFileInfo fetchInfo = fileStore.fetchInfo(); + if (!fetchInfo.isDirectory() && fetchInfo.exists()) { + IWorkbenchPage page = window.getActivePage(); + try { + IDE.openEditorOnFileStore(page, fileStore); + } catch (PartInitException e) { + String msg = NLS + .bind( + IDEWorkbenchMessages.OpenLocalFileAction_message_errorOnOpen, + fileStore.getName()); + IDEWorkbenchPlugin.log(msg, e.getStatus()); + MessageDialog + .open( + MessageDialog.ERROR, + window.getShell(), + IDEWorkbenchMessages.OpenLocalFileAction_title, + msg, SWT.SHEET); + } + } else { + String msgFmt = IDEWorkbenchMessages.OpenLocalFileAction_message_fileNotFound; + String msg = NLS.bind(msgFmt, path); + MessageDialog.open(MessageDialog.ERROR, window.getShell(), IDEWorkbenchMessages.OpenLocalFileAction_title, msg, SWT.SHEET); + } + } + }); + } + }); + } + /** * Creates the display used by the application. *