001: /*
002: * Sun Public License Notice
003: *
004: * The contents of this file are subject to the Sun Public License
005: * Version 1.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://www.sun.com/
008: *
009: * The Original Code is NetBeans. The Initial Developer of the Original
010: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
011: * Microsystems, Inc. All Rights Reserved.
012: If you wish your version of this file to be governed by only the CDDL
013: or only the GPL Version 2, indicate your decision by adding
014: "[Contributor] elects to include this software in this distribution
015: under the [CDDL or GPL Version 2] license." If you do not indicate a
016: single choice of license, a recipient has the option to distribute
017: your version of this file under either the CDDL, the GPL Version 2 or
018: to extend the choice of license to its licensees as provided above.
019: However, if you add GPL Version 2 code and therefore, elected the GPL
020: Version 2 license, then the option applies only if the new code is
021: made subject to such option by the copyright holder.
022: If you wish your version of this file to be governed by only the CDDL
023: or only the GPL Version 2, indicate your decision by adding
024: "[Contributor] elects to include this software in this distribution
025: under the [CDDL or GPL Version 2] license." If you do not indicate a
026: single choice of license, a recipient has the option to distribute
027: your version of this file under either the CDDL, the GPL Version 2 or
028: to extend the choice of license to its licensees as provided above.
029: However, if you add GPL Version 2 code and therefore, elected the GPL
030: Version 2 license, then the option applies only if the new code is
031: made subject to such option by the copyright holder.
032: */
033: package org.netbeans.modules.mashup.db.wizard;
034:
035: import java.awt.Component;
036: import javax.swing.AbstractAction;
037: import javax.swing.Action;
038: import javax.swing.JComponent;
039: import javax.swing.JMenu;
040: import javax.swing.JMenuItem;
041: import javax.swing.JPopupMenu;
042: import javax.swing.event.MenuEvent;
043: import javax.swing.event.MenuListener;
044:
045: import net.java.hulp.i18n.Logger;
046: import org.netbeans.modules.etl.logger.Localizer;
047: import org.netbeans.modules.etl.logger.LogUtil;
048: import org.netbeans.modules.mashup.tables.wizard.MashupTableWizardIterator;
049: import org.openide.awt.DynamicMenuContent;
050: import org.openide.util.Utilities;
051: import org.openide.util.actions.Presenter;
052: import org.openide.util.actions.SystemAction;
053:
054: /**
055: *
056: * @author ks161616
057: */
058: public class NewFFDBAction extends AbstractAction implements
059: Presenter.Menu {
060:
061: private JMenuItem menuPresenter = null;
062: private static transient final Logger mLogger = LogUtil
063: .getLogger(NewFFDBAction.class.getName());
064: private static transient final Localizer mLoc = Localizer.get();
065: public static String nbBundle1 = mLoc.t("PRSR001: Mashup Database");
066:
067: public NewFFDBAction() {
068: super (Localizer.parse(nbBundle1));
069: }
070:
071: public void actionPerformed(java.awt.event.ActionEvent e) {
072: }
073:
074: public JMenuItem getMenuPresenter() {
075: if (menuPresenter == null) {
076: menuPresenter = new MenuPresenter();
077: }
078: return menuPresenter;
079: }
080:
081: private final class MenuPresenter extends JMenu implements
082: DynamicMenuContent, MenuListener {
083:
084: public MenuPresenter() {
085: super ((String) getValue(Action.NAME));
086: addMenuListener(this );
087: }
088:
089: public JComponent[] synchMenuPresenters(
090: javax.swing.JComponent[] items) {
091: return getMenuPresenters();
092: }
093:
094: public JComponent[] getMenuPresenters() {
095: return new JComponent[] { this };
096: }
097:
098: public void menuSelected(MenuEvent e) {
099: getPopupMenu().removeAll();
100: MashupTableWizardIterator.IS_PROJECT_CALL = false;
101: JPopupMenu menu = Utilities
102: .actionsToPopup(
103: new Action[] {
104: SystemAction
105: .get(NewFlatfileDatabaseWizardAction.class),
106: SystemAction
107: .get(NewFlatfileTableAction.class),
108: SystemAction
109: .get(NewJDBCTableAction.class),
110: SystemAction
111: .get(FlatfileDBViewerAction.class) },
112: Utilities.actionsGlobalContext());
113: while (menu.getComponentCount() > 0) {
114: Component c = menu.getComponent(0);
115: menu.remove(0);
116: getPopupMenu().add(c);
117: }
118: }
119:
120: public void menuCanceled(MenuEvent e) {
121: }
122:
123: public void menuDeselected(MenuEvent e) {
124: }
125: }
126: }
|