KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > forte > actions > EnhydraAction


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Lisa Reese
21  *
22  */

23
24
25 package org.enhydra.kelp.forte.actions;
26
27 import java.awt.event.ActionEvent JavaDoc;
28 import java.awt.Component JavaDoc;
29 import javax.swing.*;
30
31 import org.openide.util.HelpCtx;
32 import org.openide.util.NbBundle;
33 import org.openide.util.actions.Presenter;
34 import org.openide.util.actions.SystemAction;
35 /**
36  *
37  * @author rees0234
38  * @version
39  */

40 public class EnhydraAction extends SystemAction implements Presenter.Menu, Presenter.Popup {
41
42     public void actionPerformed (ActionEvent JavaDoc ev) {
43         // do nothing; should not be called
44
}
45
46     public String JavaDoc getName () {
47         return NbBundle.getMessage (EnhydraAction.class, "LBL_Enhydra_Tools");
48     }
49
50     protected String JavaDoc iconResource () {
51         return "XMLCActionIcon.gif";
52     }
53
54     public HelpCtx getHelpCtx () {
55    // return new HelpCtx(EnhydraAction.class);
56
return HelpCtx.DEFAULT_HELP;
57     }
58
59     /** List of system actions to be displayed within this one's toolbar or submenu. */
60     private static final SystemAction[] grouped = new SystemAction[] {
61                 SystemAction.get (XMLCAction.class),
62                 SystemAction.get (DeploymentAction.class),
63                 SystemAction.get (AppWizardAction.class),
64             };
65
66     private static Icon icon = null;
67
68     public JMenuItem getMenuPresenter () {
69         JMenu menu = new JMenu (getName ());
70         if (icon == null) icon = new ImageIcon (EnhydraAction.class.getResource (iconResource ()));
71         menu.setIcon (icon);
72         for (int i = 0; i < grouped.length; i++) {
73             SystemAction action = grouped[i];
74             if (action == null) {
75                 menu.addSeparator ();
76             } else if (action instanceof Presenter.Menu) {
77                 menu.add (((Presenter.Menu) action).getMenuPresenter ());
78             }
79         }
80         return menu;
81     }
82
83     public JMenuItem getPopupPresenter () {
84         JMenu menu = new JMenu (getName ());
85         // Conventional not to set an icon here.
86
for (int i = 0; i < grouped.length; i++) {
87             SystemAction action = grouped[i];
88             if (action == null) {
89                 menu.addSeparator ();
90             } else if (action instanceof Presenter.Popup) {
91                 menu.add (((Presenter.Popup) action).getPopupPresenter ());
92             }
93         }
94         return menu;
95     }
96
97 }
98
Popular Tags