本文整理汇总了Java中org.controlsfx.validation.Severity类的典型用法代码示例。如果您正苦于以下问题:Java Severity类的具体用法?Java Severity怎么用?Java Severity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Severity类属于org.controlsfx.validation包,在下文中一共展示了Severity类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDecorationNode
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
private Node createDecorationNode(ValidationMessage message) {
Node icon = Severity.ERROR == message.getSeverity() ? createErrorNode()
: createWarningNode();
Label label = new Label();
label.setGraphic(icon);
Tooltip tp = createTooltip(message);
label.setTooltip(tp);
label.setAlignment(Pos.CENTER);
// Play animation only when validation message text differs from previous message text of
// this control.
ValidationMessage lastControlValidationMessage = lastMessageMap.get(message.getTarget());
if (lastControlValidationMessage == null
|| !lastControlValidationMessage.getText().equals(message.getText())) {
animation.setNode(label);
animation.playFromStart();
}
// Remember the last validation message of control.
lastMessageMap.put(message.getTarget(), message);
return label;
}
示例2: registerValidators
import org.controlsfx.validation.Severity; //导入依赖的package包/类
private void registerValidators() {
vd.registerValidator(emne, Validator.createEmptyValidator("Tittel mangler", Severity.WARNING));
vd.registerValidator(datePicker, Validator.createEmptyValidator("Dato mangler", Severity.WARNING));
vd.registerValidator(capacityField, Validator.createRegexValidator("Kapasiteten må være et tall", "[0-9]*",
Severity.ERROR));
vd.registerValidator(toTimeField,
Validator.combine(
Validator.createEmptyValidator("Sluttidspunkt mangler", Severity.WARNING),
Validator.createRegexValidator("Tid må være på formen hh:mm",
"^$|([0-1]?[0-9]|2[0-3]):[0-5][0-9]", Severity.ERROR),
Validator.createPredicateValidator(o -> isTimeValid(),
"Sluttidspunkt må være etter starttidspunkt", Severity.ERROR)));
vd.registerValidator(fromTimeField,
Validator.combine(
Validator.createEmptyValidator("Starttidspunkt mangler", Severity.WARNING),
Validator.createRegexValidator("Tid må være på formen hh:mm",
"^$|([0-1]?[0-9]|2[0-3]):[0-5][0-9]", Severity.ERROR)));
vd.setValidationDecorator(new ValidationDecoration());
}
示例3: createBooleanFormatValidator
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* Factory method to create a {@link Validator} which checks whether the
* string representation of a value represents a valid boolean.
*
* @param <T>
* the type of the {@link Validator}.
*
* @param message
* text of a message to be created if value is invalid
* @param severity
* severity of a message to be created if value is invalid
* @return new {@link Validator}
*/
public static <T> Validator<T> createBooleanFormatValidator(
final String message, final Severity severity) {
return (control, value) -> {
boolean invalidValue = value == null;
if (!invalidValue) {
invalidValue = !"true".equalsIgnoreCase(value.toString())
&& !"false".equalsIgnoreCase(value.toString());
}
return ValidationResult.fromMessageIf(control, message, severity,
invalidValue);
};
}
示例4: createURIFormatValidator
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* Factory method to create a {@link Validator} which checks if the string
* representation of a value represents a valid URI.
*
* @param <T>
* the type of the {@link Validator}.
*
* @param message
* text of a message to be created if value is invalid.
* @param severity
* severity of a message to be created if value is invalid.
* @return new {@link Validator}.
*/
public static <T> Validator<T> createURIFormatValidator(
final String message, final Severity severity) {
return (control, value) -> {
boolean condition = value == null;
if (!condition) {
try {
URI.create(value.toString());
}
catch (Exception e) {
condition = true;
}
}
return ValidationResult.fromMessageIf(control, message, severity,
condition);
};
}
示例5: AllwaysWrongValidator
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* Custom validator to ensure primers and barcodes contain either only ACGTs OR
* that the field is empty
*/
public static Validator<String> AllwaysWrongValidator(String message){
Validator<String> validator = new Validator<String>() {
@Override
public ValidationResult apply(Control control, String value) {
boolean condition = true;
return ValidationResult.fromMessageIf(control, message, Severity.ERROR, condition );
}
};
return validator;
}
示例6: createTooltip
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected Tooltip createTooltip(ValidationMessage message) {
Tooltip tp = new Tooltip(message.getText());
tp.setAutoFix(true);
tp.setAutoHide(true);
tp.setConsumeAutoHidingEvents(false);
tp.setStyle(Severity.ERROR == message.getSeverity() ? ERROR_TP_STYLE : WARNING_TP_STYLE);
return tp;
}
示例7: createDecorationNode
import org.controlsfx.validation.Severity; //导入依赖的package包/类
public Node createDecorationNode(ValidationMessage message) {
Node graphic = Severity.ERROR == message.getSeverity() ? createErrorNode() : createWarningNode();
graphic.getStyleClass().add(Severity.ERROR == message.getSeverity() ? "error-icon" : "warning-icon");
Label label = new Label();
label.setGraphic(graphic);
label.setTooltip(createTooltip(message));
label.setAlignment(Pos.CENTER);
return label;
}
示例8: apply
import org.controlsfx.validation.Severity; //导入依赖的package包/类
@Override
public ValidationResult apply(Control control, String value) {
boolean condition = value != null ? !value.matches("[ACGT]+") : value == null;
return ValidationResult.fromMessageIf(control, "Invalid Alphabet", Severity.ERROR, condition);
}
示例9: showOptions
import org.controlsfx.validation.Severity; //导入依赖的package包/类
@FXML
private void showOptions() {
Dialog<Path> optionsDialog = new Dialog<>();
optionsDialog.setTitle("Options");
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(15);
grid.setPadding(new Insets(0, 10, 10, 10));
TextField gameFolderTextField = new TextField();
gameFolderTextField.setPrefWidth(350);
HBox gameFolderHBox = new HBox();
gameFolderHBox.setAlignment(Pos.BASELINE_CENTER);
gameFolderHBox.setSpacing(5);
gameFolderHBox.getChildren().add(new Label("Game folder (tiled):"));
gameFolderHBox.getChildren().add(gameFolderTextField);
ValidationSupport validationSupport = new ValidationSupport();
validationSupport.registerValidator(gameFolderTextField, false,
Validator.createPredicateValidator(o -> isValidGameFolder(Paths.get(gameFolderTextField.getText())), "Is not a Cataclysm directory", Severity.ERROR));
Path gameFolder = ApplicationSettings.getInstance().getPath(GAME_FOLDER);
if (gameFolder != null) {
gameFolderTextField.setText(gameFolder.toAbsolutePath().toString());
}
Button chooseDirButton = new Button("...");
chooseDirButton.setOnAction(event -> {
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle("Please choose Cataclysm: DDA root directory (Tiled version)");
File file = new File(gameFolderTextField.getText());
if(file.isDirectory()) {
directoryChooser.setInitialDirectory(file);
} else {
directoryChooser.setInitialDirectory(Paths.get("").toAbsolutePath().toFile());
}
File chosenFile = directoryChooser.showDialog(optionsDialog.getOwner());
if (chosenFile != null) {
gameFolderTextField.setText(chosenFile.getAbsolutePath());
}
});
gameFolderHBox.getChildren().add(chooseDirButton);
grid.add(gameFolderHBox, 1, 1);
optionsDialog.getDialogPane().setContent(grid);
ButtonType saveButtonType = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
optionsDialog.getDialogPane().getButtonTypes().addAll(saveButtonType, ButtonType.CANCEL);
Button saveButton = (Button) optionsDialog.getDialogPane().lookupButton(saveButtonType);
validationSupport.invalidProperty().addListener((observable, oldValue, newValue) -> {
saveButton.setDisable(newValue);
});
optionsDialog.setResultConverter(dialogButton -> {
if (dialogButton == saveButtonType) {
return Paths.get(gameFolderTextField.getText());
}
return null;
});
Optional<Path> result = optionsDialog.showAndWait();
result.ifPresent(gameFolderPath -> ApplicationSettings.getInstance().setPath(GAME_FOLDER, gameFolderPath));
}
示例10: createNumberFormatValidator
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* Factory method to create a {@link Validator}, which checks whether the
* string representation of a value represents a valid instance of the
* provided number type.
*
* @param <T>
* the type of the {@link Validator}.
*
* @param type
* the number type to check for.
* @param message
* text of a message to be created if value is invalid
* @param severity
* severity of a message to be created if value is invalid
* @return new {@link Validator}
*/
public static <T> Validator<T> createNumberFormatValidator(
final Class<? extends Number> type, final String message,
final Severity severity) {
return (control, value) -> {
boolean condition = value == null;
if (!condition) {
try {
if (type == Byte.class) {
Byte.parseByte(value.toString());
}
else if (type == Double.class) {
Double.parseDouble(value.toString());
}
else if (type == Float.class) {
Float.parseFloat(value.toString());
}
else if (type == Integer.class) {
Integer.parseInt(value.toString());
}
else if (type == Long.class) {
Long.parseLong(value.toString());
}
else if (type == Short.class) {
Short.parseShort(value.toString());
}
}
catch (NumberFormatException e) {
condition = true;
}
}
return ValidationResult.fromMessageIf(control, message, severity,
condition);
};
}
示例11: createTooltip
import org.controlsfx.validation.Severity; //导入依赖的package包/类
protected Tooltip createTooltip(ValidationMessage message) {
Tooltip tooltip = new Tooltip(message.getText());
tooltip.getStyleClass().add(Severity.ERROR == message.getSeverity() ? "tooltip-error" : "tooltip-warning");
return tooltip;
}
示例12: createNumberRangeValidator
import org.controlsfx.validation.Severity; //导入依赖的package包/类
/**
* Factory method to create a {@link Validator} which checks whether the
* string representation of a value represents a valid instance of the
* provided number type.
* <p>
* Note: if the value does not evaluate to a valid number type, the
* {@link Validator} evaluates to {@code false}.
* </p>
*
* @param <T>
* the type of the {@link Validator}.
* @param <S>
* the type of the number range.
*
* @param min
* the lower boundary of the range.
* @param max
* the upper boundary of the range.
* @param includeMin
* whether to include the lower boundary of the range (i.e.,
* smaller or equal).
* @param includeMax
* whether to include the upper boundary of the range (i.e.,
* greater or equal).
* @param message
* text of a message to be created if value is invalid
* @return new {@link Validator}.
*/
public static <T, S extends Number> Validator<T> createNumberRangeValidator(
final S min, final S max, boolean includeMin, boolean includeMax,
final String message) {
return ValidationUtils.createNumberRangeValidator(min, max, includeMin,
includeMax, message, Severity.ERROR);
}