use of com.evolveum.midpoint.web.util.InfoTooltipBehavior in project midpoint by Evolveum.
the class SynchronizationStep method initObjectSyncEditor.
private void initObjectSyncEditor(WebMarkupContainer editor) {
Label editorLabel = new Label(ID_EDITOR_LABEL, new AbstractReadOnlyModel<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<ShadowKindType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
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<List<QName>>(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 AbstractReadOnlyModel<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<QName>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".focusType"), new AbstractReadOnlyModel<List<QName>>() {
@Override
public List<QName> getObject() {
return 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<Boolean>(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, Form<?> form) {
conditionEditPerformed(target);
}
};
addDisableClassModifier(editorCondition);
editor.add(editorCondition);
AjaxSubmitLink editorConfirmation = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONFIRMATION) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
confirmationEditPerformed(target);
}
};
addDisableClassModifier(editorConfirmation);
editor.add(editorConfirmation);
DropDownChoice editorObjectTemplate = new DropDownChoice<>(ID_EDITOR_OBJECT_TEMPLATE, new PropertyModel<ObjectReferenceType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectTemplateRef"), new AbstractReadOnlyModel<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<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
parentPage.addEditingEnabledBehavior(editorReconcile);
editor.add(editorReconcile);
TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
parentPage.addEditingEnabledBehavior(opportunistic);
editor.add(opportunistic);
MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION, new PropertyModel<List<ConditionalSearchFilterType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".correlation"), new PropertyModel<ConditionalSearchFilterType>(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<List<SynchronizationReactionType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reaction"), new PropertyModel<SynchronizationReactionType>(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 {
// TODO i18n
sb.append("sync");
}
}
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.util.InfoTooltipBehavior in project midpoint by Evolveum.
the class SchemaListPanel method initDetailsPanel.
private void initDetailsPanel(WebMarkupContainer parent) {
WebMarkupContainer detailsContainer = new WebMarkupContainer(ID_DETAILS_PANEL);
detailsContainer.setOutputMarkupId(true);
detailsContainer.setOutputMarkupPlaceholderTag(true);
parent.add(detailsContainer);
Label displayName = new Label(ID_DETAILS_DISPLAY_NAME, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_DISPLAY_NAME));
detailsContainer.add(displayName);
Label description = new Label(ID_DETAILS_DESCRIPTION, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_DESCRIPTION));
detailsContainer.add(description);
Label kind = new Label(ID_DETAILS_KIND, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_KIND));
detailsContainer.add(kind);
Label intent = new Label(ID_DETAILS_INTENT, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_INTENT));
detailsContainer.add(intent);
Label nativeObjectClass = new Label(ID_DETAILS_NATIVE_OBJECT_CLASS, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_NATIVE_OBJECT_CLASS));
detailsContainer.add(nativeObjectClass);
CheckBox isDefault = new CheckBox(ID_DETAILS_DEFAULT, new PropertyModel<Boolean>(detailsModel, ObjectClassDetailsDto.F_IS_DEFAULT));
isDefault.setEnabled(false);
detailsContainer.add(isDefault);
Label kindTooltip = new Label(ID_T_KIND);
kindTooltip.add(new InfoTooltipBehavior());
detailsContainer.add(kindTooltip);
Label intentTooltip = new Label(ID_T_INTENT);
intentTooltip.add(new InfoTooltipBehavior());
detailsContainer.add(intentTooltip);
Label nativeObjClassTooltip = new Label(ID_T_NATIVE_OBJECT_CLASS);
nativeObjClassTooltip.add(new InfoTooltipBehavior());
detailsContainer.add(nativeObjClassTooltip);
Label defaultTooltip = new Label(ID_T_DEFAULT);
defaultTooltip.add(new InfoTooltipBehavior());
detailsContainer.add(defaultTooltip);
}
use of com.evolveum.midpoint.web.util.InfoTooltipBehavior in project midpoint by Evolveum.
the class TaskSchedulingTabPanel method initLayoutForSchedulingTable.
private void initLayoutForSchedulingTable() {
// models
final IModel<Boolean> recurringCheckModel = new PropertyModel<>(taskDtoModel, TaskDto.F_RECURRING);
final IModel<Boolean> boundCheckModel = new PropertyModel<Boolean>(taskDtoModel, TaskDto.F_BOUND);
// behaviors
final VisibleEnableBehaviour visibleIfEditAndRunnableOrRunning = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return parentPage.isEdit() && parentPage.getTaskDto().isRunnableOrRunning();
}
};
final VisibleEnableBehaviour visibleIfRecurringAndScheduleIsAccessible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && !boundCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && (!parentPage.getTaskDto().isRunnableOrRunning() || !boundCheckModel.getObject()) && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndNotRunningAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunning() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndThreadStopIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_THREAD_STOP_ACTION));
}
};
// components
final WebMarkupContainer schedulingTable = new WebMarkupContainer(ID_SCHEDULING_TABLE);
schedulingTable.setOutputMarkupId(true);
add(schedulingTable);
WebMarkupContainer recurringContainer = new WebMarkupContainer(ID_RECURRING_CONTAINER);
AjaxCheckBox recurringCheck = new AjaxCheckBox(ID_RECURRING_CHECK, recurringCheckModel) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(schedulingTable);
}
};
recurringCheck.setOutputMarkupId(true);
recurringCheck.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_RECURRENCE);
}
});
recurringContainer.add(recurringCheck);
WebMarkupContainer suspendReqRecurring = new WebMarkupContainer(ID_SUSPEND_REQ_RECURRING);
suspendReqRecurring.add(visibleIfEditAndRunnableOrRunning);
recurringContainer.add(suspendReqRecurring);
recurringContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_RECURRENCE));
schedulingTable.add(recurringContainer);
final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
boundContainer.setOutputMarkupId(true);
final AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND_CHECK, boundCheckModel) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(schedulingTable);
}
};
bound.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_BINDING);
}
});
boundContainer.add(bound);
WebMarkupContainer suspendReqBound = new WebMarkupContainer(ID_SUSPEND_REQ_BOUND);
suspendReqBound.add(visibleIfEditAndRunnableOrRunning);
boundContainer.add(suspendReqBound);
boundContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_BINDING));
}
});
Label boundHelp = new Label(ID_BOUND_HELP);
boundHelp.add(new InfoTooltipBehavior());
boundContainer.add(boundHelp);
schedulingTable.add(boundContainer);
WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
intervalContainer.add(visibleIfRecurringAndScheduleIsAccessible);
intervalContainer.setOutputMarkupId(true);
schedulingTable.add(intervalContainer);
TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_INTERVAL));
interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
interval.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
intervalContainer.add(interval);
WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
cronContainer.add(visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible);
cronContainer.setOutputMarkupId(true);
schedulingTable.add(cronContainer);
TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(taskDtoModel, TaskDto.F_CRON_SPECIFICATION));
cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
cron.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
cronContainer.add(cron);
Label cronHelp = new Label(ID_CRON_HELP);
cronHelp.add(new InfoTooltipBehavior());
cronContainer.add(cronHelp);
WebMarkupContainer notStartBeforeContainer = new WebMarkupContainer(ID_NOT_START_BEFORE_CONTAINER);
DateInput notStartBefore = new DateInput(ID_NOT_START_BEFORE_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_BEFORE));
notStartBefore.setOutputMarkupId(true);
notStartBefore.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
notStartBeforeContainer.add(notStartBefore);
notStartBeforeContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(notStartBeforeContainer);
WebMarkupContainer notStartAfterContainer = new WebMarkupContainer(ID_NOT_START_AFTER_CONTAINER);
DateInput notStartAfter = new DateInput(ID_NOT_START_AFTER_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_AFTER));
notStartAfter.setOutputMarkupId(true);
notStartAfter.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
notStartAfterContainer.add(notStartAfter);
notStartAfterContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(notStartAfterContainer);
WebMarkupContainer misfireActionContainer = new WebMarkupContainer(ID_MISFIRE_ACTION_CONTAINER);
DropDownChoice misfire = new DropDownChoice(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(taskDtoModel, TaskDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(parentPage));
misfire.add(enabledIfEditAndScheduleIsEditable);
misfireActionContainer.add(misfire);
misfireActionContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(misfireActionContainer);
WebMarkupContainer threadStopContainer = new WebMarkupContainer(ID_THREAD_STOP_CONTAINER);
DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {
@Override
public ThreadStopActionType getObject() {
return taskDtoModel.getObject().getThreadStopActionType();
}
@Override
public void setObject(ThreadStopActionType object) {
taskDtoModel.getObject().setThreadStopActionType(object);
}
}, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(parentPage));
threadStop.add(enabledIfEditAndThreadStopIsEditable);
threadStopContainer.add(threadStop);
threadStopContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_THREAD_STOP_ACTION));
schedulingTable.add(threadStopContainer);
org.apache.wicket.markup.html.form.Form<?> form = parentPage.getForm();
// TODO implement more intelligently when other tabs have validators as well
for (IFormValidator validator : form.getFormValidators()) {
form.remove(validator);
}
form.add(new StartEndDateValidator(notStartBefore, notStartAfter));
form.add(new ScheduleValidator(parentPage.getTaskManager(), recurringCheck, bound, interval, cron));
}
use of com.evolveum.midpoint.web.util.InfoTooltipBehavior in project midpoint by Evolveum.
the class WebComponentUtil method createHelp.
public static Component createHelp(String id) {
Label helpLabel = new Label(id);
helpLabel.add(new InfoTooltipBehavior());
return helpLabel;
}
use of com.evolveum.midpoint.web.util.InfoTooltipBehavior in project midpoint by Evolveum.
the class MappingEditorDialog method initLayout.
public void initLayout(WebMarkupContainer content) {
Form form = new Form(ID_MAIN_FORM);
form.setOutputMarkupId(true);
content.add(form);
TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(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<String>(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<Boolean>(model, MappingTypeDto.F_MAPPING + ".authoritative"), createStringResource("MappingEditorDialog.label.authoritative"), "SchemaHandlingStep.mapping.tooltip.authoritative", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
authoritative.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(authoritative);
CheckFormGroup exclusive = new CheckFormGroup(ID_EXCLUSIVE, new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".exclusive"), createStringResource("MappingEditorDialog.label.exclusive"), "SchemaHandlingStep.mapping.tooltip.exclusive", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
exclusive.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(exclusive);
DropDownFormGroup strength = new DropDownFormGroup<>(ID_STRENGTH, new PropertyModel<MappingStrengthType>(model, MappingTypeDto.F_MAPPING + ".strength"), WebComponentUtil.createReadonlyModelFromEnum(MappingStrengthType.class), new EnumChoiceRenderer<MappingStrengthType>(this), createStringResource("MappingEditorDialog.label.strength"), "SchemaHandlingStep.mapping.tooltip.strength", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
strength.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
form.add(strength);
MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".channel"), true, readOnlyModel) {
@Override
protected String createNewEmptyItem() {
return "";
}
@Override
protected IModel<List<String>> createChoiceList() {
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.getChannelList();
}
};
}
@Override
protected IChoiceRenderer<String> createRenderer() {
return new StringChoiceRenderer("Channel.", "#");
}
};
form.add(channel);
MultiValueDropDownPanel exceptChannel = new MultiValueDropDownPanel<String>(ID_EXCEPT_CHANNEL, new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".exceptChannel"), true, readOnlyModel) {
@Override
protected String createNewEmptyItem() {
return "";
}
@Override
protected IModel<List<String>> createChoiceList() {
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.getChannelList();
}
};
}
@Override
protected IChoiceRenderer<String> createRenderer() {
return new StringChoiceRenderer("Channel.", "#");
}
};
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<String>(model, MappingTypeDto.F_TARGET), createStringResource("MappingEditorDialog.label.target"), "SchemaHandlingStep.mapping.tooltip.target", true, 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<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_EXPRESSION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.expressionType"), "SchemaHandlingStep.mapping.tooltip.expressionType", true, 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<ExpressionUtil.Language>(model, MappingTypeDto.F_EXPRESSION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.expressionLanguage", true, 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<ObjectReferenceType>(model, MappingTypeDto.F_EXPRESSION_POLICY_REF), new AbstractReadOnlyModel<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", true, 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<String>(model, MappingTypeDto.F_EXPRESSION), createStringResource("MappingEditorDialog.label.expression"), "SchemaHandlingStep.mapping.tooltip.expression", true, 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<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_CONDITION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this), createStringResource("MappingEditorDialog.label.conditionType"), "SchemaHandlingStep.mapping.tooltip.conditionType", true, 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<ExpressionUtil.Language>(model, MappingTypeDto.F_CONDITION_LANG), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this), createStringResource("MappingEditorDialog.label.language"), "SchemaHandlingStep.mapping.tooltip.conditionLanguage", true, 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<ObjectReferenceType>(model, MappingTypeDto.F_CONDITION_POLICY_REF), new AbstractReadOnlyModel<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", true, 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<String>(model, MappingTypeDto.F_CONDITION), createStringResource("MappingEditorDialog.label.condition"), "SchemaHandlingStep.mapping.tooltip.condition", true, 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(true));
form.add(channelTooltip);
Label exceptChannelTooltip = new Label(ID_T_EXCEPT_CHANNEL);
exceptChannelTooltip.add(new InfoTooltipBehavior(true));
form.add(exceptChannelTooltip);
Label sourceTooltip = new Label(ID_T_SOURCE);
sourceTooltip.add(new InfoTooltipBehavior(true));
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, Form<?> form) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getPageBase().getFeedbackPanel(), getContent());
}
};
save.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
form.add(save);
}
Aggregations