1/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.ide.eclipse.monitor;
18
19import org.eclipse.jface.action.GroupMarker;
20import org.eclipse.jface.action.IMenuManager;
21import org.eclipse.jface.action.MenuManager;
22import org.eclipse.ui.IWorkbenchActionConstants;
23import org.eclipse.ui.IWorkbenchWindow;
24import org.eclipse.ui.actions.ActionFactory;
25import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
26import org.eclipse.ui.application.ActionBarAdvisor;
27import org.eclipse.ui.application.IActionBarConfigurer;
28import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
29import org.eclipse.ui.internal.WorkbenchImages;
30
31public class MonitorActionBarAdvisor extends ActionBarAdvisor {
32    private IWorkbenchAction mQuitAction;
33    private IWorkbenchAction mCopyAction;
34    private IWorkbenchAction mSelectAllAction;
35    private IWorkbenchAction mFindAction;
36    private IWorkbenchAction mOpenPerspectiveAction;
37    private IWorkbenchAction mResetPerspectiveAction;
38    private IWorkbenchAction mPreferencesAction;
39    private IWorkbenchAction mAboutAction;
40
41    public MonitorActionBarAdvisor(IActionBarConfigurer configurer) {
42        super(configurer);
43    }
44
45    @Override
46    protected void makeActions(IWorkbenchWindow window) {
47        mQuitAction = ActionFactory.QUIT.create(window);
48        register(mQuitAction);
49
50        mCopyAction = ActionFactory.COPY.create(window);
51        register(mCopyAction);
52
53        mSelectAllAction = ActionFactory.SELECT_ALL.create(window);
54        register(mSelectAllAction);
55
56        mFindAction = ActionFactory.FIND.create(window);
57        mFindAction.setText("Find...");     // replace the default "Find and Replace..."
58        register(mFindAction);
59
60        mOpenPerspectiveAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(window);
61        register(mOpenPerspectiveAction);
62
63        mResetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window);
64        register(mResetPerspectiveAction);
65
66        mPreferencesAction = ActionFactory.PREFERENCES.create(window);
67        register(mPreferencesAction);
68
69        mAboutAction = ActionFactory.ABOUT.create(window);
70        register(mAboutAction);
71    }
72
73    @Override
74    protected void fillMenuBar(IMenuManager menuBar) {
75        MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
76        MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
77        MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
78        MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW);
79
80        menuBar.add(fileMenu);
81        menuBar.add(editMenu);
82        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
83        menuBar.add(windowMenu);
84        menuBar.add(helpMenu);
85
86        // contents of File menu
87        fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
88        fileMenu.add(mQuitAction);
89
90        // contents of Edit menu
91        editMenu.add(mCopyAction);
92        editMenu.add(mSelectAllAction);
93        editMenu.add(mFindAction);
94
95        // contents of Window menu
96        windowMenu.add(mOpenPerspectiveAction);
97        windowMenu.add(mResetPerspectiveAction);
98        windowMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
99        windowMenu.add(mPreferencesAction);
100
101        // contents of Help menu
102        helpMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
103        helpMenu.add(mAboutAction);
104    };
105}
106