Пример #1
0
 public void propertyChange(java.beans.PropertyChangeEvent e) {
   if (Control.showProperty) {
     log.debug(
         "Property change: ({}) old: ({}) new: ({})",
         e.getPropertyName(),
         e.getOldValue(),
         e.getNewValue());
   }
   if (e.getPropertyName().equals(CarRoads.CARROADS_CHANGED_PROPERTY)) {
     CarRoads.instance().updateComboBox(roadComboBox);
     if (_engine != null) {
       roadComboBox.setSelectedItem(_engine.getRoadName());
     }
   }
   if (e.getPropertyName().equals(EngineModels.ENGINEMODELS_CHANGED_PROPERTY)) {
     engineModels.updateComboBox(modelComboBox);
     if (_engine != null) {
       modelComboBox.setSelectedItem(_engine.getModel());
     }
   }
   if (e.getPropertyName().equals(EngineTypes.ENGINETYPES_CHANGED_PROPERTY)) {
     engineTypes.updateComboBox(typeComboBox);
     if (_engine != null) {
       typeComboBox.setSelectedItem(_engine.getTypeName());
     }
   }
   if (e.getPropertyName().equals(EngineLengths.ENGINELENGTHS_CHANGED_PROPERTY)) {
     engineLengths.updateComboBox(lengthComboBox);
     if (_engine != null) {
       lengthComboBox.setSelectedItem(_engine.getLength());
     }
   }
   if (e.getPropertyName().equals(EngineManager.CONSISTLISTLENGTH_CHANGED_PROPERTY)) {
     manager.updateConsistComboBox(consistComboBox);
     if (_engine != null) {
       consistComboBox.setSelectedItem(_engine.getConsistName());
     }
   }
   if (e.getPropertyName().equals(CarOwners.CAROWNERS_CHANGED_PROPERTY)) {
     CarOwners.instance().updateComboBox(ownerComboBox);
     if (_engine != null) {
       ownerComboBox.setSelectedItem(_engine.getOwner());
     }
   }
   if (e.getPropertyName().equals(LocationManager.LISTLENGTH_CHANGED_PROPERTY)) {
     LocationManager.instance().updateComboBox(locationBox);
     if (_engine != null) {
       locationBox.setSelectedItem(_engine.getLocation());
     }
   }
   if (e.getPropertyName().equals(EngineAttributeEditFrame.DISPOSE)) {
     editActive = false;
   }
 }
Пример #2
0
  public void loadEngine(Engine engine) {
    _engine = engine;

    if (!CarRoads.instance().containsName(engine.getRoadName())) {
      String msg =
          MessageFormat.format(
              Bundle.getMessage("roadNameNotExist"), new Object[] {engine.getRoadName()});
      if (JOptionPane.showConfirmDialog(
              this, msg, Bundle.getMessage("engineAddRoad"), JOptionPane.YES_NO_OPTION)
          == JOptionPane.YES_OPTION) {
        CarRoads.instance().addName(engine.getRoadName());
      }
    }
    roadComboBox.setSelectedItem(engine.getRoadName());

    roadNumberTextField.setText(engine.getNumber());

    if (!engineModels.containsName(engine.getModel())) {
      String msg =
          MessageFormat.format(
              Bundle.getMessage("modelNameNotExist"), new Object[] {engine.getModel()});
      if (JOptionPane.showConfirmDialog(
              this, msg, Bundle.getMessage("engineAddModel"), JOptionPane.YES_NO_OPTION)
          == JOptionPane.YES_OPTION) {
        engineModels.addName(engine.getModel());
      }
    }
    modelComboBox.setSelectedItem(engine.getModel());

    if (!engineTypes.containsName(engine.getTypeName())) {
      String msg =
          MessageFormat.format(
              Bundle.getMessage("typeNameNotExist"), new Object[] {engine.getTypeName()});
      if (JOptionPane.showConfirmDialog(
              this, msg, Bundle.getMessage("engineAddType"), JOptionPane.YES_NO_OPTION)
          == JOptionPane.YES_OPTION) {
        engineTypes.addName(engine.getTypeName());
      }
    }
    typeComboBox.setSelectedItem(engine.getTypeName());
    bUnitCheckBox.setSelected(engine.isBunit());

    if (!engineLengths.containsName(engine.getLength())) {
      String msg =
          MessageFormat.format(
              Bundle.getMessage("lengthNameNotExist"), new Object[] {engine.getLength()});
      if (JOptionPane.showConfirmDialog(
              this, msg, Bundle.getMessage("engineAddLength"), JOptionPane.YES_NO_OPTION)
          == JOptionPane.YES_OPTION) {
        engineLengths.addName(engine.getLength());
      }
    }
    lengthComboBox.setSelectedItem(engine.getLength());
    weightTextField.setText(engine.getWeightTons());
    hpTextField.setText(engine.getHp());

    locationBox.setSelectedItem(engine.getLocation());
    Location l = locationManager.getLocationById(engine.getLocationId());
    if (l != null) {
      l.updateComboBox(trackLocationBox);
      trackLocationBox.setSelectedItem(engine.getTrack());
    } else {
      trackLocationBox.removeAllItems();
    }

    builtTextField.setText(engine.getBuilt());

    if (!CarOwners.instance().containsName(engine.getOwner())) {
      String msg =
          MessageFormat.format(
              Bundle.getMessage("ownerNameNotExist"), new Object[] {engine.getOwner()});
      if (JOptionPane.showConfirmDialog(
              this, msg, Bundle.getMessage("addOwner"), JOptionPane.YES_NO_OPTION)
          == JOptionPane.YES_OPTION) {
        CarOwners.instance().addName(engine.getOwner());
      }
    }
    consistComboBox.setSelectedItem(engine.getConsistName());

    ownerComboBox.setSelectedItem(engine.getOwner());
    valueTextField.setText(engine.getValue());
    rfidComboBox.setSelectedItem(engine.getIdTag());
    commentTextField.setText(engine.getComment());

    setTitle(Bundle.getMessage("TitleEngineEdit"));
  }