Search in sources :

Example 1 with JMenuItem

use of javax.swing.JMenuItem in project pcgen by PCGen.

the class GMGenSystem method createEditMenu.

// Create the edit menu
private void createEditMenu() {
    editMenu = new JMenu();
    cutEditItem = new JMenuItem();
    copyEditItem = new JMenuItem();
    pasteEditItem = new JMenuItem();
    editSeparator1 = new JSeparator();
    preferencesEditItem = new JMenuItem();
    // EDIT MENU
    CommonMenuText.name(editMenu, PCGenActionMap.MNU_EDIT);
    editMenu.addMenuListener(this);
    CommonMenuText.name(cutEditItem, MNU_CUT);
    editMenu.add(cutEditItem);
    CommonMenuText.name(copyEditItem, MNU_COPY);
    editMenu.add(copyEditItem);
    CommonMenuText.name(pasteEditItem, MNU_PASTE);
    editMenu.add(pasteEditItem);
    // Preferences... on MAC OS X is in the application menu. See macOSXRegistration()
    if (!SystemUtils.IS_OS_MAC_OSX) {
        editMenu.add(editSeparator1);
        CommonMenuText.name(preferencesEditItem, PCGenActionMap.MNU_TOOLS_PREFERENCES);
        editMenu.add(preferencesEditItem);
        preferencesEditItem.setEnabled(true);
        ActionListener[] listenerArray = preferencesEditItem.getActionListeners();
        for (final ActionListener aListenerArray : listenerArray) {
            preferencesEditItem.removeActionListener(aListenerArray);
        }
        preferencesEditItem.addActionListener(this::mPreferencesActionPerformed);
    }
    systemMenuBar.add(editMenu);
}
Also used : ActionListener(java.awt.event.ActionListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JSeparator(javax.swing.JSeparator)

Example 2 with JMenuItem

use of javax.swing.JMenuItem in project voltdb by VoltDB.

the class DatabaseManagerSwing method main.

public void main() {
    JMenu jmenu;
    JMenuItem mitem;
    try {
        prefs = new DBMPrefs(fMain instanceof JApplet);
    } catch (Exception e) {
        System.err.println("Failed to load preferences.  Proceeding with defaults:\n");
    }
    if (prefs == null) {
        setLF(CommonSwing.Native);
    } else {
        autoRefresh = prefs.autoRefresh;
        displayRowCounts = prefs.showRowCounts;
        showSys = prefs.showSysTables;
        showSchemas = prefs.showSchemas;
        gridFormat = prefs.resultGrid;
        showTooltips = prefs.showTooltips;
        setLF(prefs.laf);
    }
    // (ulrivo): An actual icon.  N.b., this adds some tips to the tip map
    fMain.getContentPane().add(createToolBar(), "North");
    if (fMain instanceof java.awt.Frame) {
        ((java.awt.Frame) fMain).setIconImage(CommonSwing.getIcon("Frame"));
    }
    if (fMain instanceof java.awt.Window) {
        ((java.awt.Window) fMain).addWindowListener(this);
    }
    JMenuBar bar = new JMenuBar();
    // used shortcuts: CERGTSIUDOLM
    String[] fitems = { "-Connect...", "--", "OOpen Script...", "-Save Script...", "-Save Result...", "--", "-Exit" };
    jmenu = addMenu(bar, "File", fitems);
    // All actions after Connect and the divider are local.
    for (int i = 2; i < jmenu.getItemCount(); i++) {
        mitem = jmenu.getItem(i);
        if (mitem != null) {
            localActionList.add(mitem);
        }
    }
    Object[] vitems = { "RRefresh Tree", boxAutoRefresh, "--", boxRowCounts, boxShowSys, boxShowSchemas, boxShowGrid };
    addMenu(bar, "View", vitems);
    String[] sitems = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "EEXECUTE", "---", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "CCOMMIT*", "LROLLBACK*", "-CHECKPOINT*", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" };
    addMenu(bar, "Command", sitems);
    mRecent = new JMenu("Recent");
    mRecent.setMnemonic(KeyEvent.VK_R);
    bar.add(mRecent);
    ButtonGroup lfGroup = new ButtonGroup();
    lfGroup.add(rbNativeLF);
    lfGroup.add(rbJavaLF);
    lfGroup.add(rbMotifLF);
    boxShowSchemas.setSelected(showSchemas);
    boxShowGrid.setSelected(gridFormat);
    boxTooltips.setSelected(showTooltips);
    boxShowGrid.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, Event.CTRL_MASK));
    boxAutoRefresh.setSelected(autoRefresh);
    boxRowCounts.setSelected(displayRowCounts);
    boxShowSys.setSelected(showSys);
    rbNativeLF.setActionCommand("LFMODE:" + CommonSwing.Native);
    rbJavaLF.setActionCommand("LFMODE:" + CommonSwing.Java);
    rbMotifLF.setActionCommand("LFMODE:" + CommonSwing.Motif);
    tipMap.put(mitemUpdateSchemas, "Refresh the schema list in this menu");
    tipMap.put(rbAllSchemas, "Display items in all schemas");
    tipMap.put(mitemAbout, "Display product information");
    tipMap.put(mitemHelp, "Display advice for obtaining help");
    tipMap.put(boxAutoRefresh, "Refresh tree (and schema list) automatically" + "when YOU modify database objects");
    tipMap.put(boxShowSchemas, "Display object names in tree like schemaname.basename");
    tipMap.put(rbNativeLF, "Set Look and Feel to Native for your platform");
    tipMap.put(rbJavaLF, "Set Look and Feel to Java");
    tipMap.put(rbMotifLF, "Set Look and Feel to Motif");
    boxTooltips.setToolTipText("Display tooltips (hover text), like this");
    tipMap.put(boxAutoCommit, "Shows current Auto-commit mode.  Click to change");
    tipMap.put(boxLogging, "Shows current JDBC DriverManager logging mode.  Click to change");
    tipMap.put(boxShowSys, "Show system tables in table tree to the left");
    tipMap.put(boxShowGrid, "Show query results in grid (in text if off)");
    tipMap.put(boxRowCounts, "Show row counts with table names in tree");
    boxAutoRefresh.setMnemonic(KeyEvent.VK_C);
    boxShowSchemas.setMnemonic(KeyEvent.VK_Y);
    boxAutoCommit.setMnemonic(KeyEvent.VK_A);
    boxShowSys.setMnemonic(KeyEvent.VK_Y);
    boxShowGrid.setMnemonic(KeyEvent.VK_G);
    boxRowCounts.setMnemonic(KeyEvent.VK_C);
    boxLogging.setMnemonic(KeyEvent.VK_L);
    rbAllSchemas.setMnemonic(KeyEvent.VK_ASTERISK);
    rbNativeLF.setMnemonic(KeyEvent.VK_N);
    rbJavaLF.setMnemonic(KeyEvent.VK_J);
    rbMotifLF.setMnemonic(KeyEvent.VK_M);
    mitemUpdateSchemas.setMnemonic(KeyEvent.VK_U);
    Object[] soptions = { // Added: (weconsultants@users) New menu options
    rbNativeLF, rbJavaLF, rbMotifLF, "--", "-Set Fonts", "--", boxAutoCommit, "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", boxLogging, "--", "-Insert test data" };
    addMenu(bar, "Options", soptions);
    String[] stools = { "-Dump", "-Restore", "-Transfer" };
    jmenu = addMenu(bar, "Tools", stools);
    jmenu.setEnabled(TT_AVAILABLE);
    localActionList.add(jmenu);
    for (int i = 0; i < jmenu.getItemCount(); i++) {
        mitem = jmenu.getItem(i);
        if (mitem != null) {
            localActionList.add(mitem);
        }
    }
    mnuSchemas.setMnemonic(KeyEvent.VK_S);
    bar.add(mnuSchemas);
    JMenu mnuHelp = new JMenu("Help");
    mnuHelp.setMnemonic(KeyEvent.VK_H);
    mnuHelp.add(mitemAbout);
    mnuHelp.add(mitemHelp);
    mnuHelp.add(boxTooltips);
    rbAllSchemas.addActionListener(schemaListListener);
    // May be illegal:
    mitemUpdateSchemas.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            updateSchemaList();
        }
    });
    mitemHelp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            JOptionPane.showMessageDialog(fMain.getContentPane(), HELP_TEXT, "HELP", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    mitemAbout.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            JOptionPane.showMessageDialog(fMain.getContentPane(), ABOUT_TEXT, "About", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    boxTooltips.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            showTooltips = boxTooltips.isSelected();
            resetTooltips();
        }
    });
    bar.add(mnuHelp);
    if (fMain instanceof JApplet) {
        ((JApplet) fMain).setJMenuBar(bar);
    } else if (fMain instanceof JFrame) {
        ((JFrame) fMain).setJMenuBar(bar);
    }
    initGUI();
    sRecent = new String[iMaxRecent];
    // Modified: (weconsultants@users)Mode code to CommonSwing for general use
    if (!(fMain instanceof JApplet)) {
        CommonSwing.setFramePositon((JFrame) fMain);
    }
    // Modified: (weconsultants@users) Changed from deprecated show()
    ((Component) fMain).setVisible(true);
    // (ulrivo): load query from command line
    if (defScript != null) {
        if (defDirectory != null) {
            defScript = defDirectory + File.separator + defScript;
        }
        // if insert stmet is thousands of records...skip showing it
        // as text.  Too huge.
        sqlScriptBuffer = DatabaseManagerCommon.readFile(defScript);
        if (4096 <= sqlScriptBuffer.length()) {
            int eoThirdLine = sqlScriptBuffer.indexOf('\n');
            if (eoThirdLine > 0) {
                eoThirdLine = sqlScriptBuffer.indexOf('\n', eoThirdLine + 1);
            }
            if (eoThirdLine > 0) {
                eoThirdLine = sqlScriptBuffer.indexOf('\n', eoThirdLine + 1);
            }
            if (eoThirdLine < 1) {
                eoThirdLine = 100;
            }
            txtCommand.setText("............... Script File loaded: " + defScript + " ..................... \n" + "............... Click Execute or Clear " + "...................\n" + sqlScriptBuffer.substring(0, eoThirdLine + 1) + "..........................................." + "..............................\n" + "............................................." + "............................\n");
            txtCommand.setEnabled(false);
        } else {
            txtCommand.setText(sqlScriptBuffer);
            sqlScriptBuffer = null;
            txtCommand.setEnabled(true);
        }
    }
    // This must be done AFTER all tip texts are put into the map
    resetTooltips();
    txtCommand.requestFocus();
}
Also used : JFrame(javax.swing.JFrame) ActionEvent(java.awt.event.ActionEvent) InvocationTargetException(java.lang.reflect.InvocationTargetException) AccessControlException(java.security.AccessControlException) SQLException(java.sql.SQLException) IOException(java.io.IOException) JApplet(javax.swing.JApplet) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JFrame(javax.swing.JFrame) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) JComponent(javax.swing.JComponent) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 3 with JMenuItem

use of javax.swing.JMenuItem in project ACS by ACS-Community.

the class SmartTextPane method getPopup.

/**
	 * Insert the method's description here.
	 * Creation date: (18.2.2002 17:58:02)
	 * @return javax.swing.JPopupMenu
	 */
public javax.swing.JPopupMenu getPopup() {
    if (popup == null) {
        popup = new JPopupMenu("Smart text pane");
        JMenuItem saveItem = new JMenuItem("Save");
        saveItem.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                saveTextToFile();
            }
        });
        popup.add(saveItem);
    }
    return popup;
}
Also used : JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 4 with JMenuItem

use of javax.swing.JMenuItem in project ACS by ACS-Community.

the class ScriptFilter method getFileMenuExitButton.

/**
	 * This method initializes FileMenuExitButton
	 * @return javax.swing.JMenuItem
	 */
private JMenuItem getFileMenuExitButton() {
    if (FileMenuExitButton == null) {
        FileMenuExitButton = new JMenuItem();
        FileMenuExitButton.setText("Exit");
        FileMenuExitButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                askClose();
            }
        });
    }
    return FileMenuExitButton;
}
Also used : JMenuItem(javax.swing.JMenuItem) ActionEvent(java.awt.event.ActionEvent)

Example 5 with JMenuItem

use of javax.swing.JMenuItem in project ACS by ACS-Community.

the class ScriptFilter method getFileMenuSelectSMButton.

/**
	 * This method initializes FileMenuSelectSMButton
	 * @return javax.swing.JMenuItem
	 */
private JMenuItem getFileMenuSelectSMButton() {
    if (FileMenuSelectSMButton == null) {
        FileMenuSelectSMButton = new JMenuItem();
        FileMenuSelectSMButton.setText("Choose Sampling Manager");
        FileMenuSelectSMButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                String s = (String) JOptionPane.showInputDialog(SamplingSystemGUI.this, "Please Select a Sampling Manager", "Sampling Manager Selection", JOptionPane.PLAIN_MESSAGE, null, (Object[]) SampTool.getSamplingManagers(), MAN_NAME);
                if (s != null && !s.trim().equals(""))
                    SamplingSystemGUI.this.MAN_NAME = s;
                checkSamplingManager();
            }
        });
    }
    return FileMenuSelectSMButton;
}
Also used : JMenuItem(javax.swing.JMenuItem) ActionEvent(java.awt.event.ActionEvent)

Aggregations

JMenuItem (javax.swing.JMenuItem)1138 ActionEvent (java.awt.event.ActionEvent)559 ActionListener (java.awt.event.ActionListener)463 JMenu (javax.swing.JMenu)373 JPopupMenu (javax.swing.JPopupMenu)229 JMenuBar (javax.swing.JMenuBar)104 AbstractAction (javax.swing.AbstractAction)90 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)76 ArrayList (java.util.ArrayList)72 JPanel (javax.swing.JPanel)70 Point (java.awt.Point)65 JSeparator (javax.swing.JSeparator)63 File (java.io.File)61 JLabel (javax.swing.JLabel)61 BorderLayout (java.awt.BorderLayout)57 JButton (javax.swing.JButton)54 Component (java.awt.Component)53 ButtonGroup (javax.swing.ButtonGroup)50 Dimension (java.awt.Dimension)46 MouseEvent (java.awt.event.MouseEvent)45