Пример #1
0
  /**
   * Validates the private fields.
   *
   * @param page the page to update in case of error
   */
  private void validate(CroquisNewWizardPage page) {

    String msg = null;
    if (StringUtils.isEmpty(this.fileName)) msg = "You must set the name of the file to create.";
    else if (this.fileName.contains(".") && !this.fileName.endsWith(".peip"))
      msg = "The file must have a .peip extension.";
    else if (getFile().exists()) msg = "There is already an EIP chain file with this name.";
    if (StringUtils.isEmpty(this.chainName)) msg = "You must set the name of the EIP chain.";

    page.updateStatus(msg);
  }
  /**
   * Allows to remove unset features from the model.
   *
   * <p>To guarantee insertion order in the wizard, one can preset all the values in {@link
   * #presetServiceValues(AbstractEndpoint)}. The insertion order must respect the one in XML
   * schema.
   *
   * <p>This method allows to remove the values that were not set or that should not be written.
   *
   * @param ae
   * @param features
   */
  protected void hackEmfModel(AbstractEndpoint ae, EStructuralFeature... features) {

    if (features == null) return;

    for (EStructuralFeature feature : features) {
      if (feature.isUnsettable()) continue;

      Object value = ae.eGet(feature);
      if (value == null || value instanceof String && StringUtils.isEmpty((String) value))
        ae.eSet(feature, null);
    }
  }