use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class MultiValueTextPanel method initButtons.
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxLink plus = new AjaxLink(ID_PLUS) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
plus.add(new AttributeAppender("class", getPlusClassModifier(item)));
plus.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(plus);
AjaxLink minus = new AjaxLink(ID_MINUS) {
@Override
public void onClick(AjaxRequestTarget target) {
removeValuePerformed(target, item);
}
};
minus.add(new AttributeAppender("class", getMinusClassModifier()));
minus.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(minus);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class MultiValueTextPanel method initLayout.
private void initLayout(final NonEmptyModel<Boolean> readOnlyModel, final boolean emptyStringToNull) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModel().getObject().isEmpty();
}
});
add(placeholderContainer);
AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (buttonsDisabled()) {
return " " + CSS_DISABLED;
}
return "";
}
}));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(placeholderAdd);
ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {
@Override
protected void populateItem(final ListItem<T> item) {
TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
text.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
text.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
text.setConvertEmptyInputStringToNull(emptyStringToNull);
item.add(text);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
repeater.setOutputMarkupPlaceholderTag(true);
repeater.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isEmpty();
}
});
add(repeater);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class QNameEditorPanel method initLayout.
private void initLayout(String localPartLabelKey, String localPartTooltipKey, String namespaceLabelKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) {
Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString(localPartLabelKey));
localPartLabel.setOutputMarkupId(true);
localPartLabel.setOutputMarkupPlaceholderTag(true);
add(localPartLabel);
WebMarkupContainer localPartRequired = new WebMarkupContainer(ID_LOCAL_PART_REQUIRED);
localPartRequired.setVisible(markLocalPartAsRequired);
add(localPartRequired);
Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString(namespaceLabelKey));
namespaceLabel.setOutputMarkupId(true);
namespaceLabel.setOutputMarkupPlaceholderTag(true);
add(namespaceLabel);
WebMarkupContainer namespaceRequired = new WebMarkupContainer(ID_NAMESPACE_REQUIRED);
namespaceRequired.setVisible(markNamespaceAsRequired);
add(namespaceRequired);
TextField localPart = new TextField<>(ID_LOCAL_PART, localpartModel);
localPart.setOutputMarkupId(true);
localPart.setOutputMarkupPlaceholderTag(true);
localPart.setRequired(isLocalPartRequired());
localPart.add(new UpdateBehavior());
add(localPart);
DropDownChoice namespace = new DropDownChoice<>(ID_NAMESPACE, namespaceModel, prepareNamespaceList());
namespace.setOutputMarkupId(true);
namespace.setOutputMarkupPlaceholderTag(true);
namespace.setNullValid(false);
namespace.setRequired(isNamespaceRequired());
namespace.add(new UpdateBehavior());
add(namespace);
Label localPartTooltip = new Label(ID_T_LOCAL_PART);
localPartTooltip.add(new AttributeAppender("data-original-title", getString(localPartTooltipKey)));
localPartTooltip.add(new InfoTooltipBehavior());
localPartTooltip.setOutputMarkupPlaceholderTag(true);
add(localPartTooltip);
Label namespaceTooltip = new Label(ID_T_NAMESPACE);
namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey)));
namespaceTooltip.add(new InfoTooltipBehavior());
namespaceTooltip.setOutputMarkupPlaceholderTag(true);
add(namespaceTooltip);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class MultiValueAutoCompleteTextPanel method initLayout.
private void initLayout(final boolean inputEnabled, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModel().getObject().isEmpty();
}
});
add(placeholderContainer);
AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (buttonsDisabled()) {
return " " + CSS_DISABLED;
}
return "";
}
}));
placeholderAdd.setOutputMarkupId(true);
placeholderAdd.setOutputMarkupPlaceholderTag(true);
placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
placeholderContainer.add(placeholderAdd);
ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {
@Override
protected void populateItem(final ListItem<T> item) {
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setMaxHeightInPx(200);
AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT, createTextModel(item.getModel()), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return createAutoCompleteObjectList(input);
}
};
autoCompleteEditor.add(createAutoCompleteValidator());
autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
item.add(autoCompleteEditor);
autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
if (!inputEnabled) {
autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
}
item.add(autoCompleteEditor);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
repeater.setOutputMarkupPlaceholderTag(true);
repeater.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isEmpty();
}
});
add(repeater);
}
use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.
the class MultiValueAutoCompleteTextPanel method initButtons.
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxLink add = new AjaxLink(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
add.add(new AttributeAppender("class", getPlusClassModifier(item)));
add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(add);
AjaxLink remove = new AjaxLink(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removeValuePerformed(target, item);
}
};
remove.add(new AttributeAppender("class", getMinusClassModifier()));
remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(remove);
}
Aggregations