diff options
Diffstat (limited to 'changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/editors/FileHyperlink.java')
-rw-r--r-- | changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/editors/FileHyperlink.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/editors/FileHyperlink.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/editors/FileHyperlink.java new file mode 100644 index 0000000000..0777645a68 --- /dev/null +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/editors/FileHyperlink.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2006 Red Hat Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Kyu Lee <klee@redhat.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.changelog.core.editors; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.hyperlink.IHyperlink; +import org.eclipse.linuxtools.changelog.core.ChangelogPlugin; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; + +/** + * Hyperlink that opens up editor for a file. + * + * @author klee (Kyu Lee) + * + */ +public class FileHyperlink implements IHyperlink { + + private IFile fileLoc; + + private IRegion region; + + public FileHyperlink(IRegion regionIn, IFile fileIn) { + fileLoc = fileIn; + region = regionIn; + } + + public IRegion getHyperlinkRegion() { + return region; + } + + public String getTypeLabel() { + // TODO Auto-generated method stub + return null; + } + + public String getHyperlinkText() { + // TODO Auto-generated method stub + return null; + } + + /** + * Opens the hyperlink in new editor window. + */ + public void open() { + IWorkbench ws = getWorkbench(); + + try { + + org.eclipse.ui.ide.IDE.openEditor(ws.getActiveWorkbenchWindow() + .getActivePage(), fileLoc, true); + } catch (PartInitException e) { + e.printStackTrace(); + + } + + } + + private IWorkbench getWorkbench() { + return ChangelogPlugin.getDefault().getWorkbench(); + } + +} |