Search in sources :

Example 31 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class AccessTokenDirectoryPanel method getColumns.

@Override
protected List<IColumn<AccessTokenTO, String>> getColumns() {
    List<IColumn<AccessTokenTO, String>> columns = new ArrayList<>();
    columns.add(new KeyPropertyColumn<>(new StringResourceModel(Constants.KEY_FIELD_NAME, this), Constants.KEY_FIELD_NAME, Constants.KEY_FIELD_NAME));
    columns.add(new PropertyColumn<>(new ResourceModel("owner"), "owner", "owner"));
    columns.add(new AbstractColumn<AccessTokenTO, String>(new ResourceModel("issuedAt", "")) {

        private static final long serialVersionUID = -1822504503325964706L;

        @Override
        public void populateItem(final Item<ICellPopulator<AccessTokenTO>> cellItem, final String componentId, final IModel<AccessTokenTO> model) {
            JwsJwtCompactConsumer consumer = new JwsJwtCompactConsumer(model.getObject().getBody());
            cellItem.add(new Label(componentId, SyncopeConsoleSession.get().getDateFormat().format(new Date(consumer.getJwtClaims().getIssuedAt()))));
        }
    });
    columns.add(new DatePropertyColumn<>(new ResourceModel("expiryTime"), "expiryTime", "expiryTime"));
    return columns;
}
Also used : AccessTokenTO(org.apache.syncope.common.lib.to.AccessTokenTO) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) Date(java.util.Date) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) JwsJwtCompactConsumer(org.apache.cxf.rs.security.jose.jws.JwsJwtCompactConsumer) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 32 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class ActionDataTablePanel method addCancelButton.

public void addCancelButton(final BaseModal<?> modal) {
    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -4804368561204623354L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            modal.close(target);
        }
    };
    cancel.setDefaultFormProcessing(false);
    bulkActionForm.addOrReplace(cancel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IndicatingAjaxButton(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton) AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) Form(org.apache.wicket.markup.html.form.Form) ResourceModel(org.apache.wicket.model.ResourceModel) IndicatingAjaxButton(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton)

Example 33 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class ParametersDirectoryPanel method getColumns.

@Override
protected List<IColumn<AttrTO, String>> getColumns() {
    final List<IColumn<AttrTO, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn<>(new ResourceModel("schema"), "schema"));
    columns.add(new PropertyColumn<AttrTO, String>(new ResourceModel("values"), "values") {

        private static final long serialVersionUID = -1822504503325964706L;

        @Override
        public void populateItem(final Item<ICellPopulator<AttrTO>> item, final String componentId, final IModel<AttrTO> rowModel) {
            PlainSchemaTO modelSchemaTO = (PlainSchemaTO) rowModel.getObject().getSchemaInfo();
            AttrSchemaType type = modelSchemaTO.getType();
            if (type == AttrSchemaType.Binary || type == AttrSchemaType.Encrypted) {
                item.add(new Label(componentId, type.name()).add(new AttributeModifier("style", "font-style:italic")));
            } else {
                super.populateItem(item, componentId, rowModel);
            }
        }
    });
    return columns;
}
Also used : ArrayList(java.util.ArrayList) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AttrSchemaType(org.apache.syncope.common.lib.types.AttrSchemaType) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 34 with ResourceModel

use of org.apache.wicket.model.ResourceModel 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)

Example 35 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class RemediationDirectoryPanel method getActions.

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

        private static final long serialVersionUID = 6193210574968203299L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
            modal.header(new ResourceModel("error"));
            modal.setContent(new ExecMessageModal(model.getObject().getError()));
            modal.show(true);
            target.add(modal);
        }
    }, ActionLink.ActionType.VIEW_DETAILS, StandardEntitlement.REMEDIATION_READ);
    if (model.getObject().getOperation() == ResourceOperation.DELETE) {
        String entitlements = StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_DELETE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_DELETE : AnyEntitlement.DELETE.getFor(model.getObject().getAnyType()) }, ",");
        panel.add(new ActionLink<RemediationTO>() {

            private static final long serialVersionUID = 6193210574968203299L;

            @Override
            public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
                try {
                    restClient.remedy(model.getObject().getKey(), model.getObject().getKeyPayload());
                    SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                    target.add(container);
                } catch (SyncopeClientException e) {
                    LOG.error("While performing remediation {}", model.getObject().getKey(), e);
                    SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
                }
                ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
            }
        }, ActionLink.ActionType.CLOSE, entitlements, true);
    } else {
        String entitlements = model.getObject().getOperation() == ResourceOperation.CREATE ? StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_CREATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_CREATE : AnyEntitlement.CREATE.getFor(model.getObject().getAnyType()) }, ",") : StringUtils.join(new String[] { StandardEntitlement.REMEDIATION_REMEDY, AnyTypeKind.USER.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.USER_UPDATE : AnyTypeKind.GROUP.name().equals(model.getObject().getAnyType()) ? StandardEntitlement.GROUP_UPDATE : AnyEntitlement.UPDATE.getFor(model.getObject().getAnyType()) }, ",");
        panel.add(new ActionLink<RemediationTO>() {

            private static final long serialVersionUID = 6193210574968203299L;

            @Override
            public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
                modal.setFormModel(new CompoundPropertyModel<>(model.getObject()));
                RemediationTO remediationTO = model.getObject();
                switch(remediationTO.getAnyType()) {
                    case "USER":
                        UserTO newUserTO;
                        UserTO previousUserTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newUserTO = (UserTO) remediationTO.getAnyTOPayload();
                            previousUserTO = null;
                        } else {
                            previousUserTO = new UserRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newUserTO = AnyOperations.patch(previousUserTO, (UserPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<UserTO> userEvent = new AjaxWizard.EditItemActionEvent<>(newUserTO, target);
                        userEvent.forceModalPanel(new RemediationUserWizardBuilder(model.getObject(), previousUserTO, newUserTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getLeft(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, userEvent);
                        break;
                    case "GROUP":
                        GroupTO newGroupTO;
                        GroupTO previousGroupTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newGroupTO = (GroupTO) remediationTO.getAnyTOPayload();
                            previousGroupTO = null;
                        } else {
                            previousGroupTO = new GroupRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newGroupTO = AnyOperations.patch(previousGroupTO, (GroupPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<GroupTO> groupEvent = new AjaxWizard.EditItemActionEvent<>(newGroupTO, target);
                        groupEvent.forceModalPanel(new RemediationGroupWizardBuilder(model.getObject(), previousGroupTO, newGroupTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getMiddle(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, groupEvent);
                        break;
                    default:
                        AnyObjectTO newAnyObjectTO;
                        AnyObjectTO previousAnyObjectTO;
                        if (remediationTO.getAnyPatchPayload() == null) {
                            newAnyObjectTO = (AnyObjectTO) remediationTO.getAnyTOPayload();
                            previousAnyObjectTO = null;
                        } else {
                            previousAnyObjectTO = new AnyObjectRestClient().read(remediationTO.getAnyPatchPayload().getKey());
                            newAnyObjectTO = AnyOperations.patch(previousAnyObjectTO, (AnyObjectPatch) remediationTO.getAnyPatchPayload());
                        }
                        AjaxWizard.EditItemActionEvent<AnyObjectTO> anyObjectEvent = new AjaxWizard.EditItemActionEvent<>(newAnyObjectTO, target);
                        anyObjectEvent.forceModalPanel(new RemediationAnyObjectWizardBuilder(model.getObject(), previousAnyObjectTO, newAnyObjectTO, new AnyTypeRestClient().read(remediationTO.getAnyType()).getClasses(), FormLayoutInfoUtils.fetch(Arrays.asList(remediationTO.getAnyType())).getRight().values().iterator().next(), pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT));
                        send(RemediationDirectoryPanel.this, Broadcast.EXACT, anyObjectEvent);
                }
            }
        }, ActionLink.ActionType.EDIT, entitlements);
    }
    panel.add(new ActionLink<RemediationTO>() {

        private static final long serialVersionUID = 6193210574968203299L;

        @Override
        public void onClick(final AjaxRequestTarget target, final RemediationTO ignore) {
            try {
                restClient.delete(model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.REMEDIATION_DELETE, true);
    return panel;
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) ResourceModel(org.apache.wicket.model.ResourceModel) StringResourceModel(org.apache.wicket.model.StringResourceModel) GroupRestClient(org.apache.syncope.client.console.rest.GroupRestClient) AnyObjectRestClient(org.apache.syncope.client.console.rest.AnyObjectRestClient) BasePage(org.apache.syncope.client.console.pages.BasePage) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) RemediationTO(org.apache.syncope.common.lib.to.RemediationTO) UserRestClient(org.apache.syncope.client.console.rest.UserRestClient) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserTO(org.apache.syncope.common.lib.to.UserTO)

Aggregations

ResourceModel (org.apache.wicket.model.ResourceModel)48 ArrayList (java.util.ArrayList)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)19 Label (org.apache.wicket.markup.html.basic.Label)17 StringResourceModel (org.apache.wicket.model.StringResourceModel)15 Panel (org.apache.wicket.markup.html.panel.Panel)11 List (java.util.List)9 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)9 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)8 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 Form (org.apache.wicket.markup.html.form.Form)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)4 Fragment (org.apache.wicket.markup.html.panel.Fragment)4 NavbarButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton)3 StringUtils (org.apache.commons.lang3.StringUtils)3