Commit | Line | Data |
---|---|---|
828e5592 PT |
1 | /******************************************************************************* |
2 | * Copyright (c) 2012 Ericsson | |
3 | * | |
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 | |
8 | * | |
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 | ||
23 | public class TmfActionProvider extends CommonActionProvider { | |
24 | ||
25 | private OpenAction openAction; | |
26 | private DeleteAction deleteAction; | |
27 | private RefreshAction refreshAction; | |
28 | ||
29 | /** | |
30 | * Default constructor | |
31 | */ | |
32 | public TmfActionProvider() { | |
33 | } | |
34 | ||
35 | /* | |
36 | * (non-Javadoc) | |
37 | * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite) | |
38 | */ | |
39 | @Override | |
40 | public void init(ICommonActionExtensionSite aSite) { | |
41 | ICommonViewerSite viewSite = aSite.getViewSite(); | |
42 | if (viewSite instanceof ICommonViewerWorkbenchSite) { | |
43 | ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite; | |
44 | openAction = new OpenAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
45 | deleteAction = new DeleteAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
46 | refreshAction = new RefreshAction(workbenchSite.getPage(), workbenchSite.getSelectionProvider()); | |
47 | } | |
48 | } | |
49 | ||
50 | /* | |
51 | * (non-Javadoc) | |
52 | * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) | |
53 | */ | |
54 | @Override | |
55 | public void fillActionBars(IActionBars actionBars) { | |
56 | if (openAction.isEnabled()) { | |
57 | actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openAction); | |
58 | } | |
59 | if (deleteAction.isEnabled()) { | |
60 | actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); | |
61 | } | |
62 | if (refreshAction.isEnabled()) { | |
63 | actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); | |
64 | } | |
65 | } | |
66 | ||
67 | } |