Search in sources :

Example 1 with WizardIssuesDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto in project midpoint by Evolveum.

the class WizardIssuesPanel method initLayout.

private void initLayout() {
    WebMarkupContainer panel = new WebMarkupContainer(ID_PANEL);
    panel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().hasIssues();
        }
    });
    panel.add(AttributeAppender.append("class", new IModel<String>() {

        @Override
        public String getObject() {
            WizardIssuesDto issuesDto = WizardIssuesPanel.this.getModelObject();
            WizardIssuesDto.Severity severity = issuesDto.getSeverity();
            return severity != null ? "box-" + severity.getColorStyle() : null;
        }
    }));
    add(panel);
    Label title = new Label(ID_TITLE, new IModel<String>() {

        @Override
        public String getObject() {
            WizardIssuesDto issuesDto = WizardIssuesPanel.this.getModelObject();
            WizardIssuesDto.Severity severity = issuesDto.getSeverity();
            if (severity == null) {
                return "";
            } else if (severity == WizardIssuesDto.Severity.INFO) {
                return getString("Wizard.Notes");
            } else {
                return getString("Wizard.Issues");
            }
        }
    });
    panel.add(title);
    WebMarkupContainer table = new WebMarkupContainer(ID_TABLE);
    panel.add(table);
    ListView<WizardIssuesDto.Issue> issues = new ListView<WizardIssuesDto.Issue>(ID_ROW, new PropertyModel<>(getModel(), WizardIssuesDto.F_ISSUES)) {

        @Override
        protected void populateItem(ListItem<WizardIssuesDto.Issue> item) {
            WizardIssuesDto.Issue issue = item.getModelObject();
            Label severityLabel = new Label(ID_SEVERITY, "");
            severityLabel.add(AttributeAppender.replace("class", issue.getSeverityClass()));
            item.add(severityLabel);
            item.add(new Label(ID_TEXT, issue.getText()));
        }
    };
    table.add(issues);
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WizardIssuesDto(com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 2 with WizardIssuesDto

use of com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto in project midpoint by Evolveum.

the class ResourceWizardIssuesModel method load.

@NotNull
@Override
protected WizardIssuesDto load() {
    final WizardIssuesDto issuesDto = new WizardIssuesDto();
    if (!resourceModel.isLoaded()) {
        // e.g. in first two wizard steps (IT PROBABLY DOES NOT WORK AS EXPECTED)
        return issuesDto;
    }
    ResourceValidator validator = wizardPage.getResourceValidator();
    ValidationResult validationResult = validator.validate(resourceModel.getObject(), Scope.QUICK, WebComponentUtil.getCurrentLocale(), wizardPage.createSimpleTask("validate"), new OperationResult("validate"));
    issuesDto.fillFrom(validationResult);
    issuesDto.sortIssues();
    return issuesDto;
}
Also used : ResourceValidator(com.evolveum.midpoint.model.api.validator.ResourceValidator) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ValidationResult(com.evolveum.midpoint.model.api.validator.ValidationResult) WizardIssuesDto(com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

WizardIssuesDto (com.evolveum.midpoint.web.component.wizard.resource.dto.WizardIssuesDto)2 ResourceValidator (com.evolveum.midpoint.model.api.validator.ResourceValidator)1 ValidationResult (com.evolveum.midpoint.model.api.validator.ValidationResult)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 IModel (org.apache.wicket.model.IModel)1 NotNull (org.jetbrains.annotations.NotNull)1