use of com.evolveum.midpoint.web.component.input.CheckPanel in project midpoint by Evolveum.
the class SearchFilterPanel method initSearchItemField.
protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
CheckPanel checkPanel = new CheckPanel(ID_CHECK_DISABLE_FIELD, new PropertyModel<>(getModel(), FilterSearchItem.F_APPLY_FILTER));
(checkPanel).getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
searchPerformed(ajaxRequestTarget);
}
});
checkPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
checkPanel.add(new VisibleBehaviour(this::canRemoveSearchItem));
checkPanel.setOutputMarkupId(true);
searchItemContainer.add(checkPanel);
ParameterType functionParameter = getModelObject().getPredefinedFilter().getParameter();
QName returnType = functionParameter != null ? functionParameter.getType() : null;
Component inputPanel;
if (returnType == null) {
inputPanel = new WebMarkupContainer(ID_SEARCH_ITEM_FIELD);
} else {
Class<?> inputClass = getPrismContext().getSchemaRegistry().determineClassForType(returnType);
Validate.notNull(inputClass, "Couldn't find class for type " + returnType);
SearchItem.Type inputType = getModelObject().getInputType(inputClass, getPageBase());
IModel<List<DisplayableValue<?>>> choices = null;
switch(inputType) {
case REFERENCE:
SearchFilterParameterType parameter = getModelObject().getPredefinedFilter().getParameter();
MutablePrismReferenceDefinition def = null;
if (parameter != null) {
Class<?> clazz = getPrismContext().getSchemaRegistry().determineClassForType(parameter.getType());
QName type = getPrismContext().getSchemaRegistry().determineTypeForClass(clazz);
def = getPrismContext().definitionFactory().createReferenceDefinition(new QName(parameter.getName()), type);
def.setTargetTypeName(parameter.getTargetType());
}
inputPanel = new ReferenceValueSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), FilterSearchItem.F_INPUT_VALUE), def);
break;
case BOOLEAN:
choices = (IModel) createBooleanChoices();
case ENUM:
if (choices == null) {
choices = CollectionUtils.isEmpty(getModelObject().getAllowedValues(getPageBase())) ? createEnumChoices((Class<? extends Enum>) inputClass) : Model.ofList(getModelObject().getAllowedValues(getPageBase()));
}
if (choices != null) {
inputPanel = WebComponentUtil.createDropDownChoices(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), FilterSearchItem.F_INPUT), (IModel) choices, true, getPageBase());
break;
}
case DATE:
inputPanel = new DateSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), FilterSearchItem.F_INPUT_VALUE));
break;
case ITEM_PATH:
inputPanel = new ItemPathSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), FilterSearchItem.F_INPUT_VALUE));
break;
case TEXT:
LookupTableType lookupTable = getModelObject().getLookupTable(getPageBase());
if (lookupTable != null) {
inputPanel = createAutoCompetePanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), FilterSearchItem.F_INPUT_VALUE), lookupTable);
break;
}
default:
inputPanel = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), FilterSearchItem.F_INPUT_VALUE));
}
if (inputPanel instanceof InputPanel && !(inputPanel instanceof AutoCompleteTextPanel)) {
((InputPanel) inputPanel).getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
((InputPanel) inputPanel).getBaseFormComponent().add(AttributeAppender.append("style", "width: 140px; max-width: 400px !important;"));
((InputPanel) inputPanel).getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
}
inputPanel.setOutputMarkupId(true);
searchItemContainer.add(inputPanel);
}
searchItemContainer.add(inputPanel);
}
Aggregations