Example usage for org.apache.wicket.markup.html.list ListView ListView

List of usage examples for org.apache.wicket.markup.html.list ListView ListView

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.list ListView ListView.

Prototype

public ListView(final String id, final List<T> list) 

Source Link

Usage

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java

License:Apache License

private void initAttributesLayout(WebMarkupContainer constructionContainer) {
    WebMarkupContainer attributes = new WebMarkupContainer(ID_ATTRIBUTES);
    attributes.setOutputMarkupId(true);//  w w  w. j  av  a2 s.  c o  m
    attributes.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION.equals(dto.getType());
        }
    });
    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);
            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
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel.java

License:Apache License

private void initPanelLayout(IModel<String> labelModel) {
    final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
    assignments.setOutputMarkupId(true);
    add(assignments);/*w w w  . j  a  va2 s. c o  m*/

    Label label = new Label(ID_HEADER, labelModel);
    assignments.add(label);

    InlineMenu assignmentMenu = new InlineMenu(ID_MENU, new Model((Serializable) createAssignmentMenu()));
    assignments.add(assignmentMenu);

    ListView<AssignmentEditorDto> list = new ListView<AssignmentEditorDto>(ID_LIST, assignmentModel) {

        @Override
        protected void populateItem(ListItem<AssignmentEditorDto> item) {
            AssignmentEditorPanel editor = new AssignmentEditorPanel(ID_ROW, item.getModel());
            item.add(editor);
        }
    };
    list.setOutputMarkupId(true);
    assignments.add(list);

    AjaxCheckBox checkAll = new AjaxCheckBox(ID_CHECK_ALL, new Model()) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            List<AssignmentEditorDto> assignmentEditors = assignmentModel.getObject();

            for (AssignmentEditorDto dto : assignmentEditors) {
                dto.setSelected(this.getModelObject());
            }

            target.add(assignments);
        }
    };
    assignments.add(checkAll);

    initModalWindows();
}

From source file:com.evolveum.midpoint.web.component.assignment.ConstructionAssociationPanel.java

License:Apache License

private void initLayout() {
    ListView<RefinedAssociationDefinition> associationsPanel = new ListView<RefinedAssociationDefinition>(
            ID_ASSOCIATIONS, refinedAssociationDefinitionsModel) {
        @Override//w  w w  .jav a 2 s.c  om
        protected void populateItem(ListItem<RefinedAssociationDefinition> item) {
            GenericMultiValueLabelEditPanel associationReferencesPanel = new GenericMultiValueLabelEditPanel<ObjectReferenceType>(
                    ID_ASSOCIATION_REFERENCE_PANEL, getShadowReferencesModel(item.getModelObject()),
                    Model.of(WebComponentUtil.getAssociationDisplayName(item.getModelObject())), ID_LABEL_SIZE,
                    ID_INPUT_SIZE, true) {
                private static final long serialVersionUID = 1L;

                @Override
                protected boolean isEditButtonEnabled() {
                    return false;
                }

                @Override
                protected void addValuePerformed(AjaxRequestTarget target) {
                    addNewShadowRefValuePerformed(target, item.getModelObject());
                }

                protected void addFirstPerformed(AjaxRequestTarget target) {
                    addNewShadowRefValuePerformed(target, item.getModelObject());
                }

                @Override
                protected IModel<String> createTextModel(final IModel<ObjectReferenceType> model) {
                    return new IModel<String>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public String getObject() {
                            ObjectReferenceType obj = model.getObject();
                            if (obj == null) {
                                return "";
                            }
                            return WebComponentUtil.getDisplayNameOrName(obj, getPageBase(),
                                    OPERATION_LOAD_SHADOW_DISPLAY_NAME);
                        }
                    };
                }

                @Override
                protected void removeValuePerformed(AjaxRequestTarget target,
                        ListItem<ObjectReferenceType> item) {
                    ObjectReferenceType removedShadowRef = item.getModelObject();
                    ContainerWrapper<ConstructionType> constructionContainerWrapper = ConstructionAssociationPanel.this
                            .getModelObject();
                    ContainerWrapper associationWrapper = constructionContainerWrapper.findContainerWrapper(
                            constructionContainerWrapper.getPath().append(ConstructionType.F_ASSOCIATION));
                    associationWrapper.getValues().forEach(associationValueWrapper -> {
                        if (ValueStatus.DELETED
                                .equals(((ContainerValueWrapper) associationValueWrapper).getStatus())) {
                            return;
                        }
                        PrismContainerValue associationValue = ((ContainerValueWrapper) associationValueWrapper)
                                .getContainerValue();
                        ResourceObjectAssociationType assoc = (ResourceObjectAssociationType) associationValue
                                .asContainerable();
                        if (assoc == null || assoc.getOutbound() == null
                                || assoc.getOutbound().getExpression() == null || ExpressionUtil
                                        .getShadowRefValue(assoc.getOutbound().getExpression()) == null) {
                            return;
                        }
                        List<ObjectReferenceType> shadowRefList = ExpressionUtil
                                .getShadowRefValue(assoc.getOutbound().getExpression());
                        shadowRefList.forEach(shadowRef -> {
                            if (shadowRef.equals(removedShadowRef)) {
                                ((ContainerValueWrapper) associationValueWrapper)
                                        .setStatus(ValueStatus.DELETED);
                            }
                        });
                    });
                    super.removeValuePerformed(target, item);
                }

            };
            associationReferencesPanel.setOutputMarkupId(true);
            item.add(associationReferencesPanel);
        }
    };

    associationsPanel.setOutputMarkupId(true);
    add(associationsPanel);
}

From source file:com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel.java

License:Apache License

private void addPrivilegesPanel(WebMarkupContainer body) {
    privilegesNames = getPrivilegesNamesList();
    ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames) {
        private static final long serialVersionUID = 1L;

        @Override// ww w  .  jav a2s. c  o  m
        protected void populateItem(ListItem<String> item) {
            Label privilageNameLabel = new Label(ID_PRIVILEGE, item.getModel());
            item.add(privilageNameLabel);
        }
    };
    privilegesListComponent.setOutputMarkupId(true);
    privilegesListComponent.add(new VisibleEnableBehaviour() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
                return true;
            }
            return false;
        }
    });
    body.addOrReplace(privilegesListComponent);
}

From source file:com.evolveum.midpoint.web.component.assignment.SimpleParametricRoleSelector.java

License:Apache License

private void initLayout() {

    IModel<String> labelParamModel = new IModel<String>() {
        @Override/*from w ww.  ja va 2 s .  c o m*/
        public void detach() {
        }

        @Override
        public String getObject() {
            return getLabelParam();
        }

        @Override
        public void setObject(String object) {
        }
    };
    add(new Label(ID_LABEL_PARAM, labelParamModel) {
        @Override
        protected void onConfigure() {
            setVisible(getLabelParam() != null);
            super.onConfigure();
        }
    });

    IModel<String> labelRoleModel = new IModel<String>() {
        @Override
        public void detach() {
        }

        @Override
        public String getObject() {
            return getLabelRole();
        }

        @Override
        public void setObject(String object) {
        }
    };
    add(new Label(ID_LABEL_ROLE, labelRoleModel) {
        @Override
        protected void onConfigure() {
            setVisible(getLabelRole() != null);
            super.onConfigure();
        }
    });

    paramList = new ListView<String>(ID_LIST_PARAM, paramListModel) {
        @Override
        protected void populateItem(ListItem<String> item) {
            item.add(createParamLink(ID_ITEM_PARAM, item.getModel()));
        }

    };
    paramList.setOutputMarkupId(true);
    add(paramList);

    final Model<String> addInputModel = new Model<String>();
    TextField<String> addInput = new TextField<>(ID_ADD_INPUT, addInputModel);
    addInput.setOutputMarkupId(true);
    addInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // nothing to do, Ajax behavior is there only to get data to model
        }
    });
    add(addInput);

    AjaxLink<String> addLink = new AjaxLink<String>(ID_ADD_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            String newParam = addInputModel.getObject();
            LOGGER.debug("ADD cliked, input field value: {}", newParam);
            if (!StringUtils.isBlank(newParam)) {
                addParam(newParam);

            }
            addInputModel.setObject(null);
            target.add(SimpleParametricRoleSelector.this);
        }
    };
    add(addLink);

    AjaxLink<String> deleteLink = new AjaxLink<String>(ID_DELETE_LINK) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.debug("DELETE cliked, selected param: {}", selectedParam);
            deleteParam(selectedParam);
            target.add(SimpleParametricRoleSelector.this);
        }
    };
    add(deleteLink);
}

From source file:com.evolveum.midpoint.web.component.assignment.SimpleRoleSelector.java

License:Apache License

private void initLayout() {
    setOutputMarkupId(true);/*from   w  ww  . j av a  2s  . co m*/
    ListView<PrismObject<R>> list = new ListView<PrismObject<R>>(ID_LIST, availableRoles) {
        @Override
        protected void populateItem(ListItem<PrismObject<R>> item) {
            item.add(createRoleLink(ID_ITEM, item.getModel()));
        }
    };
    list.setOutputMarkupId(true);
    add(list);

    AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            reset();
            target.add(SimpleRoleSelector.this);
        }
    };
    buttonReset.setBody(createStringResource("SimpleRoleSelector.reset"));
    add(buttonReset);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel.java

License:Apache License

private void initLayout(final IModel<String> label, final String labelSize, final String textSize) {

    Label l = new Label(ID_LABEL, label);

    if (StringUtils.isNotEmpty(labelSize)) {
        l.add(AttributeAppender.prepend("class", labelSize));
    }//w  w  w.  j av  a2  s .c  o  m
    add(l);

    WebMarkupContainer addFirstContainer = new WebMarkupContainer(ID_ADD_FIRST_CONTAINER);
    addFirstContainer.setOutputMarkupId(true);
    addFirstContainer.setOutputMarkupPlaceholderTag(true);
    addFirstContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isEmpty();
        }
    });
    add(addFirstContainer);

    AjaxLink addFirst = new AjaxLink(ID_ADD_FIRST) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addFirstPerformed(target);
        }
    };
    addFirstContainer.add(addFirst);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> listItem) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    if (StringUtils.isNotEmpty(textSize)) {
                        sb.append(textSize).append(' ');
                    }
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) {
                        sb.append(getOffsetClass()).append(' ');
                        sb.append(CLASS_MULTI_VALUE);
                    }
                    return sb.toString();
                }
            }));
            listItem.add(textWrapper);

            TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("onblur") {
                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setEnabled(false);
            text.add(AttributeAppender.replace("placeholder", label));
            text.setLabel(label);
            textWrapper.add(text);

            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            textWrapper.add(feedback);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) {
                        return CLASS_MULTI_VALUE;
                    }

                    return null;
                }
            }));

            AjaxLink edit = new AjaxLink(ID_EDIT) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editValuePerformed(target, listItem.getModel());
                }
            };
            textWrapper.add(edit);

            listItem.add(buttonGroup);

            initButtons(buttonGroup, listItem);
        }
    };

    initDialog();
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel.java

License:Apache License

private void initLayout(final boolean inputEnabled) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override/*from ww  w. ja  va2s. c om*/
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);

    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
            autoCompleteSettings.setShowListOnEmptyInput(true);
            AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT,
                    createTextModel(item.getModel()), autoCompleteSettings) {

                @Override
                protected Iterator<String> getChoices(String input) {
                    return createAutoCompleteObjectList(input);
                }
            };
            autoCompleteEditor.add(createAutoCompleteValidator());
            autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("onchange") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            item.add(autoCompleteEditor);

            autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));

            if (!inputEnabled) {
                autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(autoCompleteEditor);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueChoosePanel.java

License:Apache License

private void initLayout(final IModel<String> label, final String labelSize, final String textSize,
        final boolean required, Class<T> type) {

    Label l = new Label(ID_LABEL, label);

    if (StringUtils.isNotEmpty(labelSize)) {
        l.add(AttributeAppender.prepend("class", labelSize));
    }//from   ww w. j  a  v a2s .c om
    add(l);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> listItem) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    if (StringUtils.isNotEmpty(textSize)) {
                        sb.append(textSize).append(' ');
                    }
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(getOffsetClass())) {
                        sb.append(getOffsetClass()).append(' ');
                        sb.append(CLASS_MULTI_VALUE);
                    }
                    return sb.toString();
                }
            }));
            listItem.add(textWrapper);

            TextField text = new TextField<>(ID_TEXT, createTextModel(listItem.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("onblur") {
                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setRequired(required);
            text.setEnabled(false);
            text.add(AttributeAppender.replace("placeholder", label));
            text.setLabel(label);
            textWrapper.add(text);

            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            textWrapper.add(feedback);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (listItem.getIndex() > 0 && StringUtils.isNotEmpty(labelSize)) {
                        return CLASS_MULTI_VALUE;
                    }

                    return null;
                }
            }));

            AjaxLink edit = new AjaxLink(ID_EDIT) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editValuePerformed(target);
                }
            };
            textWrapper.add(edit);

            listItem.add(buttonGroup);

            initButtons(buttonGroup, listItem);
        }
    };

    initDialog(type);
    add(repeater);
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueDropDownPanel.java

License:Apache License

private void initLayout(final boolean nullValid) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override// www.j  a  v  a2  s .c o m
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);

    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);

    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {

            DropDownChoice choice = new DropDownChoice<>(ID_INPUT, createDropDownItemModel(item.getModel()),
                    createChoiceList(), createRenderer());
            choice.setNullValid(nullValid);
            item.add(choice);

            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}