use of org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings in project midpoint by Evolveum.
the class PageTaskAdd method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_FORM_MAIN);
add(mainForm);
final DropDownChoice resource = new DropDownChoice<>(ID_RESOURCE, new PropertyModel<TaskAddResourcesDto>(model, TaskAddDto.F_RESOURCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {
@Override
public List<TaskAddResourcesDto> getObject() {
return createResourceList();
}
}, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
resource.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
return sync || recon || importAccounts;
}
});
resource.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
PageTaskAdd.this.loadResource();
target.add(get(ID_FORM_MAIN + ":" + ID_OBJECT_CLASS));
}
});
resource.setOutputMarkupId(true);
mainForm.add(resource);
final DropDownChoice focusType = new DropDownChoice<>(ID_FOCUS_TYPE, new PropertyModel<QName>(model, TaskAddDto.F_FOCUS_TYPE), new AbstractReadOnlyModel<List<QName>>() {
@Override
public List<QName> getObject() {
return createFocusTypeList();
}
}, new QNameChoiceRenderer());
focusType.setOutputMarkupId(true);
focusType.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
return TaskCategory.RECOMPUTATION.equals(dto.getCategory());
}
});
mainForm.add(focusType);
final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(model, TaskAddDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
kind.setOutputMarkupId(true);
kind.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
return sync || recon || importAccounts;
}
});
mainForm.add(kind);
final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(model, TaskAddDto.F_INTENT));
mainForm.add(intent);
intent.setOutputMarkupId(true);
intent.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
return sync || recon || importAccounts;
}
});
if (model.getObject() != null && model.getObject().getResource() != null && model.getObject().getResource().getOid() != null) {
loadResource();
}
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setMaxHeightInPx(200);
final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(model, TaskAddDto.F_OBJECT_CLASS), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return prepareObjectClassChoiceList(input);
}
};
objectClass.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
TaskAddDto dto = model.getObject();
boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
return sync || recon || importAccounts;
}
});
mainForm.add(objectClass);
DropDownChoice type = new DropDownChoice<>(ID_CATEGORY, new PropertyModel<String>(model, TaskAddDto.F_CATEGORY), new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return WebComponentUtil.createTaskCategoryList();
}
}, new StringChoiceRenderer("pageTask.category."));
type.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(resource);
target.add(intent);
target.add(kind);
target.add(objectClass);
target.add(focusType);
}
});
type.setRequired(true);
mainForm.add(type);
TextField<String> name = new TextField<>(ID_NAME, new PropertyModel<String>(model, TaskAddDto.F_NAME));
name.setRequired(true);
mainForm.add(name);
initScheduling(mainForm);
initAdvanced(mainForm);
CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(model, TaskAddDto.F_DRY_RUN));
mainForm.add(dryRun);
initButtons(mainForm);
}
use of org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings in project midpoint by Evolveum.
the class MultiValueAutoCompleteTextPanel method initLayout.
private void initLayout(final boolean inputEnabled, final NonEmptyModel<Boolean> readOnlyModel) {
WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.setOutputMarkupPlaceholderTag(true);
placeholderContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModel().getObject().isEmpty();
}
});
add(placeholderContainer);
AjaxLink<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) {
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setMaxHeightInPx(200);
AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT, createTextModel(item.getModel()), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return createAutoCompleteObjectList(input);
}
};
autoCompleteEditor.add(createAutoCompleteValidator());
autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
item.add(autoCompleteEditor);
autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
if (!inputEnabled) {
autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
}
item.add(autoCompleteEditor);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
item.add(buttonGroup);
initButtons(buttonGroup, item, readOnlyModel);
}
};
repeater.setOutputMarkupId(true);
repeater.setOutputMarkupPlaceholderTag(true);
repeater.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isEmpty();
}
});
add(repeater);
}
use of org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings in project midpoint by Evolveum.
the class AutoCompleteTextPanel method createAutoCompleteSettings.
@Override
protected AutoCompleteSettings createAutoCompleteSettings() {
AutoCompleteSettings settings = super.createAutoCompleteSettings();
settings.setThrottleDelay(500);
return settings;
}
use of org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings in project midpoint by Evolveum.
the class SchemaHandlingStep method initObjectTypeEditor.
private void initObjectTypeEditor(WebMarkupContainer editor) {
Label editorLabel = new Label(ID_EDITOR_NAME, (IModel<Object>) () -> {
ResourceObjectTypeDefinitionTypeDto selected = schemaHandlingDtoModel.getObject().getSelectedObjectTypeDto();
return selected != null ? selected.getObjectType().getDisplayName() : "";
});
editorLabel.setOutputMarkupId(true);
editor.add(editorLabel);
DropDownChoice<?> editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_KIND)), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<>(this));
editorKind.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorKind);
editor.add(editorKind);
TextField<?> editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_INTENT)));
editorIntent.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorIntent);
editor.add(editorIntent);
TextField<?> editorDisplayName = new TextField<>(ID_EDITOR_DISPLAY_NAME, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DISPLAY_NAME)));
editorDisplayName.add(new UpdateNamesBehaviour());
parentPage.addEditingEnabledBehavior(editorDisplayName);
editor.add(editorDisplayName);
TextArea<?> editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DESCRIPTION)));
parentPage.addEditingEnabledBehavior(editorDescription);
editor.add(editorDescription);
final CheckBox editorDefault = new CheckBox(ID_EDITOR_DEFAULT, new PropertyModel<>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_DEFAULT)));
editorDefault.add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
Boolean newValue = editorDefault.getModelObject();
if (Boolean.TRUE.equals(newValue)) {
SchemaHandlingDto dto = schemaHandlingDtoModel.getObject();
ResourceObjectTypeDefinitionTypeDto selected = dto.getSelectedObjectTypeDto();
ShadowKindType selectedKind = fillDefault(selected.getObjectType().getKind());
for (ResourceObjectTypeDefinitionTypeDto currentObjectTypeDto : dto.getObjectTypeDtoList()) {
ShadowKindType currentKind = fillDefault(currentObjectTypeDto.getObjectType().getKind());
if (currentObjectTypeDto != selected && currentKind == selectedKind && Boolean.TRUE.equals(currentObjectTypeDto.getObjectType().isDefault())) {
currentObjectTypeDto.getObjectType().setDefault(false);
}
}
}
parentPage.refreshIssues(target);
}
});
parentPage.addEditingEnabledBehavior(editorDefault);
editor.add(editorDefault);
AjaxSubmitLink editorDependency = new AjaxSubmitLink(ID_EDITOR_BUTTON_DEPENDENCY) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
dependencyEditPerformed(target);
}
};
addDisabledClassModifier(editorDependency);
editor.add(editorDependency);
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
autoCompleteSettings.setMaxHeightInPx(200);
AutoCompleteTextField<String> editorObjectClass = new AutoCompleteTextField<String>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_CLASS_NAME), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return getObjectClassChoices(input);
}
};
editorObjectClass.add(new UpdateNamesBehaviour());
editorObjectClass.add(createObjectClassValidator((IModel<List<QName>>) () -> schemaHandlingDtoModel.getObject().getObjectClassList()));
parentPage.addEditingEnabledBehavior(editorObjectClass);
editorObjectClass.setConvertEmptyInputStringToNull(true);
editor.add(editorObjectClass);
MultiValueTextEditPanel<?> editorAttributes = new MultiValueTextEditPanel<ResourceAttributeDefinitionType>(ID_EDITOR_ATTRIBUTES, new PropertyModel<>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_ATTRIBUTE)), new PropertyModel<>(schemaHandlingDtoModel, SchemaHandlingDto.F_SELECTED_ATTRIBUTE), false, true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<ResourceAttributeDefinitionType> model) {
return new Model<String>() {
@Override
public String getObject() {
if (model == null || model.getObject() == null) {
return null;
}
ResourceAttributeDefinitionType attribute = model.getObject();
return formatItemInfo(attribute, attribute.getRef(), attribute.getDisplayName(), attribute.getInbound(), attribute.getOutbound());
}
};
}
@Override
protected ResourceAttributeDefinitionType createNewEmptyItem() {
return createEmptyAttributeObject();
}
@Override
protected void performAddValueHook(AjaxRequestTarget target, ResourceAttributeDefinitionType added) {
parentPage.refreshIssues(target);
}
@Override
protected void editPerformed(AjaxRequestTarget target, ResourceAttributeDefinitionType object) {
editAttributePerformed(target, object);
}
@Override
protected boolean buttonsDisabled() {
return !isAnySelected();
}
@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ResourceAttributeDefinitionType> item) {
resetThirdRowContainer(target);
parentPage.refreshIssues(target);
}
};
editorAttributes.setOutputMarkupId(true);
editor.add(editorAttributes);
MultiValueTextEditPanel<?> editorAssociations = new MultiValueTextEditPanel<ResourceObjectAssociationType>(ID_EDITOR_ASSOCIATIONS, new PropertyModel<>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_ASSOCIATION)), new PropertyModel<>(schemaHandlingDtoModel, SchemaHandlingDto.F_SELECTED_ASSOCIATION), false, true, parentPage.getReadOnlyModel()) {
@Override
protected IModel<String> createTextModel(final IModel<ResourceObjectAssociationType> model) {
return new Model<String>() {
@Override
public String getObject() {
ResourceObjectAssociationType association = model.getObject();
if (association == null) {
return null;
}
return formatItemInfo(association, association.getRef(), association.getDisplayName(), association.getInbound(), association.getOutbound());
}
};
}
@Override
protected ResourceObjectAssociationType createNewEmptyItem() {
return createEmptyAssociationObject();
}
@Override
protected void performAddValueHook(AjaxRequestTarget target, ResourceObjectAssociationType added) {
parentPage.refreshIssues(target);
}
@Override
protected void editPerformed(AjaxRequestTarget target, ResourceObjectAssociationType object) {
editAssociationPerformed(target, object);
}
@Override
protected boolean buttonsDisabled() {
return !isAnySelected();
}
@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ResourceObjectAssociationType> item) {
resetThirdRowContainer(target);
parentPage.refreshIssues(target);
}
};
editorAssociations.setOutputMarkupId(true);
editor.add(editorAssociations);
// DropDownChoice editorAssignmentPolicyRef = new DropDownChoice<>(ID_EDITOR_ASSIGNMENT_POLICY,
// new PropertyModel<AssignmentPolicyEnforcementType>(schemaHandlingDtoModel,
// getExpression(ResourceObjectTypeDefinitionType.F_ASSIGNMENT_POLICY_ENFORCEMENT)),
// WebComponentUtil.createReadonlyModelFromEnum(AssignmentPolicyEnforcementType.class),
// new EnumChoiceRenderer<AssignmentPolicyEnforcementType>(this));
// parentPage.addEditingEnabledBehavior(editorAssignmentPolicyRef);
// editor.add(editorAssignmentPolicyRef);
AjaxSubmitLink editorIteration = new AjaxSubmitLink(ID_EDITOR_BUTTON_ITERATION) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
iterationEditPerformed(target);
}
};
addDisabledClassModifier(editorIteration);
editor.add(editorIteration);
AjaxSubmitLink editorProtected = new AjaxSubmitLink(ID_EDITOR_BUTTON_PROTECTED) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
protectedEditPerformed(target);
}
};
addDisabledClassModifier(editorProtected);
editor.add(editorProtected);
AjaxSubmitLink editorActivation = new AjaxSubmitLink(ID_EDITOR_BUTTON_ACTIVATION) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
activationEditPerformed(target);
}
};
addDisabledClassModifier(editorActivation);
editor.add(editorActivation);
AjaxSubmitLink editorCredentials = new AjaxSubmitLink(ID_EDITOR_BUTTON_CREDENTIALS) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
credentialsEditPerformed(target);
}
};
addDisabledClassModifier(editorCredentials);
editor.add(editorCredentials);
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 defaultTooltip = new Label(ID_T_DEFAULT);
defaultTooltip.add(new InfoTooltipBehavior());
editor.add(defaultTooltip);
Label dependencyTooltip = new Label(ID_T_DEPENDENCY);
dependencyTooltip.add(new InfoTooltipBehavior());
editor.add(dependencyTooltip);
Label objectClassTooltip = new Label(ID_T_OBJECT_CLASS);
objectClassTooltip.add(new InfoTooltipBehavior());
editor.add(objectClassTooltip);
Label attributesTooltip = new Label(ID_T_ATTRIBUTES);
attributesTooltip.add(new InfoTooltipBehavior());
editor.add(attributesTooltip);
Label associationsTooltip = new Label(ID_T_ASSOCIATIONS);
associationsTooltip.add(new InfoTooltipBehavior());
editor.add(associationsTooltip);
Label iterationTooltip = new Label(ID_T_ITERATION);
iterationTooltip.add(AttributeAppender.append("title", createStringResource("SchemaHandlingStep.tooltip.iteration", WebComponentUtil.getMidpointCustomSystemName(getPageBase(), "midpoint.default.system.name"))));
iterationTooltip.add(new InfoTooltipBehavior());
editor.add(iterationTooltip);
Label protectedTooltip = new Label(ID_T_PROTECTED);
protectedTooltip.add(new InfoTooltipBehavior());
editor.add(protectedTooltip);
Label activationTooltip = new Label(ID_T_ACTIVATION);
activationTooltip.add(new InfoTooltipBehavior());
editor.add(activationTooltip);
Label credentialsTooltip = new Label(ID_T_CREDENTIALS);
credentialsTooltip.add(new InfoTooltipBehavior());
editor.add(credentialsTooltip);
}
Aggregations