]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2003, 2011 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.jdt.internal.ui.navigator; | |
12 | ||
13 | import org.eclipse.jface.action.IAction; | |
14 | import org.eclipse.jface.action.IMenuManager; | |
15 | import org.eclipse.jface.viewers.TreeViewer; | |
16 | ||
17 | import org.eclipse.ui.IActionBars; | |
18 | import org.eclipse.ui.IViewPart; | |
19 | import org.eclipse.ui.actions.ActionContext; | |
20 | import org.eclipse.ui.navigator.CommonActionProvider; | |
21 | import org.eclipse.ui.navigator.ICommonActionExtensionSite; | |
22 | import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; | |
23 | ||
24 | import org.eclipse.jdt.ui.actions.OpenAction; | |
25 | import org.eclipse.jdt.ui.actions.OpenEditorActionGroup; | |
26 | ||
27 | public class PackageExplorerOpenActionProvider extends CommonActionProvider { | |
28 | ||
29 | ||
30 | public IAction fOpenAndExpand; | |
31 | public OpenEditorActionGroup fOpenGroup; | |
32 | ||
33 | private boolean fInViewPart = false; | |
34 | ||
35 | @Override | |
36 | public void fillActionBars(IActionBars actionBars) { | |
37 | if (fInViewPart) { | |
38 | fOpenGroup.generated_2953987140663770286(this, actionBars); | |
39 | } | |
40 | ||
41 | } | |
42 | ||
43 | @Override | |
44 | public void fillContextMenu(IMenuManager menu) { | |
45 | ||
46 | if (fInViewPart) { | |
47 | fOpenGroup.generated_3287162131719738023(menu); | |
48 | } | |
49 | } | |
50 | ||
51 | @Override | |
52 | public void init(ICommonActionExtensionSite site) { | |
53 | ||
54 | ICommonViewerWorkbenchSite workbenchSite = null; | |
55 | if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) | |
56 | workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite(); | |
57 | ||
58 | if (workbenchSite != null) { | |
59 | if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { | |
60 | IViewPart viewPart = (IViewPart) workbenchSite.getPart(); | |
61 | ||
62 | fOpenGroup = new OpenEditorActionGroup(viewPart); | |
63 | ||
64 | if (site.getStructuredViewer() instanceof TreeViewer) | |
65 | fOpenAndExpand = new OpenAndExpand(workbenchSite.getSite(), (OpenAction) fOpenGroup.getOpenAction(), (TreeViewer) site.getStructuredViewer()); | |
66 | fInViewPart = true; | |
67 | } | |
68 | } | |
69 | } | |
70 | ||
71 | @Override | |
72 | public void setContext(ActionContext context) { | |
73 | super.setContext(context); | |
74 | if (fInViewPart) { | |
75 | fOpenGroup.setContext(context); | |
76 | } | |
77 | } | |
78 | ||
79 | /* | |
80 | * @see org.eclipse.ui.actions.ActionGroup#dispose() | |
81 | * @since 3.5 | |
82 | */ | |
83 | @Override | |
84 | public void dispose() { | |
85 | if (fOpenGroup != null) | |
86 | fOpenGroup.dispose(); | |
87 | super.dispose(); | |
88 | } | |
89 | ||
90 | } |