Search in sources :

Example 61 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class OperationResultPanel method initError.

private void initError(WebMarkupContainer operationPanel, final IModel<OpResult> model, Page parentPage) {
    Label errorLabel = new Label("errorLabel", parentPage.getString("FeedbackAlertMessageDetails.error"));
    errorLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());
        }
    });
    errorLabel.setOutputMarkupId(true);
    operationPanel.add(errorLabel);
    Label errorMessage = new Label("errorMessage", new PropertyModel<String>(model, "exceptionMessage"));
    errorMessage.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());
        }
    });
    errorMessage.setOutputMarkupId(true);
    operationPanel.add(errorMessage);
    final Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE, new PropertyModel<String>(model, "exceptionsStackTrace"));
    errorStackTrace.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // return true;
            return model.getObject().isShowError();
        }
    });
    errorStackTrace.setOutputMarkupId(true);
    operationPanel.add(errorStackTrace);
    AjaxLink errorStackTraceLink = new AjaxLink("errorStackTraceLink") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowError(!model.getObject().isShowError());
            // hack to be able to expand/collapse OpResult after rendered.
            result.setAlreadyShown(false);
            //				model.getObject().setShowError(!model.getObject().isShowError());
            target.add(OperationResultPanel.this);
        }
    };
    errorStackTraceLink.setOutputMarkupId(true);
    errorStackTraceLink.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotBlank(model.getObject().getExceptionsStackTrace());
        }
    });
    operationPanel.add(errorStackTraceLink);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 62 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class ValidationErrorPanel method initHeader.

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer("iconType");
    iconType.setOutputMarkupId(true);
    iconType.add(new AttributeAppender("class", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            FeedbackMessage result = getModelObject();
            if (result == null) {
                return " fa-info";
            }
            switch(result.getLevel()) {
                case FeedbackMessage.INFO:
                case FeedbackMessage.DEBUG:
                    return " fa-info";
                case FeedbackMessage.SUCCESS:
                    return " fa-check";
                case FeedbackMessage.ERROR:
                case FeedbackMessage.FATAL:
                    return " fa-ban";
                case FeedbackMessage.UNDEFINED:
                // TODO:
                case FeedbackMessage.WARNING:
                default:
                    return " fa-warning";
            }
        }
    }));
    box.add(iconType);
    Label message = new Label(ID_MESSAGE, new PropertyModel<Serializable>(getModel(), "message"));
    box.add(message);
    AjaxLink close = new AjaxLink("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Serializable(java.io.Serializable) Label(org.apache.wicket.markup.html.basic.Label) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 63 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class ObjectPolicyConfigurationEditor method initButtons.

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<ObjectPolicyConfigurationTypeDto> item) {
    AjaxLink<String> add = new AjaxLink<String>(ID_BUTTON_ADD) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addPerformed(target);
        }
    };
    add.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(item);
        }
    });
    buttonGroup.add(add);
    AjaxLink<String> remove = new AjaxLink<String>(ID_BUTTON_REMOVE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removePerformed(target, item);
        }
    };
    remove.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    buttonGroup.add(remove);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 64 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink 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);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 65 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class WizardSteps method initLayout.

protected void initLayout() {
    ListView<WizardStepDto> linkContainer = new ListView<WizardStepDto>(ID_LINK_REPEATER, getModel()) {

        @Override
        protected void populateItem(ListItem<WizardStepDto> item) {
            final WizardStepDto dto = item.getModelObject();
            item.setRenderBodyOnly(true);
            AjaxSubmitLink button = new AjaxSubmitLink(ID_LINK) {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                    changeStepPerformed(target, dto);
                }

                @Override
                protected void onError(AjaxRequestTarget target, Form<?> form) {
                    target.add(getPageBase().getFeedbackPanel());
                }
            };
            item.add(button);
            button.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isEnabled() {
                    final boolean enabled = ((PageResourceWizard) getPageBase()).isCurrentStepComplete();
                    //						System.out.println(dto.getName() + " enabled = " + enabled);
                    return enabled;
                }

                @Override
                public boolean isVisible() {
                    return dto.isVisible();
                }
            });
            button.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return dto.getWizardStep() == getActiveStep() ? "current" : null;
                }
            }));
            button.add(AttributeModifier.replace("style", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    final boolean enabled = ((PageResourceWizard) getPageBase()).isCurrentStepComplete();
                    // TODO respect color scheme (and find a better style for disabled anyway...)
                    return enabled ? null : "color: #FFF;";
                }
            }));
            Label label = new Label(ID_LABEL, createLabelModel(dto.getName()));
            button.add(label);
        }
    };
    add(linkContainer);
    AjaxLink help = new AjaxLink(ID_BUTTON_HELP) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHelpPerformed(target);
        }
    };
    add(help);
    initModals();
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) PageResourceWizard(com.evolveum.midpoint.web.page.admin.resources.PageResourceWizard) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)83 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)82 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)50 Label (org.apache.wicket.markup.html.basic.Label)50 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)44 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)28 ListItem (org.apache.wicket.markup.html.list.ListItem)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)17 ListView (org.apache.wicket.markup.html.list.ListView)17 TextField (org.apache.wicket.markup.html.form.TextField)15 ArrayList (java.util.ArrayList)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 AttributeModifier (org.apache.wicket.AttributeModifier)12 List (java.util.List)11 Form (org.apache.wicket.markup.html.form.Form)11 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)10 IModel (org.apache.wicket.model.IModel)9 Model (org.apache.wicket.model.Model)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)6