use of com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer in project midpoint by Evolveum.
the class SynchronizationStep method initObjectSyncEditor.
private void initObjectSyncEditor(WebMarkupContainer editor) {
Label editorLabel = new Label(ID_EDITOR_LABEL, new IModel<String>() {
@Override
public String getObject() {
if (!isAnySelected()) {
// shouldn't occur
return null;
}
String name = syncDtoModel.getObject().getSelected().getName() != null ? syncDtoModel.getObject().getSelected().getName() : "";
return getString("SynchronizationStep.label.editSyncObject", name);
}
});
editorLabel.setOutputMarkupId(true);
editor.add(editorLabel);
TextField editorName = new TextField<>(ID_EDITOR_NAME, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".name"));
editorName.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorName);
editor.add(editorName);
TextArea editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".description"));
parentPage.addEditingEnabledBehavior(editorDescription);
editor.add(editorDescription);
DropDownChoice editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<>());
editorKind.setNullValid(true);
editorKind.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorKind);
editor.add(editorKind);
TextField editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".intent"));
editorIntent.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorIntent);
editor.add(editorIntent);
MultiValueAutoCompleteTextPanel<QName> editorObjectClass = new MultiValueAutoCompleteTextPanel<QName>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectClass"), true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<QName> model) {
return new PropertyModel<>(model, "localPart");
}
@Override
protected QName createNewEmptyItem() {
return new QName("");
}
@Override
protected boolean buttonsDisabled() {
return !isAnySelected();
}
@Override
protected List<QName> createObjectList() {
return syncDtoModel.getObject().getObjectClassList();
}
@Override
protected String createAutoCompleteObjectLabel(QName object) {
return object.getLocalPart();
}
@Override
protected IValidator<String> createAutoCompleteValidator() {
return createObjectClassValidator(new IModel<List<QName>>() {
@Override
public List<QName> getObject() {
return syncDtoModel.getObject().getObjectClassList();
}
});
}
};
parentPage.addEditingEnabledBehavior(editorObjectClass);
editor.add(editorObjectClass);
// TODO: switch to ObjectTypeSelectPanel
DropDownChoice editorFocus = new DropDownChoice<>(ID_EDITOR_FOCUS, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".focusType"), (IModel<List<QName>>) () -> WebComponentUtil.createFocusTypeList(), new QNameChoiceRenderer());
editorFocus.setNullValid(true);
editorFocus.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorFocus);
editor.add(editorFocus);
CheckBox editorEnabled = new CheckBox(ID_EDITOR_ENABLED, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".enabled"));
parentPage.addEditingEnabledBehavior(editorEnabled);
editor.add(editorEnabled);
AjaxSubmitLink editorCondition = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONDITION) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
conditionEditPerformed(target);
}
};
addDisableClassModifier(editorCondition);
editor.add(editorCondition);
AjaxSubmitLink editorConfirmation = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONFIRMATION) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
confirmationEditPerformed(target);
}
};
addDisableClassModifier(editorConfirmation);
editor.add(editorConfirmation);
DropDownChoice editorObjectTemplate = new DropDownChoice<>(ID_EDITOR_OBJECT_TEMPLATE, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectTemplateRef"), new IModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), syncDtoModel.getObject().getObjectTemplateMap());
}
}, new ObjectReferenceChoiceRenderer(syncDtoModel.getObject().getObjectTemplateMap()));
editorObjectTemplate.setNullValid(true);
parentPage.addEditingEnabledBehavior(editorObjectTemplate);
editor.add(editorObjectTemplate);
CheckBox editorReconcile = new CheckBox(ID_EDITOR_RECONCILE, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
parentPage.addEditingEnabledBehavior(editorReconcile);
editor.add(editorReconcile);
TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
parentPage.addEditingEnabledBehavior(opportunistic);
editor.add(opportunistic);
MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".correlation"), new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_CORRELATION), false, true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<ConditionalSearchFilterType> model) {
return new Model<String>() {
@Override
public String getObject() {
StringBuilder sb = new StringBuilder();
ConditionalSearchFilterType searchFilter = model.getObject();
if (searchFilter != null && searchFilter.getDescription() != null) {
sb.append(searchFilter.getDescription());
}
if (sb.toString().isEmpty()) {
sb.append(getString("SynchronizationStep.label.notSpecified"));
}
return sb.toString();
}
};
}
@Override
protected ConditionalSearchFilterType createNewEmptyItem() {
return new ConditionalSearchFilterType();
}
@Override
protected void editPerformed(AjaxRequestTarget target, ConditionalSearchFilterType object) {
correlationEditPerformed(target, object);
}
@Override
protected void performAddValueHook(AjaxRequestTarget target, ConditionalSearchFilterType added) {
parentPage.refreshIssues(target);
}
@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ConditionalSearchFilterType> item) {
parentPage.refreshIssues(target);
}
@Override
protected boolean buttonsDisabled() {
return !isAnySelected();
}
};
editor.add(editorCorrelation);
MultiValueTextEditPanel editorReaction = new MultiValueTextEditPanel<SynchronizationReactionType>(ID_EDITOR_REACTION, new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reaction"), new PropertyModel<>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_REACTION), false, true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<SynchronizationReactionType> model) {
return new Model<String>() {
@Override
public String getObject() {
SynchronizationReactionType reaction = model.getObject();
if (reaction == null) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append(reaction.getName() != null ? reaction.getName() + " " : "");
sb.append("(");
if (reaction.getSituation() != null) {
sb.append(reaction.getSituation());
}
if (Boolean.TRUE.equals(reaction.isSynchronize()) || !reaction.getAction().isEmpty()) {
sb.append(" -> ");
if (!reaction.getAction().isEmpty()) {
boolean first = true;
for (SynchronizationActionType action : reaction.getAction()) {
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append(StringUtils.substringAfter(action.getHandlerUri(), "#"));
}
} else {
sb.append(getString("SynchronizationStep.label.editorReaction"));
}
}
sb.append(")");
return sb.toString();
}
};
}
@Override
protected SynchronizationReactionType createNewEmptyItem() {
return new SynchronizationReactionType();
}
@Override
protected void editPerformed(AjaxRequestTarget target, SynchronizationReactionType object) {
reactionEditPerformed(target, object);
}
@Override
protected void performAddValueHook(AjaxRequestTarget target, SynchronizationReactionType added) {
parentPage.refreshIssues(target);
}
@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationReactionType> item) {
parentPage.refreshIssues(target);
}
@Override
protected boolean buttonsDisabled() {
return !isAnySelected();
}
};
editorReaction.setOutputMarkupId(true);
editor.add(editorReaction);
Label kindTooltip = new Label(ID_T_KIND);
kindTooltip.add(new InfoTooltipBehavior());
editor.add(kindTooltip);
Label intentTooltip = new Label(ID_T_INTENT);
intentTooltip.add(new InfoTooltipBehavior());
editor.add(intentTooltip);
Label objClassTooltip = new Label(ID_T_OBJ_CLASS);
objClassTooltip.add(new InfoTooltipBehavior());
editor.add(objClassTooltip);
Label focusTooltip = new Label(ID_T_FOCUS);
focusTooltip.add(new InfoTooltipBehavior());
editor.add(focusTooltip);
Label enabledTooltip = new Label(ID_T_ENABLED);
enabledTooltip.add(new InfoTooltipBehavior());
editor.add(enabledTooltip);
Label conditionTooltip = new Label(ID_T_CONDITION);
conditionTooltip.add(new InfoTooltipBehavior());
editor.add(conditionTooltip);
Label confirmationTooltip = new Label(ID_T_CONFIRMATION);
confirmationTooltip.add(new InfoTooltipBehavior());
editor.add(confirmationTooltip);
Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
objTemplateTooltip.add(new InfoTooltipBehavior());
editor.add(objTemplateTooltip);
Label reconcileTooltip = new Label(ID_T_RECONCILE);
reconcileTooltip.add(new InfoTooltipBehavior());
editor.add(reconcileTooltip);
Label opportunisticTooltip = new Label(ID_T_OPPORTUNISTIC);
opportunisticTooltip.add(new InfoTooltipBehavior());
editor.add(opportunisticTooltip);
Label correlationTooltip = new Label(ID_T_CORRELATION);
correlationTooltip.add(new InfoTooltipBehavior());
editor.add(correlationTooltip);
Label reactionTooltip = new Label(ID_T_REACTION);
reactionTooltip.add(new InfoTooltipBehavior());
editor.add(reactionTooltip);
}
use of com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer in project midpoint by Evolveum.
the class ResourceDependencyEditor method initLayout.
protected void initLayout(final PageResourceWizard parentPage) {
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
container.setOutputMarkupId(true);
add(container);
ListView repeater = new ListView<ResourceObjectTypeDependencyType>(ID_REPEATER, getModel()) {
@Override
protected void populateItem(final ListItem<ResourceObjectTypeDependencyType> item) {
WebMarkupContainer linkContainer = new WebMarkupContainer(ID_DEPENDENCY_LINK);
linkContainer.setOutputMarkupId(true);
linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
item.add(linkContainer);
Label linkLabel = new Label(ID_DEPENDENCY_LINK_NAME, createDependencyLabelModel(item));
linkContainer.add(linkLabel);
AjaxLink<Void> delete = new AjaxLink<Void>(ID_DELETE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteDependencyPerformed(target, item);
}
};
parentPage.addEditingVisibleBehavior(delete);
linkContainer.add(delete);
WebMarkupContainer dependencyBody = new WebMarkupContainer(ID_DEPENDENCY_BODY);
dependencyBody.setOutputMarkupId(true);
dependencyBody.setMarkupId(createCollapseItemId(item, false).getObject());
if (changeState != ChangeState.SKIP) {
dependencyBody.add(new AttributeModifier("class", new IModel<String>() {
@Override
public String getObject() {
if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
return "panel-collapse collapse in";
} else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
return "panel-collapse collapse in";
} else {
return "panel-collapse collapse";
}
}
}));
}
item.add(dependencyBody);
TextField order = new TextField<>(ID_ORDER, new PropertyModel<Integer>(item.getModelObject(), "order"));
order.add(prepareAjaxOnComponentTagUpdateBehavior());
parentPage.addEditingEnabledBehavior(order);
dependencyBody.add(order);
DropDownChoice strictness = new DropDownChoice<>(ID_STRICTNESS, new PropertyModel<>(item.getModelObject(), "strictness"), WebComponentUtil.createReadonlyModelFromEnum(ResourceObjectTypeDependencyStrictnessType.class), new EnumChoiceRenderer<>(this));
strictness.add(prepareAjaxOnComponentTagUpdateBehavior());
parentPage.addEditingEnabledBehavior(strictness);
dependencyBody.add(strictness);
DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<>(item.getModelObject(), "kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<>(this));
kind.add(prepareAjaxOnComponentTagUpdateBehavior());
parentPage.addEditingEnabledBehavior(kind);
dependencyBody.add(kind);
TextField intent = new TextField<>(ID_INTENT, new PropertyModel<String>(item.getModelObject(), "intent"));
intent.add(prepareAjaxOnComponentTagUpdateBehavior());
parentPage.addEditingEnabledBehavior(intent);
dependencyBody.add(intent);
DropDownChoice resource = new DropDownChoice<>(ID_REF, new PropertyModel<>(item.getModelObject(), "resourceRef"), new IModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ResourceType.class, getPageBase(), resourceMap);
}
}, new ObjectReferenceChoiceRenderer(resourceMap));
resource.add(prepareAjaxOnComponentTagUpdateBehavior());
parentPage.addEditingEnabledBehavior(resource);
dependencyBody.add(resource);
Label orderTooltip = new Label(ID_T_ORDER);
orderTooltip.add(new InfoTooltipBehavior());
dependencyBody.add(orderTooltip);
Label strictnessTooltip = new Label(ID_T_STRICTNESS);
strictnessTooltip.add(new InfoTooltipBehavior());
dependencyBody.add(strictnessTooltip);
Label kindTooltip = new Label(ID_T_KIND);
kindTooltip.add(new InfoTooltipBehavior());
dependencyBody.add(kindTooltip);
Label intentTooltip = new Label(ID_T_INTENT);
intentTooltip.add(new InfoTooltipBehavior());
dependencyBody.add(intentTooltip);
Label resourceRefTooltip = new Label(ID_T_RESOURCE_REF);
resourceRefTooltip.add(new InfoTooltipBehavior());
dependencyBody.add(resourceRefTooltip);
}
};
repeater.setOutputMarkupId(true);
container.add(repeater);
AjaxLink<Void> add = new AjaxLink<Void>(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addDependencyPerformed(target);
}
};
parentPage.addEditingVisibleBehavior(add);
add(add);
}
use of com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer in project midpoint by Evolveum.
the class MappingEditorDialog method initLayout.
public 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, MappingTypeDto.F_MAPPING + ".name"), createStringResource("MappingEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
name.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(name);
TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".description"), createStringResource("MappingEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
description.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(description);
CheckFormGroup authoritative = new CheckFormGroup(ID_AUTHORITATIVE, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".authoritative"), createStringResource("MappingEditorDialog.label.authoritative"), "SchemaHandlingStep.mapping.tooltip.authoritative", ID_LABEL_SIZE, ID_INPUT_SIZE);
authoritative.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(authoritative);
CheckFormGroup exclusive = new CheckFormGroup(ID_EXCLUSIVE, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".exclusive"), createStringResource("MappingEditorDialog.label.exclusive"), "SchemaHandlingStep.mapping.tooltip.exclusive", ID_LABEL_SIZE, ID_INPUT_SIZE);
exclusive.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(exclusive);
DropDownFormGroup strength = new DropDownFormGroup<>(ID_STRENGTH, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".strength"), WebComponentUtil.createReadonlyModelFromEnum(MappingStrengthType.class), new EnumChoiceRenderer<>(this), createStringResource("MappingEditorDialog.label.strength"), "SchemaHandlingStep.mapping.tooltip.strength", ID_LABEL_SIZE, ID_INPUT_SIZE, false);
strength.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(strength);
MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".channel"), true, readOnlyModel) {
@Override
protected String createNewEmptyItem() {
return "";
}
@Override
protected IModel<List<String>> createChoiceList() {
return new IModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.getChannelList();
}
};
}
@Override
protected IChoiceRenderer<String> createRenderer() {
return CHANNEL_RENDERER;
}
};
form.add(channel);
MultiValueDropDownPanel exceptChannel = new MultiValueDropDownPanel<String>(ID_EXCEPT_CHANNEL, new PropertyModel<>(model, MappingTypeDto.F_MAPPING + ".exceptChannel"), true, readOnlyModel) {
@Override
protected String createNewEmptyItem() {
return "";
}
@Override
protected IModel<List<String>> createChoiceList() {
return new IModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.getChannelList();
}
};
}
@Override
protected IChoiceRenderer<String> createRenderer() {
return CHANNEL_RENDERER;
}
};
form.add(exceptChannel);
// TODO - create some nice ItemPathType editor in near future
MultiValueTextPanel source = new MultiValueTextPanel<>(ID_SOURCE, new PropertyModel<List<String>>(model, MappingTypeDto.F_SOURCE), readOnlyModel, true);
form.add(source);
// TODO - create some nice ItemPathType editor in near future
TextFormGroup target = new TextFormGroup(ID_TARGET, new PropertyModel<>(model, MappingTypeDto.F_TARGET), createStringResource("MappingEditorDialog.label.target"), "SchemaHandlingStep.mapping.tooltip.target", ID_LABEL_SIZE, ID_INPUT_SIZE, false, isTargetRequired);
target.setOutputMarkupId(true);
target.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(target);
DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> expressionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_EXPRESSION_TYPE, new PropertyModel<>(model, MappingTypeDto.F_EXPRESSION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<>(this), createStringResource("MappingEditorDialog.label.expressionType"), "SchemaHandlingStep.mapping.tooltip.expressionType", ID_LABEL_SIZE, ID_INPUT_SIZE, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
return new DropDownChoice<>(id, getModel(), choices, renderer);
}
};
expressionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateExpression();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_LANG));
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_POLICY_REF));
}
});
expressionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(expressionType);
DropDownFormGroup expressionLanguage = new DropDownFormGroup<>(ID_EXPRESSION_LANG, new PropertyModel<>(model, MappingTypeDto.F_EXPRESSION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.expressionLanguage", ID_LABEL_SIZE, ID_INPUT_SIZE, false);
expressionLanguage.setOutputMarkupId(true);
expressionLanguage.setOutputMarkupPlaceholderTag(true);
expressionLanguage.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getExpressionType());
}
@Override
public boolean isEnabled() {
return !readOnlyModel.getObject();
}
});
form.add(expressionLanguage);
expressionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateExpressionLanguage();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
}
});
DropDownFormGroup<ObjectReferenceType> expressionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_EXPRESSION_POLICY_REF, new PropertyModel<>(model, MappingTypeDto.F_EXPRESSION_POLICY_REF), new IModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
}
}, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.expressionValuePolicyRef", ID_LABEL_SIZE, ID_INPUT_SIZE, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
return new DropDownChoice<>(id, getModel(), choices, renderer);
}
};
expressionGeneratePolicy.setOutputMarkupId(true);
expressionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
expressionGeneratePolicy.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getExpressionType());
}
@Override
public boolean isEnabled() {
return !readOnlyModel.getObject();
}
});
expressionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateExpressionGeneratePolicy();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
}
});
form.add(expressionGeneratePolicy);
AceEditorFormGroup expression = new AceEditorFormGroup(ID_EXPRESSION, new PropertyModel<>(model, MappingTypeDto.F_EXPRESSION), createStringResource("MappingEditorDialog.label.expression"), "SchemaHandlingStep.mapping.tooltip.expression", ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
expression.setOutputMarkupId(true);
expression.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(expression);
DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> conditionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(ID_CONDITION_TYPE, new PropertyModel<>(model, MappingTypeDto.F_CONDITION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<>(this), createStringResource("MappingEditorDialog.label.conditionType"), "SchemaHandlingStep.mapping.tooltip.conditionType", ID_LABEL_SIZE, ID_INPUT_SIZE, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices, IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
return new DropDownChoice<>(id, getModel(), choices, renderer);
}
};
conditionType.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateCondition();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_LANG));
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_POLICY_REF));
}
});
form.add(conditionType);
conditionType.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
DropDownFormGroup conditionLanguage = new DropDownFormGroup<>(ID_CONDITION_LANG, new PropertyModel<>(model, MappingTypeDto.F_CONDITION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.conditionLanguage", ID_LABEL_SIZE, ID_INPUT_SIZE, false);
conditionLanguage.setOutputMarkupId(true);
conditionLanguage.setOutputMarkupPlaceholderTag(true);
conditionLanguage.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getConditionType());
}
@Override
public boolean isEnabled() {
return !readOnlyModel.getObject();
}
});
conditionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateConditionLanguage();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
}
});
form.add(conditionLanguage);
DropDownFormGroup<ObjectReferenceType> conditionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(ID_CONDITION_POLICY_REF, new PropertyModel<>(model, MappingTypeDto.F_CONDITION_POLICY_REF), new IModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
}
}, new ObjectReferenceChoiceRenderer(policyMap), createStringResource("MappingEditorDialog.label.passPolicyRef"), "SchemaHandlingStep.mapping.tooltip.conditionValuePolicyRef", ID_LABEL_SIZE, ID_INPUT_SIZE, false) {
@Override
protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices, IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
return new DropDownChoice<>(id, getModel(), choices, renderer);
}
};
conditionGeneratePolicy.setOutputMarkupId(true);
conditionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
conditionGeneratePolicy.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getConditionType());
}
@Override
public boolean isEnabled() {
return !readOnlyModel.getObject();
}
});
conditionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
model.getObject().updateConditionGeneratePolicy();
target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
}
});
form.add(conditionGeneratePolicy);
AceEditorFormGroup condition = new AceEditorFormGroup(ID_CONDITION, new PropertyModel<>(model, MappingTypeDto.F_CONDITION), createStringResource("MappingEditorDialog.label.condition"), "SchemaHandlingStep.mapping.tooltip.condition", ID_LABEL_SIZE, ID_INPUT_SIZE, false, CODE_ROW_COUNT);
condition.setOutputMarkupId(true);
condition.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(condition);
Label channelTooltip = new Label(ID_T_CHANNEL);
channelTooltip.add(new InfoTooltipBehavior());
form.add(channelTooltip);
Label exceptChannelTooltip = new Label(ID_T_EXCEPT_CHANNEL);
exceptChannelTooltip.add(new InfoTooltipBehavior());
form.add(exceptChannelTooltip);
Label sourceTooltip = new Label(ID_T_SOURCE);
sourceTooltip.add(new InfoTooltipBehavior());
form.add(sourceTooltip);
AjaxButton cancel = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("MappingEditorDialog.button.cancel")) {
@Override
public void onClick(AjaxRequestTarget target) {
cancelPerformed(target);
}
};
form.add(cancel);
AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("MappingEditorDialog.button.apply")) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target) {
target.add(getPageBase().getFeedbackPanel(), getContent());
}
};
save.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
form.add(save);
setCloseButtonCallback(new CloseButtonCallback() {
@Override
public boolean onCloseButtonClicked(AjaxRequestTarget target) {
cancelPerformed(target);
return true;
}
});
}
use of com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer in project midpoint by Evolveum.
the class ResourceCredentialsEditor method initLayout.
protected void initLayout(final PageResourceWizard parentPage) {
DropDownChoice<?> fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY, new PropertyModel<>(getModel(), "password.fetchStrategy"), WebComponentUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class), new EnumChoiceRenderer<>(this));
parentPage.addEditingEnabledBehavior(fetchStrategy);
add(fetchStrategy);
VisibleEnableBehaviour showIfEditingOrOutboundExists = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
ResourceCredentialsDefinitionType credentials = getModel().getObject();
if (credentials == null || credentials.getPassword() == null) {
return !parentPage.isReadOnly();
}
return !parentPage.isReadOnly() || credentials.getPassword().getOutbound() != null;
}
};
TextField<?> outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, (IModel<String>) () -> {
ResourceCredentialsDefinitionType credentials = getModel().getObject();
if (credentials == null || credentials.getPassword() == null) {
return null;
}
// TODO: support multiple password mappings
MappingType outbound = null;
List<MappingType> outbounds = credentials.getPassword().getOutbound();
if (!outbounds.isEmpty()) {
outbound = outbounds.get(0);
}
return MappingTypeDto.createMappingLabel(outbound, LOGGER, getPageBase().getPrismContext(), getString("MappingType.label.placeholder"), getString("MultiValueField.nameNotSpecified"));
});
outboundLabel.setEnabled(false);
outboundLabel.setOutputMarkupId(true);
outboundLabel.add(showIfEditingOrOutboundExists);
add(outboundLabel);
AjaxSubmitLink outbound = new AjaxSubmitLink(ID_OUTBOUND_BUTTON) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
outboundEditPerformed(target);
}
};
outbound.setOutputMarkupId(true);
outbound.add(showIfEditingOrOutboundExists);
add(outbound);
MultiValueTextEditPanel<?> inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND, new PropertyModel<>(getModel(), "password.inbound"), null, false, true, parentPage.getReadOnlyModel()) {
@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) {
inboundEditPerformed(target, object);
}
};
inbound.setOutputMarkupId(true);
add(inbound);
DropDownChoice<?> passwordPolicy = new DropDownChoice<>(ID_PASS_POLICY, new PropertyModel<>(getModel(), "password.passwordPolicyRef"), (IModel<List<ObjectReferenceType>>) () -> WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), passPolicyMap), new ObjectReferenceChoiceRenderer(passPolicyMap));
parentPage.addEditingEnabledBehavior(passwordPolicy);
add(passwordPolicy);
Label fetchTooltip = new Label(ID_T_FETCH);
fetchTooltip.add(new InfoTooltipBehavior());
add(fetchTooltip);
Label outTooltip = new Label(ID_T_OUT);
outTooltip.add(new InfoTooltipBehavior());
add(outTooltip);
Label inTooltip = new Label(ID_T_IN);
inTooltip.add(new InfoTooltipBehavior());
add(inTooltip);
Label passPolicyTooltip = new Label(ID_T_PASS_POLICY);
passPolicyTooltip.add(new InfoTooltipBehavior());
add(passPolicyTooltip);
initModals(parentPage.getReadOnlyModel());
}
use of com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer in project midpoint by Evolveum.
the class SynchronizationReactionEditor method initLayout.
protected void initLayout(PageResourceWizard parentPage) {
Label label = new Label(ID_LABEL, new ResourceModel("SynchronizationReactionEditor.label.edit"));
add(label);
TextField name = new TextField<>(ID_NAME, new PropertyModel<String>(getModel(), "name"));
name.add(new ReactionListUpdateBehavior());
parentPage.addEditingEnabledBehavior(name);
add(name);
TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
parentPage.addEditingEnabledBehavior(description);
add(description);
DropDownChoice situation = new DropDownChoice<>(ID_SITUATION, new PropertyModel<>(getModel(), "situation"), WebComponentUtil.createReadonlyModelFromEnum(SynchronizationSituationType.class), new EnumChoiceRenderer<>(this));
situation.setNullValid(true);
situation.add(new ReactionListUpdateBehavior());
parentPage.addEditingEnabledBehavior(situation);
situation.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
((PageResourceWizard) getPageBase()).refreshIssues(target);
}
});
add(situation);
MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<>(getModel(), "channel"), true, parentPage.getReadOnlyModel()) {
@Override
protected String createNewEmptyItem() {
return "";
}
@Override
protected IModel<List<String>> createChoiceList() {
return new IModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.getChannelList();
}
};
}
@Override
protected IChoiceRenderer<String> createRenderer() {
return CHANNEL_RENDERER;
}
};
add(channel);
TriStateComboPanel synchronize = new TriStateComboPanel(ID_SYNCHRONIZE, new PropertyModel<>(getModel(), "synchronize"));
synchronize.getBaseFormComponent().add(new ReactionListUpdateBehavior());
parentPage.addEditingEnabledBehavior(synchronize);
add(synchronize);
CheckBox reconcile = new CheckBox(ID_RECONCILE, new PropertyModel<>(getModel(), "reconcile"));
parentPage.addEditingEnabledBehavior(reconcile);
add(reconcile);
DropDownChoice objectTemplateRef = new DropDownChoice<>(ID_OBJECT_TEMPLATE_REF, new PropertyModel<>(getModel(), "objectTemplateRef"), new IModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), objectTemplateMap);
}
}, new ObjectReferenceChoiceRenderer(objectTemplateMap));
objectTemplateRef.setNullValid(true);
parentPage.addEditingEnabledBehavior(objectTemplateRef);
add(objectTemplateRef);
MultiValueTextEditPanel action = new MultiValueTextEditPanel<SynchronizationActionType>(ID_ACTION, new PropertyModel<>(getModel(), "action"), null, false, true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<SynchronizationActionType> model) {
return new Model<String>() {
@Override
public String getObject() {
SynchronizationActionType action = model.getObject();
if (action == null) {
return null;
}
StringBuilder sb = new StringBuilder();
sb.append(action.getName() != null ? action.getName() : "-");
if (action.getHandlerUri() != null) {
sb.append(" (").append(StringUtils.substringAfter(action.getHandlerUri(), "#")).append(")");
}
return sb.toString();
}
};
}
@Override
protected void performAddValueHook(AjaxRequestTarget target, SynchronizationActionType added) {
target.add(parentStep.getReactionList());
((PageResourceWizard) getPageBase()).refreshIssues(target);
}
@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationActionType> item) {
target.add(parentStep.getReactionList());
((PageResourceWizard) getPageBase()).refreshIssues(target);
}
@Override
protected SynchronizationActionType createNewEmptyItem() {
return new SynchronizationActionType();
}
@Override
protected void editPerformed(AjaxRequestTarget target, SynchronizationActionType object) {
actionEditPerformed(target, object);
}
};
action.setOutputMarkupId(true);
add(action);
Label situationTooltip = new Label(ID_T_SITUATION);
situationTooltip.add(new InfoTooltipBehavior());
add(situationTooltip);
Label channelTooltip = new Label(ID_T_CHANNEL);
channelTooltip.add(new InfoTooltipBehavior());
add(channelTooltip);
Label synchronizeTooltip = new Label(ID_T_SYNCHRONIZE);
synchronizeTooltip.add(new InfoTooltipBehavior());
add(synchronizeTooltip);
Label reconcileTooltip = new Label(ID_T_RECONCILE);
reconcileTooltip.add(new InfoTooltipBehavior());
add(reconcileTooltip);
Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
objTemplateTooltip.add(new InfoTooltipBehavior());
add(objTemplateTooltip);
Label actionTooltip = new Label(ID_T_ACTION);
actionTooltip.add(new InfoTooltipBehavior());
add(actionTooltip);
initModals();
}
Aggregations