KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > windows > actions > ToolbarsListAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core.windows.actions;
21
22 import org.netbeans.core.windows.view.ui.toolbars.ToolbarConfiguration;
23 import org.openide.awt.Mnemonics;
24 import org.openide.awt.ToolbarPool;
25 import org.openide.util.NbBundle;
26 import org.openide.util.Utilities;
27 import org.openide.util.actions.Presenter;
28
29 import javax.swing.*;
30
31
32 /** Action that lists toolbars of current toolbar config in a submenu, the
33  * same like a popup menu on toolbars area.
34  *
35  * @author Dafe Simonek
36  */

37 public class ToolbarsListAction extends AbstractAction
38                                 implements Presenter.Menu {
39     
40     public ToolbarsListAction() {
41         putValue(NAME,NbBundle.getMessage(ToolbarsListAction.class, "CTL_ToolbarsListAction"));
42         putValue("noIconInMenu", Boolean.TRUE); // NOI18N
43
}
44     
45     /** Perform the action. Tries the performer and then scans the ActionMap
46      * of selected topcomponent.
47      */

48     public void actionPerformed(java.awt.event.ActionEvent JavaDoc ev) {
49         // no operation
50
}
51     
52     public JMenuItem getMenuPresenter() {
53         String JavaDoc label = NbBundle.getMessage(ToolbarsListAction.class, "CTL_ToolbarsListAction");
54         JMenu menu = new JMenu(label);
55         //#40584 fix start setting the empty, transparent icon for the menu item to align it correctly with other items
56
//menu.setIcon(new ImageIcon(Utilities.loadImage("org/openide/resources/actions/empty.gif"))); //NOI18N
57
//#40584 fix end
58
Mnemonics.setLocalizedText(menu, label);
59         ToolbarConfiguration curConf =
60             ToolbarConfiguration.findConfiguration(ToolbarPool.getDefault().getConfiguration());
61         if (curConf == null) {
62             return null;
63         }
64         return curConf.getToolbarsMenu(menu);
65     }
66     
67 }
68
69
Popular Tags