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