• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Severity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:24,代码来源:CuteGraphicValidationDecoration.java


示例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());
}
 
开发者ID:Fellesprosjekt-27,项目名称:fellesprosjekt,代码行数:24,代码来源:CreateEventController.java


示例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);
    };
}
 
开发者ID:aftenkap,项目名称:jutility-javafx,代码行数:30,代码来源:ValidationUtils.java


示例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);
    };
}
 
开发者ID:aftenkap,项目名称:jutility-javafx,代码行数:37,代码来源:ValidationUtils.java


示例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;	
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:19,代码来源:ControlFXValidatorFactory.java


示例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;
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:13,代码来源:CuteGraphicValidationDecoration.java


示例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;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:10,代码来源:IconValidationDecorator.java


示例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);
}
 
开发者ID:drivenbyentropy,项目名称:aptasuite,代码行数:7,代码来源:ControlFXValidatorFactory.java


示例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));

}
 
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA-Map-Editor,代码行数:75,代码来源:EditorMain.java


示例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);
    };
}
 
开发者ID:aftenkap,项目名称:jutility-javafx,代码行数:63,代码来源:ValidationUtils.java


示例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;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:6,代码来源:IconValidationDecorator.java


示例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);
}
 
开发者ID:aftenkap,项目名称:jutility-javafx,代码行数:36,代码来源:ValidationUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DropRequest类代码示例发布时间:2022-05-22
下一篇:
Java BoolValue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap