Search in sources :

Example 66 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PageResources method createRowMenuItems.

private List<InlineMenuItem> createRowMenuItems(boolean isHeader) {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    menuItems.add(new InlineMenuItem(createStringResource("PageResources.inlineMenuItem.test"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            SelectableBean<ResourceType> rowDto = getRowModel().getObject();
            testResourcePerformed(target, rowDto.getValue());
        }
    }, isHeader ? InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.HEADER_TEST_CONNECTION.getMenuItemId() : InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.TEST_CONNECTION.getMenuItemId(), GuiStyleConstants.CLASS_TEST_CONNECTION_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()));
    menuItems.add(new InlineMenuItem(createStringResource("PageBase.button.delete"), new Model<Boolean>(true), new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                deleteResourcePerformed(target, null);
            } else {
                SelectableBean<ResourceType> rowDto = getRowModel().getObject();
                deleteResourcePerformed(target, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.HEADER_DELETE.getMenuItemId() : InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.DELETE_RESOURCE.getMenuItemId(), GuiStyleConstants.CLASS_DELETE_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()));
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.deleteSyncToken"), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            SelectableBean<ResourceType> rowDto = getRowModel().getObject();
            deleteResourceSyncTokenPerformed(target, rowDto.getValue());
        }
    }));
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.editResource"), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            SelectableBean<ResourceType> rowDto = getRowModel().getObject();
            editResourcePerformed(rowDto.getValue());
        }
    }));
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.button.editAsXml"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<ResourceType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            SelectableBean<ResourceType> rowDto = getRowModel().getObject();
            editAsXmlPerformed(rowDto.getValue());
        }
    }, InlineMenuItem.RESOURCE_INLINE_MENU_ITEM_ID.EDIT_XML.getMenuItemId(), GuiStyleConstants.CLASS_EDIT_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()));
    return menuItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 67 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PageResources method deleteResourcePerformed.

private void deleteResourcePerformed(AjaxRequestTarget target, ResourceType single) {
    List<ResourceType> selected = isAnyResourceSelected(target, single);
    singleDelete = single;
    if (selected.isEmpty()) {
        return;
    }
    ConfirmationPanel dialog = new ConfirmationPanel(((PageBase) getPage()).getMainPopupBodyId(), createDeleteConfirmString("pageResources.message.deleteResourceConfirm", "pageResources.message.deleteResourcesConfirm", true)) {

        @Override
        public void yesPerformed(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            deleteResourceConfirmedPerformed(target);
        }
    };
    ((PageBase) getPage()).showMainPopup(dialog, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 68 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PageAccount method initButtons.

private void initButtons(Form mainForm) {
    AjaxSubmitButton save = new AjaxSubmitButton("save", createStringResource("pageAccount.button.save")) {

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

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

        @Override
        public boolean isVisible() {
            ObjectWrapper wrapper = accountModel.getObject();
            return !wrapper.isProtectedAccount();
        }
    });
    mainForm.add(save);
    AjaxButton back = new AjaxButton("back", createStringResource("pageAccount.button.back")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    mainForm.add(back);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(org.apache.wicket.markup.html.form.Form) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 69 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PageRoles method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<RoleType> roleListPanel = new MainObjectListPanel<RoleType>(ID_TABLE, RoleType.class, TableId.TABLE_ROLES, null, this) {

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return listInlineMenuHelper.createRowActions(false);
        }

        @Override
        protected List<IColumn<SelectableBean<RoleType>, String>> createColumns() {
            return PageRoles.this.initColumns();
        }

        @Override
        protected IColumn<SelectableBean<RoleType>, String> createActionsColumn() {
            return PageRoles.this.createActionsColumn();
        }

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, RoleType object) {
            PageRoles.this.roleDetailsPerformed(target, object.getOid());
            ;
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            navigateToNext(PageRole.class);
        }
    };
    roleListPanel.setOutputMarkupId(true);
    roleListPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES);
    mainForm.add(roleListPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 70 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget 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)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)393 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)108 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)105 ArrayList (java.util.ArrayList)91 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)82 Form (org.apache.wicket.markup.html.form.Form)78 IModel (org.apache.wicket.model.IModel)73 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)71 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)56 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 ListItem (org.apache.wicket.markup.html.list.ListItem)43 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)34 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 ListView (org.apache.wicket.markup.html.list.ListView)32 TextField (org.apache.wicket.markup.html.form.TextField)30