Search in sources :

Example 1 with SearchSpecialItemPanel

use of com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel in project midpoint by Evolveum.

the class TenantSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    IModel tenantModel = new PropertyModel(searchBoxConfiguration, SearchBoxConfigurationHelper.F_TENANT) {

        @Override
        public void setObject(Object object) {
            if (object == null) {
                searchBoxConfiguration.resetTenantRef();
            } else {
                super.setObject(object);
            }
        }
    };
    PrismReferenceDefinition tenantRefDef = getTenantDefinition();
    SearchSpecialItemPanel panel = new SearchSpecialItemPanel(id, tenantModel) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            return new ReferenceValueSearchPanel(id, getModelValue(), tenantRefDef) {

                @Override
                public Boolean isItemPanelEnabled() {
                    return !searchBoxConfiguration.isIndirect();
                }

                @Override
                protected List<QName> getAllowedRelations() {
                    return Collections.singletonList(RelationTypes.MEMBER.getRelation());
                }
            };
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getTenantConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            if (getTenantConfig().getDisplay().getHelp() != null) {
                return Model.of(WebComponentUtil.getTranslatedPolyString(getTenantConfig().getDisplay().getHelp()));
            }
            String help = tenantRefDef.getHelp();
            if (StringUtils.isNotEmpty(help)) {
                return getPageBase().createStringResource(help);
            }
            return Model.of(tenantRefDef.getDocumentation());
        }
    };
    panel.add(new VisibleBehaviour(() -> searchBoxConfiguration == null || !searchBoxConfiguration.isIndirect()));
    return panel;
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ReferenceValueSearchPanel(com.evolveum.midpoint.web.component.search.ReferenceValueSearchPanel) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)

Example 2 with SearchSpecialItemPanel

use of com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel in project midpoint by Evolveum.

the class IndirectSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    SearchSpecialItemPanel panel = new SearchSpecialItemPanel(id, new PropertyModel(searchBoxConfiguration, SearchBoxConfigurationHelper.F_INDIRECT_ITEM + "." + IndirectSearchItemConfigurationType.F_INDIRECT.getLocalPart())) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            List<Boolean> choices = new ArrayList<>();
            choices.add(Boolean.TRUE);
            choices.add(Boolean.FALSE);
            DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, getModelValue(), Model.ofList(choices), new ChoiceRenderer<Boolean>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(Boolean val) {
                    if (val) {
                        return getPageBase().createStringResource("Boolean.TRUE").getString();
                    }
                    return getPageBase().createStringResource("Boolean.FALSE").getString();
                }
            }, false);
            inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 68" + "px; max-width: 400px !important;"));
            inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> searchBoxConfiguration != null && !searchBoxConfiguration.isSearchScope(SearchBoxScopeType.SUBTREE)));
            inputPanel.setOutputMarkupId(true);
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getIndirectConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getIndirectConfig().getDisplay().getHelp()));
        }
    };
    panel.add(new VisibleBehaviour(this::isPanelVisible));
    return panel;
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) ArrayList(java.util.ArrayList) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 3 with SearchSpecialItemPanel

use of com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel in project midpoint by Evolveum.

the class ProjectSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    IModel projectModel = new PropertyModel(getMemberPanelStorage(), SearchBoxConfigurationHelper.F_PROJECT) {

        @Override
        public void setObject(Object object) {
            if (object == null) {
                getMemberPanelStorage().resetProjectRef();
            } else {
                super.setObject(object);
            }
        }
    };
    PrismReferenceDefinition projectRefDef = getProjectRefDef();
    SearchSpecialItemPanel panel = new SearchSpecialItemPanel(id, projectModel) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            return new ReferenceValueSearchPanel(id, getModelValue(), projectRefDef) {

                @Override
                public Boolean isItemPanelEnabled() {
                    return !(getMemberPanelStorage().isIndirect());
                }

                @Override
                protected List<QName> getAllowedRelations() {
                    return Collections.singletonList(RelationTypes.MEMBER.getRelation());
                }
            };
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getProjectSearchConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            if (getProjectSearchConfig().getDisplay().getHelp() != null) {
                return Model.of(WebComponentUtil.getTranslatedPolyString(getProjectSearchConfig().getDisplay().getHelp()));
            }
            String help = projectRefDef.getHelp();
            if (StringUtils.isNotEmpty(help)) {
                return getPageBase().createStringResource(help);
            }
            return Model.of(projectRefDef.getDocumentation());
        }
    };
    panel.add(new VisibleBehaviour(() -> getMemberPanelStorage() == null || !getMemberPanelStorage().isIndirect()));
    return panel;
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ReferenceValueSearchPanel(com.evolveum.midpoint.web.component.search.ReferenceValueSearchPanel) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)

Example 4 with SearchSpecialItemPanel

use of com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel in project midpoint by Evolveum.

the class ScopeSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    return new SearchSpecialItemPanel(id, new PropertyModel(scopeConfigModel, ScopeSearchItemConfigurationType.F_DEFAULT_VALUE.getLocalPart())) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, getModelValue(), Model.of(Arrays.asList(SearchBoxScopeType.values())), new EnumChoiceRenderer(), false);
            inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 88px; max-width: 400px !important;"));
            inputPanel.setOutputMarkupId(true);
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getScopeConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getScopeConfig().getDisplay().getHelp()));
        }
    };
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) PropertyModel(org.apache.wicket.model.PropertyModel) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)

Example 5 with SearchSpecialItemPanel

use of com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel in project midpoint by Evolveum.

the class RoleCatalogTabPanel method createScopeItem.

private SearchItem createScopeItem(Search search) {
    return new SpecialSearchItem(search) {

        @Override
        public ObjectFilter createFilter(PageBase pageBase, VariablesMap variables) {
            return null;
        }

        @Override
        public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
            return new SearchSpecialItemPanel(id, new PropertyModel(getRoleCatalogStorage(), RoleCatalogStorage.F_ORG_SEARCH_SCOPE)) {

                @Override
                protected WebMarkupContainer initSearchItemField(String id) {
                    DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, getModelValue(), Model.of(Arrays.asList(SearchBoxScopeType.values())), new EnumChoiceRenderer(), false);
                    inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
                    inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 88px; max-width: 400px !important;"));
                    inputPanel.setOutputMarkupId(true);
                    return inputPanel;
                }

                @Override
                protected IModel<String> createLabelModel() {
                    return getPageBase().createStringResource("abstractRoleMemberPanel.searchScope");
                }

                @Override
                protected IModel<String> createHelpModel() {
                    return getPageBase().createStringResource("abstractRoleMemberPanel.searchScope.tooltip");
                }
            };
        }
    };
}
Also used : SpecialSearchItem(com.evolveum.midpoint.web.component.search.SpecialSearchItem) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) PropertyModel(org.apache.wicket.model.PropertyModel) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)

Aggregations

SearchSpecialItemPanel (com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)6 PropertyModel (org.apache.wicket.model.PropertyModel)6 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 QName (javax.xml.namespace.QName)3 PrismReferenceDefinition (com.evolveum.midpoint.prism.PrismReferenceDefinition)2 ReferenceValueSearchPanel (com.evolveum.midpoint.web.component.search.ReferenceValueSearchPanel)2 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)2 ArrayList (java.util.ArrayList)2 EnumChoiceRenderer (org.apache.wicket.markup.html.form.EnumChoiceRenderer)2 IModel (org.apache.wicket.model.IModel)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 QNameIChoiceRenderer (com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer)1 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)1 SpecialSearchItem (com.evolveum.midpoint.web.component.search.SpecialSearchItem)1 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)1 RelationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType)1 RelationSearchItemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.RelationSearchItemConfigurationType)1 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)1