Search in sources :

Example 1 with ShowCarsInTrainAction

use of jmri.jmrit.operations.trains.tools.ShowCarsInTrainAction in project JMRI by JMRI.

the class TrainConductorFrame method initComponents.

private void initComponents(Train train) {
    super.initComponents();
    if (train != null) {
        setTitle(Bundle.getMessage("TitleTrainConductor") + " (" + train.getName() + ")");
    }
    // build menu
    JMenuBar menuBar = new JMenuBar();
    if (train != null) {
        JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
        toolMenu.add(new ShowCarsInTrainAction(Bundle.getMessage("MenuItemShowCarsInTrain"), train));
        menuBar.add(toolMenu);
    }
    setJMenuBar(menuBar);
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_Trains", true);
    initMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight500));
}
Also used : ShowCarsInTrainAction(jmri.jmrit.operations.trains.tools.ShowCarsInTrainAction) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 2 with ShowCarsInTrainAction

use of jmri.jmrit.operations.trains.tools.ShowCarsInTrainAction in project JMRI by JMRI.

the class TrainIcon method showPopUp.

/**
     * Pop-up only if right click and not dragged return true if a popup item is
     * set
     */
@Override
public boolean showPopUp(JPopupMenu popup) {
    if (_train != null) {
        // first action is either "Move" or "Terminate" train
        String actionText = (_train.getCurrentLocation() == _train.getTrainTerminatesRouteLocation()) ? Bundle.getMessage("Terminate") : Bundle.getMessage("Move");
        popup.add(new AbstractAction(actionText) {

            @Override
            public void actionPerformed(ActionEvent e) {
                _train.move();
            }
        });
        popup.add(makeTrainRouteMenu());
        popup.add(new TrainConductorAction(Bundle.getMessage("TitleTrainConductor"), _train));
        popup.add(new ShowCarsInTrainAction(Bundle.getMessage("MenuItemShowCarsInTrain"), _train));
        if (!isEditable()) {
            popup.add(new AbstractAction(Bundle.getMessage("SetX&Y")) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    if (!_train.setTrainIconCoordinates()) {
                        JOptionPane.showMessageDialog(null, Bundle.getMessage("SeeOperationsSettings"), Bundle.getMessage("SetX&YisDisabled"), JOptionPane.ERROR_MESSAGE);
                    }
                }
            });
        }
    }
    popup.add(new ThrottleAction(Bundle.getMessage("Throttle")));
    popup.add(makeLocoIconMenu());
    if (!isEditable()) {
        getEditor().setRemoveMenu(this, popup);
    }
    return true;
}
Also used : ActionEvent(java.awt.event.ActionEvent) ShowCarsInTrainAction(jmri.jmrit.operations.trains.tools.ShowCarsInTrainAction) AbstractAction(javax.swing.AbstractAction)

Aggregations

ShowCarsInTrainAction (jmri.jmrit.operations.trains.tools.ShowCarsInTrainAction)2 Dimension (java.awt.Dimension)1 ActionEvent (java.awt.event.ActionEvent)1 AbstractAction (javax.swing.AbstractAction)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1