Search in sources :

Example 16 with MidpointForm

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);
}
Also used : IModel(org.apache.wicket.model.IModel) HttpStatus(org.springframework.http.HttpStatus) Label(org.apache.wicket.markup.html.basic.Label) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Date(java.util.Date) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) SimpleDateFormat(java.text.SimpleDateFormat)

Example 17 with MidpointForm

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);
}
Also used : MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 18 with MidpointForm

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);
}
Also used : IModel(org.apache.wicket.model.IModel) GuiObjectColumnType(com.evolveum.midpoint.xml.ns._public.common.common_3.GuiObjectColumnType) ObjectNameColumn(com.evolveum.midpoint.web.component.data.column.ObjectNameColumn) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ObjectListPanel(com.evolveum.midpoint.gui.api.component.ObjectListPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 19 with MidpointForm

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);
}
Also used : ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) ValuePolicySummaryPanel(com.evolveum.midpoint.web.page.admin.valuePolicy.component.ValuePolicySummaryPanel) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm)

Example 20 with MidpointForm

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);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) StringResourceChoiceRenderer(com.evolveum.midpoint.web.util.StringResourceChoiceRenderer) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) InputStream(java.io.InputStream) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) AceEditor(com.evolveum.midpoint.web.component.AceEditor) IOException(java.io.IOException) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List)

Aggregations

MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)75 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)41 Form (org.apache.wicket.markup.html.form.Form)39 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)19 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)17 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)17 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)15 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)14 ArrayList (java.util.ArrayList)14 Label (org.apache.wicket.markup.html.basic.Label)14 IModel (org.apache.wicket.model.IModel)14 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)11 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 List (java.util.List)7 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)7 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6