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 273013
Collapse All | Expand All

(-)a/org.eclipse.mylyn.wikitext.ui/META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 11-17 Require-Bundle: org.eclipse.mylyn.wikitext.core;bundle-version="[1.4.0,1.5.0)", Link Here
11
 org.eclipse.ui.editors,
11
 org.eclipse.ui.editors,
12
 org.eclipse.ui.workbench.texteditor,
12
 org.eclipse.ui.workbench.texteditor,
13
 org.eclipse.ui.views,
13
 org.eclipse.ui.views,
14
 org.eclipse.ui.ide;resolution:=optional,
14
 org.eclipse.ui.ide,
15
 org.eclipse.core.expressions,
15
 org.eclipse.core.expressions,
16
 org.eclipse.core.resources,
16
 org.eclipse.core.resources,
17
 org.eclipse.help
17
 org.eclipse.help
(-)a/org.eclipse.mylyn.wikitext.ui/src/org/eclipse/mylyn/internal/wikitext/ui/editor/IDEOpenEditorSupport.java (-29 lines)
Lines 1-29 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 MARINTEK 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
 *     Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.ui.editor;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.ui.IWorkbenchPage;
16
import org.eclipse.ui.ide.IDE;
17
18
/**
19
 * Uses IDE features to open a file.
20
 * 
21
 * @author Torkild U. Resheim
22
 */
23
public class IDEOpenEditorSupport implements IOpenEditorSupport {
24
25
	public void openEditor(IWorkbenchPage page, IFile file) throws Exception {
26
		IDE.openEditor(page, file);
27
	}
28
29
}
(-)a/org.eclipse.mylyn.wikitext.ui/src/org/eclipse/mylyn/internal/wikitext/ui/editor/IOpenEditorSupport.java (-29 lines)
Lines 1-29 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 MARINTEK 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
 *     Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.ui.editor;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.mylyn.internal.wikitext.ui.editor.syntax.MarkupHyperlinkDetector;
16
import org.eclipse.ui.IWorkbenchPage;
17
18
/**
19
 * Used to decouple the bundle from org.eclipse.ui.ide. If the latter is not present the {@link NullOpenEditorSupport}
20
 * will be used instead of the {@link IDEOpenEditorSupport}.
21
 * 
22
 * @author Torkild U. Resheim
23
 * @see MarkupHyperlinkDetector
24
 */
25
public interface IOpenEditorSupport {
26
27
	public void openEditor(IWorkbenchPage page, IFile file) throws Exception;
28
29
}
(-)a/org.eclipse.mylyn.wikitext.ui/src/org/eclipse/mylyn/internal/wikitext/ui/editor/NullOpenEditorSupport.java (-28 lines)
Lines 1-28 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 MARINTEK 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
 *     Torkild U. Resheim - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.wikitext.ui.editor;
13
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.ui.IWorkbenchPage;
16
17
/**
18
 * Dummy feature for opening a file when we don't have IDE support.
19
 * 
20
 * @author Torkild U. Resheim
21
 */
22
public class NullOpenEditorSupport implements IOpenEditorSupport {
23
24
	public void openEditor(IWorkbenchPage page, IFile file) {
25
		// Do nothing. We don't have IDE support. 
26
	}
27
28
}
(-)a/org.eclipse.mylyn.wikitext.ui/src/org/eclipse/mylyn/internal/wikitext/ui/editor/syntax/MarkupHyperlinkDetector.java (-26 / +6 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     David Green - initial API and implementation
9
 *     David Green - initial API and implementation
10
 *     Torkild U. Resheim - Decouple from o.e.ui.ide, bug 273013
11
 *******************************************************************************/
10
 *******************************************************************************/
12
11
13
package org.eclipse.mylyn.internal.wikitext.ui.editor.syntax;
12
package org.eclipse.mylyn.internal.wikitext.ui.editor.syntax;
Lines 29-35 import org.eclipse.jface.text.Region; Link Here
29
import org.eclipse.jface.text.hyperlink.IHyperlink;
28
import org.eclipse.jface.text.hyperlink.IHyperlink;
30
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
29
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
31
import org.eclipse.mylyn.internal.wikitext.ui.WikiTextUiPlugin;
30
import org.eclipse.mylyn.internal.wikitext.ui.WikiTextUiPlugin;
32
import org.eclipse.mylyn.internal.wikitext.ui.editor.IOpenEditorSupport;
33
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
31
import org.eclipse.mylyn.wikitext.core.parser.Attributes;
34
import org.eclipse.mylyn.wikitext.core.parser.LinkAttributes;
32
import org.eclipse.mylyn.wikitext.core.parser.LinkAttributes;
35
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
33
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
Lines 38-44 import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage; Link Here
38
import org.eclipse.osgi.util.NLS;
36
import org.eclipse.osgi.util.NLS;
39
import org.eclipse.ui.IWorkbenchPage;
37
import org.eclipse.ui.IWorkbenchPage;
40
import org.eclipse.ui.IWorkbenchWindow;
38
import org.eclipse.ui.IWorkbenchWindow;
39
import org.eclipse.ui.PartInitException;
41
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.PlatformUI;
41
import org.eclipse.ui.ide.IDE;
42
42
43
/**
43
/**
44
 * A hyperlink detector that can detect hyperlinks in markup source.
44
 * A hyperlink detector that can detect hyperlinks in markup source.
Lines 227-261 public class MarkupHyperlinkDetector implements IHyperlinkDetector { Link Here
227
			return NLS.bind(Messages.MarkupHyperlinkDetector_openFileInEditor, file.getName());
227
			return NLS.bind(Messages.MarkupHyperlinkDetector_openFileInEditor, file.getName());
228
		}
228
		}
229
229
230
		private static IOpenEditorSupport openEditorSupport;
231
232
		static {
233
			try {
234
				openEditorSupport = (IOpenEditorSupport) Class.forName(
235
						"org.eclipse.mylyn.wikitext.ui.editor.IDEOpenEditorSupport").newInstance(); //$NON-NLS-1$
236
			} catch (Exception e) {
237
				try {
238
					openEditorSupport = (IOpenEditorSupport) Class.forName(
239
							"org.eclipse.mylyn.wikitext.ui.editor.NULLOpenEditorSupport").newInstance(); //$NON-NLS-1$
240
				} catch (InstantiationException e1) {
241
					e1.printStackTrace();
242
				} catch (IllegalAccessException e1) {
243
					e1.printStackTrace();
244
				} catch (ClassNotFoundException e1) {
245
					e1.printStackTrace();
246
				}
247
			}
248
		}
249
250
		public void open() {
230
		public void open() {
251
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
231
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
252
			IWorkbenchPage activePage = window.getActivePage();
232
			IWorkbenchPage activePage = window.getActivePage();
253
			try {
233
			try {
254
				openEditorSupport.openEditor(activePage, file);
234
				IDE.openEditor(activePage, file);
255
			} catch (Exception e) {
235
			} catch (PartInitException e) {
256
				WikiTextUiPlugin.getDefault().log(e);
236
				WikiTextUiPlugin.getDefault().log(e);
257
				MessageDialog.openError(window.getShell(), Messages.MarkupHyperlinkDetector_unexpectedError,
237
				MessageDialog.openError(window.getShell(), Messages.MarkupHyperlinkDetector_unexpectedError, NLS.bind(
258
						NLS.bind(Messages.MarkupHyperlinkDetector_openException, file.getName(), e.getMessage()));
238
						Messages.MarkupHyperlinkDetector_openException, file.getName(), e.getMessage()));
259
			}
239
			}
260
		}
240
		}
261
	}
241
	}

Return to bug 273013