use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageError method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
Label codeLabel = new Label(ID_CODE, code);
add(codeLabel);
Label errorMessage = new Label(ID_ERROR_MESSAGE, createStringResource(getErrorMessageKey()));
add(errorMessage);
String errorLabel = "Unexpected error";
if (code != null) {
HttpStatus httpStatus = HttpStatus.valueOf(code);
if (httpStatus != null) {
errorLabel = httpStatus.getReasonPhrase();
}
}
Label labelLabel = new Label(ID_LABEL, errorLabel);
add(labelLabel);
final IModel<String> message = new IModel<String>() {
@Override
public String getObject() {
if (exClass == null) {
return null;
}
SimpleDateFormat df = new SimpleDateFormat();
return df.format(new Date()) + "\t" + exClass + ": " + exMessage;
}
};
Label label = new Label(ID_MESSAGE, message);
label.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return StringUtils.isNotEmpty(message.getObject());
}
});
add(label);
AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageError.button.back")) {
@Override
public void onClick(AjaxRequestTarget target) {
backPerformed(target);
}
};
add(back);
AjaxButton home = new AjaxButton(ID_HOME, createStringResource("PageError.button.home")) {
@Override
public void onClick(AjaxRequestTarget target) {
homePerformed(target);
}
};
add(home);
MidpointForm form = new MidpointForm(ID_LOGOUT_FORM);
form.add(AttributeModifier.replace("action", (IModel<String>) () -> getUrlForLogout()));
form.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return AuthUtil.getPrincipalUser() != null;
}
});
add(form);
WebMarkupContainer csrfField = SecurityUtils.createHiddenInputForCsrf(ID_CSRF_FIELD);
form.add(csrfField);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageForgotPassword method initLayout.
private void initLayout() {
Form<?> form = new MidpointForm(ID_PWDRESETFORM);
form.setOutputMarkupId(true);
form.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !submited;
}
});
initStaticLayout(form);
initDynamicLayout(form);
initButtons(form);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageAttorneySelection method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
ObjectListPanel<UserType> table = new ObjectListPanel<>(ID_TABLE, UserType.class, Collections.emptyList()) {
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_USER_SELECTION;
}
@Override
protected IColumn<SelectableBean<UserType>, String> createCheckboxColumn() {
return null;
}
@Override
protected IColumn<SelectableBean<UserType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
return new ObjectNameColumn<>(createStringResource("ObjectType.name")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target, IModel<SelectableBean<UserType>> rowModel) {
UserType object = rowModel.getObject().getValue();
selectUserPerformed(object.getOid());
}
};
}
@Override
protected List<IColumn<SelectableBean<UserType>, String>> createDefaultColumns() {
List<IColumn<SelectableBean<UserType>, String>> columns = new ArrayList<>();
columns.add(createNameColumn(null, null, null, null));
columns.addAll(PageAttorneySelection.this.initColumns());
return columns;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return null;
}
@Override
protected ISelectableDataProvider<UserType, SelectableBean<UserType>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> getAttorneySelectionQuery(), null);
}
};
table.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_USER_BOX_CSS_CLASSES);
table.setOutputMarkupId(true);
mainForm.add(table);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageValuePolicy method initLayout.
protected void initLayout() {
// TODO should be used if valuePolicyObject is edited
ValuePolicySummaryPanel summaryPanel = new ValuePolicySummaryPanel(ID_SUMMARY_PANEL, Model.of(valuePolicyModel.getObject().getObject().asObjectable()), WebComponentUtil.getSummaryPanelSpecification(ValuePolicyType.class, getCompiledGuiProfile()));
add(summaryPanel);
MidpointForm mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
// List<ItemPath> itemPath = new ArrayList<>();
// itemPath.add(ItemPath.EMPTY_PATH);
// itemPath.add(prismContext.path(ValuePolicyType.F_STRING_POLICY));
// PrismPanel<ValuePolicyType> valuePolicyForm = new PrismPanel<>(ID_VALUE_POLICY_BASIC_DETAIL, new ContainerWrapperListFromObjectWrapperModel<ValuePolicyType,ValuePolicyType>(valuePolicyModel, itemPath),null, mainForm, null, this);
// mainForm.add(valuePolicyForm);
initTabs(mainForm);
initButtons(mainForm);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageEvaluateMapping method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
AceEditor editorMapping = new AceEditor(ID_EDITOR_MAPPING, new PropertyModel<>(model, ExecuteMappingDto.F_MAPPING));
editorMapping.setHeight(400);
editorMapping.setResizeToMaxHeight(false);
mainForm.add(editorMapping);
AceEditor editorRequest = new AceEditor(ID_EDITOR_REQUEST, new PropertyModel<>(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) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target) {
executeMappingPerformed(target);
}
};
mainForm.add(evaluateMapping);
final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_MAPPING_SAMPLE, Model.of(""), (IModel<List<String>>) () -> 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) {
try (InputStream is = PageEvaluateMapping.class.getResourceAsStream(name)) {
if (is != null) {
return IOUtils.toString(is, StandardCharsets.UTF_8);
} else {
LOGGER.warn("Resource {} containing sample couldn't be found", name);
}
} catch (IOException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e, name);
}
return null;
}
});
mainForm.add(sampleChoice);
AceEditor resultText = new AceEditor(ID_RESULT_TEXT, new PropertyModel<>(model, ExecuteMappingDto.F_RESULT_TEXT));
resultText.setReadonly(true);
resultText.setHeight(300);
resultText.setResizeToMaxHeight(false);
resultText.setMode(null);
mainForm.add(resultText);
}
Aggregations