Search in sources :

Example 21 with ListItem

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

the class MainMenuPanel method initLayout.

private void initLayout() {
    WebMarkupContainer item = new WebMarkupContainer(ID_ITEM);
    item.setOutputMarkupId(true);
    item.add(AttributeModifier.append("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            MainMenuItem mainMenuItem = getModelObject();
            if (mainMenuItem.isMenuActive(getPageBase())) {
                return "active";
            }
            if (mainMenuItem.hasActiveSubmenu(getPageBase())) {
                return "active menu-open";
            }
            return null;
        }
    }));
    add(item);
    item.add(AttributeModifier.append("style", new ReadOnlyModel<>(() -> isMenuExpanded() ? "" : "display: none;")));
    WebMarkupContainer link = new AjaxLink<Void>(ID_LINK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            mainMenuPerformed();
        }
    };
    item.add(link);
    WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
    icon.add(AttributeModifier.replace("class", new PropertyModel<>(getModel(), MainMenuItem.F_ICON_CLASS)));
    link.add(icon);
    Label label = new Label(ID_LABEL, new StringResourceModel("${nameModel}", getModel()).setDefaultValue(new PropertyModel<>(getModel(), "nameModel")));
    link.add(label);
    final PropertyModel<String> bubbleModel = new PropertyModel<>(getModel(), MainMenuItem.F_BUBBLE_LABEL);
    Label bubble = new Label(ID_BUBBLE, bubbleModel);
    bubble.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return bubbleModel.getObject() != null;
        }
    });
    link.add(bubble);
    WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
    arrow.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().containsSubMenu() && bubbleModel.getObject() == null;
        }
    });
    link.add(arrow);
    WebMarkupContainer submenu = new WebMarkupContainer(ID_SUBMENU);
    item.add(submenu);
    ListView<MenuItem> subItem = new ListView<MenuItem>(ID_SUB_ITEM, new PropertyModel<>(getModel(), MainMenuItem.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<MenuItem> listItem) {
            createSubmenu(listItem);
        }
    };
    submenu.add(subItem);
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 22 with ListItem

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

the class MultiValueTextEditPanel method initLayout.

private void initLayout(final boolean inputEnabled, final boolean showPlaceholder, final NonEmptyModel<Boolean> readOnlyModel) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return showPlaceholder && (getModel().getObject() == null || getModel().getObject().isEmpty());
        }
    });
    add(placeholderContainer);
    AjaxLink<Void> placeholderAdd = new AjaxLink<Void>(ID_PLACEHOLDER_ADD) {

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

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    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) {
            TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            if (selectedModel != null && item.getModelObject() == selectedModel.getObject()) {
                // TODO color constant
                text.add(AttributeAppender.append("style", "background-color: #FFFFD0;"));
            }
            if (!inputEnabled) {
                text.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(text);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject() != null && !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : IModel(org.apache.wicket.model.IModel) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 23 with ListItem

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

the class SynchronizationStep method initObjectSyncEditor.

private void initObjectSyncEditor(WebMarkupContainer editor) {
    Label editorLabel = new Label(ID_EDITOR_LABEL, new IModel<String>() {

        @Override
        public String getObject() {
            if (!isAnySelected()) {
                // shouldn't occur
                return null;
            }
            String name = syncDtoModel.getObject().getSelected().getName() != null ? syncDtoModel.getObject().getSelected().getName() : "";
            return getString("SynchronizationStep.label.editSyncObject", name);
        }
    });
    editorLabel.setOutputMarkupId(true);
    editor.add(editorLabel);
    TextField editorName = new TextField<>(ID_EDITOR_NAME, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".name"));
    editorName.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorName);
    editor.add(editorName);
    TextArea editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".description"));
    parentPage.addEditingEnabledBehavior(editorDescription);
    editor.add(editorDescription);
    DropDownChoice editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<>());
    editorKind.setNullValid(true);
    editorKind.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorKind);
    editor.add(editorKind);
    TextField editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".intent"));
    editorIntent.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorIntent);
    editor.add(editorIntent);
    MultiValueAutoCompleteTextPanel<QName> editorObjectClass = new MultiValueAutoCompleteTextPanel<QName>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectClass"), true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<QName> model) {
            return new PropertyModel<>(model, "localPart");
        }

        @Override
        protected QName createNewEmptyItem() {
            return new QName("");
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }

        @Override
        protected List<QName> createObjectList() {
            return syncDtoModel.getObject().getObjectClassList();
        }

        @Override
        protected String createAutoCompleteObjectLabel(QName object) {
            return object.getLocalPart();
        }

        @Override
        protected IValidator<String> createAutoCompleteValidator() {
            return createObjectClassValidator(new IModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return syncDtoModel.getObject().getObjectClassList();
                }
            });
        }
    };
    parentPage.addEditingEnabledBehavior(editorObjectClass);
    editor.add(editorObjectClass);
    // TODO: switch to ObjectTypeSelectPanel
    DropDownChoice editorFocus = new DropDownChoice<>(ID_EDITOR_FOCUS, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".focusType"), (IModel<List<QName>>) () -> WebComponentUtil.createFocusTypeList(), new QNameChoiceRenderer());
    editorFocus.setNullValid(true);
    editorFocus.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorFocus);
    editor.add(editorFocus);
    CheckBox editorEnabled = new CheckBox(ID_EDITOR_ENABLED, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".enabled"));
    parentPage.addEditingEnabledBehavior(editorEnabled);
    editor.add(editorEnabled);
    AjaxSubmitLink editorCondition = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONDITION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            conditionEditPerformed(target);
        }
    };
    addDisableClassModifier(editorCondition);
    editor.add(editorCondition);
    AjaxSubmitLink editorConfirmation = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONFIRMATION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            confirmationEditPerformed(target);
        }
    };
    addDisableClassModifier(editorConfirmation);
    editor.add(editorConfirmation);
    DropDownChoice editorObjectTemplate = new DropDownChoice<>(ID_EDITOR_OBJECT_TEMPLATE, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectTemplateRef"), new IModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), syncDtoModel.getObject().getObjectTemplateMap());
        }
    }, new ObjectReferenceChoiceRenderer(syncDtoModel.getObject().getObjectTemplateMap()));
    editorObjectTemplate.setNullValid(true);
    parentPage.addEditingEnabledBehavior(editorObjectTemplate);
    editor.add(editorObjectTemplate);
    CheckBox editorReconcile = new CheckBox(ID_EDITOR_RECONCILE, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
    parentPage.addEditingEnabledBehavior(editorReconcile);
    editor.add(editorReconcile);
    TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
    parentPage.addEditingEnabledBehavior(opportunistic);
    editor.add(opportunistic);
    MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".correlation"), new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_CORRELATION), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<ConditionalSearchFilterType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ConditionalSearchFilterType searchFilter = model.getObject();
                    if (searchFilter != null && searchFilter.getDescription() != null) {
                        sb.append(searchFilter.getDescription());
                    }
                    if (sb.toString().isEmpty()) {
                        sb.append(getString("SynchronizationStep.label.notSpecified"));
                    }
                    return sb.toString();
                }
            };
        }

        @Override
        protected ConditionalSearchFilterType createNewEmptyItem() {
            return new ConditionalSearchFilterType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, ConditionalSearchFilterType object) {
            correlationEditPerformed(target, object);
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, ConditionalSearchFilterType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ConditionalSearchFilterType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editor.add(editorCorrelation);
    MultiValueTextEditPanel editorReaction = new MultiValueTextEditPanel<SynchronizationReactionType>(ID_EDITOR_REACTION, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reaction"), new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_REACTION), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<SynchronizationReactionType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    SynchronizationReactionType reaction = model.getObject();
                    if (reaction == null) {
                        return "";
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(reaction.getName() != null ? reaction.getName() + " " : "");
                    sb.append("(");
                    if (reaction.getSituation() != null) {
                        sb.append(reaction.getSituation());
                    }
                    if (Boolean.TRUE.equals(reaction.isSynchronize()) || !reaction.getAction().isEmpty()) {
                        sb.append(" -> ");
                        if (!reaction.getAction().isEmpty()) {
                            boolean first = true;
                            for (SynchronizationActionType action : reaction.getAction()) {
                                if (first) {
                                    first = false;
                                } else {
                                    sb.append(", ");
                                }
                                sb.append(StringUtils.substringAfter(action.getHandlerUri(), "#"));
                            }
                        } else {
                            sb.append(getString("SynchronizationStep.label.editorReaction"));
                        }
                    }
                    sb.append(")");
                    return sb.toString();
                }
            };
        }

        @Override
        protected SynchronizationReactionType createNewEmptyItem() {
            return new SynchronizationReactionType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, SynchronizationReactionType object) {
            reactionEditPerformed(target, object);
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, SynchronizationReactionType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationReactionType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editorReaction.setOutputMarkupId(true);
    editor.add(editorReaction);
    Label kindTooltip = new Label(ID_T_KIND);
    kindTooltip.add(new InfoTooltipBehavior());
    editor.add(kindTooltip);
    Label intentTooltip = new Label(ID_T_INTENT);
    intentTooltip.add(new InfoTooltipBehavior());
    editor.add(intentTooltip);
    Label objClassTooltip = new Label(ID_T_OBJ_CLASS);
    objClassTooltip.add(new InfoTooltipBehavior());
    editor.add(objClassTooltip);
    Label focusTooltip = new Label(ID_T_FOCUS);
    focusTooltip.add(new InfoTooltipBehavior());
    editor.add(focusTooltip);
    Label enabledTooltip = new Label(ID_T_ENABLED);
    enabledTooltip.add(new InfoTooltipBehavior());
    editor.add(enabledTooltip);
    Label conditionTooltip = new Label(ID_T_CONDITION);
    conditionTooltip.add(new InfoTooltipBehavior());
    editor.add(conditionTooltip);
    Label confirmationTooltip = new Label(ID_T_CONFIRMATION);
    confirmationTooltip.add(new InfoTooltipBehavior());
    editor.add(confirmationTooltip);
    Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
    objTemplateTooltip.add(new InfoTooltipBehavior());
    editor.add(objTemplateTooltip);
    Label reconcileTooltip = new Label(ID_T_RECONCILE);
    reconcileTooltip.add(new InfoTooltipBehavior());
    editor.add(reconcileTooltip);
    Label opportunisticTooltip = new Label(ID_T_OPPORTUNISTIC);
    opportunisticTooltip.add(new InfoTooltipBehavior());
    editor.add(opportunisticTooltip);
    Label correlationTooltip = new Label(ID_T_CORRELATION);
    correlationTooltip.add(new InfoTooltipBehavior());
    editor.add(correlationTooltip);
    Label reactionTooltip = new Label(ID_T_REACTION);
    reactionTooltip.add(new InfoTooltipBehavior());
    editor.add(reactionTooltip);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) TriStateComboPanel(com.evolveum.midpoint.web.component.input.TriStateComboPanel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) MultiValueAutoCompleteTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel) List(java.util.List) ArrayList(java.util.ArrayList) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) NonEmptyWrapperModel(com.evolveum.midpoint.gui.api.model.NonEmptyWrapperModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 24 with ListItem

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

the class ResourceDependencyEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    ListView repeater = new ListView<ResourceObjectTypeDependencyType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectTypeDependencyType> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_DEPENDENCY_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);
            Label linkLabel = new Label(ID_DEPENDENCY_LINK_NAME, createDependencyLabelModel(item));
            linkContainer.add(linkLabel);
            AjaxLink<Void> delete = new AjaxLink<Void>(ID_DELETE_BUTTON) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteDependencyPerformed(target, item);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            linkContainer.add(delete);
            WebMarkupContainer dependencyBody = new WebMarkupContainer(ID_DEPENDENCY_BODY);
            dependencyBody.setOutputMarkupId(true);
            dependencyBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                dependencyBody.add(new AttributeModifier("class", new IModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(dependencyBody);
            TextField order = new TextField<>(ID_ORDER, new PropertyModel<Integer>(item.getModelObject(), "order"));
            order.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(order);
            dependencyBody.add(order);
            DropDownChoice strictness = new DropDownChoice<>(ID_STRICTNESS, new PropertyModel<>(item.getModelObject(), "strictness"), WebComponentUtil.createReadonlyModelFromEnum(ResourceObjectTypeDependencyStrictnessType.class), new EnumChoiceRenderer<>(this));
            strictness.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(strictness);
            dependencyBody.add(strictness);
            DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<>(item.getModelObject(), "kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<>(this));
            kind.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(kind);
            dependencyBody.add(kind);
            TextField intent = new TextField<>(ID_INTENT, new PropertyModel<String>(item.getModelObject(), "intent"));
            intent.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(intent);
            dependencyBody.add(intent);
            DropDownChoice resource = new DropDownChoice<>(ID_REF, new PropertyModel<>(item.getModelObject(), "resourceRef"), new IModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return WebModelServiceUtils.createObjectReferenceList(ResourceType.class, getPageBase(), resourceMap);
                }
            }, new ObjectReferenceChoiceRenderer(resourceMap));
            resource.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(resource);
            dependencyBody.add(resource);
            Label orderTooltip = new Label(ID_T_ORDER);
            orderTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(orderTooltip);
            Label strictnessTooltip = new Label(ID_T_STRICTNESS);
            strictnessTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(strictnessTooltip);
            Label kindTooltip = new Label(ID_T_KIND);
            kindTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(kindTooltip);
            Label intentTooltip = new Label(ID_T_INTENT);
            intentTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(intentTooltip);
            Label resourceRefTooltip = new Label(ID_T_RESOURCE_REF);
            resourceRefTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(resourceRefTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);
    AjaxLink<Void> add = new AjaxLink<Void>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addDependencyPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) IModel(org.apache.wicket.model.IModel) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 25 with ListItem

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

the class ResourceProtectedEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    ListView repeater = new ListView<ResourceObjectPatternType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectPatternType> item) {
            WebMarkupContainer linkCont = new WebMarkupContainer(ID_ACCOUNT_LINK);
            linkCont.setOutputMarkupId(true);
            linkCont.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkCont);
            Label accountLabel = new Label(ID_ACCOUNT_NAME, new IModel<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ResourceObjectPatternType account = item.getModelObject();
                    sb.append("#").append(item.getIndex() + 1).append(" - ");
                    return sb.toString();
                }
            });
            linkCont.add(accountLabel);
            AjaxLink<Void> delete = new AjaxLink<Void>(ID_BUTTON_DELETE) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteProtectedAccountPerformed(target, item);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            linkCont.add(delete);
            WebMarkupContainer accountBody = new WebMarkupContainer(ID_ACCOUNT_BODY);
            accountBody.setOutputMarkupId(true);
            accountBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                accountBody.add(new AttributeModifier("class", new IModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(accountBody);
            // TODO - maybe add some validator and auto-complete functionality?
            TextField name = new TextField<>(ID_NAME, new PropertyModel<String>(item.getModel(), "name"));
            name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            parentPage.addEditingEnabledBehavior(name);
            accountBody.add(name);
            // TODO - maybe add some validator and auto-complete functionality?
            TextField uid = new TextField<>(ID_UID, new PropertyModel<String>(item.getModel(), "uid"));
            uid.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            parentPage.addEditingEnabledBehavior(uid);
            accountBody.add(uid);
            SearchFilterPanel searchFilterPanel = new SearchFilterPanel<>(ID_FILTER_EDITOR, new NonEmptyPropertyModel<>(item.getModel(), "filter"), parentPage.getReadOnlyModel());
            accountBody.add(searchFilterPanel);
            Label nameTooltip = new Label(ID_T_NAME);
            nameTooltip.add(new InfoTooltipBehavior());
            accountBody.add(nameTooltip);
            Label uidTooltip = new Label(ID_T_UID);
            uidTooltip.add(new InfoTooltipBehavior());
            accountBody.add(uidTooltip);
            Label filterTooltip = new Label(ID_T_FILTER);
            filterTooltip.add(new InfoTooltipBehavior());
            accountBody.add(filterTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);
    AjaxLink<Void> add = new AjaxLink<Void>(ID_BUTTON_ADD) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addProtectedAccountPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) ResourceObjectPatternType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectPatternType) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) SearchFilterPanel(com.evolveum.midpoint.web.component.input.SearchFilterPanel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)127 ListView (org.apache.wicket.markup.html.list.ListView)103 Label (org.apache.wicket.markup.html.basic.Label)79 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)70 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)69 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 IModel (org.apache.wicket.model.IModel)40 List (java.util.List)38 ArrayList (java.util.ArrayList)37 PropertyModel (org.apache.wicket.model.PropertyModel)28 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)23 TextField (org.apache.wicket.markup.html.form.TextField)15 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)14 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)14 QName (javax.xml.namespace.QName)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10