Search in sources :

Example 96 with JMenuItem

use of javax.swing.JMenuItem in project JMRI by JMRI.

the class HelpUtil method makeHelpMenu.

public static JMenu makeHelpMenu(String ref, boolean direct) {
    if (!initOK()) {
        log.warn("help initialization not completed");
        // initialization failed
        return null;
    }
    JMenu helpMenu = new JMenu(Bundle.getMessage("HELP"));
    JMenuItem item = makeHelpMenuItem(ref);
    if (item == null) {
        log.error("Can't make help menu item for " + ref);
        return null;
    }
    helpMenu.add(item);
    if (direct) {
        item = new JMenuItem(Bundle.getMessage("MenuItemHelp"));
        globalHelpBroker.enableHelpOnButton(item, "index", null);
        helpMenu.add(item);
        // add standard items
        JMenuItem license = new JMenuItem(Bundle.getMessage("MenuItemLicense"));
        helpMenu.add(license);
        license.addActionListener(new apps.LicenseAction());
        JMenuItem directories = new JMenuItem(Bundle.getMessage("MenuItemLocations"));
        helpMenu.add(directories);
        directories.addActionListener(new jmri.jmrit.XmlFileLocationAction());
        JMenuItem updates = new JMenuItem(Bundle.getMessage("MenuItemCheckUpdates"));
        helpMenu.add(updates);
        updates.addActionListener(new apps.CheckForUpdateAction());
        JMenuItem context = new JMenuItem(Bundle.getMessage("MenuItemContext"));
        helpMenu.add(context);
        context.addActionListener(new apps.ReportContextAction());
        JMenuItem console = new JMenuItem(Bundle.getMessage("MenuItemConsole"));
        helpMenu.add(console);
        console.addActionListener(new apps.SystemConsoleAction());
        helpMenu.add(new jmri.jmrit.mailreport.ReportAction());
        // Put about dialog in Apple's prefered area on Mac OS X
        if (SystemType.isMacOSX()) {
            try {
                Application.getApplication().setAboutHandler((EventObject eo) -> {
                    new AboutDialog(null, true).setVisible(true);
                });
            } catch (java.lang.RuntimeException re) {
                log.error("Unable to put About handler in default location", re);
            }
        }
        // Include About in Help menu if not on Mac OS X or not using Aqua Look and Feel
        if (!SystemType.isMacOSX() || !UIManager.getLookAndFeel().isNativeLookAndFeel()) {
            helpMenu.addSeparator();
            JMenuItem about = new JMenuItem(Bundle.getMessage("MenuItemAbout") + " " + jmri.Application.getApplicationName());
            helpMenu.add(about);
            about.addActionListener(new AboutAction());
        }
    }
    return helpMenu;
}
Also used : AboutDialog(jmri.swing.AboutDialog) AboutAction(apps.AboutAction) EventObject(java.util.EventObject) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 97 with JMenuItem

use of javax.swing.JMenuItem in project JMRI by JMRI.

the class HelpUtil method makeHelpMenuItem.

public static JMenuItem makeHelpMenuItem(String ref) {
    if (!initOK()) {
        // initialization failed
        return null;
    }
    JMenuItem menuItem = new JMenuItem(Bundle.getMessage("MenuItemWindowHelp"));
    globalHelpBroker.enableHelpOnButton(menuItem, ref, null);
    // start help to see what happend
    log.debug("help: {}:{}:{}", globalHelpSet.getHomeID(), globalHelpSet.getTitle(), globalHelpSet.getHelpSetURL());
    return menuItem;
}
Also used : JMenuItem(javax.swing.JMenuItem)

Example 98 with JMenuItem

use of javax.swing.JMenuItem in project JMRI by JMRI.

the class PowerManagerMenu method setDefault.

void setDefault() {
    // name of default
    PowerManager manager = InstanceManager.getNullableDefault(jmri.PowerManager.class);
    if (manager == null) {
        return;
    }
    String defaultMgr = manager.getUserName();
    for (JMenuItem item : items) {
        if (defaultMgr.equals(item.getActionCommand())) {
            item.setSelected(true);
        }
    }
}
Also used : PowerManager(jmri.PowerManager) JMenuItem(javax.swing.JMenuItem)

Example 99 with JMenuItem

use of javax.swing.JMenuItem in project JMRI by JMRI.

the class Source method createPopUpMenu.

//ArrayList<LayoutBlock> protectingBlocks;
void createPopUpMenu() {
    if (entryExitPopUp != null) {
        return;
    }
    entryExitPopUp = new JMenu(Bundle.getMessage("MenuEntryExit"));
    editClear = new JMenuItem(Bundle.getMessage("MenuItemClearRoute"));
    editClear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancelClearInterlockFromSource(EntryExitPairs.CLEARROUTE);
        }
    });
    entryExitPopUp.add(editClear);
    editCancel = new JMenuItem(Bundle.getMessage("MenuItemCancelRoute"));
    editCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancelClearInterlockFromSource(EntryExitPairs.CANCELROUTE);
        }
    });
    entryExitPopUp.add(editCancel);
    editOneClick = new JMenuItem(Bundle.getMessage("MenuItemLockManualRoute"));
    editOneClick.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new ManuallySetRoute(pd);
        }
    });
    entryExitPopUp.add(editOneClick);
    clear = new JMenuItem(Bundle.getMessage("MenuItemClearRoute"));
    clear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancelClearInterlockFromSource(EntryExitPairs.CLEARROUTE);
        }
    });
    cancel = new JMenuItem(Bundle.getMessage("MenuItemCancelRoute"));
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cancelClearInterlockFromSource(EntryExitPairs.CANCELROUTE);
        }
    });
    oneClick = new JMenuItem(Bundle.getMessage("MenuItemLockManualRoute"));
    oneClick.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new ManuallySetRoute(pd);
        }
    });
    pd.getPanel().addToPopUpMenu(pd.getSensor(), entryExitPopUp, jmri.jmrit.display.Editor.EDITPOPUPONLY);
    pd.getPanel().addToPopUpMenu(pd.getSensor(), clear, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
    pd.getPanel().addToPopUpMenu(pd.getSensor(), cancel, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
    pd.getPanel().addToPopUpMenu(pd.getSensor(), oneClick, jmri.jmrit.display.Editor.VIEWPOPUPONLY);
    setMenuEnabled(false);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 100 with JMenuItem

use of javax.swing.JMenuItem in project JMRI by JMRI.

the class CsvExportAction method startLogging.

void startLogging(ActionEvent e) {
    System.out.println("" + e);
    ((JMenuItem) (e.getSource())).setText("Stop CSV Export Reading...");
    // initialize chooser
    if (fileChooser == null) {
        fileChooser = new JFileChooser();
    } else {
        fileChooser.rescanCurrentDirectory();
    }
    // get file
    int retVal = fileChooser.showSaveDialog(mParent);
    if (retVal == JFileChooser.APPROVE_OPTION) {
        File file = fileChooser.getSelectedFile();
        if (log.isDebugEnabled()) {
            log.debug("start to log to file " + file);
        }
        try {
            str = new PrintStream(new FileOutputStream(file));
            Distributor.instance().addReadingListener(this);
            logging = true;
        } catch (IOException ex) {
            log.error("Error opening file: " + ex);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) JFileChooser(javax.swing.JFileChooser) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) JMenuItem(javax.swing.JMenuItem) File(java.io.File)

Aggregations

JMenuItem (javax.swing.JMenuItem)1130 ActionEvent (java.awt.event.ActionEvent)559 ActionListener (java.awt.event.ActionListener)464 JMenu (javax.swing.JMenu)369 JPopupMenu (javax.swing.JPopupMenu)225 JMenuBar (javax.swing.JMenuBar)103 AbstractAction (javax.swing.AbstractAction)90 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)76 ArrayList (java.util.ArrayList)71 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