use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class RunReportPopupPanel method createInputMarkup.
private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
param.setEditing(true);
WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
paramValueMarkup.setOutputMarkupId(true);
InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
paramValueMarkup.add(input);
//buttons
AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addValue(paramValueMarkup, param, target);
}
};
addButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isAddButtonVisible(param);
}
});
paramValueMarkup.add(addButton);
AjaxLink<String> removeButton = new AjaxLink<String>(ID_REMOVE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
removeValue(paramValueMarkup, param, valueModel.getObject(), target);
}
};
removeButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isRemoveButtonVisible();
}
});
paramValueMarkup.add(removeButton);
return paramValueMarkup;
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class ACAttributeValuePanel method createTypedInputComponent.
private InputPanel createTypedInputComponent(String id, PrismPropertyDefinition definition) {
QName valueType = definition.getTypeName();
final String baseExpression = ACValueConstructionDto.F_VALUE;
InputPanel panel;
if (DOMUtil.XSD_DATETIME.equals(valueType)) {
panel = new DatePanel(id, new PropertyModel<>(getModel(), baseExpression));
} else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
panel = new PasswordPanel(id, new PropertyModel<>(getModel(), baseExpression));
} else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) {
panel = new TriStateComboPanel(id, new PropertyModel<>(getModel(), baseExpression));
} else if (SchemaConstants.T_POLY_STRING_TYPE.equals(valueType)) {
panel = new TextPanel<>(id, new PropertyModel<>(getModel(), baseExpression + ".orig"), String.class);
} else {
Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
if (type != null && type.isPrimitive()) {
type = ClassUtils.primitiveToWrapper(type);
}
panel = new TextPanel<>(id, new PropertyModel<>(getModel(), baseExpression), type);
if (ObjectType.F_NAME.equals(definition.getItemName())) {
panel.getBaseFormComponent().setRequired(true);
}
}
return panel;
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class SearchSpecialItemPanel method initLayout.
protected void initLayout() {
setOutputMarkupId(true);
WebMarkupContainer searchItemContainer = new WebMarkupContainer(ID_SEARCH_ITEM_CONTAINER);
searchItemContainer.setOutputMarkupId(true);
add(searchItemContainer);
IModel<String> labelModel = createLabelModel();
Label searchItemLabel = new Label(ID_SEARCH_ITEM_LABEL, labelModel);
searchItemLabel.setOutputMarkupId(true);
searchItemLabel.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(labelModel.getObject())));
IModel<String> titleModel = createTitleModel();
if (StringUtils.isNotEmpty(titleModel.getObject())) {
searchItemLabel.add(AttributeAppender.append("title", titleModel));
}
searchItemContainer.add(searchItemLabel);
Label help = new Label(ID_HELP);
IModel<String> helpModel = createHelpModel();
help.add(AttributeModifier.replace("title", createStringResource(helpModel.getObject() != null ? helpModel.getObject() : "")));
help.add(new InfoTooltipBehavior() {
@Override
public String getDataPlacement() {
return "left";
}
});
help.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(helpModel.getObject())));
searchItemContainer.add(help);
WebMarkupContainer inputPanel = initSearchItemField(ID_SEARCH_ITEM_FIELD);
if (inputPanel instanceof InputPanel && !(inputPanel instanceof AutoCompleteTextPanel)) {
((InputPanel) inputPanel).getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
}
inputPanel.setOutputMarkupId(true);
searchItemContainer.add(inputPanel);
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class SearchTypePanel method initSearchItemField.
protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
Component searchItemField = new WebMarkupContainer(ID_SEARCH_ITEM_FIELD);
ContainerTypeSearchItem<C> item = getModelObject();
if (item != null && item.getAllowedValues() != null) {
List<DisplayableValue<Class<C>>> allowedValues = item.getAllowedValues();
if (allowedValues != null && !allowedValues.isEmpty()) {
IModel<List<DisplayableValue<?>>> choices = new ListModel(item.getAllowedValues());
searchItemField = WebComponentUtil.createDropDownChoices(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), ContainerTypeSearchItem.F_TYPE), (IModel) choices, false, getPageBase());
}
}
if (searchItemField instanceof InputPanel && !(searchItemField instanceof AutoCompleteTextPanel)) {
((InputPanel) searchItemField).getBaseFormComponent().add(AttributeAppender.append("style", "width: 175px; max-width: 400px !important;"));
((InputPanel) searchItemField).getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
}
searchItemField.setOutputMarkupId(true);
searchItemContainer.add(searchItemField);
}
use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.
the class PolyStringEditorPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
String localizedValue = getLocalizedPolyStringValue();
WebMarkupContainer localizedValueContainer = new WebMarkupContainer(ID_LOCALIZED_VALUE_CONTAINER);
localizedValueContainer.setOutputMarkupId(true);
localizedValueContainer.add(getInputFieldClassAppenderForContainer());
localizedValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isNotEmpty(localizedValue)));
add(localizedValueContainer);
Label localizedValueLabel = new Label(ID_LOCALIZED_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.localizedValue"));
localizedValueLabel.setOutputMarkupId(true);
localizedValueLabel.add(new VisibleBehaviour(() -> showFullData));
localizedValueContainer.add(localizedValueLabel);
WebMarkupContainer localizedValueWithButton = new WebMarkupContainer(ID_LOCALIZED_VALUE_WITH_BUTTON);
localizedValueWithButton.setOutputMarkupId(true);
localizedValueWithButton.add(getInputFieldClassAppender());
localizedValueContainer.add(localizedValueWithButton);
TextPanel<String> localizedValuePanel = new TextPanel<>(ID_LOCALIZED_VALUE_PANEL, Model.of(localizedValue));
localizedValuePanel.setOutputMarkupId(true);
localizedValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
localizedValuePanel.add(new EnableBehaviour(() -> false));
localizedValueWithButton.add(localizedValuePanel);
AjaxButton showHideLanguagesLocalizedButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_LOCALIZED) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesLocalizedButton.setOutputMarkupId(true);
// showHideLanguagesLocalizedButton.add(AttributeAppender.append("style", "cursor: pointer;"));
localizedValueWithButton.add(showHideLanguagesLocalizedButton);
WebMarkupContainer originValueContainer = new WebMarkupContainer(ID_ORIGIN_VALUE_CONTAINER);
originValueContainer.setOutputMarkupId(true);
originValueContainer.add(getInputFieldClassAppenderForContainer());
originValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isEmpty(localizedValue)));
add(originValueContainer);
Label origValueLabel = new Label(ID_ORIG_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.origValue"));
origValueLabel.setOutputMarkupId(true);
origValueLabel.add(new VisibleBehaviour(() -> showFullData));
originValueContainer.add(origValueLabel);
WebMarkupContainer origValueWithButton = new WebMarkupContainer(ID_ORIG_VALUE_WITH_BUTTON);
origValueWithButton.add(getInputFieldClassAppender());
origValueWithButton.setOutputMarkupId(true);
originValueContainer.add(origValueWithButton);
InputPanel origValuePanel;
IModel<String> origValueModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getOrig() : null;
}
@Override
public void setObject(String object) {
PolyString oldModelObject = getModelObject();
if (oldModelObject != null && (oldModelObject.getTranslation() != null || MapUtils.isNotEmpty(oldModelObject.getLang()))) {
getModel().setObject(new PolyString(object, oldModelObject.getNorm(), oldModelObject.getTranslation(), oldModelObject.getLang()));
} else if (StringUtils.isNotBlank(object)) {
getModel().setObject(new PolyString(object));
} else {
getModel().setObject(null);
}
}
@Override
public void detach() {
}
};
if (predefinedValuesLookupTable == null) {
origValuePanel = new TextPanel<>(ID_ORIG_VALUE, origValueModel, String.class, false);
} else {
origValuePanel = new AutoCompleteTextPanel<String>(ID_ORIG_VALUE, origValueModel, String.class, hasValueEnumerationRef, predefinedValuesLookupTable) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<String> getIterator(String input) {
return getPredefinedValuesIterator(input).iterator();
}
};
}
origValuePanel.setOutputMarkupId(true);
origValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
origValueWithButton.add(origValuePanel);
WebMarkupContainer fullDataContainer = new WebMarkupContainer(ID_FULL_DATA_CONTAINER);
fullDataContainer.setOutputMarkupId(true);
fullDataContainer.add(new VisibleBehaviour(() -> showFullData));
add(fullDataContainer);
TextPanel<String> keyValue = new TextPanel<>(ID_KEY_VALUE, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getTranslation() != null ? getModelObject().getTranslation().getKey() : null;
}
@Override
public void setObject(String object) {
if (getModelObject() == null) {
getModel().setObject(new PolyString(""));
}
if (getModelObject().getTranslation() == null) {
getModelObject().setTranslation(new PolyStringTranslationType());
}
getModelObject().getTranslation().setKey(object);
}
@Override
public void detach() {
}
});
keyValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
keyValue.setOutputMarkupId(true);
fullDataContainer.add(keyValue);
IModel<String> langChoiceModel = Model.of();
WebMarkupContainer languageEditorContainer = new WebMarkupContainer(ID_LANGUAGE_EDITOR);
languageEditorContainer.setOutputMarkupId(true);
languageEditorContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getLanguageChoicesModel().getObject())));
fullDataContainer.add(languageEditorContainer);
final DropDownChoicePanel<String> languageChoicePanel = new DropDownChoicePanel<>(ID_LANGUAGES_LIST, langChoiceModel, getLanguageChoicesModel(), true);
languageChoicePanel.setOutputMarkupId(true);
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
removeLanguageValue(currentlySelectedLang.toString());
clearSelectedLanguageValue();
currentlySelectedLang.append(getLanguagesChoicePanel().getBaseFormComponent().getModelObject());
}
});
languageEditorContainer.add(languageChoicePanel);
final TextPanel<String> newLanguageValue = new TextPanel<>(ID_VALUE_TO_ADD, Model.of());
newLanguageValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
languageChoicePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.setOutputMarkupId(true);
languageEditorContainer.add(newLanguageValue);
AjaxLink<Void> addLanguageButton = new AjaxLink<Void>(ID_ADD_LANGUAGE_VALUE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getModel().getObject(), newLanguageValue.getBaseFormComponent().getModelObject());
languageChoicePanel.getModel().setObject(null);
newLanguageValue.getBaseFormComponent().getModel().setObject(null);
clearSelectedLanguageValue();
target.add(PolyStringEditorPanel.this);
}
};
addLanguageButton.add(AttributeAppender.append("style", "cursor: pointer;"));
addLanguageButton.setOutputMarkupId(true);
languageEditorContainer.add(addLanguageButton);
ListView<String> languagesContainer = new ListView<String>(ID_LANGUAGES_REPEATER, getLanguagesListModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> listItem) {
TextPanel<String> languageName = new TextPanel<>(ID_LANGUAGE_NAME, listItem.getModel());
languageName.add(new EnableBehaviour(() -> false));
languageName.setOutputMarkupId(true);
listItem.add(languageName);
TextPanel<String> translation = new TextPanel<>(ID_TRANSLATION, Model.of(getLanguageValueByKey(listItem.getModelObject())));
translation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
translation.setOutputMarkupId(true);
translation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
listItem.add(translation);
AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_LANGUAGE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
removeLanguageValue(listItem.getModelObject());
target.add(PolyStringEditorPanel.this);
}
};
removeButton.setOutputMarkupId(true);
listItem.add(removeButton);
}
};
languagesContainer.setOutputMarkupId(true);
fullDataContainer.add(languagesContainer);
AjaxButton showHideLanguagesButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_ORIG) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesButton.setOutputMarkupId(true);
// showHideLanguagesButton.add(AttributeAppender.append("style", "cursor: pointer;"));
origValueWithButton.add(showHideLanguagesButton);
}
Aggregations