Lines 19-27
Link Here
|
19 |
import java.net.URL; |
19 |
import java.net.URL; |
20 |
import java.util.Properties; |
20 |
import java.util.Properties; |
21 |
|
21 |
|
|
|
22 |
import org.eclipse.core.filesystem.EFS; |
23 |
import org.eclipse.core.filesystem.IFileInfo; |
24 |
import org.eclipse.core.filesystem.IFileStore; |
22 |
import org.eclipse.core.runtime.IConfigurationElement; |
25 |
import org.eclipse.core.runtime.IConfigurationElement; |
23 |
import org.eclipse.core.runtime.IExecutableExtension; |
26 |
import org.eclipse.core.runtime.IExecutableExtension; |
24 |
import org.eclipse.core.runtime.IStatus; |
27 |
import org.eclipse.core.runtime.IStatus; |
|
|
28 |
import org.eclipse.core.runtime.Path; |
25 |
import org.eclipse.core.runtime.Platform; |
29 |
import org.eclipse.core.runtime.Platform; |
26 |
import org.eclipse.core.runtime.Status; |
30 |
import org.eclipse.core.runtime.Status; |
27 |
import org.eclipse.equinox.app.IApplication; |
31 |
import org.eclipse.equinox.app.IApplication; |
Lines 32-41
Link Here
|
32 |
import org.eclipse.osgi.util.NLS; |
36 |
import org.eclipse.osgi.util.NLS; |
33 |
import org.eclipse.swt.SWT; |
37 |
import org.eclipse.swt.SWT; |
34 |
import org.eclipse.swt.widgets.Display; |
38 |
import org.eclipse.swt.widgets.Display; |
|
|
39 |
import org.eclipse.swt.widgets.Event; |
40 |
import org.eclipse.swt.widgets.Listener; |
35 |
import org.eclipse.swt.widgets.MessageBox; |
41 |
import org.eclipse.swt.widgets.MessageBox; |
36 |
import org.eclipse.swt.widgets.Shell; |
42 |
import org.eclipse.swt.widgets.Shell; |
37 |
import org.eclipse.ui.IWorkbench; |
43 |
import org.eclipse.ui.IWorkbench; |
|
|
44 |
import org.eclipse.ui.IWorkbenchPage; |
45 |
import org.eclipse.ui.IWorkbenchWindow; |
46 |
import org.eclipse.ui.PartInitException; |
38 |
import org.eclipse.ui.PlatformUI; |
47 |
import org.eclipse.ui.PlatformUI; |
|
|
48 |
import org.eclipse.ui.ide.IDE; |
39 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
49 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
40 |
import org.eclipse.ui.internal.ide.ChooseWorkspaceData; |
50 |
import org.eclipse.ui.internal.ide.ChooseWorkspaceData; |
41 |
import org.eclipse.ui.internal.ide.ChooseWorkspaceDialog; |
51 |
import org.eclipse.ui.internal.ide.ChooseWorkspaceDialog; |
Lines 85-92
Link Here
|
85 |
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext context) |
95 |
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext context) |
86 |
*/ |
96 |
*/ |
87 |
public Object start(IApplicationContext appContext) throws Exception { |
97 |
public Object start(IApplicationContext appContext) throws Exception { |
88 |
Display display = createDisplay(); |
98 |
final Display display = createDisplay(); |
89 |
|
99 |
|
|
|
100 |
hookOpenDocListener(display); |
101 |
|
90 |
try { |
102 |
try { |
91 |
|
103 |
|
92 |
// look and see if there's a splash shell we can parent off of |
104 |
// look and see if there's a splash shell we can parent off of |
Lines 134-139
Link Here
|
134 |
} |
146 |
} |
135 |
} |
147 |
} |
136 |
|
148 |
|
|
|
149 |
/** |
150 |
* @param display |
151 |
*/ |
152 |
protected void hookOpenDocListener(final Display display) { |
153 |
display.addListener(SWT.OpenDoc, new Listener() { |
154 |
public void handleEvent(Event event) { |
155 |
final String path = event.text; |
156 |
if (path == null) { |
157 |
return; |
158 |
} |
159 |
display.asyncExec(new Runnable() { |
160 |
public void run() { |
161 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
162 |
if (window == null) { |
163 |
return; |
164 |
} |
165 |
IFileStore fileStore = EFS.getLocalFileSystem() |
166 |
.getStore(new Path(path)); |
167 |
IFileInfo fetchInfo = fileStore.fetchInfo(); |
168 |
if (!fetchInfo.isDirectory() && fetchInfo.exists()) { |
169 |
IWorkbenchPage page = window.getActivePage(); |
170 |
try { |
171 |
IDE.openEditorOnFileStore(page, fileStore); |
172 |
} catch (PartInitException e) { |
173 |
String msg = NLS |
174 |
.bind( |
175 |
IDEWorkbenchMessages.OpenLocalFileAction_message_errorOnOpen, |
176 |
fileStore.getName()); |
177 |
IDEWorkbenchPlugin.log(msg, e.getStatus()); |
178 |
MessageDialog |
179 |
.open( |
180 |
MessageDialog.ERROR, |
181 |
window.getShell(), |
182 |
IDEWorkbenchMessages.OpenLocalFileAction_title, |
183 |
msg, SWT.SHEET); |
184 |
} |
185 |
} else { |
186 |
String msgFmt = IDEWorkbenchMessages.OpenLocalFileAction_message_fileNotFound; |
187 |
String msg = NLS.bind(msgFmt, path); |
188 |
MessageDialog.open(MessageDialog.ERROR, window.getShell(), IDEWorkbenchMessages.OpenLocalFileAction_title, msg, SWT.SHEET); |
189 |
} |
190 |
} |
191 |
}); |
192 |
} |
193 |
}); |
194 |
} |
195 |
|
137 |
/** |
196 |
/** |
138 |
* Creates the display used by the application. |
197 |
* Creates the display used by the application. |
139 |
* |
198 |
* |