@Override
 public void validate(UIValidationContext validator) {
   boolean overwriteValue = overwrite.getValue() != null && overwrite.getValue();
   JavaResource resource = (JavaResource) validator.getUIContext().getInitialSelection().get();
   JavaClass javaClass;
   if (!overwriteValue) {
     try {
       String fieldName = conversationFieldName.getValue();
       String beginName = beginMethodName.getValue();
       String endName = endMethodName.getValue();
       javaClass = (JavaClass) resource.getJavaSource();
       if (javaClass.hasField(fieldName)
           && !javaClass.getField(fieldName).isType(Conversation.class)) {
         validator.addValidationError(
             conversationFieldName, "Field [" + fieldName + "] already exists.");
       }
       if (javaClass.hasMethodSignature(beginName)
           && (javaClass.getMethod(beginName).getParameters().size() == 0)) {
         validator.addValidationError(beginMethodName, "Method [" + beginName + "] exists.");
       }
       if (javaClass.hasMethodSignature(endName)
           && (javaClass.getMethod(endName).getParameters().size() == 0)) {
         validator.addValidationError(endMethodName, "Method [" + endName + "] exists.");
       }
     } catch (FileNotFoundException e) {
       validator.addValidationError(null, "The selected resource file was not found");
     }
   }
 }
 @Override
 public void validate(UIValidationContext validator) {
   super.validate(validator);
   try {
     if (!isTargetClassJPAEntity()) {
       validator.addValidationError(forEntity, "The selected class must be JPA entity");
     }
   } catch (FileNotFoundException e) {
     validator.addValidationError(
         forEntity, "You must select existing JPA entity to create repository for");
   }
 }
示例#3
0
  @Override
  public void validate(UIValidationContext context) {
    String packg = topLevelPackage.getValue();
    if (packg != null && !packg.matches("(?i)(~\\.)?([a-z0-9_]+\\.?)+[a-z0-9_]")) {
      context.addValidationError(
          topLevelPackage, "Top level package must be a valid package name.");
    }

    if (overwrite.isEnabled() && overwrite.getValue() == false) {
      context.addValidationError(targetLocation, "Target location is not empty.");
    }
  }
 @Override
 public void validate(UIValidationContext validator) {
   String repository = archetypeRepository.getValue();
   if (!Strings.isNullOrEmpty(repository) && !Strings.isURL(repository)) {
     validator.addValidationError(archetypeRepository, "Archetype repository must be a valid URL");
   }
 }
 @Override
 public void validate(UIValidationContext validator) {
   Boolean pseudoValue = pseudo.getValue();
   Boolean passivatingValue = passivating.getValue();
   if (pseudoValue != null && passivatingValue != null) {
     if (pseudoValue && passivatingValue) {
       validator.addValidationError(passivating, "Cannot create a passivating pseudo-scope");
     }
   }
 }