Search in sources :

Example 1 with SearchFilterPanel

use of com.evolveum.midpoint.web.component.input.SearchFilterPanel 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)

Example 2 with SearchFilterPanel

use of com.evolveum.midpoint.web.component.input.SearchFilterPanel in project midpoint by Evolveum.

the class ConditionalSearchFilterEditor method initLayout.

protected void initLayout(PageResourceWizard parentPage) {
    ExpressionEditorPanel expressionEditor = new ExpressionEditorPanel(ID_EXPRESSION_PANEL, new PropertyModel<>(getModel(), ConditionalSearchFilterType.F_CONDITION.getLocalPart()), parentPage) {

        @Override
        public void performExpressionHook(AjaxRequestTarget target) {
            if (getExpressionDtoModel().getObject() != null) {
                ExpressionType expression = getExpressionDtoModel().getObject().getExpressionObject();
                ConditionalSearchFilterEditor.this.getModel().getObject().setCondition(expression);
            }
        }

        @Override
        public String getTypeLabelKey() {
            return "ConditionalSearchFilterEditor.condition.type.label";
        }

        @Override
        public String getDescriptionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.description.label";
        }

        @Override
        public String getUpdateLabelKey() {
            return "ConditionalSearchFilterEditor.condition.update.label";
        }

        @Override
        public String getExpressionLabelKey() {
            return "ConditionalSearchFilterEditor.condition.label";
        }
    };
    add(expressionEditor);
    SearchFilterPanel filterClauseEditor = new SearchFilterPanel<>(ID_FILTER_CLAUSE_PANEL, (NonEmptyModel<ConditionalSearchFilterType>) getModel(), parentPage.getReadOnlyModel());
    add(filterClauseEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) SearchFilterPanel(com.evolveum.midpoint.web.component.input.SearchFilterPanel) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ExpressionEditorPanel(com.evolveum.midpoint.web.component.input.ExpressionEditorPanel)

Aggregations

SearchFilterPanel (com.evolveum.midpoint.web.component.input.SearchFilterPanel)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ExpressionEditorPanel (com.evolveum.midpoint.web.component.input.ExpressionEditorPanel)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)1 ConditionalSearchFilterType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType)1 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)1 ResourceObjectPatternType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectPatternType)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 TextField (org.apache.wicket.markup.html.form.TextField)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 IModel (org.apache.wicket.model.IModel)1