use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class SwitchablePropertyValuePanel method getValueField.
private <T> Component getValueField(String id) {
Component searchItemField = null;
ItemDefinition propertyDef = getPropertyItemDefinition();
if (propertyDef != null) {
PrismObject<LookupTableType> lookupTable = WebComponentUtil.findLookupTable(propertyDef, getPageBase());
if (propertyDef instanceof PrismReferenceDefinition) {
searchItemField = new ReferenceValueSearchPanel(id, new PropertyModel<>(getModel(), "value.value"), (PrismReferenceDefinition) propertyDef) {
private static final long serialVersionUID = 1L;
@Override
protected void referenceValueUpdated(ObjectReferenceType ort, AjaxRequestTarget target) {
SwitchablePropertyValuePanel.this.getModelObject().getValue().setValue(ort);
}
};
} else if (propertyDef instanceof PrismPropertyDefinition) {
List<DisplayableValue> allowedValues = new ArrayList<>();
if (((PrismPropertyDefinition) propertyDef).getAllowedValues() != null) {
allowedValues.addAll(((PrismPropertyDefinition) propertyDef).getAllowedValues());
} else if (propertyDef.getTypeClass().equals(boolean.class) || Boolean.class.isAssignableFrom(propertyDef.getTypeClass())) {
allowedValues.add(new SearchValue<>(Boolean.TRUE, getString("Boolean.TRUE")));
allowedValues.add(new SearchValue<>(Boolean.FALSE, getString("Boolean.FALSE")));
}
if (lookupTable != null) {
searchItemField = new AutoCompleteTextPanel<String>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE), String.class, true, lookupTable.asObjectable()) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<String> getIterator(String input) {
return WebComponentUtil.prepareAutoCompleteList(lookupTable.asObjectable(), input, ((PageBase) getPage()).getLocalizationService()).iterator();
}
};
} else if (CollectionUtils.isNotEmpty(allowedValues)) {
List<T> allowedValuesList = new ArrayList<>();
allowedValues.forEach(val -> allowedValuesList.add((T) val.getValue()));
searchItemField = new DropDownChoicePanel<T>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE), Model.ofList(allowedValuesList), new IChoiceRenderer<T>() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(T val) {
if (val instanceof DisplayableValue) {
return ((DisplayableValue) val).getLabel();
}
return val;
}
@Override
public String getIdValue(T val, int index) {
return Integer.toString(index);
}
@Override
public T getObject(String id, IModel<? extends List<? extends T>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
}
}, true);
} else {
searchItemField = new TextPanel<String>(id, new PropertyModel<>(getModel(), "value." + ValueSearchFilterItem.F_VALUE));
}
}
}
if (searchItemField instanceof InputPanel) {
((InputPanel) searchItemField).getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
}
return searchItemField != null ? searchItemField : new WebMarkupContainer(id);
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class SearchPropertyPanel method initSearchItemField.
protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
Component searchItemField;
PropertySearchItem<T> item = getModelObject();
IModel<List<DisplayableValue<?>>> choices = null;
switch(item.getSearchItemType()) {
case REFERENCE:
searchItemField = new ReferenceValueSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"), (PrismReferenceDefinition) item.getDefinition().getDef()) {
@Override
public Boolean isItemPanelEnabled() {
return item.isEnabled();
}
@Override
protected boolean isAllowedNotFoundObjectRef() {
return item.getSearch().getTypeClass().equals(AuditEventRecordType.class);
}
@Override
protected List<QName> getAllowedRelations() {
if (item.getSearch().getTypeClass().equals(AuditEventRecordType.class)) {
return Collections.emptyList();
}
return super.getAllowedRelations();
}
};
break;
case BOOLEAN:
choices = (IModel) createBooleanChoices();
case ENUM:
if (choices == null) {
choices = new ListModel(item.getAllowedValues(getPageBase()));
}
searchItemField = WebComponentUtil.createDropDownChoices(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "value"), (IModel) choices, true, getPageBase());
break;
case DATE:
searchItemField = new DateIntervalSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "fromDate"), new PropertyModel(getModel(), "toDate"));
break;
case ITEM_PATH:
searchItemField = new ItemPathSearchPanel(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), "value.value"));
break;
case TEXT:
PrismObject<LookupTableType> lookupTable = WebComponentUtil.findLookupTable(item.getDefinition().getDef(), getPageBase());
if (lookupTable != null) {
searchItemField = createAutoCompetePanel(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"), lookupTable.asObjectable());
} else {
searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value.value"));
}
break;
default:
searchItemField = new TextPanel<String>(ID_SEARCH_ITEM_FIELD, new PropertyModel<>(getModel(), "value"));
}
if (searchItemField instanceof InputPanel && !(searchItemField instanceof AutoCompleteTextPanel)) {
FormComponent<?> baseFormComponent = ((InputPanel) searchItemField).getBaseFormComponent();
baseFormComponent.add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
baseFormComponent.add(AttributeAppender.append("style", "width: 140px; max-width: 400px !important;"));
baseFormComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
baseFormComponent.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return item.isEnabled();
}
@Override
public boolean isVisible() {
return item.isVisible();
}
});
}
searchItemField.setOutputMarkupId(true);
searchItemContainer.add(searchItemField);
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class AbstractInputGuiComponentFactory method configure.
@Override
public void configure(PrismPropertyPanelContext<T> panelCtx, Component component) {
if (!(component instanceof InputPanel)) {
return;
}
InputPanel panel = (InputPanel) component;
final List<FormComponent> formComponents = panel.getFormComponents();
for (FormComponent<T> formComponent : formComponents) {
PrismPropertyWrapper<T> propertyWrapper = panelCtx.unwrapWrapperModel();
IModel<String> label = LambdaModel.of(propertyWrapper::getDisplayName);
formComponent.setLabel(label);
formComponent.setRequired(panelCtx.isMandatory());
if (formComponent instanceof TextField) {
formComponent.add(new AttributeModifier("size", "42"));
}
formComponent.add(panelCtx.getAjaxEventBehavior());
formComponent.add(panelCtx.getVisibleEnableBehavior());
}
panel.getValidatableComponent().add(panelCtx.getExpressionValidator());
panelCtx.getFeedback().setFilter(new ComponentFeedbackMessageFilter(panel.getValidatableComponent()));
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class ACAttributeValuePanel method initLayout.
private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
ACValueConstructionDto dto = getModel().getObject();
PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
InputPanel input = createTypedInputComponent(ID_INPUT, definition);
for (FormComponent comp : input.getFormComponents()) {
comp.setLabel(new PropertyModel<>(dto.getAttribute(), ACAttributeDto.F_NAME));
if (!ignoreMandatoryAttributes) {
comp.setRequired(definition.getMinOccurs() > 0);
}
comp.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
}
add(input);
AjaxLink<Void> addLink = new AjaxLink<Void>(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addPerformed(target);
}
};
add(addLink);
addLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isAddVisible();
}
});
AjaxLink<Void> removeLink = new AjaxLink<Void>(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removePerformed(target);
}
};
add(removeLink);
removeLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isRemoveVisible();
}
});
}
Aggregations