Search in sources :

Example 1 with ActionLink

use of org.apache.syncope.client.console.wicket.markup.html.form.ActionLink in project syncope by apache.

the class AnyObjectDirectoryPanel method getActions.

@Override
public ActionsPanel<AnyObjectTO> getActions(final IModel<AnyObjectTO> model) {
    final ActionsPanel<AnyObjectTO> panel = super.getActions(model);
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new AnyWrapper<>(new AnyObjectRestClient().read(model.getObject().getKey())), target));
        }
    }, ActionType.EDIT, StringUtils.join(new String[] { AnyEntitlement.READ.getFor(type), AnyEntitlement.UPDATE.getFor(type) }, ",")).setRealm(realm);
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            final AnyObjectTO clone = SerializationUtils.clone(model.getObject());
            clone.setKey(null);
            send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new AnyWrapper<>(clone), target));
        }

        @Override
        protected boolean statusCondition(final AnyObjectTO modelObject) {
            return addAjaxLink.isVisibleInHierarchy() && realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.CLONE, AnyEntitlement.CREATE.getFor(type)).setRealm(realm);
    if (wizardInModal) {
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770645L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                final IModel<AnyWrapper<AnyObjectTO>> formModel = new CompoundPropertyModel<>(new AnyWrapper<>(model.getObject()));
                altDefaultModal.setFormModel(formModel);
                target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false)));
                altDefaultModal.header(new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject())))));
                altDefaultModal.show(true);
            }
        }, ActionType.MANAGE_RESOURCES, AnyEntitlement.UPDATE.getFor(type)).setRealm(realm);
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef)));
                utilityModal.header(new StringResourceModel("any.propagation.tasks", model));
                utilityModal.show(true);
            }
        }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST);
        panel.add(new ActionLink<AnyObjectTO>() {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
                target.add(utilityModal.setContent(new NotificationTasks(AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef)));
                utilityModal.header(new StringResourceModel("any.notification.tasks", model));
                utilityModal.show(true);
                target.add(utilityModal);
            }
        }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST);
    }
    panel.add(new ActionLink<AnyObjectTO>() {

        private static final long serialVersionUID = -7978723352517770646L;

        @Override
        public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) {
            try {
                restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting object {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }

        @Override
        protected boolean statusCondition(final AnyObjectTO modelObject) {
            return realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.DELETE, AnyEntitlement.DELETE.getFor(type), true).setRealm(realm);
    return panel;
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyWrapper(org.apache.syncope.client.console.wizards.any.AnyWrapper) NotificationTasks(org.apache.syncope.client.console.notifications.NotificationTasks) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AnyStatusModal(org.apache.syncope.client.console.status.AnyStatusModal) AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AnyPropagationTasks(org.apache.syncope.client.console.tasks.AnyPropagationTasks) AnyObjectRestClient(org.apache.syncope.client.console.rest.AnyObjectRestClient) StringResourceModel(org.apache.wicket.model.StringResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Example 2 with ActionLink

use of org.apache.syncope.client.console.wicket.markup.html.form.ActionLink in project syncope by apache.

the class GroupDirectoryPanel method getHeader.

@Override
public ActionsPanel<Serializable> getHeader(final String componentId) {
    final ActionsPanel<Serializable> panel = super.getHeader(componentId);
    panel.add(new ActionLink<Serializable>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
            target.add(displayAttributeModal.setContent(new GroupDisplayAttributesModalPanel<>(displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames)));
            displayAttributeModal.header(new ResourceModel("any.attr.display"));
            displayAttributeModal.show(true);
        }
    }, ActionType.CHANGE_VIEW, StandardEntitlement.GROUP_READ).hideLabel();
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Serializable(java.io.Serializable) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Example 3 with ActionLink

use of org.apache.syncope.client.console.wicket.markup.html.form.ActionLink in project syncope by apache.

the class GroupDirectoryPanel method getActions.

@Override
public ActionsPanel<GroupTO> getActions(final IModel<GroupTO> model) {
    final ActionsPanel<GroupTO> panel = super.getActions(model);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            send(GroupDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new GroupWrapper(restClient.read(model.getObject().getKey())), target));
        }
    }, ActionType.EDIT, StringUtils.join(new String[] { StandardEntitlement.GROUP_READ, StandardEntitlement.GROUP_UPDATE }, ",")).setRealm(realm);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = 6242834621660352855L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            GroupTO clone = SerializationUtils.clone(model.getObject());
            clone.setKey(null);
            send(GroupDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new GroupWrapper(clone), target));
        }

        @Override
        protected boolean statusCondition(final GroupTO modelObject) {
            return realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.CLONE, StandardEntitlement.GROUP_CREATE).setRealm(realm);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = 6242834621660352855L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            target.add(typeExtensionsModal.setContent(new TypeExtensionDirectoryPanel(typeExtensionsModal, model.getObject(), pageRef)));
            typeExtensionsModal.header(new StringResourceModel("typeExtensions", model));
            typeExtensionsModal.show(true);
        }
    }, ActionType.TYPE_EXTENSIONS, StandardEntitlement.GROUP_UPDATE).setRealm(realm);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            templates.setTargetObject(model.getObject());
            templates.toggle(target, true);
        }

        @Override
        public boolean isIndicatorEnabled() {
            return false;
        }
    }, ActionType.MEMBERS, StandardEntitlement.GROUP_UPDATE).setRealm(realm);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            try {
                restClient.bulkMembersAction(model.getObject().getKey(), BulkMembersActionType.PROVISION);
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While provisioning members of group {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionType.PROVISION_MEMBERS, String.format("%s,%s", StandardEntitlement.TASK_CREATE, StandardEntitlement.TASK_EXECUTE));
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            try {
                restClient.bulkMembersAction(model.getObject().getKey(), BulkMembersActionType.DEPROVISION);
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While provisioning members of group {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionType.DEPROVISION_MEMBERS, String.format("%s,%s", StandardEntitlement.TASK_CREATE, StandardEntitlement.TASK_EXECUTE));
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            IModel<AnyWrapper<GroupTO>> formModel = new CompoundPropertyModel<>(new AnyWrapper<>(model.getObject()));
            altDefaultModal.setFormModel(formModel);
            target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false)));
            altDefaultModal.header(new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject())))));
            altDefaultModal.show(true);
        }
    }, ActionType.MANAGE_RESOURCES, StandardEntitlement.GROUP_READ).setRealm(realm);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.GROUP, model.getObject().getKey(), pageRef)));
            utilityModal.header(new StringResourceModel("any.propagation.tasks", model));
            utilityModal.show(true);
        }
    }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            target.add(utilityModal.setContent(new NotificationTasks(AnyTypeKind.GROUP, model.getObject().getKey(), pageRef)));
            utilityModal.header(new StringResourceModel("any.notification.tasks", model));
            utilityModal.show(true);
        }
    }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST);
    panel.add(new ActionLink<GroupTO>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final GroupTO ignore) {
            try {
                restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting object {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }

        @Override
        protected boolean statusCondition(final GroupTO modelObject) {
            return realm.startsWith(SyncopeConstants.ROOT_REALM);
        }
    }, ActionType.DELETE, StandardEntitlement.GROUP_DELETE, true).setRealm(realm);
    return panel;
}
Also used : CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) GroupWrapper(org.apache.syncope.client.console.wizards.any.GroupWrapper) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyWrapper(org.apache.syncope.client.console.wizards.any.AnyWrapper) NotificationTasks(org.apache.syncope.client.console.notifications.NotificationTasks) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AnyStatusModal(org.apache.syncope.client.console.status.AnyStatusModal) AnyPropagationTasks(org.apache.syncope.client.console.tasks.AnyPropagationTasks) BasePage(org.apache.syncope.client.console.pages.BasePage) StringResourceModel(org.apache.wicket.model.StringResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Example 4 with ActionLink

use of org.apache.syncope.client.console.wicket.markup.html.form.ActionLink in project syncope by apache.

the class AnyObjectDirectoryPanel method getHeader.

@Override
public ActionsPanel<Serializable> getHeader(final String componentId) {
    final ActionsPanel<Serializable> panel = super.getHeader(componentId);
    panel.add(new ActionLink<Serializable>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
            target.add(displayAttributeModal.setContent(new AnyObjectDisplayAttributesModalPanel<>(displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames, type)));
            displayAttributeModal.addSubmitButton();
            displayAttributeModal.header(new ResourceModel("any.attr.display"));
            displayAttributeModal.show(true);
        }

        @Override
        protected boolean statusCondition(final Serializable modelObject) {
            return wizardInModal;
        }
    }, ActionType.CHANGE_VIEW, AnyEntitlement.READ.getFor(type)).hideLabel();
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Serializable(java.io.Serializable) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Example 5 with ActionLink

use of org.apache.syncope.client.console.wicket.markup.html.form.ActionLink in project syncope by apache.

the class UserDirectoryPanel method getHeader.

@Override
public ActionsPanel<Serializable> getHeader(final String componentId) {
    final ActionsPanel<Serializable> panel = super.getHeader(componentId);
    panel.add(new ActionLink<Serializable>() {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
            target.add(displayAttributeModal.setContent(new UserDisplayAttributesModalPanel<>(displayAttributeModal, page.getPageReference(), pSchemaNames, dSchemaNames)));
            displayAttributeModal.header(new ResourceModel("any.attr.display"));
            displayAttributeModal.addSubmitButton();
            displayAttributeModal.show(true);
        }

        @Override
        protected boolean statusCondition(final Serializable modelObject) {
            return wizardInModal;
        }
    }, ActionType.CHANGE_VIEW, StandardEntitlement.USER_READ).hideLabel();
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Serializable(java.io.Serializable) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) ActionLink(org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)

Aggregations

ActionLink (org.apache.syncope.client.console.wicket.markup.html.form.ActionLink)8 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)8 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 ResourceModel (org.apache.wicket.model.ResourceModel)4 Serializable (java.io.Serializable)3 NotificationTasks (org.apache.syncope.client.console.notifications.NotificationTasks)3 AnyStatusModal (org.apache.syncope.client.console.status.AnyStatusModal)3 AnyPropagationTasks (org.apache.syncope.client.console.tasks.AnyPropagationTasks)3 ArrayList (java.util.ArrayList)2 ListViewPanel (org.apache.syncope.client.console.panels.ListViewPanel)2 AjaxWizard (org.apache.syncope.client.console.wizards.AjaxWizard)2 AnyWrapper (org.apache.syncope.client.console.wizards.any.AnyWrapper)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1