Search in sources :

Example 56 with AjaxLink

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

the class HelpInfoPanel method initLayout.

public void initLayout(final String messageKey) {
    WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
    add(content);
    Label helpLabel = new Label(ID_HELP, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(messageKey);
        }
    });
    helpLabel.setEscapeModelStrings(false);
    content.add(helpLabel);
    AjaxLink ok = new AjaxLink(ID_BUTTON_OK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closePerformed(target);
        }
    };
    content.add(ok);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 57 with AjaxLink

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

the class StageEditorPanel method initPanelLayout.

private void initPanelLayout() {
    AjaxLink name = new AjaxLink(ID_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    Label nameLabel = new Label(ID_NAME_LABEL, getModel().getObject().getName() == null || getModel().getObject().getName().trim().equals("") ? "Stage definition #" + getModel().getObject().getNumber() : getModel().getObject().getName());
    name.add(nameLabel);
    add(name);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 58 with AjaxLink

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

the class PageAccountActivation method initLayout.

private void initLayout() {
    WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
    activationContainer.setOutputMarkupId(true);
    add(activationContainer);
    activationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !activated;
        }
    });
    Form form = new Form<>(ID_MAIN_FORM);
    activationContainer.add(form);
    Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
    usernamePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return false;
        }
    });
    form.add(usernamePanel);
    PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
    form.add(passwordPanel);
    AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {

        private static final long serialVersionUID = 1L;

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            getSession().error(getString("PageAccountActivation.account.activation.failed"));
            target.add(getFeedbackPanel());
        }
    };
    form.add(confirmPasswrod);
    WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
    confirmationContainer.setOutputMarkupId(true);
    confirmationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return activated;
        }
    });
    add(confirmationContainer);
    AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    confirmationContainer.add(linkToLogin);
    RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
    confirmationContainer.add(activatedShadows);
    List<ShadowType> shadowsToActivate = getShadowsToActivate();
    if (shadowsToActivate.isEmpty()) {
        LOGGER.error("No accounts to validate for user {}", userModel.getObject());
        getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
        throw new RestartResponseException(PageLogin.class);
    }
    for (ShadowType shadow : shadowsToActivate) {
        Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
        activatedShadows.add(shadowDesc);
    }
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 59 with AjaxLink

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

the class PageRegistrationConfirmation method initLayout.

private void initLayout(final OperationResult result) {
    WebMarkupContainer successPanel = new WebMarkupContainer(ID_SUCCESS_PANEL);
    add(successPanel);
    successPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return result.getStatus() != OperationResultStatus.FATAL_ERROR;
        }

        @Override
        public boolean isEnabled() {
            return result.getStatus() != OperationResultStatus.FATAL_ERROR;
        }
    });
    Label successMessage = new Label(ID_LABEL_SUCCESS, createStringResource("PageRegistrationConfirmation.confirmation.successful"));
    successPanel.add(successMessage);
    AjaxLink<String> continueToLogin = new AjaxLink<String>(ID_LINK_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    successPanel.add(continueToLogin);
    WebMarkupContainer errorPanel = new WebMarkupContainer(ID_ERROR_PANEL);
    add(errorPanel);
    errorPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return result.getStatus() == OperationResultStatus.FATAL_ERROR;
        }

        @Override
        public boolean isVisible() {
            return result.getStatus() == OperationResultStatus.FATAL_ERROR;
        }
    });
    Label errorMessage = new Label(ID_LABEL_ERROR, createStringResource("PageRegistrationConfirmation.confirmation.error"));
    errorPanel.add(errorMessage);
}
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) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 60 with AjaxLink

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

the class OperationResultPanel method initHeader.

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

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            OpResult message = getModelObject();
            switch(message.getStatus()) {
                case IN_PROGRESS:
                case NOT_APPLICABLE:
                    sb.append(" fa-info");
                    break;
                case SUCCESS:
                    sb.append(" fa-check");
                    break;
                case FATAL_ERROR:
                    sb.append(" fa-ban");
                    break;
                case PARTIAL_ERROR:
                case UNKNOWN:
                case WARNING:
                case HANDLED_ERROR:
                default:
                    sb.append(" fa-warning");
            }
            return sb.toString();
        }
    }));
    box.add(iconType);
    Label message = createMessage();
    AjaxLink<String> showMore = new AjaxLink<String>(ID_MESSAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowMore(!result.isShowMore());
            // hack to be able to expand/collapse OpResult after rendered.
            result.setAlreadyShown(false);
            target.add(OperationResultPanel.this);
        }
    };
    showMore.add(message);
    box.add(showMore);
    AjaxLink<String> backgroundTask = new AjaxLink<String>(ID_BACKGROUND_TASK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getBackgroundTaskOid();
            if (oid == null || !opResult.isBackgroundTaskVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.TASK);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    backgroundTask.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getBackgroundTaskOid() != null && getModelObject().isBackgroundTaskVisible();
        }
    });
    box.add(backgroundTask);
    AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(true, OperationResultPanel.this.getModelObject(), target);
        }
    };
    showAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(showAll);
    AjaxLink<String> hideAll = new AjaxLink<String>(ID_HIDE_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(false, OperationResultPanel.this.getModel().getObject(), target);
        }
    };
    hideAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(hideAll);
    AjaxLink<String> close = new AjaxLink<String>("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
    DownloadLink downloadXml = new DownloadLink("downloadXml", new AbstractReadOnlyModel<File>() {

        private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            String home = getPageBase().getMidpointConfiguration().getMidpointHome();
            File f = new File(home, "result");
            DataOutputStream dos = null;
            try {
                dos = new DataOutputStream(new FileOutputStream(f));
                dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
            } catch (IOException e) {
                LOGGER.error("Could not download result: {}", e.getMessage(), e);
            } finally {
                IOUtils.closeQuietly(dos);
            }
            return f;
        }
    });
    downloadXml.setDeleteAfterDownload(true);
    box.add(downloadXml);
}
Also used : DownloadLink(org.apache.wicket.markup.html.link.DownloadLink) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) DataOutputStream(java.io.DataOutputStream) Label(org.apache.wicket.markup.html.basic.Label) IOException(java.io.IOException) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FileOutputStream(java.io.FileOutputStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) File(java.io.File) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

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