/*
   * This method apply the new value for the specified property
   * The oldValue can be wrong or null if a multiselection was performed
   * return true if the object is modified...
   */
  private boolean applyNewFieldProperty(
      JRField field, String propertyName, Object oldValue, Object newValue) {
    if (propertyName == null) return false;

    boolean objectModified = true;

    if (propertyName.equals("fieldName")) {
      SubDataset paramSubdataset = Misc.getObjectSubDataset(getJrf().getReport(), field);
      if (paramSubdataset != null && newValue != null) {
        for (int i = 0; i < paramSubdataset.getFields().size(); ++i) {
          JRField f = (JRField) paramSubdataset.getFields().get(i);
          if (f.getName().equals(newValue)) {
            ((SheetProperty) this.getSheetProperty(propertyName))
                .setLabelError(
                    I18n.getString(
                        "messages.JRFieldDialog.DuplicatedFieldName",
                        "A field with this name already exists!"));
            ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
            return false;
          }
        }

        field.setName("" + newValue);
        ((SheetProperty) this.getSheetProperty(propertyName)).setLabelError(null);
        ((SheetProperty) this.getSheetProperty(propertyName)).updateLabel();
      }
    } else if (propertyName.equals("fieldDescription")) {
      if (newValue != null) {
        field.setDescription("" + newValue);
      }
    } else if (propertyName.equals("fieldProperties")) {
      if (newValue != null && newValue instanceof List) {
        field.setProperties((List) newValue);
      }
    } else if (propertyName.equals("fieldClassType")) {
      if (newValue != null) {
        field.setClassType("" + newValue);
      }
    }

    return objectModified;
  }