Search in sources :

Example 1 with TrackRoadEditAction

use of jmri.jmrit.operations.locations.tools.TrackRoadEditAction in project JMRI by JMRI.

the class TrackEditFrame method initComponents.

public void initComponents(Location location, Track track) {
    _location = location;
    _track = track;
    // tool tips
    autoDropCheckBox.setToolTipText(Bundle.getMessage("TipAutoTrack"));
    autoPickupCheckBox.setToolTipText(Bundle.getMessage("TipAutoTrack"));
    trackLengthTextField.setToolTipText(MessageFormat.format(Bundle.getMessage("TipTrackLength"), new Object[] { Setup.getLengthUnit().toLowerCase() }));
    // property changes
    _location.addPropertyChangeListener(this);
    // listen for car road name and type changes
    CarRoads.instance().addPropertyChangeListener(this);
    CarLoads.instance().addPropertyChangeListener(this);
    CarTypes.instance().addPropertyChangeListener(this);
    trainManager.addPropertyChangeListener(this);
    routeManager.addPropertyChangeListener(this);
    // the following code sets the frame's initial state
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // place all panels in a scroll pane.
    JPanel panels = new JPanel();
    panels.setLayout(new BoxLayout(panels, BoxLayout.Y_AXIS));
    JScrollPane pane = new JScrollPane(panels);
    // Set up the panels
    // Layout the panel by rows
    // row 1
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    JScrollPane p1Pane = new JScrollPane(p1);
    p1Pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    p1Pane.setMinimumSize(new Dimension(300, 3 * trackNameTextField.getPreferredSize().height));
    p1Pane.setBorder(BorderFactory.createTitledBorder(""));
    // row 1a
    JPanel pName = new JPanel();
    pName.setLayout(new GridBagLayout());
    pName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Name")));
    addItem(pName, trackNameTextField, 0, 0);
    // row 1b
    JPanel pLength = new JPanel();
    pLength.setLayout(new GridBagLayout());
    pLength.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Length")));
    pLength.setMinimumSize(new Dimension(60, 1));
    addItem(pLength, trackLengthTextField, 0, 0);
    // row 1c
    panelTrainDir.setLayout(new GridBagLayout());
    panelTrainDir.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainTrack")));
    panelTrainDir.setPreferredSize(new Dimension(200, 10));
    addItem(panelTrainDir, northCheckBox, 1, 1);
    addItem(panelTrainDir, southCheckBox, 2, 1);
    addItem(panelTrainDir, eastCheckBox, 3, 1);
    addItem(panelTrainDir, westCheckBox, 4, 1);
    p1.add(pName);
    p1.add(pLength);
    p1.add(panelTrainDir);
    // row 4
    panelCheckBoxes.setLayout(new GridBagLayout());
    // status panel for roads and loads
    JPanel panelRoadAndLoadStatus = new JPanel();
    panelRoadAndLoadStatus.setLayout(new BoxLayout(panelRoadAndLoadStatus, BoxLayout.X_AXIS));
    JPanel pRoadOption = new JPanel();
    pRoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("RoadOption")));
    pRoadOption.add(roadOption);
    JPanel pLoadOption = new JPanel();
    pLoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LoadOption")));
    pLoadOption.add(loadOption);
    pShipLoadOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShipLoadOption")));
    pShipLoadOption.add(shipLoadOption);
    pDestinationOption.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Destinations")));
    pDestinationOption.add(destinationOption);
    panelRoadAndLoadStatus.add(pRoadOption);
    panelRoadAndLoadStatus.add(pLoadOption);
    panelRoadAndLoadStatus.add(pShipLoadOption);
    panelRoadAndLoadStatus.add(pDestinationOption);
    // only staging uses the ship load option
    pShipLoadOption.setVisible(false);
    // only classification/interchange tracks use the destination option
    pDestinationOption.setVisible(false);
    // row 10
    // order panel
    panelOrder.setLayout(new GridBagLayout());
    panelOrder.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("PickupOrder")));
    panelOrder.add(orderNormal);
    panelOrder.add(orderFIFO);
    panelOrder.add(orderLIFO);
    ButtonGroup orderGroup = new ButtonGroup();
    orderGroup.add(orderNormal);
    orderGroup.add(orderFIFO);
    orderGroup.add(orderLIFO);
    // drop panel
    dropPanel.setLayout(new GridBagLayout());
    dropPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainsOrRoutesDrops")));
    // pickup panel
    pickupPanel.setLayout(new GridBagLayout());
    pickupPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TrainsOrRoutesPickups")));
    // row 11
    JPanel panelComment = new JPanel();
    panelComment.setLayout(new GridBagLayout());
    panelComment.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Comment")));
    addItem(panelComment, commentScroller, 0, 0);
    // adjust text area width based on window size
    adjustTextAreaColumnWidth(commentScroller, commentTextArea);
    // reader row
    JPanel readerPanel = new JPanel();
    readerPanel.setLayout(new GridBagLayout());
    readerPanel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("idReader")));
    addItem(readerPanel, readerSelector, 0, 0);
    readerPanel.setVisible(Setup.isRfidEnabled());
    // row 12
    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new GridBagLayout());
    // row 13
    addItem(panelButtons, deleteTrackButton, 0, 0);
    addItem(panelButtons, addTrackButton, 1, 0);
    addItem(panelButtons, saveTrackButton, 2, 0);
    paneCheckBoxes.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("TypesTrack")));
    panels.add(p1Pane);
    panels.add(paneCheckBoxes);
    panels.add(panelRoadAndLoadStatus);
    panels.add(panelOrder);
    panels.add(dropPanel);
    panels.add(pickupPanel);
    // add optional panels
    panels.add(panelOpt3);
    panels.add(panelOpt4);
    panels.add(panelComment);
    panels.add(readerPanel);
    panels.add(panelButtons);
    getContentPane().add(pane);
    // setup buttons
    addButtonAction(setButton);
    addButtonAction(clearButton);
    addButtonAction(deleteTrackButton);
    addButtonAction(addTrackButton);
    addButtonAction(saveTrackButton);
    addButtonAction(deleteDropButton);
    addButtonAction(addDropButton);
    addButtonAction(deletePickupButton);
    addButtonAction(addPickupButton);
    addRadioButtonAction(orderNormal);
    addRadioButtonAction(orderFIFO);
    addRadioButtonAction(orderLIFO);
    addRadioButtonAction(anyDrops);
    addRadioButtonAction(trainDrop);
    addRadioButtonAction(routeDrop);
    addRadioButtonAction(excludeTrainDrop);
    addRadioButtonAction(excludeRouteDrop);
    addRadioButtonAction(anyPickups);
    addRadioButtonAction(trainPickup);
    addRadioButtonAction(routePickup);
    addRadioButtonAction(excludeTrainPickup);
    addRadioButtonAction(excludeRoutePickup);
    //  addComboBoxAction(comboBoxTypes);
    addCheckBoxAction(autoDropCheckBox);
    addCheckBoxAction(autoPickupCheckBox);
    if (Setup.isRfidEnabled()) {
        // setup the Reader dropdown.
        // add an empty entry.
        readerSelector.addItem(null);
        for (jmri.NamedBean r : jmri.InstanceManager.getDefault(jmri.ReporterManager.class).getNamedBeanList()) {
            readerSelector.addItem((Reporter) r);
        }
    }
    // load fields and enable buttons
    if (_track != null) {
        _track.addPropertyChangeListener(this);
        trackNameTextField.setText(_track.getName());
        commentTextArea.setText(_track.getComment());
        trackLengthTextField.setText(Integer.toString(_track.getLength()));
        enableButtons(true);
        _trackName = _track.getName();
        if (Setup.isRfidEnabled()) {
            readerSelector.setSelectedItem(_track.getReporter());
        }
    } else {
        enableButtons(false);
    }
    // build menu
    JMenuBar menuBar = new JMenuBar();
    _toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    _toolMenu.add(new TrackLoadEditAction(this));
    _toolMenu.add(new TrackRoadEditAction(this));
    _toolMenu.add(new TrackEditCommentsAction(this));
    _toolMenu.add(new PoolTrackAction(this));
    menuBar.add(_toolMenu);
    setJMenuBar(menuBar);
    // load
    updateCheckboxes();
    //  updateTypeComboBoxes();
    updateTrainDir();
    updateCarOrder();
    updateDropOptions();
    updatePickupOptions();
    updateRoadOption();
    updateLoadOption();
    updateDestinationOption();
    setMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight600));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) TrackLoadEditAction(jmri.jmrit.operations.locations.tools.TrackLoadEditAction) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) TrackRoadEditAction(jmri.jmrit.operations.locations.tools.TrackRoadEditAction) PoolTrackAction(jmri.jmrit.operations.locations.tools.PoolTrackAction) Dimension(java.awt.Dimension) TrackEditCommentsAction(jmri.jmrit.operations.locations.tools.TrackEditCommentsAction) ButtonGroup(javax.swing.ButtonGroup) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 BoxLayout (javax.swing.BoxLayout)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 PoolTrackAction (jmri.jmrit.operations.locations.tools.PoolTrackAction)1 TrackEditCommentsAction (jmri.jmrit.operations.locations.tools.TrackEditCommentsAction)1 TrackLoadEditAction (jmri.jmrit.operations.locations.tools.TrackLoadEditAction)1 TrackRoadEditAction (jmri.jmrit.operations.locations.tools.TrackRoadEditAction)1