Example usage for com.jgoodies.validation.util DefaultValidationResultModel DefaultValidationResultModel

List of usage examples for com.jgoodies.validation.util DefaultValidationResultModel DefaultValidationResultModel

Introduction

In this page you can find the example usage for com.jgoodies.validation.util DefaultValidationResultModel DefaultValidationResultModel.

Prototype

public DefaultValidationResultModel() 

Source Link

Document

Constructs a DefaultValidationResultModel initialized with an empty validation result.

Usage

From source file:de.dal33t.powerfolder.ui.dialog.AddressEditor.java

License:Open Source License

public AddressEditor(Controller controller, String string) {
    super(Senior.NONE, controller, true);
    result = EditorResult.CANCEL;//ww w .  j a v  a  2  s .  c om
    validationResultModel = new DefaultValidationResultModel();

    addressModel = new ValueHolder();
    // Trigger validation when the address model changes
    addressModel.addValueChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String addressText = (String) evt.getNewValue();
            ValidationResult aResult = new AddressRangeValidator(addressText).validate(null);
            validationResultModel.setResult(aResult);
        }
    });
    addressModel.setValue(string);

    ActionListener okAction = new OKAction();
    okButton = createOKButton(okAction);
    cancelButton = createCancelButton(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });

    // Create a textfield that is bound to the address model
    inputLine = BasicComponentFactory.createTextField(addressModel, false);
    inputLine.setColumns(40);
    inputLine.addActionListener(okAction);
}

From source file:salomon.engine.util.validation.ValidationModel.java

License:Open Source License

public ValidationModel(IValidator validator) {
    super(validator.getModel());
    _validator = validator;/*  w  w w  . ja va 2s  .  c o m*/
    _validationResultModel = new DefaultValidationResultModel();
    initEventHandling();
    updateValidationResult();
    _componentFactory = new ComponentFactory(this);
}

From source file:se.streamsource.streamflow.client.ui.workspace.cases.general.forms.FormSubmissionWizardPageView.java

License:Apache License

public FormSubmissionWizardPageView(@Structure Module module, @Uses PageSubmissionDTO page,
        @Uses FormDraftModel model) {//from w ww  . j a v a 2 s .co m
    super(page.title().get());
    this.module = module;
    this.model = module.objectBuilderFactory().newObjectBuilder(FormSubmissionWizardPageModel.class).use(model)
            .newInstance();
    componentFieldMap = new HashMap<String, AbstractFieldPanel>();
    validationResultModel = new DefaultValidationResultModel();
    setLayout(new BorderLayout());
    final JXPanel panel = new JXPanel(new FormLayout());
    panel.setScrollableHeightHint(ScrollableSizeHint.VERTICAL_STRETCH);

    fieldBinders = new HashMap<StateBinder, EntityReference>(page.fields().get().size());
    FormLayout formLayout = new FormLayout("250dlu, 70dlu:grow", "");
    DefaultFormBuilder formBuilder = new DefaultFormBuilder(formLayout, panel);
    BindingFormBuilder bb = new BindingFormBuilder(formBuilder, null);

    for (FieldSubmissionDTO DTO : page.fields().get()) {
        AbstractFieldPanel component;
        FieldValue fieldValue = DTO.field().get().fieldValue().get();
        if (fieldValue instanceof FieldGroupFieldValue) {
            bb.append(new JLabel("<html><b>" + DTO.field().get().description().get() + "</b>:</html>"));
        } else if (!(fieldValue instanceof CommentFieldValue)) {
            component = getComponent(DTO);
            componentFieldMap.put(DTO.field().get().field().get().identity(), component);
            StateBinder stateBinder = component.bindComponent(bb, DTO);
            stateBinder.addObserver(this);
            fieldBinders.put(stateBinder, DTO.field().get().field().get());

        } else {
            // comment field does not have any input component
            String comment = DTO.field().get().note().get();
            comment = comment.replaceAll("\n", "<br/>");

            JEditorPane commentPane = new JEditorPane("text/html", "<html>" + comment + "</html>");
            Font font = UIManager.getFont("Label.font");
            String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize()
                    + "pt; }";
            ((HTMLDocument) commentPane.getDocument()).getStyleSheet().addRule(bodyRule);

            commentPane.setOpaque(false);
            commentPane.setBorder(null);
            commentPane.setEditable(false);
            commentPane.setFocusable(true);
            commentPane.addHyperlinkListener(new HyperlinkListener() {
                public void hyperlinkUpdate(HyperlinkEvent e) {
                    if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                        // Open in browser
                        try {
                            Desktop.getDesktop().browse(e.getURL().toURI());
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        } catch (URISyntaxException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            });

            bb.append(commentPane);
        }
    }

    JComponent validationResultsComponent = ValidationResultViewFactory.createReportList(validationResultModel);
    formBuilder.appendRow("top:30dlu:g");

    CellConstraints cc = new CellConstraints();
    formBuilder.add(validationResultsComponent, cc.xywh(1, formBuilder.getRow() + 1, 1, 1, "fill, bottom"));

    final JScrollPane scroll = new JScrollPane(panel);
    add(scroll, BorderLayout.CENTER);

    createFocusListenerForComponents(panel, panel.getComponents());
}