use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class LoggingConfigPanel method initAudit.
private void initAudit() {
CheckBox auditLog = WebComponentUtil.createAjaxCheckBox("auditLog", new PropertyModel<Boolean>(getModel(), "auditLog"));
add(auditLog);
CheckBox auditDetails = WebComponentUtil.createAjaxCheckBox("auditDetails", new PropertyModel<Boolean>(getModel(), "auditDetails"));
add(auditDetails);
DropDownChoice<String> auditAppender = new DropDownChoice<>("auditAppender", new PropertyModel<String>(getModel(), "auditAppender"), createAppendersListModel());
auditAppender.setNullValid(true);
auditAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
add(auditAppender);
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project webanno by webanno.
the class AnnotationPreferencesDialogContent method createLayerContainer.
private ListView<AnnotationLayer> createLayerContainer() {
return new ListView<AnnotationLayer>("annotationLayers") {
private static final long serialVersionUID = -4040731191748923013L;
@Override
protected void populateItem(ListItem<AnnotationLayer> item) {
// add checkbox
// get initial state
AnnotationPreference pref = stateModel.getObject().getPreferences();
List<Long> hiddenLayerIds = pref.getHiddenAnnotationLayerIds();
boolean isPreferredToShow = !hiddenLayerIds.contains(item.getModelObject().getId());
CheckBox layer_cb = new CheckBox("annotationLayerActive", Model.of(isPreferredToShow));
layer_cb.add(new AjaxEventBehavior("change") {
private static final long serialVersionUID = 8378489004897115519L;
@Override
protected void onEvent(AjaxRequestTarget target) {
// check state & live update preferences
List<Long> hiddenLayerIds = stateModel.getObject().getPreferences().getHiddenAnnotationLayerIds();
// get and switch state of checkbox
boolean isPreferredToShow = layer_cb.getModelObject();
layer_cb.setModelObject(!isPreferredToShow);
// live update preferences
if (isPreferredToShow) {
// prefer to deactivate layer
hiddenLayerIds.add(item.getModelObject().getId());
} else {
// prefer to activate layer
hiddenLayerIds.remove(item.getModelObject().getId());
}
}
});
item.add(layer_cb);
// add coloring strategy combobox
ChoiceRenderer<ColoringStrategyType> choiceRenderer = new ChoiceRenderer<>("descriptiveName");
List<ColoringStrategyType> choices = new ArrayList<ColoringStrategyType>(EnumSet.allOf(ColoringStrategyType.class));
Model<ColoringStrategyType> initialSelected = Model.of(form.getModelObject().colorPerLayer.get(item.getModelObject().getId()));
DropDownChoice<ColoringStrategyType> layer_color = new DropDownChoice<ColoringStrategyType>("layercoloring", initialSelected, choices, choiceRenderer);
layer_color.add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1060397773470276585L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
AnnotationLayer current_layer = item.getModelObject();
ColoringStrategyType selectedColor = layer_color.getModelObject();
form.getModelObject().colorPerLayer.put(current_layer.getId(), selectedColor);
}
});
item.add(layer_color);
// add label
Label lbl = new Label("annotationLayerDesc", item.getModelObject().getUiName());
item.add(lbl);
}
};
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class WebComponentUtil method createTriStateCombo.
public static DropDownChoice<Boolean> createTriStateCombo(String id, IModel<Boolean> model) {
final IChoiceRenderer<Boolean> renderer = new IChoiceRenderer<Boolean>() {
@Override
public Boolean getObject(String id, IModel<? extends List<? extends Boolean>> choices) {
return id != null ? choices.getObject().get(Integer.parseInt(id)) : null;
}
@Override
public String getDisplayValue(Boolean object) {
String key;
if (object == null) {
key = KEY_BOOLEAN_NULL;
} else {
key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE;
}
StringResourceModel model = PageBase.createStringResourceStatic(null, key);
return model.getString();
}
@Override
public String getIdValue(Boolean object, int index) {
return Integer.toString(index);
}
};
DropDownChoice<Boolean> dropDown = new DropDownChoice<Boolean>(id, model, createChoices(), renderer) {
@Override
protected CharSequence getDefaultChoice(String selectedValue) {
StringResourceModel model = PageBase.createStringResourceStatic(null, KEY_BOOLEAN_NULL);
return model.getString();
}
};
dropDown.setNullValid(true);
return dropDown;
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class MultiValueDropDownPanel method initLayout.
private void initLayout(final boolean nullValid, 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<Void> placeholderAdd = new AjaxLink<Void>(ID_PLACEHOLDER_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(new AttributeAppender("class", new IModel<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) {
DropDownChoice choice = new DropDownChoice<>(ID_INPUT, createDropDownItemModel(item.getModel()), createChoiceList(), createRenderer());
choice.setNullValid(nullValid);
choice.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
item.add(choice);
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.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class QNameEditorPanel method initLayout.
private void initLayout(String localPartTooltipKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) {
Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString("SchemaHandlingStep.association.label.associationName"));
localPartLabel.setOutputMarkupId(true);
localPartLabel.setOutputMarkupPlaceholderTag(true);
localPartLabel.add(getSpecificLabelStyleAppender());
add(localPartLabel);
WebMarkupContainer localPartRequired = new WebMarkupContainer(ID_LOCAL_PART_REQUIRED);
localPartRequired.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return markLocalPartAsRequired;
}
});
add(localPartRequired);
Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString("SchemaHandlingStep.association.label.associationNamespace"));
namespaceLabel.setOutputMarkupId(true);
namespaceLabel.setOutputMarkupPlaceholderTag(true);
namespaceLabel.add(getSpecificLabelStyleAppender());
add(namespaceLabel);
WebMarkupContainer namespaceRequired = new WebMarkupContainer(ID_NAMESPACE_REQUIRED);
namespaceRequired.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return 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);
localPartTooltip.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return localPartTooltipKey != null;
}
});
add(localPartTooltip);
Label namespaceTooltip = new Label(ID_T_NAMESPACE);
namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey)));
namespaceTooltip.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return namespaceTooltipKey != null;
}
});
namespaceTooltip.add(new InfoTooltipBehavior());
namespaceTooltip.setOutputMarkupPlaceholderTag(true);
add(namespaceTooltip);
}
Aggregations