001package jmri.jmrit.operations.rollingstock.cars.gui;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004
005import java.awt.GridBagLayout;
006import java.text.*;
007import java.util.List;
008import java.util.ResourceBundle;
009
010import javax.swing.*;
011
012import jmri.InstanceManager;
013import jmri.jmrit.operations.rollingstock.*;
014import jmri.jmrit.operations.rollingstock.cars.*;
015import jmri.jmrit.operations.rollingstock.cars.tools.CarAttributeEditFrame;
016import jmri.jmrit.operations.rollingstock.cars.tools.CarLoadEditFrame;
017import jmri.jmrit.operations.setup.Setup;
018import jmri.util.swing.JmriJOptionPane;
019
020/**
021 * Frame for user edit of car
022 *
023 * @author Dan Boudreau Copyright (C) 2008, 2010, 2011, 2014, 2018
024 */
025public class CarEditFrame extends RollingStockEditFrame {
026
027    protected static final ResourceBundle rb = ResourceBundle
028            .getBundle("jmri.jmrit.operations.rollingstock.cars.JmritOperationsCarsBundle");
029
030    CarManager carManager = InstanceManager.getDefault(CarManager.class);
031    CarManagerXml managerXml = InstanceManager.getDefault(CarManagerXml.class);
032
033    // labels
034    JLabel textWeightOz = new JLabel(Bundle.getMessage("WeightOz"));
035    JButton editLoadButton = new JButton(Bundle.getMessage("ButtonEdit"));
036    JButton fillWeightButton = new JButton(Bundle.getMessage("Calculate"));
037
038    JCheckBox passengerCheckBox = new JCheckBox(Bundle.getMessage("Passenger"));
039    JCheckBox cabooseCheckBox = new JCheckBox(Bundle.getMessage("Caboose"));
040    JCheckBox fredCheckBox = new JCheckBox(Bundle.getMessage("Fred"));
041    JCheckBox utilityCheckBox = new JCheckBox(Bundle.getMessage("Utility"));
042    JCheckBox hazardousCheckBox = new JCheckBox(Bundle.getMessage("Hazardous"));
043    JCheckBox autoWeightCheckBox = new JCheckBox(Bundle.getMessage("Auto"));
044    
045    JComboBox<String> loadComboBox = InstanceManager.getDefault(CarLoads.class).getComboBox(null);
046
047    CarLoadEditFrame carLoadEditFrame;
048
049    public CarEditFrame() {
050        super(Bundle.getMessage("TitleCarAdd"));
051    }
052
053    @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Checks for null")
054    @Override
055    public void initComponents() {
056
057        groupComboBox = InstanceManager.getDefault(KernelManager.class).getComboBox();
058
059        super.initComponents();
060
061        addButton.setText(Bundle.getMessage("TitleCarAdd"));
062
063        // type options for cars
064        addItem(pTypeOptions, passengerCheckBox, 0, 1);
065        addItem(pTypeOptions, cabooseCheckBox, 1, 1);
066        addItem(pTypeOptions, fredCheckBox, 2, 1);
067        addItem(pTypeOptions, utilityCheckBox, 3, 1);
068        addItem(pTypeOptions, hazardousCheckBox, 4, 1);
069
070        // default check box selections
071        autoWeightCheckBox.setSelected(true);
072
073        // load tool tips
074        weightTextField.setToolTipText(Bundle.getMessage("TipCarWeightOz"));
075        weightTonsTextField.setToolTipText(Bundle.getMessage("TipCarWeightTons"));
076        autoWeightCheckBox.setToolTipText(Bundle.getMessage("TipCarAutoCalculate"));
077        passengerCheckBox.setToolTipText(Bundle.getMessage("TipCarPassenger"));
078        cabooseCheckBox.setToolTipText(Bundle.getMessage("TipCarCaboose"));
079        fredCheckBox.setToolTipText(Bundle.getMessage("TipCarFred"));
080        utilityCheckBox.setToolTipText(Bundle.getMessage("TipCarUtility"));
081        hazardousCheckBox.setToolTipText(Bundle.getMessage("TipCarHazardous"));
082        blockingTextField.setToolTipText(Bundle.getMessage("TipPassengerCarBlocking"));
083        fillWeightButton.setToolTipText(Bundle.getMessage("TipCalculateCarWeight"));
084        builtTextField.setToolTipText(Bundle.getMessage("TipBuildDate"));
085        valueTextArea.setToolTipText(Bundle.getMessage("TipValue"));
086
087        editLoadButton.setToolTipText(Bundle.getMessage("TipAddDeleteReplace",
088                Bundle.getMessage("load"))); // initial caps for some languages i.e. German
089        editGroupButton.setToolTipText(Bundle.getMessage("TipAddDeleteReplace",
090                Bundle.getMessage("Kernel").toLowerCase()));
091        
092        deleteButton.setToolTipText(Bundle.getMessage("TipDeleteButton"));
093        addButton.setToolTipText(Bundle.getMessage("TipAddButton"));
094        saveButton.setToolTipText(Bundle.getMessage("TipSaveButton"));
095
096        // row 7
097        pWeightOz.setLayout(new GridBagLayout());
098        addItem(pWeightOz, textWeightOz, 0, 0);
099        addItem(pWeightOz, weightTextField, 1, 0);
100        addItem(pWeightOz, fillWeightButton, 2, 0);
101        addItem(pWeightOz, autoWeightCheckBox, 3, 0);
102
103        // row 9
104        pLoad.setLayout(new GridBagLayout());
105        pLoad.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Load")));
106        addItem(pLoad, loadComboBox, 1, 0);
107        addItem(pLoad, editLoadButton, 2, 0);
108        pLoad.setVisible(true);
109        
110        // select first item so load combobox will update
111        typeComboBox.setSelectedIndex(0);
112
113        // row 10
114        pGroup.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Kernel")));
115
116        addButtonAction(fillWeightButton);
117        addButtonAction(editLoadButton);
118
119        // setup check boxes
120        addCheckBoxAction(cabooseCheckBox);
121        addCheckBoxAction(fredCheckBox);
122        addCheckBoxAction(passengerCheckBox);
123        
124        addHelpMenu("package.jmri.jmrit.operations.Operations_CarsEdit", true); // NOI18N
125    }
126
127    @Override
128    protected ResourceBundle getRb() {
129        return rb;
130    }
131
132    @Override
133    protected RollingStockAttribute getTypeManager() {
134        return InstanceManager.getDefault(CarTypes.class);
135    }
136
137    @Override
138    protected RollingStockAttribute getLengthManager() {
139        return InstanceManager.getDefault(CarLengths.class);
140    }
141
142    public void load(Car car) {
143        setTitle(Bundle.getMessage("TitleCarEdit"));
144        super.load(car);
145
146        passengerCheckBox.setSelected(car.isPassenger());
147        cabooseCheckBox.setSelected(car.isCaboose());
148        utilityCheckBox.setSelected(car.isUtility());
149        fredCheckBox.setSelected(car.hasFred());
150        hazardousCheckBox.setSelected(car.isCarHazardous());
151
152        pBlocking.setVisible(car.isPassenger() || car.getKernel() != null);
153
154        if (!InstanceManager.getDefault(CarLoads.class).containsName(car.getTypeName(), car.getLoadName())) {
155            if (JmriJOptionPane.showConfirmDialog(this, Bundle.getMessage("loadNameNotExist",
156                    car.getLoadName()), Bundle.getMessage("addLoad"),
157                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
158                carLoadEditFrame = new CarLoadEditFrame();
159                carLoadEditFrame.initComponents(car.getTypeName(),
160                        car.getLoadName());
161            }
162        }
163        InstanceManager.getDefault(CarLoads.class).updateComboBox(car.getTypeName(), loadComboBox);
164        loadComboBox.setSelectedItem(car.getLoadName());
165        
166        // listen for changes in car load
167        car.addPropertyChangeListener(this);
168
169        groupComboBox.setSelectedItem(car.getKernelName());
170    }
171
172    @Override
173    public void comboBoxActionPerformed(java.awt.event.ActionEvent ae) {
174        if (ae.getSource() == typeComboBox && typeComboBox.getSelectedItem() != null) {
175            log.debug("Type comboBox sees change, update car loads");
176            InstanceManager.getDefault(CarLoads.class).updateComboBox((String) typeComboBox.getSelectedItem(),
177                    loadComboBox);
178            if (_rs != null) {
179                loadComboBox.setSelectedItem(((Car)_rs).getLoadName());
180            }
181        }
182        if (ae.getSource() == lengthComboBox && autoWeightCheckBox.isSelected()) {
183            calculateWeight();
184        }
185        super.comboBoxActionPerformed(ae);
186    }
187
188    @Override
189    public void checkBoxActionPerformed(java.awt.event.ActionEvent ae) {
190        if (ae.getSource() == cabooseCheckBox && cabooseCheckBox.isSelected()) {
191            fredCheckBox.setSelected(false);
192        }
193        if (ae.getSource() == fredCheckBox && fredCheckBox.isSelected()) {
194            cabooseCheckBox.setSelected(false);
195        }
196        if (ae.getSource() == passengerCheckBox) {
197            pBlocking.setVisible(passengerCheckBox.isSelected() || (_rs != null && ((Car) _rs).getKernel() != null));
198        }
199        super.checkBoxActionPerformed(ae);
200    }
201
202    // Save, Delete, Add, Clear, Calculate, Edit Load buttons
203    @Override
204    public void buttonActionPerformed(java.awt.event.ActionEvent ae) {
205        super.buttonActionPerformed(ae);
206        if (ae.getSource() == fillWeightButton) {
207            calculateWeight();
208        }
209        if (ae.getSource() == editLoadButton) {
210            if (carLoadEditFrame != null) {
211                carLoadEditFrame.dispose();
212            }
213            carLoadEditFrame = new CarLoadEditFrame();
214            carLoadEditFrame.initComponents((String) typeComboBox.getSelectedItem(),
215                    (String) loadComboBox.getSelectedItem());
216        }
217    }
218
219    @Override
220    protected boolean check(RollingStock car) {
221        // check to see if car with road and number already exists
222        Car existingCar = carManager.getByRoadAndNumber((String) roadComboBox.getSelectedItem(), roadNumberTextField
223                .getText());
224        if (existingCar != null) {
225            if (car == null) {
226                JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("carRoadExists"), Bundle
227                        .getMessage("carCanNotAdd"), JmriJOptionPane.ERROR_MESSAGE);
228                return false;
229            }
230            // old car with new road or number?
231            if (!existingCar.getId().equals(car.getId())) {
232                JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("carRoadExists"), Bundle
233                        .getMessage("carCanNotUpdate"), JmriJOptionPane.ERROR_MESSAGE);
234                return false;
235            }
236        }
237        // check car's weight has proper format
238        try {
239            Number number = NumberFormat.getNumberInstance().parse(weightTextField.getText());
240            log.debug("Car weight in oz: {}", number);
241        } catch (Exception e) {
242            JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("carWeightFormat"), Bundle
243                    .getMessage("carActualWeight"), JmriJOptionPane.ERROR_MESSAGE);
244            return false;
245        }
246
247        return super.check(car);
248    }
249
250    private void calculateWeight() {
251        if (lengthComboBox.getSelectedItem() != null) {
252            String length = (String) lengthComboBox.getSelectedItem();
253            try {
254                String carWeight = CarManager.calculateCarWeight(length);
255                weightTextField.setText(carWeight); // car weight in ounces.
256                int tons = (int) (NumberFormat.getNumberInstance().parse(carWeight).doubleValue() * Setup.getScaleTonRatio());
257                // adjust weight for caboose
258                if (cabooseCheckBox.isSelected() || passengerCheckBox.isSelected()) {
259                    tons = (int) (Double.parseDouble(length) * .9); // .9 tons/foot
260                }
261                weightTonsTextField.setText(Integer.toString(tons));
262            } catch (NumberFormatException e) {
263                JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("carLengthMustBe"), Bundle
264                        .getMessage("carWeigthCanNot"), JmriJOptionPane.ERROR_MESSAGE);
265            } catch (ParseException ex) {
266                JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("carWeightFormat"), Bundle
267                        .getMessage("carWeigthCanNot"), JmriJOptionPane.ERROR_MESSAGE);
268            }
269        }
270    }
271
272    @Override
273    protected void save(boolean isSave) {
274        if (roadComboBox.getSelectedItem() == null) {
275            return;
276        }
277        if (!super.save(carManager, isSave)) {
278            return;
279        }
280        Car car = (Car) _rs;
281
282        // ask if all cars of this type should be passenger 
283        if (isSave && car.isPassenger() ^ passengerCheckBox.isSelected()) {
284            if (JmriJOptionPane.showConfirmDialog(this, MessageFormat.format(passengerCheckBox.isSelected() ? Bundle
285                    .getMessage("carModifyTypePassenger") : Bundle.getMessage("carRemoveTypePassenger"),
286                    new Object[]{car.getTypeName()}),
287                    Bundle.getMessage("carModifyAllType",
288                            car.getTypeName()),
289                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
290                // go through the entire list and change the passenger setting
291                // for all cars of this type
292                for (Car c : carManager.getList()) {
293                    if (c.getTypeName().equals(car.getTypeName())) {
294                        c.setPassenger(passengerCheckBox.isSelected());
295                    }
296                }
297            }
298        }
299        car.setPassenger(passengerCheckBox.isSelected());
300        int blocking = Integer.parseInt(blockingTextField.getText());
301        // ask if blocking order should be the same
302        if (isSave && car.getKernel() == null && passengerCheckBox.isSelected() && car.getBlocking() != blocking) {
303            if (JmriJOptionPane.showConfirmDialog(this, Bundle.getMessage("carChangeBlocking",
304                    blocking, car.getTypeName()),
305                    Bundle.getMessage("carModifyAllType", car.getTypeName()),
306                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
307                // go through the entire list and change the passenger setting
308                // for all cars of this type
309                for (Car c : carManager.getList()) {
310                    if (c.isPassenger() && c.getTypeName().equals(car.getTypeName())) {
311                        c.setBlocking(blocking);
312                    }
313                }
314            }
315        }
316        car.setBlocking(blocking);
317        // ask if all cars of this type should be caboose
318        if (isSave && car.isCaboose() ^ cabooseCheckBox.isSelected()) {
319            if (JmriJOptionPane.showConfirmDialog(this, MessageFormat.format(cabooseCheckBox.isSelected() ? Bundle
320                    .getMessage("carModifyTypeCaboose") : Bundle.getMessage("carRemoveTypeCaboose"),
321                    new Object[]{car.getTypeName()}),
322                    Bundle.getMessage("carModifyAllType",
323                            car.getTypeName()),
324                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
325                // go through the entire list and change the caboose setting for all cars of this type
326                for (Car c : carManager.getList()) {
327                    if (c.getTypeName().equals(car.getTypeName())) {
328                        c.setCaboose(cabooseCheckBox.isSelected());
329                    }
330                }
331            }
332        }
333        car.setCaboose(cabooseCheckBox.isSelected());
334        // ask if all cars of this type should be utility
335        if (isSave && car.isUtility() ^ utilityCheckBox.isSelected()) {
336            if (JmriJOptionPane.showConfirmDialog(this, MessageFormat.format(utilityCheckBox.isSelected() ? Bundle
337                    .getMessage("carModifyTypeUtility") : Bundle.getMessage("carRemoveTypeUtility"),
338                    new Object[]{car.getTypeName()}),
339                    Bundle.getMessage("carModifyAllType",
340                            car.getTypeName()),
341                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
342                // go through the entire list and change the utility for all cars of this type
343                for (Car c : carManager.getList()) {
344                    if (c.getTypeName().equals(car.getTypeName())) {
345                        c.setUtility(utilityCheckBox.isSelected());
346                    }
347                }
348            }
349        }
350        car.setUtility(utilityCheckBox.isSelected());
351        // ask if all cars of this type should be hazardous
352        if (isSave && car.isCarHazardous() ^ hazardousCheckBox.isSelected()) {
353            if (JmriJOptionPane.showConfirmDialog(this, MessageFormat.format(hazardousCheckBox.isSelected() ? Bundle
354                    .getMessage("carModifyTypeHazardous") : Bundle.getMessage("carRemoveTypeHazardous"),
355                    new Object[]{car.getTypeName()}),
356                    Bundle.getMessage("carModifyAllType",
357                            car.getTypeName()),
358                    JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
359                // go through the entire list and change the hazardous setting for all cars of this type
360                for (Car c : carManager.getList()) {
361                    if (c.getTypeName().equals(car.getTypeName())) {
362                        c.setCarHazardous(hazardousCheckBox.isSelected());
363                    }
364                }
365            }
366        }
367        car.setCarHazardous(hazardousCheckBox.isSelected());
368        car.setFred(fredCheckBox.isSelected());
369        if (groupComboBox.getSelectedItem() != null) {
370            if (groupComboBox.getSelectedItem().equals(CarManager.NONE)) {
371                car.setKernel(null);
372                if (!car.isPassenger()) {
373                    car.setBlocking(Car.DEFAULT_BLOCKING_ORDER);
374                }
375            } else if (!car.getKernelName().equals(groupComboBox.getSelectedItem())) {
376                car.setKernel(InstanceManager.getDefault(KernelManager.class).getKernelByName((String) groupComboBox.getSelectedItem()));
377                // if car has FRED or caboose make lead
378                if (car.hasFred() || car.isCaboose()) {
379                    car.getKernel().setLead(car);
380                }
381                car.setBlocking(car.getKernel().getSize());
382            }
383        }
384        if (loadComboBox.getSelectedItem() != null && !car.getLoadName().equals(loadComboBox.getSelectedItem())) {
385            car.setLoadName((String) loadComboBox.getSelectedItem());
386            car.setWait(0); // car could be at spur with schedule
387            car.setScheduleItemId(Car.NONE);
388            // check to see if car is part of kernel, and ask if all the other cars in the kernel should be changed
389            if (car.getKernel() != null) {
390                List<Car> cars = car.getKernel().getCars();
391                if (cars.size() > 1) {
392                    if (JmriJOptionPane.showConfirmDialog(this, Bundle.getMessage("carInKernelLoad",
393                            car.toString(), car.getLoadName()),
394                            Bundle.getMessage("carPartKernel",
395                                    car.getKernelName()),
396                            JmriJOptionPane.YES_NO_OPTION) == JmriJOptionPane.YES_OPTION) {
397                        // go through the entire list and change the loads for all cars
398                        for (Car c : cars) {
399                            if (InstanceManager.getDefault(CarLoads.class).containsName(c.getTypeName(),
400                                    car.getLoadName())) {
401                                c.setLoadName(car.getLoadName());
402                                c.setWait(0); // car could be at spur with schedule
403                                c.setScheduleItemId(Car.NONE);
404                            }
405                        }
406                    }
407                }
408            }
409        }
410        
411        // place car on track after setting load name
412        checkAndSetLocationAndTrack(car);
413
414        // update blocking
415        pBlocking.setVisible(passengerCheckBox.isSelected() || car.getKernel() != null);
416        blockingTextField.setText(Integer.toString(car.getBlocking()));
417
418        // is this car part of a kernel? Ask if all cars should have the same location and track
419        if (car.getKernel() != null) {
420            List<Car> cars = car.getKernel().getCars();
421            for (Car kcar : cars) {
422                if (kcar != car) {
423                    if (kcar.getLocation() != car.getLocation() || kcar.getTrack() != car.getTrack()) {
424                        int results = JmriJOptionPane.showConfirmDialog(this, Bundle
425                                .getMessage("carInKernelLocation",
426                                car.toString(), car.getLocationName(), car.getTrackName()),
427                                Bundle.getMessage("carPartKernel",
428                                                car.getKernelName()),
429                                JmriJOptionPane.YES_NO_OPTION);
430                        if (results == JmriJOptionPane.YES_OPTION) {
431                            // change the location for all cars in kernel
432                            for (Car kcar2 : cars) {
433                                if (kcar2 != car) {
434                                    setLocationAndTrack(kcar2);
435                                }
436                            }
437                        }
438                        break; // done
439                    }
440                }
441            }
442        }
443    }
444    
445    @Override
446    protected void delete() {
447        Car car = carManager.getByRoadAndNumber((String) roadComboBox.getSelectedItem(), roadNumberTextField
448                .getText());
449        if (car != null) {
450            carManager.deregister(car);
451        }
452    }
453
454    CarAttributeEditFrame carAttributeEditFrame;
455
456    // edit buttons only one frame active at a time
457    @Override
458    public void buttonEditActionPerformed(java.awt.event.ActionEvent ae) {
459        if (carAttributeEditFrame != null) {
460            carAttributeEditFrame.dispose();
461        }
462        carAttributeEditFrame = new CarAttributeEditFrame();
463        carAttributeEditFrame.addPropertyChangeListener(this);
464
465        if (ae.getSource() == editRoadButton) {
466            carAttributeEditFrame.initComponents(CarAttributeEditFrame.ROAD, (String) roadComboBox.getSelectedItem());
467        }
468        if (ae.getSource() == editTypeButton) {
469            carAttributeEditFrame.initComponents(CarAttributeEditFrame.TYPE, (String) typeComboBox.getSelectedItem());
470        }
471        if (ae.getSource() == editColorButton) {
472            carAttributeEditFrame.initComponents(CarAttributeEditFrame.COLOR, (String) colorComboBox.getSelectedItem());
473        }
474        if (ae.getSource() == editLengthButton) {
475            carAttributeEditFrame.initComponents(CarAttributeEditFrame.LENGTH,
476                    (String) lengthComboBox.getSelectedItem());
477        }
478        if (ae.getSource() == editOwnerButton) {
479            carAttributeEditFrame.initComponents(CarAttributeEditFrame.OWNER, (String) ownerComboBox.getSelectedItem());
480        }
481        if (ae.getSource() == editGroupButton) {
482            carAttributeEditFrame.initComponents(CarAttributeEditFrame.KERNEL,
483                    (String) groupComboBox.getSelectedItem());
484        }
485    }
486
487    @Override
488    protected void addPropertyChangeListeners() {
489        InstanceManager.getDefault(CarLoads.class).addPropertyChangeListener(this);
490        InstanceManager.getDefault(KernelManager.class).addPropertyChangeListener(this);
491        carManager.addPropertyChangeListener(this);
492        super.addPropertyChangeListeners();
493    }
494
495    @Override
496    protected void removePropertyChangeListeners() {
497        InstanceManager.getDefault(CarLoads.class).removePropertyChangeListener(this);
498        InstanceManager.getDefault(KernelManager.class).removePropertyChangeListener(this);
499        carManager.removePropertyChangeListener(this);
500        if (_rs != null) {
501            _rs.removePropertyChangeListener(this);
502        }
503        super.removePropertyChangeListeners();
504    }
505    
506    @Override
507    public void dispose() {
508        if (carLoadEditFrame != null) {
509            carLoadEditFrame.dispose();
510        }
511        if (carAttributeEditFrame != null) {
512            carAttributeEditFrame.dispose();
513        }
514        super.dispose();
515    }
516
517    @Override
518    public void propertyChange(java.beans.PropertyChangeEvent e) {
519        //        if (Control.SHOW_PROPERTY) {
520        log.debug("Property change: ({}) old: ({}) new: ({})", e.getPropertyName(), e.getOldValue(), e
521                .getNewValue());
522        //        }
523        super.propertyChange(e);
524        
525        if (e.getPropertyName().equals(CarLengths.CARLENGTHS_CHANGED_PROPERTY)) {
526            InstanceManager.getDefault(CarLengths.class).updateComboBox(lengthComboBox);
527            if (_rs != null) {
528                lengthComboBox.setSelectedItem(_rs.getLength());
529            }
530        }
531        if (e.getPropertyName().equals(KernelManager.LISTLENGTH_CHANGED_PROPERTY) ||
532                e.getPropertyName().equals(Car.KERNEL_NAME_CHANGED_PROPERTY)) {
533            InstanceManager.getDefault(KernelManager.class).updateComboBox(groupComboBox);
534            if (_rs != null) {
535                groupComboBox.setSelectedItem(((Car) _rs).getKernelName());
536            }
537        }
538        if (e.getPropertyName().equals(CarLoads.LOAD_CHANGED_PROPERTY)) {
539            InstanceManager.getDefault(CarLoads.class).updateComboBox((String) typeComboBox.getSelectedItem(),
540                    loadComboBox);
541        }
542        if (e.getPropertyName().equals(Car.LOAD_CHANGED_PROPERTY) ||
543                e.getPropertyName().equals(CarLoads.LOAD_CHANGED_PROPERTY)) {
544            if (_rs != null) {
545                loadComboBox.setSelectedItem(((Car) _rs).getLoadName());
546            }
547        }
548        if (e.getPropertyName().equals(CarAttributeEditFrame.DISPOSE)) {
549            carAttributeEditFrame = null;
550        }
551    }
552
553    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CarEditFrame.class);
554}