### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/packageview/GotoPackageAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/GotoPackageAction.java,v retrieving revision 1.30 diff -u -r1.30 GotoPackageAction.java --- ui/org/eclipse/jdt/internal/ui/packageview/GotoPackageAction.java 11 Sep 2008 11:59:21 -0000 1.30 +++ ui/org/eclipse/jdt/internal/ui/packageview/GotoPackageAction.java 5 Feb 2009 22:21:01 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation 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 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and + * Goto Package not enabled in ProjectExplorer *******************************************************************************/ package org.eclipse.jdt.internal.ui.packageview; @@ -17,8 +19,10 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.SelectionDialog; +import org.eclipse.ui.part.ISetSelectionTarget; import org.eclipse.ui.progress.IProgressService; import org.eclipse.jdt.core.IPackageFragment; @@ -33,14 +37,14 @@ import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog; -class GotoPackageAction extends Action { +public class GotoPackageAction extends Action { - private PackageExplorerPart fPackageExplorer; + private IViewPart fExplorer; - GotoPackageAction(PackageExplorerPart part) { + public GotoPackageAction(IViewPart part) { super(PackagesMessages.GotoPackage_action_label); setDescription(PackagesMessages.GotoPackage_action_description); - fPackageExplorer= part; + fExplorer= part; PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PACKAGE_ACTION); } @@ -67,16 +71,16 @@ } private void gotoPackage(IPackageFragment p) { - fPackageExplorer.selectReveal(new StructuredSelection(p)); + ((ISetSelectionTarget)fExplorer).selectReveal(new StructuredSelection(p)); if (!p.equals(getSelectedElement())) { - MessageDialog.openInformation(fPackageExplorer.getSite().getShell(), + MessageDialog.openInformation(fExplorer.getSite().getShell(), getDialogTitle(), Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(p, JavaElementLabels.ALL_DEFAULT))); } } private Object getSelectedElement() { - return ((IStructuredSelection)fPackageExplorer.getSite().getSelectionProvider().getSelection()).getFirstElement(); + return ((IStructuredSelection)fExplorer.getSite().getSelectionProvider().getSelection()).getFirstElement(); } private String getDialogTitle() { Index: ui/org/eclipse/jdt/internal/ui/packageview/GotoTypeAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/GotoTypeAction.java,v retrieving revision 1.28 diff -u -r1.28 GotoTypeAction.java --- ui/org/eclipse/jdt/internal/ui/packageview/GotoTypeAction.java 11 Sep 2008 11:59:21 -0000 1.28 +++ ui/org/eclipse/jdt/internal/ui/packageview/GotoTypeAction.java 5 Feb 2009 22:21:01 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation 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 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and + * Goto Package not enabled in ProjectExplorer *******************************************************************************/ package org.eclipse.jdt.internal.ui.packageview; @@ -19,8 +21,11 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.SelectionDialog; +import org.eclipse.ui.part.ISetSelectionTarget; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; @@ -38,15 +43,15 @@ import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; -class GotoTypeAction extends Action { +public class GotoTypeAction extends Action { - private PackageExplorerPart fPackageExplorer; + private IViewPart fExplorer; - GotoTypeAction(PackageExplorerPart part) { + public GotoTypeAction(IViewPart part) { super(); setText(PackagesMessages.GotoType_action_label); setDescription(PackagesMessages.GotoType_action_description); - fPackageExplorer= part; + fExplorer= part; PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION); } @@ -85,19 +90,21 @@ element= type.getAncestor(IJavaElement.CLASS_FILE); } if (element != null) { - PackageExplorerPart view= PackageExplorerPart.openInActivePerspective(); - if (view != null) { - view.selectReveal(new StructuredSelection(element)); - if (!element.equals(getSelectedElement(view))) { - MessageDialog.openInformation(fPackageExplorer.getSite().getShell(), - getDialogTitle(), - Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT))); - } + try { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(fExplorer.getViewSite().getId()); + } catch (PartInitException e) { + return; + } + ((ISetSelectionTarget)fExplorer).selectReveal(new StructuredSelection(element)); + if (!element.equals(getSelectedElement(fExplorer))) { + MessageDialog.openInformation(fExplorer.getSite().getShell(), + getDialogTitle(), + Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT))); } } } - private Object getSelectedElement(PackageExplorerPart view) { + private Object getSelectedElement(IViewPart view) { return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement(); } Index: ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java,v retrieving revision 1.93 diff -u -r1.93 PackageExplorerActionGroup.java --- ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java 23 Jan 2009 13:08:15 -0000 1.93 +++ ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java 5 Feb 2009 22:21:01 -0000 @@ -8,6 +8,8 @@ * Contributors: * IBM Corporation - initial API and implementation * Eric Rizzo - replaced Collapse All action with generic equivalent + * Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and + * Goto Package not enabled in ProjectExplorer *******************************************************************************/ package org.eclipse.jdt.internal.ui.packageview; Index: ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorActionProvider.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorActionProvider.java,v retrieving revision 1.4 diff -u -r1.4 JavaNavigatorActionProvider.java --- ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorActionProvider.java 5 Dec 2008 11:08:45 -0000 1.4 +++ ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorActionProvider.java 5 Feb 2009 22:21:01 -0000 @@ -22,8 +22,11 @@ import org.eclipse.jdt.ui.actions.CCPActionGroup; import org.eclipse.jdt.ui.actions.GenerateActionGroup; import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; +import org.eclipse.jdt.ui.actions.JdtActionConstants; import org.eclipse.jdt.ui.actions.OpenViewActionGroup; +import org.eclipse.jdt.internal.ui.packageview.GotoPackageAction; +import org.eclipse.jdt.internal.ui.packageview.GotoTypeAction; import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup; /** @@ -37,6 +40,8 @@ *
  • {@link JavaSearchActionGroup}. Contributes the search functionality (find in workspace, project, etc).
  • *
  • {@link GenerateBuildPathActionGroup}. Contributes the "Build Path>" convenience submenu option.
  • *
  • {@link GenerateActionGroup}. Contributes the "Source>" and "Generate>" submenu .
  • + *
  • {@link GotoTypeAction}. Go to Type menu item. + *
  • {@link GotoPackageAction}. Go to Package menu item. * */ public class JavaNavigatorActionProvider extends CommonActionProvider { @@ -51,10 +56,16 @@ private GenerateActionGroup fGenerateGroup; + private GotoTypeAction fGotoTypeAction; + private GotoPackageAction fGotoPackageAction; + private boolean fInViewPart= false; public void fillActionBars(IActionBars actionBars) { if (fInViewPart) { + actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction); + actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction); + fOpenViewGroup.fillActionBars(actionBars); fCCPGroup.fillActionBars(actionBars); fBuildPathGroup.fillActionBars(actionBars); @@ -90,6 +101,9 @@ fSearchGroup= new JavaSearchActionGroup(viewPart); fBuildPathGroup= new GenerateBuildPathActionGroup(viewPart); + fGotoTypeAction= new GotoTypeAction(viewPart); + fGotoPackageAction= new GotoPackageAction(viewPart); + fInViewPart= true; } }