001package jmri.jmrit.operations.locations.tools;
002
003import java.awt.*;
004
005import javax.swing.*;
006
007import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
008import jmri.InstanceManager;
009import jmri.jmrit.operations.OperationsFrame;
010import jmri.jmrit.operations.OperationsXml;
011import jmri.jmrit.operations.locations.Location;
012import jmri.jmrit.operations.locations.Track;
013import jmri.jmrit.operations.rollingstock.cars.*;
014import jmri.jmrit.operations.setup.Control;
015import jmri.jmrit.operations.setup.Setup;
016import jmri.util.swing.JmriJOptionPane;
017
018/**
019 * Frame for user edit of track loads
020 *
021 * @author Dan Boudreau Copyright (C) 2013, 2014, 2015, 2023
022 * 
023 */
024public class TrackLoadEditFrame extends OperationsFrame implements java.beans.PropertyChangeListener {
025
026    private static boolean loadAndType = false;
027    private static boolean shipLoadAndType = false;
028
029    Location _location = null;
030    Track _track = null;
031    String _type = "";
032    JMenu _toolMenu = null;
033
034    // panels
035    JPanel pLoadControls = new JPanel();
036    JPanel panelLoads = new JPanel();
037    JScrollPane paneLoads = new JScrollPane(panelLoads);
038
039    JPanel pShipLoadControls = new JPanel();
040    JPanel panelShipLoads = new JPanel();
041    JScrollPane paneShipLoadControls;
042    JScrollPane paneShipLoads = new JScrollPane(panelShipLoads);
043
044    // major buttons
045    JButton saveButton = new JButton(Bundle.getMessage("ButtonSave"));
046
047    JButton addLoadButton = new JButton(Bundle.getMessage("AddLoad"));
048    JButton deleteLoadButton = new JButton(Bundle.getMessage("DeleteLoad"));
049    JButton deleteAllLoadsButton = new JButton(Bundle.getMessage("DeleteAll"));
050
051    JButton addShipLoadButton = new JButton(Bundle.getMessage("AddLoad"));
052    JButton deleteShipLoadButton = new JButton(Bundle.getMessage("DeleteLoad"));
053    JButton deleteAllShipLoadsButton = new JButton(Bundle.getMessage("DeleteAll"));
054
055    // check boxes
056    JCheckBox loadAndTypeCheckBox = new JCheckBox(Bundle.getMessage("TypeAndLoad"));
057    JCheckBox shipLoadAndTypeCheckBox = new JCheckBox(Bundle.getMessage("TypeAndLoad"));
058    JCheckBox holdCars = new JCheckBox(Bundle.getMessage("HoldCarsWithCustomLoads"));
059    JCheckBox disableLoadChange = new JCheckBox(Bundle.getMessage("DisableLoadChange"));
060    JCheckBox quickLoadService = new JCheckBox(Bundle.getMessage("QuickLoadService"));
061
062    // radio buttons
063    JRadioButton loadNameAll = new JRadioButton(Bundle.getMessage("AcceptAll"));
064    JRadioButton loadNameInclude = new JRadioButton(Bundle.getMessage("AcceptOnly"));
065    JRadioButton loadNameExclude = new JRadioButton(Bundle.getMessage("Exclude"));
066
067    JRadioButton shipLoadNameAll = new JRadioButton(Bundle.getMessage("ShipsAllLoads"));
068    JRadioButton shipLoadNameInclude = new JRadioButton(Bundle.getMessage("ShipOnly"));
069    JRadioButton shipLoadNameExclude = new JRadioButton(Bundle.getMessage("Exclude"));
070
071    // combo box
072    JComboBox<String> comboBoxLoads = InstanceManager.getDefault(CarLoads.class).getComboBox(null);
073    JComboBox<String> comboBoxShipLoads = InstanceManager.getDefault(CarLoads.class).getComboBox(null);
074    JComboBox<String> comboBoxTypes = InstanceManager.getDefault(CarTypes.class).getComboBox();
075    JComboBox<String> comboBoxShipTypes = InstanceManager.getDefault(CarTypes.class).getComboBox();
076
077    // labels
078    JLabel trackName = new JLabel();
079
080    public static final String DISPOSE = "dispose"; // NOI18N
081    public static final int MAX_NAME_LENGTH = Control.max_len_string_track_name;
082
083    public TrackLoadEditFrame() {
084        super(Bundle.getMessage("TitleEditTrackLoads"));
085    }
086
087    public void initComponents(Location location, Track track) {
088        _location = location;
089        _track = track;
090
091        // property changes
092        _location.addPropertyChangeListener(this);
093        // listen for car load name and type changes
094        InstanceManager.getDefault(CarLoads.class).addPropertyChangeListener(this);
095        InstanceManager.getDefault(CarTypes.class).addPropertyChangeListener(this);
096
097        // the following code sets the frame's initial state
098        getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
099
100        // Set up the panels
101        // Layout the panel by rows
102        // row 1
103        JPanel p1 = new JPanel();
104        p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
105        p1.setMaximumSize(new Dimension(2000, 250));
106
107        // row 1a
108        JPanel pTrackName = new JPanel();
109        pTrackName.setLayout(new GridBagLayout());
110        pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
111        addItem(pTrackName, trackName, 0, 0);
112
113        // row 1b
114        JPanel pLocationName = new JPanel();
115        pLocationName.setLayout(new GridBagLayout());
116        pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
117        addItem(pLocationName, new JLabel(_location.getName()), 0, 0);
118
119        p1.add(pTrackName);
120        p1.add(pLocationName);
121
122        // row 3
123        JPanel p3 = new JPanel();
124        p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
125        JScrollPane pane3 = new JScrollPane(p3);
126        pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LoadsTrack")));
127        pane3.setMaximumSize(new Dimension(2000, 400));
128
129        JPanel pLoadRadioButtons = new JPanel();
130        pLoadRadioButtons.setLayout(new FlowLayout());
131
132        pLoadRadioButtons.add(loadNameAll);
133        pLoadRadioButtons.add(loadNameInclude);
134        pLoadRadioButtons.add(loadNameExclude);
135        pLoadRadioButtons.add(loadAndTypeCheckBox);
136
137        pLoadControls.setLayout(new FlowLayout());
138
139        pLoadControls.add(comboBoxTypes);
140        pLoadControls.add(comboBoxLoads);
141        pLoadControls.add(addLoadButton);
142        pLoadControls.add(deleteLoadButton);
143        pLoadControls.add(deleteAllLoadsButton);
144
145        pLoadControls.setVisible(false);
146
147        p3.add(pLoadRadioButtons);
148        p3.add(pLoadControls);
149
150        // row 4
151        panelLoads.setLayout(new GridBagLayout());
152        paneLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
153
154        ButtonGroup loadGroup = new ButtonGroup();
155        loadGroup.add(loadNameAll);
156        loadGroup.add(loadNameInclude);
157        loadGroup.add(loadNameExclude);
158
159        // row 6
160        JPanel p6 = new JPanel();
161        p6.setLayout(new BoxLayout(p6, BoxLayout.Y_AXIS));
162        paneShipLoadControls = new JScrollPane(p6);
163        paneShipLoadControls.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShipLoadsTrack")));
164        paneShipLoadControls.setMaximumSize(new Dimension(2000, 400));
165
166        JPanel pShipLoadRadioButtons = new JPanel();
167        pShipLoadRadioButtons.setLayout(new FlowLayout());
168
169        pShipLoadRadioButtons.add(shipLoadNameAll);
170        pShipLoadRadioButtons.add(shipLoadNameInclude);
171        pShipLoadRadioButtons.add(shipLoadNameExclude);
172        pShipLoadRadioButtons.add(shipLoadAndTypeCheckBox);
173
174        pShipLoadControls.setLayout(new FlowLayout());
175
176        pShipLoadControls.add(comboBoxShipTypes);
177        pShipLoadControls.add(comboBoxShipLoads);
178        pShipLoadControls.add(addShipLoadButton);
179        pShipLoadControls.add(deleteShipLoadButton);
180        pShipLoadControls.add(deleteAllShipLoadsButton);
181
182        pShipLoadControls.setVisible(false);
183
184        p6.add(pShipLoadRadioButtons);
185        p6.add(pShipLoadControls);
186
187        // row 7
188        panelShipLoads.setLayout(new GridBagLayout());
189        paneShipLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
190
191        ButtonGroup shipLoadGroup = new ButtonGroup();
192        shipLoadGroup.add(shipLoadNameAll);
193        shipLoadGroup.add(shipLoadNameInclude);
194        shipLoadGroup.add(shipLoadNameExclude);
195        
196        JPanel pOptions = new JPanel();
197        pOptions.setLayout(new GridBagLayout());
198        pOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
199        pOptions.setMaximumSize(new Dimension(2000, 400));
200        addItemLeft(pOptions, disableLoadChange, 0, 0);
201        addItemLeft(pOptions, quickLoadService, 0, 1);
202        addItemLeft(pOptions, holdCars, 0, 2);
203        disableLoadChange.setToolTipText(Bundle.getMessage("DisableLoadChangeTip"));
204        quickLoadService.setToolTipText(Bundle.getMessage("QuickLoadServiceTip"));
205        holdCars.setToolTipText(Bundle.getMessage("HoldCarsWithCustomLoadsTip"));
206        
207        // row 12
208        JPanel panelButtons = new JPanel();
209        panelButtons.setLayout(new GridBagLayout());
210        panelButtons.setBorder(BorderFactory.createTitledBorder(""));
211        panelButtons.setMaximumSize(new Dimension(2000, 200));
212
213        // row 13
214        addItem(panelButtons, saveButton, 0, 0);
215
216        getContentPane().add(p1);
217        getContentPane().add(pane3);
218        getContentPane().add(paneLoads);
219        getContentPane().add(paneShipLoadControls);
220        getContentPane().add(paneShipLoads);
221        getContentPane().add(pOptions);
222        getContentPane().add(panelButtons);
223
224        // setup buttons
225        addButtonAction(saveButton);
226
227        addButtonAction(deleteLoadButton);
228        addButtonAction(deleteAllLoadsButton);
229        addButtonAction(addLoadButton);
230
231        addButtonAction(deleteShipLoadButton);
232        addButtonAction(deleteAllShipLoadsButton);
233        addButtonAction(addShipLoadButton);
234
235        addRadioButtonAction(loadNameAll);
236        addRadioButtonAction(loadNameInclude);
237        addRadioButtonAction(loadNameExclude);
238
239        addRadioButtonAction(shipLoadNameAll);
240        addRadioButtonAction(shipLoadNameInclude);
241        addRadioButtonAction(shipLoadNameExclude);
242
243        addComboBoxAction(comboBoxTypes);
244        addComboBoxAction(comboBoxShipTypes);
245
246        paneShipLoadControls.setVisible(false);
247        paneShipLoads.setVisible(false);
248        pOptions.setVisible(false);
249
250        // load fields and enable buttons
251        if (_track != null) {
252            _track.addPropertyChangeListener(this);
253            trackName.setText(_track.getName());
254            // only show ship loads for staging tracks
255            paneShipLoadControls.setVisible(_track.isStaging());
256            paneShipLoads.setVisible(_track.isStaging());
257            pOptions.setVisible(_track.isSpur());
258            holdCars.setEnabled(_track.getSchedule() != null && _track.getAlternateTrack() != null);
259            holdCars.setSelected(_track.isHoldCarsWithCustomLoadsEnabled());
260            disableLoadChange.setSelected(_track.isDisableLoadChangeEnabled());
261            quickLoadService.setSelected(_track.isQuickServiceEnabled());
262            updateButtons(true);
263        } else {
264            updateButtons(false);
265        }
266
267        updateTypeComboBoxes();
268        updateLoadComboBoxes();
269        updateLoadNames();
270        updateShipLoadNames();
271
272        loadAndTypeCheckBox.setSelected(loadAndType);
273        shipLoadAndTypeCheckBox.setSelected(shipLoadAndType);
274        
275        // add help menu to window
276        addHelpMenu("package.jmri.jmrit.operations.Operations_LoadOptions", true); // NOI18N
277
278        initMinimumSize(new Dimension(Control.panelWidth600, Control.panelHeight400));
279    }
280
281    // Save, Delete, Add
282    @Override
283    public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
284        if (_track == null) {
285            return;
286        }
287        if (ae.getSource() == saveButton) {
288            log.debug("track save button activated");
289            save();
290            if (Setup.isCloseWindowOnSaveEnabled()) {
291                dispose();
292            }
293        }
294        if (ae.getSource() == addLoadButton) {
295            String loadName = (String) comboBoxLoads.getSelectedItem();
296            if (loadAndTypeCheckBox.isSelected()) {
297                loadName = comboBoxTypes.getSelectedItem() + CarLoad.SPLIT_CHAR + loadName;
298            }
299            _track.addLoadName(loadName);
300            selectNextItemComboBox(comboBoxLoads);
301        }
302        if (ae.getSource() == deleteLoadButton) {
303            String loadName = (String) comboBoxLoads.getSelectedItem();
304            if (loadAndTypeCheckBox.isSelected()) {
305                loadName = comboBoxTypes.getSelectedItem() + CarLoad.SPLIT_CHAR + loadName;
306            }
307            _track.deleteLoadName(loadName);
308            selectNextItemComboBox(comboBoxLoads);
309        }
310        if (ae.getSource() == deleteAllLoadsButton) {
311            deleteAllLoads();
312        }
313        if (ae.getSource() == addShipLoadButton) {
314            String loadName = (String) comboBoxShipLoads.getSelectedItem();
315            if (shipLoadAndTypeCheckBox.isSelected()) {
316                loadName = comboBoxShipTypes.getSelectedItem() + CarLoad.SPLIT_CHAR + loadName;
317            }
318            _track.addShipLoadName(loadName);
319            selectNextItemComboBox(comboBoxShipLoads);
320        }
321        if (ae.getSource() == deleteShipLoadButton) {
322            String loadName = (String) comboBoxShipLoads.getSelectedItem();
323            if (shipLoadAndTypeCheckBox.isSelected()) {
324                loadName = comboBoxShipTypes.getSelectedItem() + CarLoad.SPLIT_CHAR + loadName;
325            }
326            _track.deleteShipLoadName(loadName);
327            selectNextItemComboBox(comboBoxShipLoads);
328        }
329        if (ae.getSource() == deleteAllShipLoadsButton) {
330            deleteAllShipLoads();
331        }
332    }
333
334    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "GUI ease of use")
335    protected void save() {
336        checkForErrors();
337        _track.setHoldCarsWithCustomLoadsEnabled(holdCars.isSelected());
338        _track.setDisableLoadChangeEnabled(disableLoadChange.isSelected());
339        _track.setQuickServiceEnabled(quickLoadService.isSelected());
340        // save the last state of the "Use car type and load" checkbox
341        loadAndType = loadAndTypeCheckBox.isSelected();
342        shipLoadAndType = shipLoadAndTypeCheckBox.isSelected();
343        // save location file
344        OperationsXml.save();
345    }
346
347    protected void updateButtons(boolean enabled) {
348        saveButton.setEnabled(enabled);
349
350        loadNameAll.setEnabled(enabled);
351        loadNameInclude.setEnabled(enabled);
352        loadNameExclude.setEnabled(enabled);
353        loadAndTypeCheckBox.setEnabled(enabled);
354
355        // enable ship options if any of the three generate loads from staging is selected
356        // or if there are any ship load restrictions for this track
357        boolean en = enabled
358                && (_track.isAddCustomLoadsAnyStagingTrackEnabled() || _track.isAddCustomLoadsAnySpurEnabled() || _track
359                .isAddCustomLoadsEnabled() || !_track.getShipLoadOption().equals(Track.ALL_LOADS));
360
361        shipLoadNameAll.setEnabled(en);
362        shipLoadNameInclude.setEnabled(en);
363        shipLoadNameExclude.setEnabled(en);
364        shipLoadAndTypeCheckBox.setEnabled(en);
365
366        addShipLoadButton.setEnabled(en);
367        deleteShipLoadButton.setEnabled(en);
368        deleteAllShipLoadsButton.setEnabled(en);
369
370        comboBoxShipLoads.setEnabled(en);
371        comboBoxShipTypes.setEnabled(en);
372    }
373
374    @Override
375    public void radioButtonActionPerformed(java.awt.event.ActionEvent ae) {
376        log.debug("radio button activated");
377        if (ae.getSource() == loadNameAll) {
378            _track.setLoadOption(Track.ALL_LOADS);
379        }
380        if (ae.getSource() == loadNameInclude) {
381            _track.setLoadOption(Track.INCLUDE_LOADS);
382        }
383        if (ae.getSource() == loadNameExclude) {
384            _track.setLoadOption(Track.EXCLUDE_LOADS);
385        }
386        if (ae.getSource() == shipLoadNameAll) {
387            _track.setShipLoadOption(Track.ALL_LOADS);
388        }
389        if (ae.getSource() == shipLoadNameInclude) {
390            _track.setShipLoadOption(Track.INCLUDE_LOADS);
391        }
392        if (ae.getSource() == shipLoadNameExclude) {
393            _track.setShipLoadOption(Track.EXCLUDE_LOADS);
394        }
395    }
396
397    // Car type combo box has been changed, show loads associated with this car type
398    @Override
399    public void comboBoxActionPerformed(java.awt.event.ActionEvent ae) {
400        updateLoadComboBoxes();
401    }
402
403    private void updateLoadComboBoxes() {
404        String carType = (String) comboBoxTypes.getSelectedItem();
405        InstanceManager.getDefault(CarLoads.class).updateComboBox(carType, comboBoxLoads);
406        carType = (String) comboBoxShipTypes.getSelectedItem();
407        InstanceManager.getDefault(CarLoads.class).updateComboBox(carType, comboBoxShipLoads);
408    }
409
410    private void updateLoadNames() {
411        log.debug("Update load names");
412        panelLoads.removeAll();
413        if (_track != null) {
414            // set radio button
415            loadNameAll.setSelected(_track.getLoadOption().equals(Track.ALL_LOADS));
416            loadNameInclude.setSelected(_track.getLoadOption().equals(Track.INCLUDE_LOADS));
417            loadNameExclude.setSelected(_track.getLoadOption().equals(Track.EXCLUDE_LOADS));
418
419            pLoadControls.setVisible(!loadNameAll.isSelected());
420
421            if (!loadNameAll.isSelected()) {
422                int x = 0;
423                int y = 0; // vertical position in panel
424
425                int numberOfLoads = getNumberOfCheckboxesPerLine() / 2 + 1;
426                for (String loadName : _track.getLoadNames()) {
427                    JLabel load = new JLabel();
428                    load.setText(loadName);
429                    addItemTop(panelLoads, load, x++, y);
430                    // limit the number of loads per line
431                    if (x > numberOfLoads) {
432                        y++;
433                        x = 0;
434                    }
435                }
436                revalidate();
437            }
438        } else {
439            loadNameAll.setSelected(true);
440        }
441        panelLoads.repaint();
442        panelLoads.revalidate();
443    }
444
445    private void updateShipLoadNames() {
446        log.debug("Update ship load names");
447        panelShipLoads.removeAll();
448        if (_track != null) {
449            // set radio button
450            shipLoadNameAll.setSelected(_track.getShipLoadOption().equals(Track.ALL_LOADS));
451            shipLoadNameInclude.setSelected(_track.getShipLoadOption().equals(Track.INCLUDE_LOADS));
452            shipLoadNameExclude.setSelected(_track.getShipLoadOption().equals(Track.EXCLUDE_LOADS));
453
454            pShipLoadControls.setVisible(!shipLoadNameAll.isSelected());
455
456            if (!shipLoadNameAll.isSelected()) {
457                int x = 0;
458                int y = 0; // vertical position in panel
459
460                int numberOfLoads = getNumberOfCheckboxesPerLine() / 2 + 1;
461                for (String loadName : _track.getShipLoadNames()) {
462                    JLabel load = new JLabel();
463                    load.setText(loadName);
464                    addItemTop(panelShipLoads, load, x++, y);
465                    // limit the number of loads per line
466                    if (x > numberOfLoads) {
467                        y++;
468                        x = 0;
469                    }
470                }
471                revalidate();
472            }
473        } else {
474            shipLoadNameAll.setSelected(true);
475        }
476        panelShipLoads.repaint();
477        panelShipLoads.revalidate();
478    }
479
480    private void deleteAllLoads() {
481        if (_track != null) {
482            for (String loadName : _track.getLoadNames()) {
483                _track.deleteLoadName(loadName);
484            }
485        }
486    }
487
488    private void deleteAllShipLoads() {
489        if (_track != null) {
490            for (String loadName : _track.getShipLoadNames()) {
491                _track.deleteShipLoadName(loadName);
492            }
493        }
494    }
495
496    private void updateTypeComboBoxes() {
497        InstanceManager.getDefault(CarTypes.class).updateComboBox(comboBoxTypes);
498        // remove car types not serviced by this location and track
499        for (int i = comboBoxTypes.getItemCount() - 1; i >= 0; i--) {
500            String type = comboBoxTypes.getItemAt(i);
501            if (_track != null && !_track.isTypeNameAccepted(type)) {
502                comboBoxTypes.removeItem(type);
503            }
504        }
505        InstanceManager.getDefault(CarTypes.class).updateComboBox(comboBoxShipTypes);
506        // remove car types not serviced by this location and track
507        for (int i = comboBoxShipTypes.getItemCount() - 1; i >= 0; i--) {
508            String type = comboBoxShipTypes.getItemAt(i);
509            if (_track != null && !_track.isTypeNameAccepted(type)) {
510                comboBoxShipTypes.removeItem(type);
511            }
512        }
513    }
514
515    private void checkForErrors() {
516        if (_track.getLoadOption().equals(Track.INCLUDE_LOADS) && _track.getLoadNames().length == 0
517                || _track.getShipLoadOption().equals(Track.INCLUDE_LOADS) && _track.getShipLoadNames().length == 0) {
518            JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("ErrorNeedLoads"), Bundle.getMessage("ErrorNoLoads"),
519                    JmriJOptionPane.ERROR_MESSAGE);
520        }
521    }
522
523    @Override
524    public void dispose() {
525        if (_track != null) {
526            _track.removePropertyChangeListener(this);
527        }
528        _location.removePropertyChangeListener(this);
529        InstanceManager.getDefault(CarLoads.class).removePropertyChangeListener(this);
530        InstanceManager.getDefault(CarTypes.class).removePropertyChangeListener(this);
531        super.dispose();
532    }
533
534    @Override
535    public void propertyChange(java.beans.PropertyChangeEvent e) {
536        if (Control.SHOW_PROPERTY) {
537            log.debug("Property change ({}) old: ({}) new: ({})", e.getPropertyName(), e.getOldValue(), e.getNewValue()); // NOI18N
538        }
539        if (e.getPropertyName().equals(Location.TYPES_CHANGED_PROPERTY)
540                || e.getPropertyName().equals(CarTypes.CARTYPES_CHANGED_PROPERTY)
541                || e.getPropertyName().equals(Track.TYPES_CHANGED_PROPERTY)) {
542            updateTypeComboBoxes();
543        }
544        if (e.getPropertyName().equals(CarLoads.LOAD_NAME_CHANGED_PROPERTY)
545                || e.getPropertyName().equals(CarLoads.LOAD_CHANGED_PROPERTY)) {
546            updateLoadComboBoxes();
547            updateLoadNames();
548            updateShipLoadNames();
549        }
550        if (e.getPropertyName().equals(Track.LOADS_CHANGED_PROPERTY)) {
551            updateLoadNames();
552            updateShipLoadNames();
553        }
554        if (_track != null) {
555            if (e.getPropertyName().equals(Track.LOAD_OPTIONS_CHANGED_PROPERTY)) {
556                updateButtons(true);
557                disableLoadChange.setSelected(_track.isDisableLoadChangeEnabled());
558                quickLoadService.setSelected(_track.isQuickServiceEnabled());
559            }
560            if (e.getPropertyName().equals(Track.HOLD_CARS_CHANGED_PROPERTY)) {
561                holdCars.setSelected(_track.isHoldCarsWithCustomLoadsEnabled());
562            }
563            if (e.getPropertyName().equals(Track.ALTERNATE_TRACK_CHANGED_PROPERTY) ||
564                    e.getPropertyName().equals(Track.SCHEDULE_ID_CHANGED_PROPERTY)) {
565                holdCars.setEnabled(_track.getSchedule() != null && _track.getAlternateTrack() != null);
566            }
567        }
568    }
569
570    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TrackLoadEditFrame.class);
571}