示例#1
0
  /**
   * Returns the default value for the attribute we want to create. This function may throw a
   * RuntimeException, if the value filled in for the default value can not be parsed!
   *
   * @return default value
   */
  protected Object getDefaultValue() {
    if (FeatureCollectionTools.isAttributeTypeNumeric(
        (AttributeType) this.typeDropDown.getSelectedItem())) {
      AttributeType at = (AttributeType) this.typeDropDown.getSelectedItem();

      if (at.equals(AttributeType.INTEGER)) {
        int i = Integer.parseInt(this.defValueTextField.getText());
        return new Integer(i);
      }
      double d = Double.parseDouble(this.defValueTextField.getText());
      return new Double(d);
    }
    return this.defValueTextField.getText();
  }
示例#2
0
  /**
   * checks and fixes the integrity of the values given, when the attribute type is changed.
   *
   * @param event the action event
   */
  public void actionPerformed(ActionEvent event) {
    if (JComboBox.class.isInstance(event.getSource())) {
      if (this.needDefaultValue
          && FeatureCollectionTools.isAttributeTypeNumeric(
              (AttributeType) this.typeDropDown.getSelectedItem())) {
        AttributeType at = (AttributeType) this.typeDropDown.getSelectedItem();

        if (at.equals(AttributeType.INTEGER)) {
          try {
            Integer.parseInt(this.defValueTextField.getText());
          } catch (Exception e) {
            this.defValueTextField.setText("0");
          }
        } else {
          try {
            Double.parseDouble(this.defValueTextField.getText());
          } catch (Exception e) {
            this.defValueTextField.setText("0.0");
          }
        }
      }
    }
  }