Search in sources :

Example 86 with ListItem

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

the class MultivalueContainerListPanelWithDetailsPanel method initDetailsPanel.

protected void initDetailsPanel() {
    WebMarkupContainer details = new WebMarkupContainer(ID_DETAILS);
    details.setOutputMarkupId(true);
    details.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return itemDetailsVisible;
        }
    });
    add(details);
    ListView<PrismContainerValueWrapper<C>> itemDetailsView = new ListView<>(MultivalueContainerListPanelWithDetailsPanel.ID_ITEMS_DETAILS, () -> detailsPanelItemsList) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<PrismContainerValueWrapper<C>> item) {
            MultivalueContainerDetailsPanel<C> detailsPanel = getMultivalueContainerDetailsPanel(item);
            item.add(detailsPanel);
            detailsPanel.setOutputMarkupId(true);
        }
    };
    itemDetailsView.setOutputMarkupId(true);
    details.add(itemDetailsView);
    WebMarkupContainer buttonsContainer = new WebMarkupContainer(ID_BUTTONS_PANEL);
    buttonsContainer.add(new VisibleBehaviour(this::isButtonPanelVisible));
    details.add(buttonsContainer);
    AjaxButton doneButton = new AjaxButton(ID_DONE_BUTTON, createStringResource("MultivalueContainerListPanel.doneButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            itemDetailsVisible = false;
            refreshTable(ajaxRequestTarget);
            ajaxRequestTarget.add(MultivalueContainerListPanelWithDetailsPanel.this);
        }
    };
    buttonsContainer.add(doneButton);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, createStringResource("MultivalueContainerListPanel.cancelButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            itemDetailsVisible = false;
            cancelItemDetailsPerformed(ajaxRequestTarget);
            ajaxRequestTarget.add(MultivalueContainerListPanelWithDetailsPanel.this);
            ajaxRequestTarget.add(getPageBase().getFeedbackPanel());
        }
    };
    buttonsContainer.add(cancelButton);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 87 with ListItem

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

the class MappingColumnPanel method initLayout.

private void initLayout() {
    ListView<PrismContainerValueWrapper<MappingType>> mappings = new ListView<>(ID_MAPPINGS, new PropertyModel<>(getModel(), "values")) {

        @Override
        protected void populateItem(ListItem<PrismContainerValueWrapper<MappingType>> item) {
            Label label = new Label(ID_MAPPING, WebComponentUtil.createMappingDescription(item.getModel()));
            label.add(AttributeAppender.append("class", createEnabledDisabledStyles(item.getModelObject())));
            item.add(label);
        }
    };
    add(mappings);
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)

Example 88 with ListItem

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

the class MultiValueChoosePanel method initLayout.

private void initLayout(final IModel<List<T>> chosenValues, final List<PrismReferenceValue> filterValues, final boolean required, final boolean multiselect) {
    AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            editValuePerformed(chosenValues.getObject(), filterValues, target, multiselect);
        }
    };
    addButton.setOutputMarkupPlaceholderTag(true);
    add(addButton);
    ListView<T> selectedRowsList = new ListView<T>(ID_SELECTED_ROWS, chosenValues) {

        @Override
        protected void populateItem(ListItem<T> item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.setOutputMarkupPlaceholderTag(true);
            // was value
            TextField<String> text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setRequired(required);
            text.setEnabled(false);
            text.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(text);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            feedback.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(feedback);
            initButtons(item, item);
            item.add(textWrapper);
        }
    };
    selectedRowsList.setReuseItems(true);
    add(selectedRowsList);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 89 with ListItem

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

the class MultiValueObjectChoosePanel method initMultiValuesListPanel.

private void initMultiValuesListPanel() {
    ListView<R> multiValuesPanel = new ListView<R>(ID_MULTI_SHADOW_REF_VALUE, MultiValueObjectChoosePanel.this.getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<R> item) {
            ValueChoosePanel<R> valueChoosePanel = new ValueChoosePanel<R>(ID_REFERENCE_VALUE_INPUT, item.getModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected ObjectFilter createCustomFilter() {
                    return MultiValueObjectChoosePanel.this.createCustomFilter();
                }

                @Override
                public List<QName> getSupportedTypes() {
                    return MultiValueObjectChoosePanel.this.getSupportedTypes();
                }

                @Override
                protected <O extends ObjectType> void choosePerformedHook(AjaxRequestTarget target, O object) {
                    chooseObjectPerformed(target, object);
                }
            };
            valueChoosePanel.setOutputMarkupId(true);
            item.add(valueChoosePanel);
            WebMarkupContainer buttonsContainer = new WebMarkupContainer(ID_BUTTONS_CONTAINER);
            buttonsContainer.setOutputMarkupId(true);
            item.add(buttonsContainer);
            AjaxButton addButton = new AjaxButton(ID_ADD_BUTTON) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    emptyObjectPanelDisplay = true;
                    target.add(MultiValueObjectChoosePanel.this);
                // MultiValueObjectChoosePanel.this.getModelObject().add(null);
                }
            };
            addButton.setOutputMarkupId(true);
            addButton.add(new EnableBehaviour(() -> item.getModelObject() != null));
            buttonsContainer.add(addButton);
            AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_BUTTON) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    MultiValueObjectChoosePanel.this.getModelObject().remove(item.getModelObject());
                    target.add(MultiValueObjectChoosePanel.this);
                }
            };
            removeButton.setOutputMarkupId(true);
            removeButton.add(new EnableBehaviour(() -> item.getModelObject() != null));
            buttonsContainer.add(removeButton);
        }
    };
    multiValuesPanel.add(new VisibleBehaviour(() -> !isEmptyModel()));
    multiValuesPanel.setOutputMarkupId(true);
    add(multiValuesPanel);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) ListItem(org.apache.wicket.markup.html.list.ListItem) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 90 with ListItem

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

the class MultiValueAutoCompleteTextPanel method initLayout.

private void initLayout(final boolean inputEnabled, 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 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.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    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);
            autoCompleteSettings.setMaxHeightInPx(200);
            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("change") {

                @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, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ListView(org.apache.wicket.markup.html.list.ListView) 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)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)131 ListView (org.apache.wicket.markup.html.list.ListView)107 Label (org.apache.wicket.markup.html.basic.Label)82 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)72 IModel (org.apache.wicket.model.IModel)44 List (java.util.List)42 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 ArrayList (java.util.ArrayList)38 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)17 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 Model (org.apache.wicket.model.Model)12 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11