Commit | Line | Data |
---|---|---|
828e5592 PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 Ericsson | |
a0a88f65 | 3 | * |
828e5592 PT |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
a0a88f65 | 8 | * |
828e5592 PT |
9 | * Contributors: |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
d34665f9 | 13 | package org.eclipse.linuxtools.internal.tmf.ui.project.handlers; |
828e5592 PT |
14 | |
15 | import org.eclipse.ui.IActionBars; | |
16 | import org.eclipse.ui.actions.ActionFactory; | |
17 | import org.eclipse.ui.navigator.CommonActionProvider; | |
18 | import org.eclipse.ui.navigator.ICommonActionConstants; | |
19 | import org.eclipse.ui.navigator.ICommonActionExtensionSite; | |
20 | import org.eclipse.ui.navigator.ICommonViewerSite; | |
21 | import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; | |
22 | ||
a0a88f65 AM |
23 | /** |
24 | * Base action provider. | |
25 | * | |
26 | * @author Patrick Tassé | |
27 | */ | |
828e5592 PT |
28 | public class TmfActionProvider extends CommonActionProvider { |
29 | ||
30 | private OpenAction openAction; | |
31 | private DeleteAction deleteAction; | |
32 | private RefreshAction refreshAction; | |
33 | ||
34 | /** | |
35 | * Default constructor | |
36 | */ | |
37 | public TmfActionProvider() { | |
38 | } | |
39 | ||
40 | /* | |
41 | * (non-Javadoc) | |
42 | * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite) | |
43 | */ | |
44 | @Override | |
45 | public void init(ICommonActionExtensionSite aSite) { | |
46 | ICommonViewerSite viewSite = aSite.getViewSite(); | |
47 | if (viewSite instanceof ICommonViewerWorkbenchSite) { | |
48 | ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite; | |
49 | openAction = new OpenAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
50 | deleteAction = new DeleteAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
51 | refreshAction = new RefreshAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
52 | } | |
53 | } | |
54 | ||
55 | /* | |
56 | * (non-Javadoc) | |
57 | * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) | |
58 | */ | |
59 | @Override | |
60 | public void fillActionBars(IActionBars actionBars) { | |
61 | if (openAction.isEnabled()) { | |
62 | actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction); | |
63 | } | |
64 | if (deleteAction.isEnabled()) { | |
65 | actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); | |
66 | } | |
67 | if (refreshAction.isEnabled()) { | |
68 | actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); | |
69 | } | |
70 | } | |
71 | ||
72 | } |