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


Java ValidationResult.fromErrorIf方法代码示例

本文整理汇总了Java中org.controlsfx.validation.ValidationResult.fromErrorIf方法的典型用法代码示例。如果您正苦于以下问题:Java ValidationResult.fromErrorIf方法的具体用法?Java ValidationResult.fromErrorIf怎么用?Java ValidationResult.fromErrorIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.controlsfx.validation.ValidationResult的用法示例。


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

示例1: recreateValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
/**
 * Recreates {@link #validationSupport}, so the old validationSupport which is bound to unwanted
 * fields can be garbage collected.
 */
private void recreateValidationSupport() {
	validationSupport = new ValidationSupport();
	CuteGraphicValidationDecoration cuteGVD = new CuteGraphicValidationDecoration(
			validationSupport);
	CompoundValidationDecoration validationDecor = new CompoundValidationDecoration(
			// These styles are located in /StreamSis/src/main/resources/css/validation.css
			new StyleClassValidationDecoration("cuteerror", "cutewarning"), cuteGVD);
	validationSupport.setValidationDecorator(validationDecor);
	Validator<String> nameTextFieldValidator = (c, newValue) -> {
		ValidationResult alreadyExistanceResult = ValidationResult.fromErrorIf(c,
				"The name is already taken. Please choose another one",
				validateNameAlreadyExistence(c, newValue));
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please choose a name for the element", !allowEmptyName && newValue.equals(""));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				alreadyExistanceResult);
		buttonStateManager.reportNewValueOfControl(originalName, newValue, c, finalResult);
		return finalResult;
	};
	validationSupport.registerValidator(nameTextField, nameTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:26,代码来源:CommonElementFieldsController.java

示例2: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> ssNameTextFieldValidator = (c, newValue) -> {
		boolean sisExist = ProjectManager.getProject().getSisSceneByName(newValue)!= null;
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please specify existing SisScene name", newValue.isEmpty());
		ValidationResult unexistingSisScene = ValidationResult.fromErrorIf(c,
				"SisScene with such name does not exist", !sisExist);
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				unexistingSisScene);
		buttonStateManager.reportNewValueOfControl(origSssAction.getSisSceneName(),
				newValue, c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(ssNameTextField, ssNameTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:18,代码来源:SwitchSisSceneActionController.java

示例3: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> soundFileTextFieldValidator = (c, newValue) -> {
		boolean extensionsValidationPassed = true;
		if (!newValue.isEmpty()) {
			extensionsValidationPassed = Util.checkFileExtension(newValue, allowedExtensions);
		}
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please select a path to sound file", newValue.isEmpty());
		ValidationResult badExtensionResult = ValidationResult.fromErrorIf(c,
				"The selected sound file has wrong extension", !extensionsValidationPassed);
		ValidationResult existingPathResult = ValidationResult.fromErrorIf(c,
				"Sound file is not found on this path",
				!Util.checkIfPathIsAbsoluteAndFileExists(newValue));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				existingPathResult, badExtensionResult);
		buttonStateManager.reportNewValueOfControl(origSoundAction.getSoundPath(),
				newValue, c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(soundFileTextField, soundFileTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:24,代码来源:SoundActionController.java

示例4: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<Toggle> operationValidator = (c, newValue) -> {
		String whyBad = null;
		if (newValue != null) {
			String nameOfOperator = ((ToggleButton) newValue).getText();
			BooleanOperator operator = BooleanOperator.valueOf(nameOfOperator);
			if (logicalChecker != null) {
				// Internally the result will depend on amount of children.
				whyBad = logicalChecker
						.whyOperatorCantBeAppliedToCurrentAmountOfCheckers(operator);
			}
		}
		ValidationResult wrongResult = ValidationResult.fromErrorIf(c,
				whyBad, whyBad != null);
		if (newValue != null) {
			ToggleButton origTB = mapWithButtons.get(origLogicalChecker.getOperator().name());
			buttonStateManager.reportNewValueOfControl(origTB, newValue, c, wrongResult);
		}
		return wrongResult;
	};
	this.validationSupport.registerValidator(segmentedButton, operationValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:25,代码来源:LogicalCheckerController.java

示例5: enableModifiersTextFieldValidation

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
private void enableModifiersTextFieldValidation() {
	if (validationSupport != null) {
		Validator<String> modifiersTextFieldValidator = (c, newValue) -> {
			KeyCodeCombination kcc = keyCombinationProperty.get();
			// Allow empty modifiers only if KeyCodeCombination is not set.
			ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
					"Need at least one modifier", kcc != null && newValue.isEmpty());
			ValidationResult finalResult = ValidationResult.fromResults(emptyResult);
			return finalResult;
		};
		validationSupport.registerValidator(modifiersTextField, modifiersTextFieldValidator);
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:14,代码来源:HotkeyRow.java

示例6: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> targetFieldValidator = (c, newValue) -> {
		boolean extensionsValidationPassed = true;
		if (!newValue.isEmpty()) {
			extensionsValidationPassed = Util.checkFileExtension(newValue, allowedExtensions);
		}
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please select a path to Target image file", newValue.isEmpty());
		ValidationResult badExtensionResult = ValidationResult.fromErrorIf(c,
				"The selected target Image file has wrong extension",
				!extensionsValidationPassed);
		ValidationResult invalidPathResult = ValidationResult.fromErrorIf(c,
				"The path seems slightly... invalid",
				!Util.checkIfAbsolutePathSeemsValid(newValue));
		ValidationResult validPathResult = ValidationResult.fromErrorIf(c,
				"Image file is not found on this path",
				!Util.checkIfPathIsAbsoluteAndFileExists(newValue));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				invalidPathResult, badExtensionResult, validPathResult);
		if (finalResult.getErrors().isEmpty()) {
			updateViewBasedOnTargetImagePath(newValue);
		} else {
			// If there are errors, let's not show image in ImageView.
			updateViewBasedOnTargetImagePath(null);
		}
		buttonStateManager.reportNewValueOfControl(origTiwa.getTargetImagePath(),
				newValue, c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(targetTextField, targetFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:34,代码来源:TargetImageWithActionsController.java

示例7: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	coordsController.setValidationSupport(validationSupport);
	simController.setValidationSupport(validationSupport);
	Validator<String> targetFieldValidator = (c, newValue) -> {
		boolean extensionsValidationPassed = true;
		if (!newValue.isEmpty()) {
			extensionsValidationPassed = Util.checkFileExtension(newValue, allowedExtensions);
		}
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please select a path to Target image file", newValue.isEmpty());
		ValidationResult badExtensionResult = ValidationResult.fromErrorIf(c,
				"The selected target Image file has wrong extension",
				!extensionsValidationPassed);
		ValidationResult invalidPathResult = ValidationResult.fromErrorIf(c,
				"The path seems slightly... invalid",
				!Util.checkIfAbsolutePathSeemsValid(newValue));
		ValidationResult validPathResult = ValidationResult.fromErrorIf(c,
				"Image file is not found on this path",
				!Util.checkIfPathIsAbsoluteAndFileExists(newValue));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				invalidPathResult, badExtensionResult, validPathResult);
		if (finalResult.getErrors().isEmpty()) {
			updateViewBasedOnTargetImagePath(newValue);
		} else {
			// If there are errors, let's not show image in ImageView.
			updateViewBasedOnTargetImagePath(null);
		}
		buttonStateManager.reportNewValueOfControl(origRegCounter.getTargetImagePath(),
				newValue, c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(targetTextField, targetFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:36,代码来源:RegionTargetCounterController.java

示例8: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> sceneNameTextFieldValidator = (c, newValue) -> {
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Specify existing scene name in Streaming Program", newValue.isEmpty());
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult);
		buttonStateManager.reportNewValueOfControl(origSspsAction.getSceneName(), newValue, c,
				finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(sceneNameTextField, sceneNameTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:14,代码来源:SwitchSPSceneActionController.java

示例9: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> variableNameTextFieldValidator = (c, newValue) -> {
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please specify Variable name", newValue.isEmpty());
		buttonStateManager.reportNewValueOfControl(origVsAction.getKey(), newValue, c,
				emptyResult);
		return emptyResult;
	};
	this.validationSupport.registerValidator(variableNameTextField,
			variableNameTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:14,代码来源:VariableSetterActionController.java

示例10: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> destinationFieldValidator = (c, newValue) -> {
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please select a path to file", newValue.isEmpty());
		ValidationResult invalidPathResult = ValidationResult.fromErrorIf(c,
				"The path seems slightly... invalid",
				!Util.checkIfAbsolutePathSeemsValid(newValue));
		ValidationResult noExtensionResult = ValidationResult.fromErrorIf(c,
				"The file should have an extension",
				!newValue.isEmpty() && Util.extractFileExtensionFromPath(newValue) == null);
		ValidationResult notAbsolutePathResult = ValidationResult.fromErrorIf(c,
				"The path should be absolute. No exceptions.",
				!(new File(newValue).isAbsolute()));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				noExtensionResult, invalidPathResult, notAbsolutePathResult);
		if (finalResult.getMessages().size() == 0) {
			filePickerHBox.setDisable(false);
		} else {
			filePickerHBox.setDisable(true);
		}
		buttonStateManager.reportNewValueOfControl(origMFCAction.getDstFilePath(), newValue, c,
				finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(destinationTextField, destinationFieldValidator);
	MSFCPontroller.setValidationSupport(validationSupport);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:30,代码来源:MultiFileCopyActionController.java

示例11: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> keyTextFieldValidator = (c, newValue) -> {
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please choose a keyboard key", newValue.isEmpty());
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult);
		KeyCodeCombination OrigKK = parseKeyCodeCombinationFromString(origHkAction.getHotkey());
		buttonStateManager.reportNewValueOfControl(keyTextFromKeyCombination(OrigKK), newValue,
				c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(keyTextField, keyTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:15,代码来源:HotkeyActionController.java

示例12: setValidationForFileTable

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
private void setValidationForFileTable() {
	if (buttonStateManager != null) {
		if (validationSupport != null) {
			if (validationSupport.getRegisteredControls().contains(srcPathTextField)) {
				disableValidationForSrcPathTextField();
			}
			Validator<ObservableList<File>> fileTableValidator = (c, newValue) -> {
				if (newValue.size() == 0) {
					clearAllButton.setDisable(true);
				} else {
					clearAllButton.setDisable(false);
				}
				ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
						"No files selected", newValue.size() == 0);
				buttonStateManager.reportNewValueOfControl(
						origLister.getPersistentSourceFileList(), newValue, c, emptyResult);
				if (emptyResult.getErrors().size() != 0) {
					sampleFile.set(null);
				}
				return emptyResult;
			};
			validationSupport.registerValidator(fileTable, true, fileTableValidator);
			disableValidationForSrcPathTextField();
		}
	} else {
		throw new RuntimeException(
				"Check if CuteButtonsStatesManager is set to this controller.");
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:30,代码来源:MultiSourceFileListerController.java

示例13: generateValidatorForIntervalTextField

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
/**
 * Generate {@link Validator} for IntegerTextField containing time interval.
 *
 * @param originalInterval
 *            The original value of IntegerTextField.
 * @param checkOrRepeat
 *            Make validator for check interval or repeat interval. True for check interval.
 * @return the Validator.
 */
private Validator<String> generateValidatorForIntervalTextField(int originalInterval,
		boolean checkOrRepeat) {
	Validator<String> intervalFieldValidator = (c, newValue) -> {
		String tooSmallWarning = "Be careful when setting such small time interval, because it"
				+ " can cause high CPU usage depending on Actor's ";
		if (checkOrRepeat) {
			tooSmallWarning += "Checker.";
		} else {
			tooSmallWarning += "On Actions and Off Actions.";
		}
		IntegerTextField tf = (IntegerTextField) c;
		int number = tf.numberProperty().get();
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"This field can't be empty.", newValue.isEmpty());
		ValidationResult justMinusResult = ValidationResult.fromErrorIf(c,
				"Oh, come on, you can't input just minus!", newValue.equals("-"));
		ValidationResult tooSmallResult = ValidationResult.fromErrorIf(c,
				"The number can't be smaller than " + ConstsAndVars.minimumCheckInterval + ".",
				checkIfIntervalBigEnough(number));
		ValidationResult aBitSmallResult = ValidationResult.fromWarningIf(c, tooSmallWarning,
				ConstsAndVars.minimumCheckInterval <= number && number < 1000);
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				tooSmallResult, justMinusResult, aBitSmallResult);
		buttonStateManager.reportNewValueOfControl(originalInterval, number, c, finalResult);
		return finalResult;
	};
	return intervalFieldValidator;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:38,代码来源:UniversalActorController.java

示例14: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	Validator<String> variableNameTextFieldValidator = (c, newValue) -> {
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please specify Variable name", newValue.isEmpty());
		buttonStateManager.reportNewValueOfControl(origVarChecker.getKey(), newValue, c,
				emptyResult);
		return emptyResult;
	};
	this.validationSupport.registerValidator(variableNameTextField,
			variableNameTextFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:14,代码来源:VariableCheckerController.java

示例15: setValidationSupport

import org.controlsfx.validation.ValidationResult; //导入方法依赖的package包/类
@Override
public void setValidationSupport(ValidationSupport validationSupport) {
	this.validationSupport = validationSupport;
	coordsController.setValidationSupport(validationSupport);
	simController.setValidationSupport(validationSupport);
	Validator<String> targetFieldValidator = (c, newValue) -> {
		boolean extensionsValidationPassed = true;
		if (!newValue.isEmpty()) {
			extensionsValidationPassed = Util.checkFileExtension(newValue, allowedExtensions);
		}
		ValidationResult emptyResult = ValidationResult.fromErrorIf(c,
				"Please select a path to Target image file", newValue.isEmpty());
		ValidationResult badExtensionResult = ValidationResult.fromErrorIf(c,
				"The selected target Image file has wrong extension",
				!extensionsValidationPassed);
		ValidationResult invalidPathResult = ValidationResult.fromErrorIf(c,
				"The path seems slightly... invalid",
				!Util.checkIfAbsolutePathSeemsValid(newValue));
		ValidationResult validPathResult = ValidationResult.fromErrorIf(c,
				"Image file is not found on this path",
				!Util.checkIfPathIsAbsoluteAndFileExists(newValue));
		ValidationResult finalResult = ValidationResult.fromResults(emptyResult,
				invalidPathResult, badExtensionResult, validPathResult);
		if (finalResult.getErrors().isEmpty()) {
			updateViewBasedOnTargetImagePath(newValue);
		} else {
			// If there are errors, let's not show image in ImageView.
			updateViewBasedOnTargetImagePath(null);
		}
		buttonStateManager.reportNewValueOfControl(origRegChecker.getTargetImagePath(),
				newValue, c, finalResult);
		return finalResult;
	};
	this.validationSupport.registerValidator(targetTextField, targetFieldValidator);
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:36,代码来源:RegionCheckerController.java


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