当前位置: 首页>>代码示例>>Java>>正文


Java UIValidationContext类代码示例

本文整理汇总了Java中org.jboss.forge.addon.ui.context.UIValidationContext的典型用法代码示例。如果您正苦于以下问题:Java UIValidationContext类的具体用法?Java UIValidationContext怎么用?Java UIValidationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UIValidationContext类属于org.jboss.forge.addon.ui.context包,在下文中一共展示了UIValidationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    UIContext uiContext = context.getUIContext();
    Map<Object, Object> attributeMap = uiContext.getAttributeMap();
    if ("next".equals(attributeMap.get("action"))) {
        // Do not validate again if next() was called
        return;
    }
    List<String> step = (List<String>) attributeMap.get(RETRY_STEP);
    DeploymentType deploymentType = (DeploymentType) attributeMap.get(DeploymentType.class);
    if (deploymentType == DeploymentType.CD && (step == null || "0".equals(step.get(0)))) {
        String openShiftCluster = (String) attributeMap.get("OPENSHIFT_CLUSTER");
        if (missionControlValidator.validateOpenShiftTokenExists(context, openShiftCluster)) {
            missionControlValidator.validateOpenShiftProjectExists(context, named.getValue(), openShiftCluster);
        }
        if (missionControlValidator.validateGitHubTokenExists(context)) {
            String repository = getGithubRepositoryNameValue();
            missionControlValidator.validateGitHubRepositoryExists(context, repository);
        }
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:22,代码来源:ProjectInfoStep.java

示例2: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    // lets ignore the mission validation as its not suitable for fabric8
    // super.validate(context);

    if (github == null || !github.isDetailsValid()) {
        // invoked too early before the github account is setup - lets return silently
        return;
    }
    String orgName = getOrganisationName(gitOrganisation.getValue());
    String repoName = getGithubRepositoryNameValue();

    if (Strings.isNotBlank(orgName)) {
        if (Strings.isNotBlank(repoName)) {
            github.validateRepositoryName(getNamed(), context, orgName, repoName);
        }
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:19,代码来源:Fabric8ProjectInfoStep.java

示例3: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
	Project selectedProject = getSelectedProject(context);
	JavaSourceFacet javaFacet = selectedProject.getFacet(JavaSourceFacet.class);
	try {
		if (null == context.getCurrentInputComponent().getValue())
			return;
		JavaResource javaResource = javaFacet.getJavaResource((String)context.getCurrentInputComponent().getValue());
		if (javaResource.exists()) {
			if (!javaResource.getJavaType().hasAnnotation(Named.class)) {
				context.addValidationError(context.getCurrentInputComponent(), javaResource.getFullyQualifiedName() + " must be annotated with @Named");
			}
		}
	} catch (FileNotFoundException e) {
		context.addValidationError(context.getCurrentInputComponent(), e.getMessage());
	}				
}
 
开发者ID:javaee-samples,项目名称:forge-addons,代码行数:18,代码来源:BatchNewJobXmlCommand.java

示例4: configureInputs

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
private void configureInputs(UIBuilder builder) {
    Project project = getSelectedProject(builder);
    final Resource<?> projectRoot = project.getRoot();
    dateOfCreated.setValue(new Date().toString());
    targetDirectory.addValidator(new UIValidator() {
        @Override
        public void validate(UIValidationContext context) {
            try {
                projectRoot.resolveChildren(targetDirectory.getValue());
            } catch (RuntimeException re) {
                context.addValidationError(targetDirectory, "Target Directory is not a child of the project root "
                        + projectRoot);
            }
        }
    });
    if (builder.getUIContext().getProvider().isGUI()) {
        postStatus
                .setItemLabelConverter(new Converter<PublishType, String>() {
                    @Override
                    public String convert(PublishType source) {
                        return source != null ? source.name() : null;
                    }
                });
    }

}
 
开发者ID:jbake-org,项目名称:jbake-forge-addon,代码行数:27,代码来源:NewPostWizard.java

示例5: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    if (deploymentType.getValue() == DeploymentType.CD) {
        if (!openShiftCluster.getValueChoices().iterator().hasNext()) {
            context.addValidationError(null, "No OpenShift token assigned");
        }
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:9,代码来源:ChooseDeploymentTypeStep.java

示例6: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    UIContext uiContext = context.getUIContext();
    Mission mission = (Mission) uiContext.getAttributeMap().get(Mission.class);
    String[] filterLabels = catalogServiceFactory.getFilterLabels(uiContext);

    Optional<Booster> booster = catalogServiceFactory.getCatalog(uiContext).getBooster(mission,
                                                                                       runtime.getValue(), filterLabels);
    if (!booster.isPresent()) {
        context.addValidationError(runtime,
                                   "No booster found for mission '" + mission + "' and runtime '" + runtime.getValue() + "'");
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:14,代码来源:ChooseRuntimeStep.java

示例7: validateGitHubTokenExists

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
public boolean validateGitHubTokenExists(UIValidationContext context) {
    Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
    String validationMessage = (String) attributeMap.computeIfAbsent("token_github_exists", key -> {
        List<String> authList = (List<String>) attributeMap.get(HttpHeaders.AUTHORIZATION);
        String authHeader = (authList == null || authList.isEmpty()) ? null : authList.get(0);
        return missionControlFacade.validateGitHubTokenExists(authHeader);
    });
    if (validationMessage != null && !MissionControl.VALIDATION_MESSAGE_OK.equals(validationMessage)) {
        context.addValidationError(context.getCurrentInputComponent(), validationMessage);
        return false;
    }
    return true;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:14,代码来源:MissionControlValidator.java

示例8: validateOpenShiftTokenExists

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
public boolean validateOpenShiftTokenExists(UIValidationContext context, String cluster) {
    Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
    String validationMessage = (String) attributeMap.computeIfAbsent("token_openshift_exists", key -> {
        List<String> authList = (List<String>) attributeMap.get(HttpHeaders.AUTHORIZATION);
        String authHeader = (authList == null || authList.isEmpty()) ? null : authList.get(0);
        return missionControlFacade.validateOpenShiftTokenExists(authHeader, cluster);
    });
    if (validationMessage != null && !MissionControl.VALIDATION_MESSAGE_OK.equals(validationMessage)) {
        context.addValidationError(context.getCurrentInputComponent(), validationMessage);
        return false;
    }
    return true;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:14,代码来源:MissionControlValidator.java

示例9: validateGitHubRepositoryExists

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
public void validateGitHubRepositoryExists(UIValidationContext context, String repository) {
    Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
    String validationMessage = (String) attributeMap.computeIfAbsent("validate_repo_" + repository, key -> {
        List<String> authList = (List<String>) attributeMap.get(HttpHeaders.AUTHORIZATION);
        String authHeader = (authList == null || authList.isEmpty()) ? null : authList.get(0);
        return missionControlFacade.validateGitHubRepositoryExists(authHeader, repository);
    });
    if (validationMessage != null && !MissionControl.VALIDATION_MESSAGE_OK.equals(validationMessage)) {
        context.addValidationError(context.getCurrentInputComponent(), validationMessage);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:12,代码来源:MissionControlValidator.java

示例10: validateOpenShiftProjectExists

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
public void validateOpenShiftProjectExists(UIValidationContext context, String project, String cluster) {
    Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
    String validationMessage = (String) attributeMap.computeIfAbsent("validate_project_" + project, key -> {
        List<String> authList = (List<String>) attributeMap.get(HttpHeaders.AUTHORIZATION);
        String authHeader = (authList == null || authList.isEmpty()) ? null : authList.get(0);
        return missionControlFacade.validateOpenShiftProjectExists(authHeader, project, cluster);
    });
    if (validationMessage != null && !MissionControl.VALIDATION_MESSAGE_OK.equals(validationMessage)) {
        context.addValidationWarning(context.getCurrentInputComponent(), validationMessage);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:12,代码来源:MissionControlValidator.java

示例11: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    if (github == null || !github.isDetailsValid()) {
        // invoked too early before the github account is setup - lets return silently
        return;
    }
    Iterable<GitRepositoryDTO> value = gitRepositoryPattern.getValue();
    if (!value.iterator().hasNext()) {
        context.addValidationError(gitRepositoryPattern, "You must select a repository to import");
    }
    // Check for repos with already existing bc
    Controller controller = new Controller(kubernetesClientHelper.getKubernetesClient());
    OpenShiftClient openShiftClient = controller.getOpenShiftClientOrNull();
    if (openShiftClient == null) {
        context.addValidationError(gitRepositoryPattern, "Could not create OpenShiftClient. Maybe the Kubernetes server version is older than 1.7?");
    }
    Iterator<GitRepositoryDTO> it = value.iterator();
    String userNameSpace = Tenants.findDefaultUserNamespace(namespaces);
    if (userNameSpace == null) {
        // Tenant not yet initialised properly!
        return;
    }
    while (it.hasNext()) {
        GitRepositoryDTO repo = it.next();
        if (repo != null && repo.getName() != null) {
            BuildConfig oldBC = openShiftClient.buildConfigs().inNamespace(userNameSpace).withName(repo.getName().toLowerCase()).get();
            if (oldBC != null && Strings.isNotBlank(KubernetesHelper.getName(oldBC))) {
                context.addValidationError(gitRepositoryPattern, "The repository " + repo.getName() + " has already a build config, please select another repo.");
                break;
            }
        }
    }


}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:36,代码来源:GitHubImportPickRepositoriesStep.java

示例12: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    if (github == null || !github.isDetailsValid()) {
        // invoked too early before the github account is setup - lets return silently
        return;
    }
    String orgName = getOrganisationName(gitOrganisation.getValue());

    if (Strings.isNullOrBlank(orgName)) {
        context.addValidationError(gitOrganisation, "Please select a github organization");
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:13,代码来源:GitHubImportPickOrganisationStep.java

示例13: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context) {
    if (github == null || !github.isDetailsValid()) {
        // invoked too early before the github account is setup - lets return silently
        return;
    }
    String orgName = getOrganisationName(gitOrganisation.getValue());
    String repoName = gitRepository.getValue();

    if (Strings.isNotBlank(orgName) && Strings.isNotBlank(repoName)) {
        github.validateRepositoryName(gitRepository, context, orgName, repoName);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:14,代码来源:GitHubRepoStep.java

示例14: validateFileDoesNotExist

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
/**
 * Validates that the given selected directory and fileName are valid and that the file doesn't already exist
 */
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
    String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
    if (files.contains(resourcePath)) {
        validator.addValidationError(fileName, "A file with that name already exists!");
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:10,代码来源:SpringBootConfigurationFileCompleter.java

示例15: validate

import org.jboss.forge.addon.ui.context.UIValidationContext; //导入依赖的package包/类
@Override
public void validate(UIValidationContext context)
{
   if (deploymentType.getValue() == DeploymentType.CD)
   {
      if (!openShiftCluster.getValueChoices().iterator().hasNext())
      {
         context.addValidationError(null, "No OpenShift token assigned");
      }
   }
}
 
开发者ID:fabric8-launcher,项目名称:launchpad-addon,代码行数:12,代码来源:ChooseDeploymentTypeStep.java


注:本文中的org.jboss.forge.addon.ui.context.UIValidationContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。