本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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());
}
}
示例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;
}
});
}
}
示例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");
}
}
}
示例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() + "'");
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
}
}
示例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");
}
}
示例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);
}
}
示例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!");
}
}
示例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");
}
}
}