01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.text;
11:
12: import org.eclipse.core.resources.IResource;
13: import org.eclipse.jdt.core.IPackageFragment;
14: import org.eclipse.jdt.ui.JavaUI;
15: import org.eclipse.jdt.ui.actions.ShowInPackageViewAction;
16: import org.eclipse.jface.text.IRegion;
17: import org.eclipse.pde.internal.core.text.bundle.BasePackageHeader;
18: import org.eclipse.pde.internal.core.util.PDEJavaHelper;
19: import org.eclipse.pde.internal.ui.PDEPlugin;
20: import org.eclipse.ui.IViewPart;
21: import org.eclipse.ui.PartInitException;
22:
23: public class PackageHyperlink extends ManifestElementHyperlink {
24:
25: BasePackageHeader fHeader;
26:
27: public PackageHyperlink(IRegion region, String pack,
28: BasePackageHeader header) {
29: super (region, pack);
30: fHeader = header;
31: }
32:
33: protected void open2() {
34: IResource res = fHeader.getBundle().getModel()
35: .getUnderlyingResource();
36: if (res == null)
37: return;
38: IPackageFragment frag = PDEJavaHelper.getPackageFragment(
39: fElement, null, res.getProject());
40: if (frag == null)
41: return;
42: try {
43: IViewPart part = PDEPlugin.getActivePage().showView(
44: JavaUI.ID_PACKAGES);
45: ShowInPackageViewAction action = new ShowInPackageViewAction(
46: part.getSite());
47: action.run(frag);
48: } catch (PartInitException e) {
49: PDEPlugin.logException(e);
50: }
51: }
52:
53: }
|