001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: //
007: package com.sun.portal.ffj.actions;
008:
009: //
010: import java.awt.event.ActionEvent;
011: import java.awt.Component;
012: import javax.swing.*;
013:
014: import org.openide.awt.JMenuPlus;
015: import org.openide.util.HelpCtx;
016: import org.openide.util.NbBundle;
017: import org.openide.util.actions.Presenter;
018: import org.openide.util.actions.SystemAction;
019:
020: //
021: public class PSGroupAction extends SystemAction implements
022: Presenter.Menu, Presenter.Popup, Presenter.Toolbar {
023: //
024: private static Icon icon = null;
025:
026: //
027: //
028: //
029: public void actionPerformed(ActionEvent ev) {
030: // do nothing; should not be called
031: }
032:
033: public String getName() {
034: return NbBundle.getMessage(PSGroupAction.class,
035: "LBL_PSGroupAction");
036: }
037:
038: public HelpCtx getHelpCtx() {
039: return HelpCtx.DEFAULT_HELP;
040: // If you will provide context help then use:
041: // return new HelpCtx (PSGroupAction.class);
042: }
043:
044: /** Perform extra initialization of this action's singleton.
045: * PLEASE do not use constructors for this purpose!
046: protected void initialize() {
047: super.initialize();
048: putProperty("someProp", value);
049: }
050: */
051:
052: //
053: //
054: //
055: private static final SystemAction[] grouped() {
056: return new SystemAction[] {
057: SystemAction.get(ExecuteAction.class),
058: SystemAction.get(ExecuteRestartAction.class),
059: SystemAction.get(PackageAction.class),
060: SystemAction.get(PackageRestartAction.class) };
061: }
062:
063: //
064: //
065: //
066: public JMenuItem getMenuPresenter() {
067: //
068: JMenu menu = new JMenuPlus(getName());
069:
070: //
071: if (icon == null)
072: icon = new ImageIcon(PSGroupAction.class
073: .getResource(iconResource()));
074: menu.setIcon(icon);
075:
076: //
077: SystemAction[] grouped = grouped();
078: for (int i = 0; i < grouped.length; i++) {
079: SystemAction action = grouped[i];
080: if (action == null) {
081: menu.addSeparator();
082: } else if (action instanceof Presenter.Menu) {
083: menu.add(((Presenter.Menu) action).getMenuPresenter());
084: }
085: }
086:
087: //
088: return menu;
089: }
090:
091: //
092: //
093: //
094: public JMenuItem getPopupPresenter() {
095: //
096: JMenu menu = new JMenu(getName());
097:
098: //
099: SystemAction[] grouped = grouped();
100: for (int i = 0; i < grouped.length; i++) {
101: SystemAction action = grouped[i];
102: if (action == null) {
103: menu.addSeparator();
104: } else if (action instanceof Presenter.Popup) {
105: menu
106: .add(((Presenter.Popup) action)
107: .getPopupPresenter());
108: }
109: }
110:
111: //
112: return menu;
113: }
114:
115: //
116: //
117: //
118: public Component getToolbarPresenter() {
119: //
120: JToolBar toolbar = new JToolBar(/* In JDK 1.3 you may add: getName () */);
121:
122: //
123: SystemAction[] grouped = grouped();
124: for (int i = 0; i < grouped.length; i++) {
125: SystemAction action = grouped[i];
126: if (action == null) {
127: toolbar.addSeparator();
128: } else if (action instanceof Presenter.Toolbar) {
129: toolbar.add(((Presenter.Toolbar) action)
130: .getToolbarPresenter());
131: }
132: }
133:
134: //
135: return toolbar;
136: }
137:
138: //
139: //
140: //
141: }
|