Search in sources :

Example 1 with ReferenceValueSearchPanel

use of com.evolveum.midpoint.web.component.search.ReferenceValueSearchPanel 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 ReferenceValueSearchPanel

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

Aggregations

PrismReferenceDefinition (com.evolveum.midpoint.prism.PrismReferenceDefinition)2 ReferenceValueSearchPanel (com.evolveum.midpoint.web.component.search.ReferenceValueSearchPanel)2 SearchSpecialItemPanel (com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 QName (javax.xml.namespace.QName)2 IModel (org.apache.wicket.model.IModel)2 PropertyModel (org.apache.wicket.model.PropertyModel)2