|
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 |
} |