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