Search in sources :

Example 16 with AjaxButton

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

the class DelegationEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.setEnabled(getModel().getObject().isEditable());
    body.add(validFrom);
    DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    validTo.setEnabled(getModel().getObject().isEditable());
    body.add(validTo);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    description.setEnabled(getModel().getObject().isEditable());
    body.add(description);
    WebMarkupContainer assignmentPrivilegesContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_CONTAINER);
    assignmentPrivilegesContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
                return true;
            }
            List<AssignmentsPreviewDto> privilegesList = privilegesListModel.getObject();
            return privilegesList != null && privilegesList.size() > 0;
        }
    });
    body.add(assignmentPrivilegesContainer);
    AjaxCheckBox assignmentPrivilegesCheckbox = new AjaxCheckBox(ID_ASSIGNMENT_PRIVILEGES_CHECKBOX, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            return getModelObject().getPrivilegeLimitationList() != null && getModelObject().getPrivilegeLimitationList().size() > 0;
        }

        @Override
        public void setObject(Boolean value) {
            if (value) {
                getModelObject().setPrivilegeLimitationList(privilegesListModel.getObject());
            } else {
                getModelObject().setPrivilegeLimitationList(new ArrayList<>());
            }
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(DelegationEditorPanel.this.get(ID_BODY).get(ID_ASSIGNMENT_PRIVILEGES_CONTAINER));
        }
    };
    assignmentPrivilegesCheckbox.setOutputMarkupId(true);
    assignmentPrivilegesCheckbox.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    assignmentPrivilegesCheckbox.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return UserDtoStatus.ADD.equals(getModelObject().getStatus());
        }
    });
    assignmentPrivilegesContainer.add(assignmentPrivilegesCheckbox);
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(labelContainer);
    Label assignmentPrivilegesLabel = new Label(ID_ASSIGNMENT_PRIVILEGES_LABEL, createStringResource("DelegationEditorPanel.allPrivilegesLabel"));
    assignmentPrivilegesLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return true;
        }
    });
    assignmentPrivilegesLabel.setOutputMarkupId(true);
    labelContainer.add(assignmentPrivilegesLabel);
    addPrivilegesPanel(assignmentPrivilegesContainer);
    AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON, pageBase.createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            AssignmentPreviewDialog assignmentPreviewDialog = new AssignmentPreviewDialog(pageBase.getMainPopupBodyId(), selectExistingPrivileges(privilegesListModel.getObject()), null, pageBase, true) {

                @Override
                protected boolean isDelegationPreview() {
                    return true;
                }

                @Override
                public StringResourceModel getTitle() {
                    return new StringResourceModel("AssignmentPreviewDialog.delegationPreviewLabel");
                }

                @Override
                protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentsPreviewDto> dtoList) {
                    DelegationEditorPanel.this.getModelObject().setPrivilegeLimitationList(dtoList);
                    pageBase.hideMainPopup(target);
                }
            };
            pageBase.showMainPopup(assignmentPreviewDialog, target);
        }
    };
    limitPrivilegesButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return UserDtoStatus.ADD.equals(getModelObject().getStatus()) && assignmentPrivilegesCheckbox.getModelObject();
        }
    });
    labelContainer.add(limitPrivilegesButton);
    AjaxCheckBox approvalRights = new AjaxCheckBox(ID_DELEGATE_APPROVAL_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getApprovalWorkItems() == null || dto.getPrivilegesLimitation().getApprovalWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getApprovalWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setApprovalWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    approvalRights.setOutputMarkupId(true);
    approvalRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    approvalRights.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    body.add(approvalRights);
    AjaxCheckBox certificationRights = new AjaxCheckBox(ID_DELEGATE_CERTIFICATION_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getCertificationWorkItems() == null || dto.getPrivilegesLimitation().getCertificationWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getCertificationWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setCertificationWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    certificationRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    certificationRights.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    certificationRights.setOutputMarkupId(true);
    body.add(certificationRights);
    AjaxCheckBox managementWorkItems = new AjaxCheckBox(ID_DELEGATE_MANAGEMENT_WI, new Model<Boolean>(false)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    managementWorkItems.setOutputMarkupId(true);
    managementWorkItems.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            //TODO not implemented yet
            return false;
        }
    });
    body.add(managementWorkItems);
    addAjaxOnUpdateBehavior(body);
}
Also used : TextArea(org.apache.wicket.markup.html.form.TextArea) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WorkItemSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemSelectorType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OtherPrivilegesLimitationType(com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AssignmentPreviewDialog(com.evolveum.midpoint.web.page.admin.users.component.AssignmentPreviewDialog) DateInput(com.evolveum.midpoint.web.component.DateInput)

Example 17 with AjaxButton

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

the class SingleButtonPanel method initLayout.

private void initLayout() {
    AjaxButton button = new AjaxButton(ID_BUTTON, createButtonStringResource(getCaption())) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            clickPerformed(target, SingleButtonPanel.this.getModel());
        }

        @Override
        public boolean isEnabled() {
            return SingleButtonPanel.this.isEnabled(SingleButtonPanel.this.getModel());
        }

        @Override
        public boolean isVisible() {
            return SingleButtonPanel.this.isVisible(SingleButtonPanel.this.getModel());
        }
    };
    button.add(new AttributeAppender("class", getButtonCssClass()));
    add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 18 with AjaxButton

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

the class MultiButtonPanel method initLayout.

protected void initLayout() {
    RepeatingView buttons = new RepeatingView(ID_BUTTONS);
    add(buttons);
    for (int id = 0; id < numberOfButtons; id++) {
        final int finalId = getButtonId(id);
        AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }

            @Override
            public boolean isEnabled() {
                return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
            }

            @Override
            public boolean isVisible() {
                return MultiButtonPanel.this.isButtonVisible(finalId, MultiButtonPanel.this.getModel());
            }
        };
        button.add(new AttributeAppender("class", getButtonCssClass(finalId)));
        button.add(new AttributeAppender("title", getButtonTitle(finalId)));
        buttons.add(button);
        buttons.add(new Label("label" + finalId, " "));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 19 with AjaxButton

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

the class PageAuditLogDetails method initLayoutBackButton.

protected void initLayoutBackButton() {
    AjaxButton back = new AjaxButton(ID_BUTTON_BACK, createStringResource("PageBase.button.back")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    add(back);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton)

Example 20 with AjaxButton

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

the class JasperReportConfigurationPanel method initFiledsTable.

private void initFiledsTable() {
    ISortableDataProvider<JasperReportFieldDto, String> provider = new ListDataProvider<JasperReportFieldDto>(this, new PropertyModel<List<JasperReportFieldDto>>(getModel(), "jasperReportDto.fields"));
    BoxedTablePanel<JasperReportFieldDto> table = new BoxedTablePanel<JasperReportFieldDto>(ID_FIELDS_TABLE, provider, initFieldColumns(), null, 10);
    //		table.setShowPaging(false);
    table.setOutputMarkupId(true);
    add(table);
    AjaxButton addParameter = new AjaxButton(ID_BUTTON_ADD_FIELD, createStringResource("JasperReportConfigurationPanel.addField")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addFieldPerformed(target);
        }
    };
    add(addParameter);
    AjaxButton deleteParameter = new AjaxButton(ID_DELETE_FIELD, createStringResource("JasperReportConfigurationPanel.deleteField")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            deleteFieldPerformed(target);
        }
    };
    add(deleteParameter);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ArrayList(java.util.ArrayList) List(java.util.List) JasperReportFieldDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportFieldDto) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Aggregations

AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)26 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)20 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)18 Form (org.apache.wicket.markup.html.form.Form)13 Label (org.apache.wicket.markup.html.basic.Label)12 ArrayList (java.util.ArrayList)11 List (java.util.List)10 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)7 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)7 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7 Form (com.evolveum.midpoint.web.component.form.Form)6 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)6 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)4 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 TextArea (org.apache.wicket.markup.html.form.TextArea)4 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)3