Search in sources :

Example 1 with RequiredFieldValidator

use of com.jfoenix.validation.RequiredFieldValidator in project SmartCity-Market by TechnionYP5777.

the class ManageCatalogProductTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    barcodeEventHandler.register(this);
    barcodeTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*"))
            barcodeTextField.setText(newValue.replaceAll("[^\\d]", ""));
        enableRunOperation();
    });
    productNameTextField.textProperty().addListener((observable, oldValue, newValue) -> enableRunOperation());
    productDescriptionTextField.textProperty().addListener((observable, oldValue, newValue) -> enableRunOperation());
    createManufacturerMap();
    productManufacturerCombo.getItems().addAll(manufacturars.keySet());
    productManufacturerCombo.valueProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(@SuppressWarnings("rawtypes") ObservableValue __, String s, String t1) {
            enableRunOperation();
        }
    });
    productPriceTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("((\\d*)|(\\d+\\.\\d*))"))
            productPriceTextField.setText(oldValue);
        enableRunOperation();
    });
    createIngredientMap();
    ingridientsCombo.getItems().addAll(ingredients.keySet());
    // productLocationTextField.textProperty().addListener((observable,
    // oldValue, newValue) -> {
    // });
    radioButtonContainerManageCatalogProduct.addRadioButtons(Arrays.asList(new RadioButton[] { addCatalogProductRadioButton, removeCatalogProductRadioButton }));
    RequiredFieldValidator validator = new RequiredFieldValidator();
    validator.setMessage("Input Required");
    validator.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    barcodeTextField.getValidators().add(validator);
    barcodeTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            barcodeTextField.validate();
    });
    RequiredFieldValidator validator2 = new RequiredFieldValidator();
    validator2.setMessage("Input Required");
    validator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    productNameTextField.getValidators().add(validator2);
    productNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            productNameTextField.validate();
    });
    RequiredFieldValidator validator3 = new RequiredFieldValidator();
    validator3.setMessage("Input Required");
    validator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    productPriceTextField.getValidators().add(validator3);
    productPriceTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            productPriceTextField.validate();
    });
    enableRunOperation();
}
Also used : ObservableValue(javafx.beans.value.ObservableValue) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 2 with RequiredFieldValidator

use of com.jfoenix.validation.RequiredFieldValidator in project SmartCity-Market by TechnionYP5777.

the class ManageEmployeesTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    userTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    passTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    securityAnswerTxt.textProperty().addListener((observable, oldValue, newValue) -> enableFinishBtn());
    radioBtnCont.addRadioButtons(Arrays.asList(new RadioButton[] { workerRadioBtn, managerRadioBtn }));
    securityCombo.getItems().addAll(SecurityQuestions.getQuestions());
    RequiredFieldValidator validator2 = new RequiredFieldValidator();
    validator2.setMessage("Input Required");
    validator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    userTxt.getValidators().add(validator2);
    userTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            userTxt.validate();
    });
    RequiredFieldValidator validator3 = new RequiredFieldValidator();
    validator3.setMessage("Input Required");
    validator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    passTxt.getValidators().add(validator3);
    passTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            passTxt.validate();
    });
    RequiredFieldValidator validator4 = new RequiredFieldValidator();
    validator4.setMessage("Input Required");
    validator4.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    securityAnswerTxt.getValidators().add(validator4);
    securityAnswerTxt.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            securityAnswerTxt.validate();
    });
    createEmployeesList();
    searchEmployee.textProperty().addListener(obs -> {
        String filter = searchEmployee.getText();
        filteredDataEmployees.setPredicate(filter == null || filter.length() == 0 ? s -> true : s -> s.contains(filter));
    });
    employeesList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {

        @Override
        public ObservableValue<Boolean> call(String item) {
            BooleanProperty observable = new SimpleBooleanProperty();
            observable.set(selectedEmployees.contains(item));
            observable.addListener((obs, wasSelected, isNowSelected) -> {
                if (isNowSelected)
                    selectedEmployees.add(item);
                else
                    selectedEmployees.remove(item);
                enableRemoveButton();
            });
            return observable;
        }
    }));
    securityCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> __, String oldValue, String newValue) {
            enableFinishBtn();
        }
    });
    enableFinishBtn();
    enableRemoveButton();
}
Also used : JFXButton(com.jfoenix.controls.JFXButton) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) GlyphsBuilder(de.jensd.fx.glyphs.GlyphsBuilder) JFXPasswordField(com.jfoenix.controls.JFXPasswordField) URL(java.net.URL) CheckBoxListCell(javafx.scene.control.cell.CheckBoxListCell) FXCollections(javafx.collections.FXCollections) EmployeeNotConnected(EmployeeDefs.AEmployeeException.EmployeeNotConnected) HashSet(java.util.HashSet) Logger(org.apache.log4j.Logger) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) SecurityQuestions(GuiUtils.SecurityQuestions) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) ConnectionFailure(EmployeeDefs.AEmployeeException.ConnectionFailure) JFXComboBox(com.jfoenix.controls.JFXComboBox) Callback(javafx.util.Callback) CriticalError(SMExceptions.CommonExceptions.CriticalError) RadioButtonEnabler(GuiUtils.RadioButtonEnabler) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) Manager(EmployeeImplementations.Manager) WorkerAlreadyExists(EmployeeDefs.AEmployeeException.WorkerAlreadyExists) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) BooleanProperty(javafx.beans.property.BooleanProperty) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) WorkerDoesNotExist(EmployeeDefs.AEmployeeException.WorkerDoesNotExist) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIcon(de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon) IManager(EmployeeContracts.IManager) ObservableValue(javafx.beans.value.ObservableValue) Login(BasicCommonClasses.Login) ObservableList(javafx.collections.ObservableList) ChangeListener(javafx.beans.value.ChangeListener) JFXTextField(com.jfoenix.controls.JFXTextField) InvalidParameter(EmployeeDefs.AEmployeeException.InvalidParameter) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Callback(javafx.util.Callback) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) RadioButton(javafx.scene.control.RadioButton) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 3 with RequiredFieldValidator

use of com.jfoenix.validation.RequiredFieldValidator in project JFoenix by jfoenixadmin.

the class TextAreaDemo method start.

@Override
public void start(Stage stage) {
    VBox main = new VBox();
    main.setSpacing(50);
    TextArea javafxTextArea = new TextArea();
    javafxTextArea.setPromptText("JavaFX Text Area");
    main.getChildren().add(javafxTextArea);
    JFXTextArea jfxTextArea = new JFXTextArea();
    jfxTextArea.setPromptText("JFoenix Text Area :D");
    jfxTextArea.setLabelFloat(true);
    RequiredFieldValidator validator = new RequiredFieldValidator();
    // NOTE adding error class to text area is causing the cursor to disapper
    validator.setMessage("Please type something!");
    FontIcon warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE);
    warnIcon.getStyleClass().add("error");
    validator.setIcon(warnIcon);
    jfxTextArea.getValidators().add(validator);
    jfxTextArea.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            jfxTextArea.validate();
        }
    });
    main.getChildren().add(jfxTextArea);
    StackPane pane = new StackPane();
    pane.getChildren().add(main);
    StackPane.setMargin(main, new Insets(100));
    pane.setStyle("-fx-background-color:WHITE");
    final Scene scene = new Scene(pane, 800, 600);
    scene.getStylesheets().add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX Button Demo");
    stage.setScene(scene);
    stage.show();
}
Also used : JFXTextArea(com.jfoenix.controls.JFXTextArea) Insets(javafx.geometry.Insets) JFXTextArea(com.jfoenix.controls.JFXTextArea) TextArea(javafx.scene.control.TextArea) FontIcon(org.kordamp.ikonli.javafx.FontIcon) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator) StackPane(javafx.scene.layout.StackPane)

Example 4 with RequiredFieldValidator

use of com.jfoenix.validation.RequiredFieldValidator in project JFoenix by jfoenixadmin.

the class TextFieldDemo method start.

@Override
public void start(Stage stage) throws Exception {
    final VBox pane = new VBox();
    pane.setSpacing(30);
    pane.setStyle("-fx-background-color:WHITE;-fx-padding:40;");
    pane.getChildren().add(new TextField());
    JFXTextField field = new JFXTextField();
    field.setLabelFloat(true);
    field.setPromptText("Type Something");
    pane.getChildren().add(field);
    JFXTextField disabledField = new JFXTextField();
    disabledField.setStyle(FX_LABEL_FLOAT_TRUE);
    disabledField.setPromptText("I'm disabled..");
    disabledField.setDisable(true);
    pane.getChildren().add(disabledField);
    JFXTextField validationField = new JFXTextField();
    validationField.setPromptText("With Validation..");
    RequiredFieldValidator validator = new RequiredFieldValidator();
    validator.setMessage("Input Required");
    FontIcon warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE);
    warnIcon.getStyleClass().add(ERROR);
    validator.setIcon(warnIcon);
    validationField.getValidators().add(validator);
    validationField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            validationField.validate();
        }
    });
    pane.getChildren().add(validationField);
    JFXPasswordField passwordField = new JFXPasswordField();
    passwordField.setStyle(FX_LABEL_FLOAT_TRUE);
    passwordField.setPromptText("Password");
    validator = new RequiredFieldValidator();
    validator.setMessage("Password Can't be empty");
    warnIcon = new FontIcon(FontAwesomeSolid.EXCLAMATION_TRIANGLE);
    warnIcon.getStyleClass().add(ERROR);
    validator.setIcon(warnIcon);
    passwordField.getValidators().add(validator);
    passwordField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            passwordField.validate();
        }
    });
    pane.getChildren().add(passwordField);
    final Scene scene = new Scene(pane, 600, 400, Color.WHITE);
    scene.getStylesheets().add(TextFieldDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
    stage.setTitle("JFX TextField Demo ");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.show();
}
Also used : JFXTextField(com.jfoenix.controls.JFXTextField) FontIcon(org.kordamp.ikonli.javafx.FontIcon) JFXPasswordField(com.jfoenix.controls.JFXPasswordField) TextField(javafx.scene.control.TextField) JFXTextField(com.jfoenix.controls.JFXTextField) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Example 5 with RequiredFieldValidator

use of com.jfoenix.validation.RequiredFieldValidator in project SmartCity-Market by TechnionYP5777.

the class CustomerRegistration_PersonalInfoScreen method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    AbstractApplicationScreen.fadeTransition(personalInfoScreenPane);
    updateFields();
    customer = InjectionFactory.getInstance(Customer.class);
    userNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (validNewUserName(newValue))
            TempCustomerProfilePassingData.customerProfile.setUserName(newValue);
        else
            DialogMessagesService.showErrorDialog(GuiCommonDefs.registrationFieldFailureTitle, null, GuiCommonDefs.registrationUsedUserName);
    });
    userValidator1 = new RequiredFieldValidator();
    userValidator1.setMessage("Input Required");
    userValidator1.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    userValidator2 = new RequiredFieldValidator();
    userValidator2.setMessage("Username Already Exists");
    userValidator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    userNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal) {
            userNameTextField.getValidators().add(userValidator1);
            userNameTextField.validate();
        } else if (!validNewUserName(userNameTextField.getText())) {
            userNameTextField.getValidators().add(userValidator2);
            userNameTextField.validate();
        }
    });
    passwordField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.password = newValue;
        enableNextButton();
    });
    RequiredFieldValidator userValidator3 = new RequiredFieldValidator();
    userValidator3.setMessage("Input Required");
    userValidator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    passwordField.getValidators().add(userValidator3);
    passwordField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            passwordField.validate();
    });
    firstNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setFirstName(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val4 = new RequiredFieldValidator();
    val4.setMessage("Input Required");
    val4.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    firstNameTextField.getValidators().add(val4);
    firstNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            firstNameTextField.validate();
    });
    lastNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setLastName(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val5 = new RequiredFieldValidator();
    val5.setMessage("Input Required");
    val5.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    lastNameTextField.getValidators().add(val5);
    lastNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            lastNameTextField.validate();
    });
    phoneNumberTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*")) {
            phoneNumberTextField.setText(newValue.replaceAll("[^\\d]", ""));
            return;
        }
        TempCustomerProfilePassingData.customerProfile.setPhoneNumber(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val6 = new RequiredFieldValidator();
    val6.setMessage("Input Required");
    val6.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    phoneNumberTextField.getValidators().add(val6);
    phoneNumberTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            phoneNumberTextField.validate();
    });
    emailTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setEmailAddress(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val9 = new RequiredFieldValidator();
    val9.setMessage("Input Required");
    val9.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    emailTextField.getValidators().add(val9);
    emailTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            emailTextField.validate();
    });
    cityTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setCity(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val10 = new RequiredFieldValidator();
    val10.setMessage("Input Required");
    val10.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    cityTextField.getValidators().add(val10);
    cityTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            cityTextField.validate();
    });
    streetTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setStreet(newValue);
        enableNextButton();
    });
    RequiredFieldValidator val7 = new RequiredFieldValidator();
    val7.setMessage("Input Required");
    val7.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    streetTextField.getValidators().add(val7);
    streetTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            streetTextField.validate();
    });
    birthDatePicker.valueProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.customerProfile.setBirthdate(newValue);
        enableNextButton();
    });
    securityQuestionComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.sequrityQuestion = newValue;
        enableNextButton();
    });
    securityQuestionComboBox.setButtonCell(new ListCell<String>() {

        @Override
        protected void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (!empty && item != null)
                setText(item + "");
            else {
                setStyle(null);
                setText(null);
            }
        }
    });
    securityAnswerTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        TempCustomerProfilePassingData.sequrityAnswer = newValue;
        enableNextButton();
    });
    RequiredFieldValidator val8 = new RequiredFieldValidator();
    val8.setMessage("Input Required");
    val8.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
    securityAnswerTextField.getValidators().add(val8);
    securityAnswerTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
        if (!newVal)
            securityAnswerTextField.validate();
    });
    birthDatePicker.setValue(LocalDate.now());
    enableNextButton();
}
Also used : ICustomer(CustomerContracts.ICustomer) Customer(CustomerImplementations.Customer) FontAwesomeIconView(de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView) RequiredFieldValidator(com.jfoenix.validation.RequiredFieldValidator)

Aggregations

RequiredFieldValidator (com.jfoenix.validation.RequiredFieldValidator)5 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)3 JFXPasswordField (com.jfoenix.controls.JFXPasswordField)2 JFXRadioButton (com.jfoenix.controls.JFXRadioButton)2 JFXTextField (com.jfoenix.controls.JFXTextField)2 ObservableValue (javafx.beans.value.ObservableValue)2 Scene (javafx.scene.Scene)2 RadioButton (javafx.scene.control.RadioButton)2 VBox (javafx.scene.layout.VBox)2 FontIcon (org.kordamp.ikonli.javafx.FontIcon)2 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 Login (BasicCommonClasses.Login)1 ICustomer (CustomerContracts.ICustomer)1 Customer (CustomerImplementations.Customer)1 IManager (EmployeeContracts.IManager)1 ConnectionFailure (EmployeeDefs.AEmployeeException.ConnectionFailure)1 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)1 InvalidParameter (EmployeeDefs.AEmployeeException.InvalidParameter)1 WorkerAlreadyExists (EmployeeDefs.AEmployeeException.WorkerAlreadyExists)1 WorkerDoesNotExist (EmployeeDefs.AEmployeeException.WorkerDoesNotExist)1