Search in sources :

Example 36 with AjaxButton

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

the class OrgMemberPanel method createManagerContainer.

private WebMarkupContainer createManagerContainer() {
    WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
    managerContainer.setOutputMarkupId(true);
    managerContainer.setOutputMarkupPlaceholderTag(true);
    RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
    view.setOutputMarkupId(true);
    ObjectQuery managersQuery = createManagerQuery();
    OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
    List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
    Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
    for (PrismObject<FocusType> manager : managers) {
        ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
        WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
        AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                detailsPerformed(target, summary.getModelObject());
            }
        };
        link.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        if (manager.getCompileTimeClass().equals(UserType.class)) {
            managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(RoleType.class)) {
            managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(OrgType.class)) {
            managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
        } else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
            managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
        }
        link.setOutputMarkupId(true);
        managerMarkup.setOutputMarkupId(true);
        managerMarkup.add(link);
        view.add(managerMarkup);
        AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                removeManagerPerformed(summary.getModelObject(), target);
                getParent().setVisible(false);
                target.add(OrgMemberPanel.this);
            }
        };
        removeManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        removeManager.setOutputMarkupId(true);
        managerMarkup.add(removeManager);
        AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
                deleteManagerPerformed(summary.getModelObject(), this, target);
            }
        };
        deleteManager.setOutputMarkupId(true);
        deleteManager.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                boolean isVisible = false;
                try {
                    isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
                } catch (Exception ex) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
                }
                return isVisible;
            }
        });
        managerMarkup.add(deleteManager);
    }
    managerContainer.add(view);
    InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
    add(menupanel);
    menupanel.setOutputMarkupId(true);
    managerContainer.add(menupanel);
    return managerContainer;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Serializable(java.io.Serializable) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) FocusSummaryPanel(com.evolveum.midpoint.web.component.FocusSummaryPanel) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) RoleSummaryPanel(com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel)

Example 37 with AjaxButton

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

the class PageXmlDataReview method initLayout.

private void initLayout(IModel<String> title, IModel<String> data) {
    WebMarkupContainer container = new WebMarkupContainer(ID_ACE_EDITOR_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    AceEditorPanel aceEditorPanel = new AceEditorPanel(ID_ACE_EDITOR_PANEL, title, data);
    aceEditorPanel.getEditor().setReadonly(true);
    aceEditorPanel.setOutputMarkupId(true);
    container.add(aceEditorPanel);
    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) AceEditorPanel(com.evolveum.midpoint.web.page.admin.reports.component.AceEditorPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 38 with AjaxButton

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

the class ChooseFocusTypeDialogPanel method initLayout.

private void initLayout() {
    DropDownChoice<QName> type = new DropDownChoice<QName>(ID_OBJECT_TYPE, Model.of(UserType.COMPLEX_TYPE), WebComponentUtil.createFocusTypeList(), new QNameChoiceRenderer());
    type.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    type.setOutputMarkupId(true);
    add(type);
    AjaxButton confirmButton = new AjaxButton(ID_BUTTON_OK, createStringResource("Button.ok")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            DropDownChoice<QName> type = (DropDownChoice<QName>) getParent().get(ID_OBJECT_TYPE);
            QName typeChosen = type.getModelObject();
            ChooseFocusTypeDialogPanel.this.okPerformed(typeChosen, target);
        }
    };
    add(confirmButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) QName(javax.xml.namespace.QName)

Example 39 with AjaxButton

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

the class ConfirmationPanel method initLayout.

private void initLayout(IModel<String> message) {
    WebMarkupContainer panel = new WebMarkupContainer(ID_PANEL);
    Label label = new Label(ID_CONFIRM_TEXT, message);
    label.setEscapeModelStrings(getLabelEscapeModelStrings());
    panel.add(label);
    AjaxButton yesButton = new AjaxButton(ID_YES, new StringResourceModel("confirmationDialog.yes", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            yesPerformed(target);
        }
    };
    panel.add(yesButton);
    AjaxButton noButton = new AjaxButton(ID_NO, new StringResourceModel("confirmationDialog.no", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            noPerformed(target);
        }
    };
    panel.add(noButton);
    add(panel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Label(org.apache.wicket.markup.html.basic.Label) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 40 with AjaxButton

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

the class DeleteAllPanel method initLayout.

private void initLayout(WebMarkupContainer content) {
    CheckBox deleteUsersCheckbox = new CheckBox(ID_CHB_USERS, new PropertyModel<Boolean>(model, DeleteAllDto.F_USERS));
    deleteUsersCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_USERS);
        }
    });
    content.add(deleteUsersCheckbox);
    CheckBox deleteOrgsCheckbox = new CheckBox(ID_CHB_ORG, new PropertyModel<Boolean>(model, DeleteAllDto.F_ORGS));
    deleteOrgsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_ORGS);
        }
    });
    content.add(deleteOrgsCheckbox);
    CheckBox deleteAccountShadowsCheckbox = new CheckBox(ID_CHB_ACCOUNT_SHADOW, new PropertyModel<Boolean>(model, DeleteAllDto.F_ACC_SHADOW));
    deleteAccountShadowsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_ACC_SHADOWS);
        }
    });
    content.add(deleteAccountShadowsCheckbox);
    CheckBox deleteNonAccountShadowsCheckbox = new CheckBox(ID_CHB_NON_ACCOUNT_SHADOW, new PropertyModel<Boolean>(model, DeleteAllDto.F_NON_ACC_SHADOW));
    deleteNonAccountShadowsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_NON_ACC_SHADOW);
        }
    });
    content.add(deleteNonAccountShadowsCheckbox);
    Label usersLabel = new Label(ID_TEXT_USERS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteUsersMessage();
        }
    });
    usersLabel.setOutputMarkupId(true);
    content.add(usersLabel);
    Label orgsLabel = new Label(ID_TEXT_ORGS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteOrgUnitsMessage();
        }
    });
    orgsLabel.setOutputMarkupId(true);
    content.add(orgsLabel);
    Label accShadowsLabel = new Label(ID_TEXT_ACC_SHADOWS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteAccountShadowsMessage();
        }
    });
    accShadowsLabel.setOutputMarkupId(true);
    content.add(accShadowsLabel);
    Label nonAccShadowsLabel = new Label(ID_TEXT_NON_ACC_SHADOW, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteNonAccountShadowsMessage();
        }
    });
    nonAccShadowsLabel.setOutputMarkupId(true);
    content.add(nonAccShadowsLabel);
    Label countLabel = new Label(ID_TOTAL, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createTotalMessage();
        }
    });
    countLabel.setOutputMarkupId(true);
    content.add(countLabel);
    AjaxButton yesButton = new AjaxButton(ID_YES, new StringResourceModel("deleteAllDialog.yes", this, null)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            yesPerformed(target);
        }
    };
    content.add(yesButton);
    AjaxButton noButton = new AjaxButton(ID_NO, new StringResourceModel("deleteAllDialog.no", this, null)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            noPerformed(target);
        }
    };
    content.add(noButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) StringResourceModel(org.apache.wicket.model.StringResourceModel) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior)

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