use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class AssignmentCatalogPanel method initViewSelector.
private void initViewSelector(WebMarkupContainer headerPanel) {
DropDownChoice<AssignmentViewType> viewSelect = new DropDownChoice(ID_VIEW_TYPE, viewModel, Model.ofList(viewTypeList != null && viewTypeList.size() > 0 ? viewTypeList : createAssignableTypesList()), new EnumChoiceRenderer<AssignmentViewType>(this));
viewSelect.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
if (AssignmentViewType.USER_TYPE.equals(viewSelect.getModelObject())) {
initUserViewSelectionPopup(createStringResource("AssignmentCatalogPanel.selectAssignmentsUserOwner"), target);
} else {
AssignmentCatalogPanel.this.addOrReplaceLayout(target, getCatalogItemsPanelContainer());
target.add(getCatalogItemsPanelContainer());
target.add(getHeaderPanel());
}
}
});
viewSelect.setOutputMarkupId(true);
headerPanel.add(viewSelect);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class PageAccounts method initSearchForm.
private void initSearchForm(Form searchForm) {
BasicSearchPanel<AccountDetailsSearchDto> basicSearch = new BasicSearchPanel<AccountDetailsSearchDto>(ID_SEARCH_BASIC) {
@Override
protected IModel<String> createSearchTextModel() {
return new PropertyModel<>(searchModel, AccountDetailsSearchDto.F_SEARCH_TEXT);
}
@Override
protected void searchPerformed(AjaxRequestTarget target) {
PageAccounts.this.searchPerformed(target);
}
@Override
protected void clearSearchPerformed(AjaxRequestTarget target) {
PageAccounts.this.clearSearchPerformed(target);
}
};
basicSearch.setOutputMarkupId(true);
searchForm.add(basicSearch);
DropDownChoice failedOperationType = new DropDownChoice<>(ID_SEARCH_FAILED_OPERATION_TYPE, new PropertyModel<FailedOperationTypeType>(searchModel, AccountDetailsSearchDto.F_FAILED_OPERATION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(FailedOperationTypeType.class), new EnumChoiceRenderer<FailedOperationTypeType>(this));
failedOperationType.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
failedOperationType.setOutputMarkupId(true);
failedOperationType.setNullValid(true);
searchForm.add(failedOperationType);
DropDownChoice kind = new DropDownChoice<>(ID_SEARCH_KIND, new PropertyModel<ShadowKindType>(searchModel, AccountDetailsSearchDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
kind.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
kind.setOutputMarkupId(true);
kind.setNullValid(true);
searchForm.add(kind);
DropDownChoice intent = new DropDownChoice<>(ID_SEARCH_INTENT, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_INTENT), createIntentChoices(), new StringChoiceRenderer(null));
intent.setNullValid(true);
intent.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
intent.setOutputMarkupId(true);
searchForm.add(intent);
AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_SEARCH_OBJECT_CLASS, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_OBJECT_CLASS)) {
@Override
protected Iterator<String> getChoices(String input) {
if (Strings.isEmpty(input)) {
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
}
AccountDetailsSearchDto dto = searchModel.getObject();
List<QName> accountObjectClassList = dto.getObjectClassList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);
for (QName s : accountObjectClassList) {
if (s.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) {
choices.add(s.getLocalPart());
if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
break;
}
}
}
return choices.iterator();
}
};
objectClass.add(AttributeModifier.replace("placeholder", createStringResource("PageAccounts.accounts.objectClass")));
objectClass.setOutputMarkupId(true);
objectClass.add(createObjectClassValidator());
objectClass.add(new SearchFormEnterBehavior(basicSearch.getSearchButton()));
searchForm.add(objectClass);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class PageEvaluateMapping method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
AceEditor editorMapping = new AceEditor(ID_EDITOR_MAPPING, new PropertyModel<String>(model, ExecuteMappingDto.F_MAPPING));
editorMapping.setHeight(400);
editorMapping.setResizeToMaxHeight(false);
mainForm.add(editorMapping);
AceEditor editorRequest = new AceEditor(ID_EDITOR_REQUEST, new PropertyModel<String>(model, ExecuteMappingDto.F_REQUEST));
editorRequest.setHeight(430);
editorRequest.setResizeToMaxHeight(false);
mainForm.add(editorRequest);
AjaxSubmitButton evaluateMapping = new AjaxSubmitButton(ID_EXECUTE, createStringResource("PageEvaluateMapping.button.evaluateMapping")) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
executeMappingPerformed(target);
}
};
mainForm.add(evaluateMapping);
final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_MAPPING_SAMPLE, Model.of(""), new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return SAMPLES;
}
}, new StringResourceChoiceRenderer("PageEvaluateMapping.sample"));
sampleChoice.setNullValid(true);
sampleChoice.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
String sampleName = sampleChoice.getModelObject();
if (StringUtils.isEmpty(sampleName)) {
return;
}
model.getObject().setMapping(readResource(SAMPLES_DIR + "/" + sampleName + ".map.xml.data"));
model.getObject().setRequest(readResource(SAMPLES_DIR + "/" + sampleName + ".req.xml.data"));
model.getObject().setResultText("");
target.add(PageEvaluateMapping.this);
}
private String readResource(String name) {
InputStream is = PageEvaluateMapping.class.getResourceAsStream(name);
if (is != null) {
try {
return IOUtils.toString(is, "UTF-8");
} catch (IOException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e, name);
} finally {
IOUtils.closeQuietly(is);
}
} else {
LOGGER.warn("Resource {} containing sample couldn't be found", name);
}
return null;
}
});
mainForm.add(sampleChoice);
AceEditor resultText = new AceEditor(ID_RESULT_TEXT, new PropertyModel<String>(model, ExecuteMappingDto.F_RESULT_TEXT));
resultText.setReadonly(true);
resultText.setHeight(300);
resultText.setResizeToMaxHeight(false);
resultText.setMode(null);
mainForm.add(resultText);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class NotificationConfigPanel method initLayout.
@Override
protected void initLayout() {
TextField<String> defaultFromField = WebComponentUtil.createAjaxTextField(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "defaultFrom"));
CheckBox debugCheck = WebComponentUtil.createAjaxCheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "debug"));
DropDownChoice mailServerConfigChooser = new DropDownChoice<>(ID_MAIL_SERVER, new PropertyModel<MailServerConfigurationTypeDto>(getModel(), NotificationConfigurationDto.F_SELECTED_SERVER), new AbstractReadOnlyModel<List<MailServerConfigurationTypeDto>>() {
@Override
public List<MailServerConfigurationTypeDto> getObject() {
return getModel().getObject().getServers();
}
}, new ChoiceableChoiceRenderer<MailServerConfigurationTypeDto>());
mailServerConfigChooser.setNullValid(true);
mailServerConfigChooser.add(new AjaxFormSubmitBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
getForm().onFormSubmitted();
}
});
mailServerConfigChooser.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
preparePasswordFieldPlaceholder();
target.add(NotificationConfigPanel.this);
}
});
add(mailServerConfigChooser);
Label serverConfigTooltip = new Label(ID_MAIL_SERVER_TOOLTIP);
serverConfigTooltip.add(new InfoTooltipBehavior());
add(serverConfigTooltip);
WebMarkupContainer serverConfigContainer = new WebMarkupContainer(ID_MAIL_SERVER_CONFIG_CONTAINER);
serverConfigContainer.setOutputMarkupId(true);
serverConfigContainer.setOutputMarkupPlaceholderTag(true);
serverConfigContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject() != null) {
return getModelObject().getSelectedServer() != null;
}
return false;
}
});
add(serverConfigContainer);
TextField<String> hostField = WebComponentUtil.createAjaxTextField(ID_HOST, new PropertyModel<String>(getModel(), "selectedServer.host"));
TextField<Integer> portField = WebComponentUtil.createAjaxTextField(ID_PORT, new PropertyModel<Integer>(getModel(), "selectedServer.port"));
TextField<String> userNameField = WebComponentUtil.createAjaxTextField(ID_USERNAME, new PropertyModel<String>(getModel(), "selectedServer.username"));
PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "selectedServer.password"));
passwordField.setRequired(false);
passwordField.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
TextField<String> redirectToFileField = WebComponentUtil.createAjaxTextField(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "redirectToFile"));
DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(), "selectedServer.mailTransportSecurityType"), WebComponentUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class), new EnumChoiceRenderer<MailTransportSecurityType>(this), createStringResource("SystemConfigPanel.mail.transportSecurity"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
// transportSecurity.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
serverConfigContainer.add(hostField);
serverConfigContainer.add(portField);
serverConfigContainer.add(userNameField);
serverConfigContainer.add(passwordField);
serverConfigContainer.add(transportSecurity);
add(defaultFromField);
add(debugCheck);
add(redirectToFileField);
AjaxSubmitLink buttonAddNewMailServerConfig = new AjaxSubmitLink(ID_BUTTON_ADD_NEW_MAIL_SERVER_CONFIG) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
MailServerConfigurationTypeDto newConfig = new MailServerConfigurationTypeDto();
newConfig.setHost(getString("SystemConfigPanel.mail.config.placeholder"));
if (getModelObject() != null) {
getModelObject().getServers().add(newConfig);
getModelObject().setSelectedServer(newConfig);
}
preparePasswordFieldPlaceholder();
target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
add(buttonAddNewMailServerConfig);
AjaxSubmitLink removeMailServerConfig = new AjaxSubmitLink(ID_BUTTON_REMOVE_MAIL_SERVER_CONFIG) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
if (getModelObject() != null) {
NotificationConfigurationDto notificationConfig = getModelObject();
MailServerConfigurationTypeDto selected = notificationConfig.getSelectedServer();
if (notificationConfig.getServers().contains(selected)) {
notificationConfig.getServers().remove(selected);
notificationConfig.setSelectedServer(null);
} else {
warn(getString("SystemConfigPanel.mail.server.remove.warn"));
}
target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
}
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
removeMailServerConfig.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (getModelObject() != null && getModelObject().getSelectedServer() != null) {
return null;
} else {
return " disabled";
}
}
}));
add(removeMailServerConfig);
}
use of org.apache.wicket.ajax.form.OnChangeAjaxBehavior in project midpoint by Evolveum.
the class PageRepositoryQuery method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
List<QName> objectTypeList = WebComponentUtil.createObjectTypeList();
Collections.sort(objectTypeList, new Comparator<QName>() {
@Override
public int compare(QName o1, QName o2) {
return String.CASE_INSENSITIVE_ORDER.compare(o1.getLocalPart(), o2.getLocalPart());
}
});
DropDownChoice<QName> objectTypeChoice = new DropDownChoice<>(ID_OBJECT_TYPE, new PropertyModel<QName>(model, RepoQueryDto.F_OBJECT_TYPE), new ListModel<>(objectTypeList), new QNameChoiceRenderer());
objectTypeChoice.setOutputMarkupId(true);
objectTypeChoice.setNullValid(true);
objectTypeChoice.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(get(ID_MAIN_FORM).get(ID_MIDPOINT_QUERY_BUTTON_BAR));
}
});
mainForm.add(objectTypeChoice);
AceEditor editorMidPoint = new AceEditor(ID_EDITOR_MIDPOINT, new PropertyModel<String>(model, RepoQueryDto.F_MIDPOINT_QUERY));
editorMidPoint.setHeight(400);
editorMidPoint.setResizeToMaxHeight(false);
mainForm.add(editorMidPoint);
AceEditor editorHibernate = new AceEditor(ID_EDITOR_HIBERNATE, new PropertyModel<String>(model, RepoQueryDto.F_HIBERNATE_QUERY));
editorHibernate.setHeight(300);
editorHibernate.setResizeToMaxHeight(false);
editorHibernate.setReadonly(!isAdmin);
editorHibernate.setMode(null);
mainForm.add(editorHibernate);
AceEditor hibernateParameters = new AceEditor(ID_HIBERNATE_PARAMETERS, new PropertyModel<String>(model, RepoQueryDto.F_HIBERNATE_PARAMETERS));
hibernateParameters.setReadonly(true);
hibernateParameters.setHeight(100);
hibernateParameters.setResizeToMaxHeight(false);
hibernateParameters.setMode(null);
mainForm.add(hibernateParameters);
WebMarkupContainer hibernateParametersNote = new WebMarkupContainer(ID_HIBERNATE_PARAMETERS_NOTE);
hibernateParametersNote.setVisible(isAdmin);
mainForm.add(hibernateParametersNote);
WebMarkupContainer midPointQueryButtonBar = new WebMarkupContainer(ID_MIDPOINT_QUERY_BUTTON_BAR);
midPointQueryButtonBar.setOutputMarkupId(true);
mainForm.add(midPointQueryButtonBar);
AjaxSubmitButton executeMidPoint = new AjaxSubmitButton(ID_EXECUTE_MIDPOINT, createStringResource("PageRepositoryQuery.button.translateAndExecute")) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
queryPerformed(Action.EXECUTE_MIDPOINT, target);
}
};
midPointQueryButtonBar.add(executeMidPoint);
AjaxSubmitButton compileMidPoint = new AjaxSubmitButton(ID_COMPILE_MIDPOINT, createStringResource("PageRepositoryQuery.button.translate")) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
queryPerformed(Action.TRANSLATE_ONLY, target);
}
};
midPointQueryButtonBar.add(compileMidPoint);
AjaxSubmitButton useInObjectList = new AjaxSubmitButton(ID_USE_IN_OBJECT_LIST, createStringResource("PageRepositoryQuery.button.useInObjectList")) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
useInObjectListPerformed(target);
}
};
useInObjectList.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return USE_IN_OBJECT_LIST_AVAILABLE_FOR.contains(model.getObject().getObjectType());
}
});
midPointQueryButtonBar.add(useInObjectList);
final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_QUERY_SAMPLE, Model.of(""), new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
return SAMPLES;
}
}, new StringResourceChoiceRenderer("PageRepositoryQuery.sample"));
sampleChoice.setNullValid(true);
sampleChoice.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
String sampleName = sampleChoice.getModelObject();
if (StringUtils.isEmpty(sampleName)) {
return;
}
String resourceName = SAMPLES_DIR + "/" + sampleName + ".xml.data";
InputStream is = PageRepositoryQuery.class.getResourceAsStream(resourceName);
if (is != null) {
try {
String localTypeName = StringUtils.substringBefore(sampleName, "_");
model.getObject().setObjectType(new QName(SchemaConstants.NS_C, localTypeName));
model.getObject().setMidPointQuery(IOUtils.toString(is, "UTF-8"));
model.getObject().setHibernateQuery("");
model.getObject().setHibernateParameters("");
model.getObject().setQueryResultObject(null);
model.getObject().resetQueryResultText();
target.add(PageRepositoryQuery.this);
} catch (IOException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e, resourceName);
}
} else {
LOGGER.warn("Resource {} containing sample couldn't be found", resourceName);
}
}
});
mainForm.add(sampleChoice);
AjaxSubmitButton executeHibernate = new AjaxSubmitButton(ID_EXECUTE_HIBERNATE, createStringResource("PageRepositoryQuery.button.execute")) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
queryPerformed(Action.EXECUTE_HIBERNATE, target);
}
};
executeHibernate.setVisible(isAdmin);
mainForm.add(executeHibernate);
Label resultLabel = new Label(ID_RESULT_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (model.getObject().getQueryResultText() == null) {
return "";
}
Object queryResult = model.getObject().getQueryResultObject();
if (queryResult instanceof List) {
return getString("PageRepositoryQuery.resultObjects", ((List) queryResult).size());
} else if (queryResult instanceof Throwable) {
return getString("PageRepositoryQuery.resultException", queryResult.getClass().getName());
} else {
// including null
return getString("PageRepositoryQuery.result");
}
}
});
mainForm.add(resultLabel);
WebMarkupContainer incompleteResultsNote = new WebMarkupContainer(ID_INCOMPLETE_RESULTS_NOTE);
incompleteResultsNote.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !isAdmin && model.getObject().getQueryResultText() != null;
}
});
mainForm.add(incompleteResultsNote);
AceEditor resultText = new AceEditor(ID_RESULT_TEXT, new PropertyModel<String>(model, RepoQueryDto.F_QUERY_RESULT_TEXT));
resultText.setReadonly(true);
resultText.setHeight(300);
resultText.setResizeToMaxHeight(false);
resultText.setMode(null);
resultText.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().getQueryResultText() != null;
}
});
mainForm.add(resultText);
}
Aggregations