Search in sources :

Example 16 with ListView

use of org.apache.wicket.markup.html.list.ListView 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 AbstractReadOnlyModel<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 AbstractReadOnlyModel<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<List<WizardIssuesDto.Issue>>(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 : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) 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) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 17 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class ActionsExecutedInformationPanel method initLayout.

protected void initLayout() {
    WebMarkupContainer tableLinesContainer = new WebMarkupContainer(ID_OBJECTS_TABLE_LINES_CONTAINER);
    ListView tableLines = new ListView<ActionsExecutedObjectsTableLineDto>(ID_OBJECTS_TABLE_LINES, new AbstractReadOnlyModel<List<ActionsExecutedObjectsTableLineDto>>() {

        @Override
        public List<ActionsExecutedObjectsTableLineDto> getObject() {
            final ActionsExecutedInformationDto modelObject = getModelObject();
            if (modelObject == null) {
                return new ArrayList<>();
            }
            if (showResultingActionsOnly) {
                return modelObject.getUniqueObjectsTableLines();
            } else {
                return modelObject.getObjectsTableLines();
            }
        }
    }) {

        protected void populateItem(final ListItem<ActionsExecutedObjectsTableLineDto> item) {
            item.add(new Label(ID_OBJECT_TYPE, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    String key = item.getModelObject().getObjectTypeLocalizationKey();
                    if (key != null) {
                        return createStringResource(key).getString();
                    } else {
                        return item.getModelObject().getObjectType().getLocalPart();
                    }
                }
            }));
            item.add(new Label(ID_OPERATION, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return createStringResource(item.getModelObject().getOperation()).getString();
                }
            }));
            item.add(new Label(ID_CHANNEL, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    String channel = item.getModelObject().getChannel();
                    if (channel != null && !channel.isEmpty()) {
                        String key = "Channel." + channel;
                        return createStringResource(key).getString();
                    } else {
                        return "";
                    }
                }
            }));
            item.add(new Label(ID_SUCCESS_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_SUCCESS_COUNT)));
            item.add(new Label(ID_LAST_SUCCESS_OBJECT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_OBJECT)));
            item.add(new Label(ID_LAST_SUCCESS_TIMESTAMP, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_TIMESTAMP)));
            item.add(new Label(ID_FAILURE_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_FAILURE_COUNT)));
        }
    };
    tableLinesContainer.add(tableLines);
    tableLinesContainer.setOutputMarkupId(true);
    add(tableLinesContainer);
    final Label showResultingActionsOnlyLabel = new Label(ID_SHOW_RESULTING_ACTIONS_ONLY_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return showResultingActionsOnly ? createStringResource("ActionsExecutedInformationPanel.showingResultingActionsOnly").getString() : createStringResource("ActionsExecutedInformationPanel.showingAllActions").getString();
        }
    });
    showResultingActionsOnlyLabel.setOutputMarkupId(true);
    add(showResultingActionsOnlyLabel);
    add(new AjaxFallbackLink<String>(ID_SHOW_RESULTING_ACTIONS_ONLY_LINK) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            showResultingActionsOnly = !showResultingActionsOnly;
            ajaxRequestTarget.add(ActionsExecutedInformationPanel.this);
        }
    });
    add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }
    });
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ActionsExecutedInformationDto(com.evolveum.midpoint.web.page.admin.server.dto.ActionsExecutedInformationDto) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 18 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class TaskBasicTabPanel method initLayoutBasic.

private void initLayoutBasic() {
    // Name
    WebMarkupContainer nameContainer = new WebMarkupContainer(ID_NAME_CONTAINER);
    RequiredTextField<String> name = new RequiredTextField<>(ID_NAME, new PropertyModel<String>(taskDtoModel, TaskDto.F_NAME));
    name.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_NAME)));
    name.add(new AttributeModifier("style", "width: 100%"));
    name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    nameContainer.add(name);
    nameContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_NAME)));
    add(nameContainer);
    // Description
    WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(taskDtoModel, TaskDto.F_DESCRIPTION));
    description.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_DESCRIPTION)));
    //        description.add(new AttributeModifier("style", "width: 100%"));
    //        description.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    descriptionContainer.add(description);
    descriptionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_DESCRIPTION)));
    add(descriptionContainer);
    // OID
    Label oid = new Label(ID_OID, new PropertyModel(getObjectWrapperModel(), ID_OID));
    add(oid);
    // Identifier
    WebMarkupContainer identifierContainer = new WebMarkupContainer(ID_IDENTIFIER_CONTAINER);
    identifierContainer.add(new Label(ID_IDENTIFIER, new PropertyModel(taskDtoModel, TaskDto.F_IDENTIFIER)));
    identifierContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_TASK_IDENTIFIER)));
    add(identifierContainer);
    // Category
    WebMarkupContainer categoryContainer = new WebMarkupContainer(ID_CATEGORY_CONTAINER);
    categoryContainer.add(new Label(ID_CATEGORY, WebComponentUtil.createCategoryNameModel(this, new PropertyModel(taskDtoModel, TaskDto.F_CATEGORY))));
    categoryContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_CATEGORY)));
    add(categoryContainer);
    // Parent
    WebMarkupContainer parentContainer = new WebMarkupContainer(ID_PARENT_CONTAINER);
    final LinkPanel parent = new LinkPanel(ID_PARENT, new PropertyModel<String>(taskDtoModel, TaskDto.F_PARENT_TASK_NAME)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            String oid = taskDtoModel.getObject().getParentTaskOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageTaskEdit.class, parameters);
            }
        }
    };
    parentContainer.add(parent);
    parentContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_PARENT)));
    add(parentContainer);
    // Owner
    WebMarkupContainer ownerContainer = new WebMarkupContainer(ID_OWNER_CONTAINER);
    final LinkPanel owner = new LinkPanel(ID_OWNER, new PropertyModel<String>(taskDtoModel, TaskDto.F_OWNER_NAME)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            String oid = taskDtoModel.getObject().getOwnerOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageUser.class, parameters);
            }
        }
    };
    ownerContainer.add(owner);
    ownerContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_OWNER_REF)));
    add(ownerContainer);
    // Handler URI
    ListView<String> handlerUriContainer = new ListView<String>(ID_HANDLER_URI_CONTAINER, new PropertyModel(taskDtoModel, TaskDto.F_HANDLER_URI_LIST)) {

        @Override
        protected void populateItem(ListItem<String> item) {
            item.add(new Label(ID_HANDLER_URI, item.getModelObject()));
        }
    };
    handlerUriContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_HANDLER_URI), new ItemPath(TaskType.F_OTHER_HANDLERS_URI_STACK)));
    add(handlerUriContainer);
    // Execution
    WebMarkupContainer executionContainer = new WebMarkupContainer(ID_EXECUTION_CONTAINER);
    Label execution = new Label(ID_EXECUTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDtoExecutionStatus executionStatus = taskDtoModel.getObject().getExecution();
            if (executionStatus != TaskDtoExecutionStatus.CLOSED) {
                return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name());
            } else {
                return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name() + ".withTimestamp", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (taskDtoModel.getObject().getCompletionTimestamp() != null) {
                            // todo correct formatting
                            return new Date(taskDtoModel.getObject().getCompletionTimestamp()).toLocaleString();
                        } else {
                            return "?";
                        }
                    }
                });
            }
        }
    });
    executionContainer.add(execution);
    Label node = new Label(ID_NODE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (!TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
                return null;
            }
            return parentPage.getString("pageTaskEdit.message.node", dto.getExecutingAt());
        }
    });
    executionContainer.add(node);
    executionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_EXECUTION_STATUS), new ItemPath(TaskType.F_NODE_AS_OBSERVED)));
    add(executionContainer);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TextArea(org.apache.wicket.markup.html.form.TextArea) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) TaskDtoExecutionStatus(com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AttributeModifier(org.apache.wicket.AttributeModifier) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Date(java.util.Date) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ListItem(org.apache.wicket.markup.html.list.ListItem) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 19 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class AssignmentEditorPanel method initAttributesLayout.

private void initAttributesLayout(WebMarkupContainer constructionContainer) {
    WebMarkupContainer attributes = new WebMarkupContainer(ID_ATTRIBUTES);
    attributes.setOutputMarkupId(true);
    attributes.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    attributes.setEnabled(getModel().getObject().isEditable());
    constructionContainer.add(attributes);
    ListView<ACAttributeDto> attribute = new ListView<ACAttributeDto>(ID_ATTRIBUTE, attributesModel) {

        @Override
        protected void populateItem(ListItem<ACAttributeDto> listItem) {
            final IModel<ACAttributeDto> attrModel = listItem.getModel();
            ACAttributePanel acAttribute = new ACAttributePanel(ID_AC_ATTRIBUTE, attrModel, ignoreMandatoryAttributes());
            acAttribute.setRenderBodyOnly(true);
            listItem.add(acAttribute);
            listItem.setOutputMarkupId(true);
            listItem.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
                    if (editorDto.isShowEmpty()) {
                        return true;
                    }
                    ACAttributeDto dto = attrModel.getObject();
                    return !dto.isEmpty();
                }
            });
        }
    };
    attributes.add(attribute);
// todo extension
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 20 with ListView

use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.

the class PageAccounts method initLayout.

private void initLayout() {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);
    add(form);
    Form accForm = new Form(ID_FORM_ACCOUNT);
    accForm.setOutputMarkupId(true);
    add(accForm);
    Form searchForm = new Form(ID_SEARCH_FORM);
    initSearchForm(searchForm);
    searchForm.setOutputMarkupPlaceholderTag(true);
    searchForm.setOutputMarkupId(true);
    searchForm.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return resourceModel.getObject() != null;
        }
    });
    add(searchForm);
    DropDownChoice<ResourceItemDto> resources = new DropDownChoice<>(ID_RESOURCES, resourceModel, resourcesModel, new ChoiceableChoiceRenderer<ResourceItemDto>());
    form.add(resources);
    initLinks(form, accForm);
    initTotals(form);
    final AjaxDownloadBehaviorFromFile ajaxDownloadBehavior = new AjaxDownloadBehaviorFromFile(true) {

        @Override
        protected File initFile() {
            return downloadFile;
        }
    };
    ajaxDownloadBehavior.setRemoveFile(false);
    form.add(ajaxDownloadBehavior);
    WebMarkupContainer filesContainer = new WebMarkupContainer(ID_FILES_CONTAINER);
    filesContainer.setOutputMarkupId(true);
    accForm.add(filesContainer);
    ModalWindow resultPopup = createModalWindow(ID_RESULT_DIALOG, createStringResource("PageAccounts.result.popoup"), 1100, 560);
    resultPopup.setContent(new AceEditorDialog(resultPopup.getContentId()));
    add(resultPopup);
    filesModel = createFilesModel();
    ListView<String> files = new ListView<String>(ID_FILES, filesModel) {

        @Override
        protected void populateItem(final ListItem<String> item) {
            AjaxLink file = new AjaxLink(ID_FILE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    downloadPerformed(target, item.getModelObject(), ajaxDownloadBehavior);
                }
            };
            file.add(new Label(ID_FILE_NAME, item.getModelObject()));
            item.add(file);
        }
    };
    files.setRenderBodyOnly(true);
    filesContainer.add(files);
    WebMarkupContainer accountsContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);
    accountsContainer.setOutputMarkupId(true);
    accForm.add(accountsContainer);
    ObjectDataProvider provider = new ObjectDataProvider(this, ShadowType.class);
    provider.setOptions(SelectorOptions.createCollection(GetOperationOptions.createRaw()));
    provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
    TablePanel accounts = new TablePanel(ID_ACCOUNTS, provider, createAccountsColumns(), UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS, getItemsPerPage(UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS));
    accounts.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return resourceModel.getObject() != null;
        }
    });
    accounts.setItemsPerPage(50);
    accountsContainer.add(accounts);
}
Also used : Form(org.apache.wicket.markup.html.form.Form) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) Label(org.apache.wicket.markup.html.basic.Label) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) ListView(org.apache.wicket.markup.html.list.ListView) AceEditorDialog(com.evolveum.midpoint.web.page.admin.configuration.component.AceEditorDialog) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Aggregations

ListView (org.apache.wicket.markup.html.list.ListView)54 ListItem (org.apache.wicket.markup.html.list.ListItem)51 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)39 Label (org.apache.wicket.markup.html.basic.Label)39 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)33 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)27 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)25 List (java.util.List)21 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)17 PropertyModel (org.apache.wicket.model.PropertyModel)15 ArrayList (java.util.ArrayList)14 TextField (org.apache.wicket.markup.html.form.TextField)13 Form (org.apache.wicket.markup.html.form.Form)10 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)9 AttributeModifier (org.apache.wicket.AttributeModifier)8 Model (org.apache.wicket.model.Model)8 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7 IModel (org.apache.wicket.model.IModel)7 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5