Example usage for com.jgoodies.validation.view ValidationResultViewFactory createReportList

List of usage examples for com.jgoodies.validation.view ValidationResultViewFactory createReportList

Introduction

In this page you can find the example usage for com.jgoodies.validation.view ValidationResultViewFactory createReportList.

Prototype

public static JComponent createReportList(ValidationResultModel model) 

Source Link

Document

Creates and returns a list that presents validation messages.

Usage

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

License:Open Source License

@Override
protected JComponent getContent() {
    FormLayout layout = new FormLayout("pref", "pref, 3dlu, 40dlu");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();//w ww  .  ja v  a 2  s.c  om
    CellConstraints cc = new CellConstraints();

    builder.add(inputLine, cc.xy(1, 1));
    builder.add(ValidationResultViewFactory.createReportList(validationResultModel), cc.xy(1, 3));

    return builder.getPanel();
}

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) {// w w w .j a v  a  2 s .  c o  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());
}