ApplicationActionBarAdvisor.java
01 /*
02  *
03  * Licensed to the Apache Software Foundation (ASF) under one
04  * or more contributor license agreements.  See the NOTICE file
05  * distributed with this work for additional information
06  * regarding copyright ownership.  The ASF licenses this file
07  * to you under the Apache License, Version 2.0 (the
08  * "License"); you may not use this file except in compliance
09  * with the License.  You may obtain a copy of the License at
10  
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 package org.apache.qpid.management.ui;
22 
23 import org.apache.qpid.management.ui.actions.VersionAction;
24 import org.eclipse.jface.action.Action;
25 import org.eclipse.jface.action.GroupMarker;
26 import org.eclipse.jface.action.ICoolBarManager;
27 import org.eclipse.jface.action.IMenuManager;
28 import org.eclipse.jface.action.MenuManager;
29 import org.eclipse.jface.action.Separator;
30 import org.eclipse.ui.IWorkbenchActionConstants;
31 import org.eclipse.ui.IWorkbenchWindow;
32 import org.eclipse.ui.actions.ActionFactory;
33 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
34 import org.eclipse.ui.application.ActionBarAdvisor;
35 import org.eclipse.ui.application.IActionBarConfigurer;
36 
37 /**
38  * An action bar advisor is responsible for creating, adding, and disposing of the
39  * actions added to a workbench window. Each window will be populated with
40  * new actions.
41  */
42 public class ApplicationActionBarAdvisor extends ActionBarAdvisor
43 {
44 
45     // Actions - important to allocate these only in makeActions, and then use them
46     // in the fill methods.  This ensures that the actions aren't recreated
47     // when fillActionBars is called with FILL_PROXY.
48     private IWorkbenchAction exitAction;
49     private Action _aboutAction;
50 
51     public ApplicationActionBarAdvisor(IActionBarConfigurer configurer)
52     {
53         super(configurer);
54     }
55     
56     protected void makeActions(final IWorkbenchWindow window)
57     {        
58         // Creates the actions and registers them.
59         // Registering is needed to ensure that key bindings work.
60         // The corresponding commands keybindings are defined in the plugin.xml file.
61         // Registering also provides automatic disposal of the actions when
62         // the window is closed.
63 
64         exitAction = ActionFactory.QUIT.create(window);
65         register(exitAction);
66         
67         _aboutAction = new VersionAction(window);
68         register(_aboutAction);
69     }
70     
71     
72     protected void fillMenuBar(IMenuManager menuBar)
73     {
74         MenuManager fileMenu = new MenuManager("&Qpid Manager""qpidmanager");
75         MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
76         
77         menuBar.add(fileMenu);
78         // Add a group marker indicating where action set menus will appear.
79         menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
80         menuBar.add(helpMenu);
81         
82         fileMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
83         fileMenu.add(new Separator());
84         fileMenu.add(new GroupMarker("mbeanactions"));
85         fileMenu.add(new Separator());
86         fileMenu.add(exitAction);
87         
88         // Help
89         helpMenu.add(_aboutAction);
90     }
91     
92     protected void fillCoolBar(ICoolBarManager coolBar)
93     {
94         
95     }
96 }