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