use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior 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 placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<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.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class MultiValueChoosePanel method initLayout.
private void initLayout(final IModel<List<T>> chosenValues, final List<PrismReferenceValue> filterValues, final boolean required, final boolean multiselect) {
AjaxLink<String> edit = new AjaxLink<String>(ID_EDIT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editValuePerformed(chosenValues.getObject(), filterValues, target, multiselect);
}
};
edit.setOutputMarkupPlaceholderTag(true);
add(edit);
ListView<T> selectedRowsList = new ListView<T>(ID_SELECTED_ROWS, chosenValues) {
@Override
protected void populateItem(ListItem<T> item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.setOutputMarkupPlaceholderTag(true);
//was value
TextField<String> text = new TextField<String>(ID_TEXT, createTextModel(item.getModel()));
text.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
}
});
text.setRequired(required);
text.setEnabled(false);
text.setOutputMarkupPlaceholderTag(true);
textWrapper.add(text);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
feedback.setOutputMarkupPlaceholderTag(true);
textWrapper.add(feedback);
initButtons(item, item);
item.add(textWrapper);
}
};
selectedRowsList.setReuseItems(true);
add(selectedRowsList);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior 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.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ItemPathPanel method initLayout.
private void initLayout() {
ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, new AbstractReadOnlyModel<ItemPathDto>() {
private static final long serialVersionUID = 1L;
public ItemPathDto getObject() {
return ItemPathPanel.this.getModelObject();
}
}) {
private static final long serialVersionUID = 1L;
@Override
protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
return initNamspaceDefinitionMap();
}
};
itemDefPanel.setOutputMarkupId(true);
add(itemDefPanel);
AjaxButton plusButton = new AjaxButton(ID_PLUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
}
};
plusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
return true;
}
return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
}
});
plusButton.setOutputMarkupId(true);
add(plusButton);
AjaxButton minusButton = new AjaxButton(ID_MINUS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ItemPathDto path = ItemPathPanel.this.getModelObject();
// ItemPathDto parent = null;
// if (path.getItemDef() == null){
// parent = path.getParentPath();
// } else {
// parent = path;
// }
refreshItemPathPanel(path, false, target);
}
};
minusButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
}
});
minusButton.setOutputMarkupId(true);
add(minusButton);
DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<QName>(ID_NAMESPACE, new PropertyModel<QName>(getModel(), "objectType"), new ListModel<QName>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
refreshItemPath(ItemPathPanel.this.getModelObject(), target);
}
});
namespacePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
}
});
namespacePanel.setOutputMarkupId(true);
add(namespacePanel);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method initLayout.
protected void initLayout() {
final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label"));
add(label);
ListView<ObjectPolicyConfigurationTypeDto> repeater = new ListView<ObjectPolicyConfigurationTypeDto>(ID_REPEATER, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<ObjectPolicyConfigurationTypeDto> item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (item.getIndex() > 0) {
return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(textWrapper);
TextField<String> name = new TextField<>(ID_NAME, createNameModel(item.getModel()));
name.setOutputMarkupId(true);
name.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
name.setEnabled(false);
name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder")));
textWrapper.add(name);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name));
textWrapper.add(feedback);
AjaxLink<String> edit = new AjaxLink<String>(ID_BUTTON_EDIT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editPerformed(target, item);
}
};
textWrapper.add(edit);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (item.getIndex() > 0) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(buttonGroup);
initButtons(buttonGroup, item);
}
};
// initDialog();
repeater.setOutputMarkupId(true);
add(repeater);
}
Aggregations