Search in sources :

Example 71 with AbstractAction

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

the class LayoutTurntable method showPopUp.

/**
     * Display popup menu for information and editing
     */
protected void showPopUp(MouseEvent e) {
    if (popup != null) {
        popup.removeAll();
    } else {
        popup = new JPopupMenu();
    }
    JMenuItem jmi = popup.add(rb.getString("Turntable"));
    jmi.setEnabled(false);
    popup.add(new JSeparator(JSeparator.HORIZONTAL));
    popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            editTurntable(instance);
        }
    });
    popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (layoutEditor.removeTurntable(instance)) {
                // Returned true if user did not cancel
                remove();
                dispose();
            }
        }
    });
    layoutEditor.setShowAlignmentMenu(popup);
    popup.show(e.getComponent(), e.getX(), e.getY());
}
Also used : ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator)

Example 72 with AbstractAction

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

the class TrackSegment method showPopUp.

/**
     * Display popup menu for information and editing.
     */
protected void showPopUp(MouseEvent e) {
    if (popup != null) {
        popup.removeAll();
    } else {
        popup = new JPopupMenu();
    }
    String info = rb.getString("TrackSegment");
    if (getArc()) {
        if (getCircle()) {
            info = info + " (" + Bundle.getMessage("Circle") + ")";
        } else {
            info = info + " (" + Bundle.getMessage("Ellipse") + ")";
        }
    } else if (getBezier()) {
        info = info + " (" + Bundle.getMessage("Bezier") + ")";
    } else {
        info = info + " (" + Bundle.getMessage("Line") + ")";
    }
    JMenuItem jmi = popup.add(info);
    jmi.setEnabled(false);
    jmi = popup.add(ident);
    jmi.setEnabled(false);
    if (!dashed) {
        jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Solid"));
    } else {
        jmi = popup.add(rb.getString("Style") + " - " + rb.getString("Dashed"));
    }
    jmi.setEnabled(false);
    if (!mainline) {
        jmi = popup.add(rb.getString("NotMainline"));
    } else {
        jmi = popup.add(rb.getString("Mainline"));
    }
    jmi.setEnabled(false);
    if (blockName.equals("")) {
        jmi = popup.add(rb.getString("NoBlock"));
    } else {
        jmi = popup.add(Bundle.getMessage("BeanNameBlock") + ": " + getLayoutBlock().getID());
    }
    jmi.setEnabled(false);
    if (hidden) {
        jmi = popup.add(rb.getString("Hidden"));
    } else {
        jmi = popup.add(rb.getString("NotHidden"));
    }
    jmi.setEnabled(false);
    popup.add(new JSeparator(JSeparator.HORIZONTAL));
    popup.add(new AbstractAction(Bundle.getMessage("ButtonEdit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            editTrackSegment();
        }
    });
    popup.add(new AbstractAction(Bundle.getMessage("ButtonDelete")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            layoutEditor.removeTrackSegment(instance);
            remove();
            dispose();
        }
    });
    JMenu lineType = new JMenu(rb.getString("ChangeTo"));
    lineType.add(new AbstractAction(Bundle.getMessage("Line")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(0);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Circle")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(1);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Ellipse")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(2);
        }
    });
    lineType.add(new AbstractAction(Bundle.getMessage("Bezier")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            changeType(3);
        }
    });
    popup.add(lineType);
    if (getArc()) {
        popup.add(new AbstractAction(rb.getString("FlipAngle")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                flipAngle();
            }
        });
    }
    if (getArc() || getBezier()) {
        if (hideConstructionLines()) {
            popup.add(new AbstractAction(rb.getString("ShowConstruct")) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    hideConstructionLines(SHOWCON);
                }
            });
        } else {
            popup.add(new AbstractAction(rb.getString("HideConstruct")) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    hideConstructionLines(HIDECON);
                }
            });
        }
    }
    if ((!blockName.equals("")) && (jmri.InstanceManager.getDefault(LayoutBlockManager.class).isAdvancedRoutingEnabled())) {
        popup.add(new AbstractAction(rb.getString("ViewBlockRouting")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                AbstractAction routeTableAction = new LayoutBlockRouteTableAction("ViewRouting", getLayoutBlock());
                routeTableAction.actionPerformed(e);
            }
        });
    }
    popup.show(e.getComponent(), e.getX(), e.getY());
}
Also used : ActionEvent(java.awt.event.ActionEvent) LayoutBlockRouteTableAction(jmri.jmrit.display.layoutEditor.blockRoutingTable.LayoutBlockRouteTableAction) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) JMenu(javax.swing.JMenu)

Example 73 with AbstractAction

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

the class UserInterface method buildMenu.

protected void buildMenu() {
    this.setJMenuBar(new JMenuBar());
    JMenu menu = new JMenu(rb.getString("MenuMenu"));
    serverOnOff = new JMenuItem(rb.getString("MenuMenuStop"));
    serverOnOff.addActionListener(new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (isListen) {
                // Stop server
                disableServer();
                serverOnOff.setText(rb.getString("MenuMenuStart"));
                portLabel.setText(rb.getString("LabelNone"));
                manualPortLabel.setText(null);
            } else {
                // Restart server
                serverOnOff.setText(rb.getString("MenuMenuStop"));
                isListen = true;
                createServerThread();
            }
        }
    });
    menu.add(serverOnOff);
    menu.add(new ControllerFilterAction());
    Action prefsAction = new apps.gui3.TabbedPreferencesAction(ResourceBundle.getBundle("apps.AppsBundle").getString("MenuItemPreferences"), "WITHROTTLE");
    menu.add(prefsAction);
    this.getJMenuBar().add(menu);
    // add help menu
    addHelpMenu("package.jmri.jmrit.withrottle.UserInterface", true);
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) AbstractAction(javax.swing.AbstractAction) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 74 with AbstractAction

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

the class Apps method fileMenu.

/**
     * Create default File menu
     *
     * @param menuBar Menu bar to be populated
     * @param wi      WindowInterface where this menu will appear as part of the
     *                menu bar
     */
protected void fileMenu(JMenuBar menuBar, WindowInterface wi) {
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    menuBar.add(fileMenu);
    fileMenu.add(new PrintDecoderListAction(Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false));
    fileMenu.add(new PrintDecoderListAction(Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true));
    // Use Mac OS X native Quit if using Aqua look and feel
    if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) {
        fileMenu.add(new JSeparator());
        fileMenu.add(new AbstractAction(Bundle.getMessage("MenuItemQuit")) {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleQuit();
            }
        });
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) PrintDecoderListAction(jmri.jmrit.decoderdefn.PrintDecoderListAction) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JSeparator(javax.swing.JSeparator)

Example 75 with AbstractAction

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

the class SignalPro method statusPanel.

@Override
protected JPanel statusPanel() {
    JPanel j = new JPanel();
    j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
    j.add(super.statusPanel());
    // Buttons
    Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            Apps.handleQuit();
        }
    };
    JPanel p3 = new JPanel();
    p3.setLayout(new java.awt.FlowLayout());
    JButton h1 = new JButton(Bundle.getMessage("ButtonHelp"));
    jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.SignalPro.SignalPro");
    h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    p3.add(h1);
    JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
    q1.addActionListener(quit);
    q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    p3.add(q1);
    j.add(p3);
    return j;
}
Also used : JPanel(javax.swing.JPanel) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) AbstractAction(javax.swing.AbstractAction)

Aggregations

AbstractAction (javax.swing.AbstractAction)174 ActionEvent (java.awt.event.ActionEvent)162 Action (javax.swing.Action)42 InputMap (javax.swing.InputMap)34 JButton (javax.swing.JButton)33 JMenu (javax.swing.JMenu)30 JPanel (javax.swing.JPanel)30 ActionListener (java.awt.event.ActionListener)24 JMenuItem (javax.swing.JMenuItem)24 ActionMap (javax.swing.ActionMap)23 JScrollPane (javax.swing.JScrollPane)16 JPopupMenu (javax.swing.JPopupMenu)15 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)14 BorderLayout (java.awt.BorderLayout)14 BoxLayout (javax.swing.BoxLayout)12 JSeparator (javax.swing.JSeparator)12 JDialog (javax.swing.JDialog)11 WindowEvent (java.awt.event.WindowEvent)9 JMenuBar (javax.swing.JMenuBar)9 JTextField (javax.swing.JTextField)9