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