KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > text > PackageHyperlink


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.text;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.jdt.core.IPackageFragment;
15 import org.eclipse.jdt.ui.JavaUI;
16 import org.eclipse.jdt.ui.actions.ShowInPackageViewAction;
17 import org.eclipse.jface.text.IRegion;
18 import org.eclipse.pde.internal.core.text.bundle.BasePackageHeader;
19 import org.eclipse.pde.internal.core.util.PDEJavaHelper;
20 import org.eclipse.pde.internal.ui.PDEPlugin;
21 import org.eclipse.ui.IViewPart;
22 import org.eclipse.ui.PartInitException;
23
24 public class PackageHyperlink extends ManifestElementHyperlink {
25
26     BasePackageHeader fHeader;
27     
28     public PackageHyperlink(IRegion region, String JavaDoc pack, BasePackageHeader header) {
29         super(region, pack);
30         fHeader = header;
31     }
32
33     protected void open2() {
34         IResource res = fHeader.getBundle().getModel().getUnderlyingResource();
35         if (res == null)
36             return;
37         IPackageFragment frag = PDEJavaHelper.getPackageFragment(fElement, null, res.getProject());
38         if (frag == null)
39             return;
40         try {
41             IViewPart part = PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES);
42             ShowInPackageViewAction action = new ShowInPackageViewAction(part.getSite());
43             action.run(frag);
44         } catch (PartInitException e) {
45             PDEPlugin.logException(e);
46         }
47     }
48
49 }
50
Popular Tags