View | Details | Raw Unified | Return to bug 262097
Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/packageview/GotoPackageAction.java (-8 / +12 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and 
11
 *        Goto Package not enabled in ProjectExplorer 
10
 *******************************************************************************/
12
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.packageview;
13
package org.eclipse.jdt.internal.ui.packageview;
12
14
Lines 17-24 Link Here
17
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.StructuredSelection;
20
import org.eclipse.jface.viewers.StructuredSelection;
19
21
22
import org.eclipse.ui.IViewPart;
20
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.dialogs.SelectionDialog;
24
import org.eclipse.ui.dialogs.SelectionDialog;
25
import org.eclipse.ui.part.ISetSelectionTarget;
22
import org.eclipse.ui.progress.IProgressService;
26
import org.eclipse.ui.progress.IProgressService;
23
27
24
import org.eclipse.jdt.core.IPackageFragment;
28
import org.eclipse.jdt.core.IPackageFragment;
Lines 33-46 Link Here
33
import org.eclipse.jdt.internal.ui.JavaPlugin;
37
import org.eclipse.jdt.internal.ui.JavaPlugin;
34
import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog;
38
import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog;
35
39
36
class GotoPackageAction extends Action {
40
public class GotoPackageAction extends Action {
37
41
38
	private PackageExplorerPart fPackageExplorer;
42
	private IViewPart fExplorer;
39
43
40
	GotoPackageAction(PackageExplorerPart part) {
44
	public GotoPackageAction(IViewPart part) {
41
		super(PackagesMessages.GotoPackage_action_label);
45
		super(PackagesMessages.GotoPackage_action_label);
42
		setDescription(PackagesMessages.GotoPackage_action_description);
46
		setDescription(PackagesMessages.GotoPackage_action_description);
43
		fPackageExplorer= part;
47
		fExplorer= part;
44
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PACKAGE_ACTION);
48
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_PACKAGE_ACTION);
45
	}
49
	}
46
50
Lines 67-82 Link Here
67
	}
71
	}
68
72
69
	private void gotoPackage(IPackageFragment p) {
73
	private void gotoPackage(IPackageFragment p) {
70
		fPackageExplorer.selectReveal(new StructuredSelection(p));
74
		((ISetSelectionTarget)fExplorer).selectReveal(new StructuredSelection(p));
71
		if (!p.equals(getSelectedElement())) {
75
		if (!p.equals(getSelectedElement())) {
72
			MessageDialog.openInformation(fPackageExplorer.getSite().getShell(),
76
			MessageDialog.openInformation(fExplorer.getSite().getShell(),
73
				getDialogTitle(),
77
				getDialogTitle(),
74
				Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(p, JavaElementLabels.ALL_DEFAULT)));
78
				Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(p, JavaElementLabels.ALL_DEFAULT)));
75
		}
79
		}
76
	}
80
	}
77
81
78
	private Object getSelectedElement() {
82
	private Object getSelectedElement() {
79
		return ((IStructuredSelection)fPackageExplorer.getSite().getSelectionProvider().getSelection()).getFirstElement();
83
		return ((IStructuredSelection)fExplorer.getSite().getSelectionProvider().getSelection()).getFirstElement();
80
	}
84
	}
81
85
82
	private String getDialogTitle() {
86
	private String getDialogTitle() {
(-)ui/org/eclipse/jdt/internal/ui/packageview/GotoTypeAction.java (-14 / +21 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and 
11
 *        Goto Package not enabled in ProjectExplorer 
10
 *******************************************************************************/
12
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.packageview;
13
package org.eclipse.jdt.internal.ui.packageview;
12
14
Lines 19-26 Link Here
19
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.jface.viewers.StructuredSelection;
21
23
24
import org.eclipse.ui.IViewPart;
25
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.dialogs.SelectionDialog;
27
import org.eclipse.ui.dialogs.SelectionDialog;
28
import org.eclipse.ui.part.ISetSelectionTarget;
24
29
25
import org.eclipse.jdt.core.ICompilationUnit;
30
import org.eclipse.jdt.core.ICompilationUnit;
26
import org.eclipse.jdt.core.IJavaElement;
31
import org.eclipse.jdt.core.IJavaElement;
Lines 38-52 Link Here
38
import org.eclipse.jdt.internal.ui.JavaPlugin;
43
import org.eclipse.jdt.internal.ui.JavaPlugin;
39
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
44
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
40
45
41
class GotoTypeAction extends Action {
46
public class GotoTypeAction extends Action {
42
47
43
	private PackageExplorerPart fPackageExplorer;
48
	private IViewPart fExplorer;
44
49
45
	GotoTypeAction(PackageExplorerPart part) {
50
	public GotoTypeAction(IViewPart part) {
46
		super();
51
		super();
47
		setText(PackagesMessages.GotoType_action_label);
52
		setText(PackagesMessages.GotoType_action_label);
48
		setDescription(PackagesMessages.GotoType_action_description);
53
		setDescription(PackagesMessages.GotoType_action_description);
49
		fPackageExplorer= part;
54
		fExplorer= part;
50
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION);
55
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION);
51
	}
56
	}
52
57
Lines 85-103 Link Here
85
			element= type.getAncestor(IJavaElement.CLASS_FILE);
90
			element= type.getAncestor(IJavaElement.CLASS_FILE);
86
		}
91
		}
87
		if (element != null) {
92
		if (element != null) {
88
			PackageExplorerPart view= PackageExplorerPart.openInActivePerspective();
93
			try {
89
			if (view != null) {
94
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(fExplorer.getViewSite().getId());
90
				view.selectReveal(new StructuredSelection(element));
95
			} catch (PartInitException e) {
91
				if (!element.equals(getSelectedElement(view))) {
96
				return;
92
					MessageDialog.openInformation(fPackageExplorer.getSite().getShell(),
97
			}
93
						getDialogTitle(),
98
			((ISetSelectionTarget)fExplorer).selectReveal(new StructuredSelection(element));
94
						Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT)));
99
			if (!element.equals(getSelectedElement(fExplorer))) {
95
				}
100
				MessageDialog.openInformation(fExplorer.getSite().getShell(),
101
					getDialogTitle(),
102
					Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT)));
96
			}
103
			}
97
		}
104
		}
98
	}
105
	}
99
106
100
	private Object getSelectedElement(PackageExplorerPart view) {
107
	private Object getSelectedElement(IViewPart view) {
101
		return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement();
108
		return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement();
102
	}
109
	}
103
110
(-)ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerActionGroup.java (+2 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Eric Rizzo - replaced Collapse All action with generic equivalent
10
 *     Eric Rizzo - replaced Collapse All action with generic equivalent
11
 *     Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and 
12
 *        Goto Package not enabled in ProjectExplorer 
11
 *******************************************************************************/
13
 *******************************************************************************/
12
14
13
package org.eclipse.jdt.internal.ui.packageview;
15
package org.eclipse.jdt.internal.ui.packageview;
(-)ui/org/eclipse/jdt/internal/ui/navigator/JavaNavigatorActionProvider.java (+14 lines)
Lines 22-29 Link Here
22
import org.eclipse.jdt.ui.actions.CCPActionGroup;
22
import org.eclipse.jdt.ui.actions.CCPActionGroup;
23
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
23
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
24
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
24
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
25
import org.eclipse.jdt.ui.actions.JdtActionConstants;
25
import org.eclipse.jdt.ui.actions.OpenViewActionGroup;
26
import org.eclipse.jdt.ui.actions.OpenViewActionGroup;
26
27
28
import org.eclipse.jdt.internal.ui.packageview.GotoPackageAction;
29
import org.eclipse.jdt.internal.ui.packageview.GotoTypeAction;
27
import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup;
30
import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup;
28
31
29
/**
32
/**
Lines 37-42 Link Here
37
 * <li>{@link JavaSearchActionGroup}. Contributes the search functionality (find in workspace, project, etc).</li>
40
 * <li>{@link JavaSearchActionGroup}. Contributes the search functionality (find in workspace, project, etc).</li>
38
 * <li>{@link GenerateBuildPathActionGroup}. Contributes the "Build Path>" convenience submenu option.</li>
41
 * <li>{@link GenerateBuildPathActionGroup}. Contributes the "Build Path>" convenience submenu option.</li>
39
 * <li>{@link GenerateActionGroup}. Contributes the "Source>" and "Generate>" submenu .</li>
42
 * <li>{@link GenerateActionGroup}. Contributes the "Source>" and "Generate>" submenu .</li>
43
 * <li>{@link GotoTypeAction}.  Go to Type menu item.
44
 * <li>{@link GotoPackageAction}.  Go to Package menu item.
40
 * </ul>
45
 * </ul>
41
 */
46
 */
42
public class JavaNavigatorActionProvider extends CommonActionProvider {
47
public class JavaNavigatorActionProvider extends CommonActionProvider {
Lines 51-60 Link Here
51
56
52
	private GenerateActionGroup fGenerateGroup;
57
	private GenerateActionGroup fGenerateGroup;
53
58
59
	private GotoTypeAction fGotoTypeAction;
60
	private GotoPackageAction fGotoPackageAction;
61
	
54
	private boolean fInViewPart= false;
62
	private boolean fInViewPart= false;
55
63
56
	public void fillActionBars(IActionBars actionBars) {
64
	public void fillActionBars(IActionBars actionBars) {
57
		if (fInViewPart) {
65
		if (fInViewPart) {
66
			actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_TYPE, fGotoTypeAction);
67
			actionBars.setGlobalActionHandler(JdtActionConstants.GOTO_PACKAGE, fGotoPackageAction);
68
			
58
			fOpenViewGroup.fillActionBars(actionBars);
69
			fOpenViewGroup.fillActionBars(actionBars);
59
			fCCPGroup.fillActionBars(actionBars);
70
			fCCPGroup.fillActionBars(actionBars);
60
			fBuildPathGroup.fillActionBars(actionBars);
71
			fBuildPathGroup.fillActionBars(actionBars);
Lines 90-95 Link Here
90
				fSearchGroup= new JavaSearchActionGroup(viewPart);
101
				fSearchGroup= new JavaSearchActionGroup(viewPart);
91
				fBuildPathGroup= new GenerateBuildPathActionGroup(viewPart);
102
				fBuildPathGroup= new GenerateBuildPathActionGroup(viewPart);
92
103
104
				fGotoTypeAction= new GotoTypeAction(viewPart);
105
				fGotoPackageAction= new GotoPackageAction(viewPart);
106
				
93
				fInViewPart= true;
107
				fInViewPart= true;
94
			}
108
			}
95
		}
109
		}

Return to bug 262097