use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class ObjectBrowserPanel method initLayout.
private void initLayout() {
MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
warningMessage.setOutputMarkupId(true);
warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
add(warningMessage);
List<ObjectTypes> supported = new ArrayList<>();
for (QName qname : supportedTypes) {
supported.add(ObjectTypes.getObjectTypeFromTypeQName(qname));
}
WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
typePanel.setOutputMarkupId(true);
typePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return supportedTypes.size() != 1;
}
});
add(typePanel);
DropDownChoice<ObjectTypes> typeSelect = new DropDownChoice<>(ID_TYPE, typeModel, new ListModel<>(supported), new EnumChoiceRenderer<>(this));
typeSelect.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
listPanel = createObjectListPanel(typeModel.getObject(), multiselect);
addOrReplace(listPanel);
target.add(listPanel);
}
});
typePanel.add(typeSelect);
ObjectTypes objType = defaultType != null ? ObjectTypes.getObjectType(defaultType) : null;
ObjectListPanel<O> listPanel = createObjectListPanel(objType, multiselect);
add(listPanel);
AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedRealObjects();
ObjectTypes type = ObjectBrowserPanel.this.typeModel.getObject();
QName qname = type != null ? type.getTypeQName() : null;
ObjectBrowserPanel.this.addPerformed(target, qname, selected);
}
};
addButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return multiselect;
}
});
add(addButton);
AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("Button.cancel")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
getPageBase().hideMainPopup(ajaxRequestTarget);
}
};
add(cancelButton);
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class AttributeEditorUtils method addMatchingRuleFields.
static void addMatchingRuleFields(final BasePanel<? extends ResourceItemDefinitionType> editor, final NonEmptyModel<Boolean> readOnlyModel) {
// normalizes unqualified QNames
final IModel<QName> matchingRuleModel = new IModel<QName>() {
@Override
public QName getObject() {
QName rawRuleName = editor.getModelObject().getMatchingRule();
if (rawRuleName == null) {
return null;
}
try {
MatchingRule<?> rule = editor.getPageBase().getMatchingRuleRegistry().getMatchingRule(rawRuleName, null);
return rule.getName();
} catch (SchemaException e) {
// we could get here if invalid QName is specified - but we don't want to throw an exception in that case
LoggingUtils.logUnexpectedException(LOGGER, "Invalid matching rule name encountered in resource wizard: {} -- continuing", e, rawRuleName);
return rawRuleName;
}
}
@Override
public void setObject(QName value) {
editor.getModelObject().setMatchingRule(value);
}
@Override
public void detach() {
}
};
final List<QName> matchingRuleList = WebComponentUtil.getMatchingRuleList();
DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE, matchingRuleModel, new IModel<List<QName>>() {
@Override
public List<QName> getObject() {
return matchingRuleList;
}
}, new QNameChoiceRenderer());
matchingRule.setNullValid(true);
matchingRule.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
QName ruleName = matchingRuleModel.getObject();
return ruleName == null || WebComponentUtil.getMatchingRuleList().contains(ruleName);
}
@Override
public boolean isEnabled() {
return !readOnlyModel.getObject();
}
});
editor.add(matchingRule);
Label unknownMatchingRule = new Label(ID_UNKNOWN_MATCHING_RULE, new IModel<String>() {
@Override
public String getObject() {
return editor.getString("ResourceAttributeEditor.label.unknownMatchingRule", matchingRuleModel.getObject());
}
});
unknownMatchingRule.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
QName ruleName = matchingRuleModel.getObject();
return ruleName != null && !WebComponentUtil.getMatchingRuleList().contains(ruleName);
}
});
editor.add(unknownMatchingRule);
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class SynchronizationActionEditorDialog method initLayout.
private void initLayout(WebMarkupContainer content) {
Form form = new MidpointForm(ID_MAIN_FORM);
form.setOutputMarkupId(true);
content.add(form);
TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".name"), createStringResource("SynchronizationActionEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(name);
TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".description"), createStringResource("SynchronizationActionEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(description);
DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions> handlerUri = new DropDownFormGroup<SynchronizationActionTypeDto.HandlerUriActions>(ID_HANDLER_URI, new PropertyModel<>(model, SynchronizationActionTypeDto.F_HANDLER_URI), WebComponentUtil.createReadonlyModelFromEnum(SynchronizationActionTypeDto.HandlerUriActions.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.handlerUri"), createStringResource("SynchronizationStep.action.tooltip.handlerUri", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<SynchronizationActionTypeDto.HandlerUriActions>> choices, IChoiceRenderer<SynchronizationActionTypeDto.HandlerUriActions> renderer, boolean required) {
DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
choice.setNullValid(true);
return choice;
}
};
form.add(handlerUri);
DropDownFormGroup<BeforeAfterType> order = new DropDownFormGroup<BeforeAfterType>(ID_ORDER, new PropertyModel<>(model, SynchronizationActionTypeDto.F_ACTION_OBJECT + ".order"), WebComponentUtil.createReadonlyModelFromEnum(BeforeAfterType.class), new EnumChoiceRenderer<>(this), createStringResource("SynchronizationActionEditorDialog.label.order"), createStringResource("SynchronizationStep.action.tooltip.order", WebComponentUtil.getMidpointCustomSystemName((PageResourceWizard) getPage(), "midpoint.default.system.name")), ID_LABEL_SIZE, ID_INPUT_SIZE, false, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<BeforeAfterType>> choices, IChoiceRenderer<BeforeAfterType> renderer, boolean required) {
DropDownChoice choice = new DropDownChoice<>(id, getModel(), choices, renderer);
choice.setNullValid(true);
return choice;
}
};
form.add(order);
initButtons(form);
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class ResourceActivationEditor method prepareActivationPanelBody.
private void prepareActivationPanelBody(String containerValue, String fetchStrategyId, String outboundId, String inboundId, NonEmptyModel<Boolean> readOnlyModel) {
DropDownChoice fetchStrategy = new DropDownChoice<>(fetchStrategyId, new PropertyModel<>(getModel(), containerValue + ".fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<>(this));
fetchStrategy.setNullValid(true);
fetchStrategy.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
add(fetchStrategy);
MultiValueTextEditPanel outbound = new MultiValueTextEditPanel<MappingType>(outboundId, new PropertyModel<>(getModel(), containerValue + ".outbound"), null, false, true, readOnlyModel) {
@Override
protected IModel<String> createTextModel(final IModel<MappingType> model) {
return new Model<String>() {
@Override
public String getObject() {
return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
}
};
}
@Override
protected MappingType createNewEmptyItem() {
return WizardUtil.createEmptyMapping();
}
@Override
protected void editPerformed(AjaxRequestTarget target, MappingType object) {
mappingEditPerformed(target, object, false);
}
};
add(outbound);
MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(inboundId, new PropertyModel<>(getModel(), containerValue + ".inbound"), null, false, true, readOnlyModel) {
@Override
protected IModel<String> createTextModel(final IModel<MappingType> model) {
return new Model<String>() {
@Override
public String getObject() {
return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
}
};
}
@Override
protected MappingType createNewEmptyItem() {
return WizardUtil.createEmptyMapping();
}
@Override
protected void editPerformed(AjaxRequestTarget target, MappingType object) {
mappingEditPerformed(target, object, true);
}
};
inbound.setOutputMarkupId(true);
add(inbound);
}
use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.
the class ExecuteChangeOptionsPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
createContainer(ID_FORCE_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_FORCE), FORCE_LABEL, FORCE_HELP, true);
createContainer(ID_RECONCILE_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_RECONCILE), RECONCILE_LABEL, RECONCILE_HELP, showReconcile);
createContainer(ID_RECONCILE_AFFECTED_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_RECONCILE_AFFECTED), RECONCILE_AFFECTED_LABEL, RECONCILE_AFFECTED_HELP, showReconcileAffected);
createContainer(ID_EXECUTE_AFTER_ALL_APPROVALS_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_EXECUTE_AFTER_ALL_APPROVALS), EXECUTE_AFTER_ALL_APPROVALS_LABEL, EXECUTE_AFTER_ALL_APPROVALS_HELP, true);
createContainer(ID_KEEP_DISPLAYING_RESULTS_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_KEEP_DISPLAYING_RESULTS), KEEP_DISPLAYING_RESULTS_LABEL, KEEP_DISPLAYING_RESULTS_HELP, showKeepDisplayingResults, true);
createContainer(ID_SAVE_IN_BACKGROUND_CONTAINER, new PropertyModel<>(getModel(), ExecuteChangeOptionsDto.F_SAVE_IN_BACKGROUND), SAVE_IN_BACKGROUND_LABEL, SAVE_IN_BACKGROUND_HELP, showKeepDisplayingResults, true);
boolean canRecordTrace;
try {
canRecordTrace = getPageBase().isAuthorized(ModelAuthorizationAction.RECORD_TRACE.getUrl());
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check trace recording authorization", t);
canRecordTrace = false;
}
WebMarkupContainer tracingContainer = new WebMarkupContainer(ID_TRACING_CONTAINER);
tracingContainer.setVisible(canRecordTrace && WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()));
add(tracingContainer);
DropDownChoice tracing = new DropDownChoice<>(ID_TRACING, PropertyModel.of(getModel(), ExecuteChangeOptionsDto.F_TRACING), PropertyModel.of(getModel(), ExecuteChangeOptionsDto.F_TRACING_CHOICES), new IChoiceRenderer<TracingProfileType>() {
private static final long serialVersionUID = 1L;
@Override
public Object getDisplayValue(TracingProfileType profile) {
if (profile == null) {
return "(none)";
} else if (profile.getDisplayName() != null) {
return profile.getDisplayName();
} else if (profile.getName() != null) {
return profile.getName();
} else {
return "(unnamed profile)";
}
}
@Override
public String getIdValue(TracingProfileType object, int index) {
return String.valueOf(index);
}
@Override
public TracingProfileType getObject(String id, IModel<? extends List<? extends TracingProfileType>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
}
});
tracing.setNullValid(true);
tracingContainer.add(tracing);
}
Aggregations