Search in sources :

Example 1 with TransferActionListener

use of jmri.util.com.sun.TransferActionListener in project JMRI by JMRI.

the class TableFrames method initComponents.

@Override
public void initComponents() {
    setTitle(Bundle.getMessage("TitleOBlocks"));
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    fileMenu.add(new jmri.configurexml.SaveMenu());
    JMenuItem printItem = new JMenuItem(Bundle.getMessage("PrintOBlockTable"));
    fileMenu.add(printItem);
    printItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                // MessageFormat headerFormat = new MessageFormat(getTitle());  // not used below
                MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
                _oBlockTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
            } catch (java.awt.print.PrinterException e1) {
                log.warn("error printing: " + e1, e1);
            }
        }
    });
    printItem = new JMenuItem(Bundle.getMessage("PrintPortalTable"));
    fileMenu.add(printItem);
    printItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                // MessageFormat headerFormat = new MessageFormat(getTitle());  // not used below
                MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
                _portalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
            } catch (java.awt.print.PrinterException e1) {
                log.warn("error printing: " + e1, e1);
            }
        }
    });
    printItem = new JMenuItem(Bundle.getMessage("PrintSignalTable"));
    fileMenu.add(printItem);
    printItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                // MessageFormat headerFormat = new MessageFormat(getTitle());  // not used below
                MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
                _signalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
            } catch (java.awt.print.PrinterException e1) {
                log.warn("error printing: " + e1, e1);
            }
        }
    });
    printItem = new JMenuItem(Bundle.getMessage("PrintXRef"));
    fileMenu.add(printItem);
    printItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                // MessageFormat headerFormat = new MessageFormat(getTitle());  // not used below
                MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
                _blockPortalTable.print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
            } catch (java.awt.print.PrinterException e1) {
                log.warn("error printing: " + e1, e1);
            }
        }
    });
    menuBar.add(fileMenu);
    JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
    editMenu.setMnemonic(KeyEvent.VK_E);
    TransferActionListener actionListener = new TransferActionListener();
    JMenuItem menuItem = new JMenuItem(Bundle.getMessage("MenuItemCut"));
    menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    if (SystemType.isMacOSX()) {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.META_MASK));
    } else {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    }
    menuItem.setMnemonic(KeyEvent.VK_T);
    editMenu.add(menuItem);
    menuItem = new JMenuItem(Bundle.getMessage("MenuItemCopy"));
    menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    if (SystemType.isMacOSX()) {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.META_MASK));
    } else {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    }
    menuItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(menuItem);
    menuItem = new JMenuItem(Bundle.getMessage("MenuItemPaste"));
    menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME));
    menuItem.addActionListener(actionListener);
    if (SystemType.isMacOSX()) {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.META_MASK));
    } else {
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
    }
    menuItem.setMnemonic(KeyEvent.VK_P);
    editMenu.add(menuItem);
    menuBar.add(editMenu);
    JMenu optionMenu = new JMenu(Bundle.getMessage("MenuOptions"));
    _showWarnItem = new JMenuItem(Bundle.getMessage("SuppressWarning"));
    _showWarnItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            String cmd = event.getActionCommand();
            setShowWarnings(cmd);
        }
    });
    optionMenu.add(_showWarnItem);
    setShowWarnings("ShowWarning");
    menuBar.add(optionMenu);
    _openMenu = new JMenu(Bundle.getMessage("OpenMenu"));
    // replaces the last item with appropriate
    updateOpenMenu();
    menuBar.add(_openMenu);
    setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrit.logix.OBlockTable", true);
    _desktop = new JDesktopPane();
    _desktop.putClientProperty("JDesktopPane.dragMode", "outline");
    _desktop.setPreferredSize(new Dimension(1100, 550));
    setContentPane(_desktop);
    _blockTableFrame = makeBlockFrame();
    _blockTableFrame.setVisible(true);
    _desktop.add(_blockTableFrame);
    _portalTableFrame = makePortalFrame();
    _portalTableFrame.setVisible(true);
    _desktop.add(_portalTableFrame);
    _signalTableFrame = makeSignalFrame();
    _signalTableFrame.setVisible(true);
    _desktop.add(_signalTableFrame);
    _blockPortalXRefFrame = makeBlockPortalFrame();
    _blockPortalXRefFrame.setVisible(false);
    _desktop.add(_blockPortalXRefFrame);
    setLocation(10, 30);
    setVisible(true);
    pack();
    errorCheck();
}
Also used : JDesktopPane(javax.swing.JDesktopPane) MessageFormat(java.text.MessageFormat) ActionEvent(java.awt.event.ActionEvent) TransferActionListener(jmri.util.com.sun.TransferActionListener) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) TransferActionListener(jmri.util.com.sun.TransferActionListener) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

Dimension (java.awt.Dimension)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MessageFormat (java.text.MessageFormat)1 JDesktopPane (javax.swing.JDesktopPane)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 JMenuItem (javax.swing.JMenuItem)1 TransferActionListener (jmri.util.com.sun.TransferActionListener)1