Search in sources :

Example 66 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class AssignmentConflictPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    Form container = new MidpointForm<>(ID_PANEL_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    Label statusIconLabel = new Label(ID_STATUS_ICON);
    statusIconLabel.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null ? (getModelObject().isResolved() ? STATUS_FIXED : (getModelObject().isWarning() ? STATUS_WARNING : STATUS_ERROR)) : STATUS_ERROR;
        }
    }));
    container.add(statusIconLabel);
    Label existingAssignment = new Label(ID_EXISTING_ASSIGNMENT, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (getModelObject() != null) {
                String name = getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment1().getAssignmentTargetObject().getOid();
                return name + " " + getMessageLabel(getModelObject().getAssignment1().isOldAssignment());
            }
            return "";
        }
    });
    existingAssignment.add(new AttributeAppender("style", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null && getModelObject().getAssignment1().isResolved() ? "text-decoration: line-through;" : "";
        }
    }));
    container.add(existingAssignment);
    Label addedAssignment = new Label(ID_ADDED_ASSIGNMENT, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            if (getModelObject() != null) {
                String name = getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment2().getAssignmentTargetObject().getOid();
                return name + " " + getMessageLabel(getModelObject().getAssignment2().isOldAssignment());
            }
            return "";
        }
    });
    addedAssignment.add(new AttributeAppender("style", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null && getModelObject().getAssignment2().isResolved() ? "text-decoration: line-through;" : "";
        }
    }));
    container.add(addedAssignment);
    IModel<String> removeButtonTitleModel = new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject().getAssignment1().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
        }
    };
    AjaxSubmitButton removeButton = new AjaxSubmitButton(ID_REMOVE_BUTTON, removeButtonTitleModel) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment1(), target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }

        @Override
        public boolean isEnabled() {
            return !getModelObject().getAssignment2().isResolved();
        }
    });
    container.add(removeButton);
    IModel<String> unselectButtonTitleModel = new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject().getAssignment2().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
        }
    };
    AjaxSubmitButton unselectButton = new AjaxSubmitButton(ID_UNSELECT_BUTTON, unselectButtonTitleModel) {

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment2(), target);
        }
    };
    unselectButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject() != null;
        }

        @Override
        public boolean isEnabled() {
            return !getModelObject().getAssignment1().isResolved();
        }
    });
    container.add(unselectButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) IModel(org.apache.wicket.model.IModel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Label(org.apache.wicket.markup.html.basic.Label) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 67 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class ProgressPanel method initButtons.

private void initButtons(final MidpointForm progressForm) {
    abortButton = new AjaxSubmitButton(ID_ABORT, createStringResource("pageAdminFocus.button.abort")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            abortPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    configureButton(abortButton);
    progressForm.add(abortButton);
    backButton = new AjaxSubmitButton(ID_BACK, createStringResource("pageAdminFocus.button.back")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            backPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    configureButton(backButton);
    progressForm.add(backButton);
    continueEditingButton = new AjaxSubmitButton(ID_CONTINUE_EDITING, createStringResource("pageAdminFocus.button.continueEditing")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            ProgressReportingAwarePage page = (ProgressReportingAwarePage) getPage();
            page.continueEditing(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    configureButton(continueEditingButton);
    progressForm.add(continueEditingButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton)

Aggregations

AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 Form (org.apache.wicket.markup.html.form.Form)27 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)23 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 ArrayList (java.util.ArrayList)9 List (java.util.List)8 Label (org.apache.wicket.markup.html.basic.Label)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 ListItem (org.apache.wicket.markup.html.list.ListItem)5 CheckFormGroup (com.evolveum.midpoint.web.component.form.CheckFormGroup)4 AceEditor (com.evolveum.midpoint.web.component.AceEditor)3 Form (com.evolveum.midpoint.web.component.form.Form)3 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)3 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)3 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3