Search in sources :

Example 1 with GenericMultiValueLabelEditPanel

use of com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel in project midpoint by Evolveum.

the class RolePolicyPanel method initLayout.

@Override
protected void initLayout() {
    minAssignmentModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            RoleType roleType = role.asObjectable();
            if (roleType.getPolicyConstraints() == null) {
                roleType.setPolicyConstraints(new PolicyConstraintsType());
            }
            return roleType.getPolicyConstraints().getMinAssignees();
        }
    };
    maxAssignmentsModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            RoleType roleType = role.asObjectable();
            if (roleType.getPolicyConstraints() == null) {
                roleType.setPolicyConstraints(new PolicyConstraintsType());
            }
            return roleType.getPolicyConstraints().getMaxAssignees();
        }
    };
    GenericMultiValueLabelEditPanel minAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MIN_ASSIGNMENTS, minAssignmentModel, createStringResource("PageRoleEditor.label.minAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMinAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    minAssignments.setOutputMarkupId(true);
    add(minAssignments);
    GenericMultiValueLabelEditPanel maxAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MAX_ASSIGNMENTS, maxAssignmentsModel, createStringResource("PageRoleEditor.label.maxAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMaxAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    maxAssignments.setOutputMarkupId(true);
    add(maxAssignments);
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultiplicityPolicyPanel(com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel) IModel(org.apache.wicket.model.IModel) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType) List(java.util.List)

Example 2 with GenericMultiValueLabelEditPanel

use of com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel in project midpoint by Evolveum.

the class AdminGuiConfigPanel method initLayout.

private void initLayout() {
    GenericMultiValueLabelEditPanel<RichHyperlinkType> dashboardLinkEditor = new GenericMultiValueLabelEditPanel<RichHyperlinkType>(ID_DASHBOARD_LINK_EDITOR, new PropertyModel<List<RichHyperlinkType>>(getModel(), "userDashboardLink"), createStringResource("AdminGuiConfigPanel.dashboardLinksConfig"), LABEL_SIZE, INPUT_SIZE, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createTextModel(final IModel<RichHyperlinkType> model) {
            return new PropertyModel<String>(model, "label");
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<RichHyperlinkType> rowModel) {
            RichHyperlinkConfigPanel contentPanel = new RichHyperlinkConfigPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject(), false) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getDashboardLinkEditorContainer());
                }

                @Override
                public StringResourceModel getTitle() {
                    return createStringResource("AdminGuiConfigPanel.dashboardLinkDialogTitle.title");
                }
            };
            showDialog(contentPanel, target);
        }

        @Override
        protected RichHyperlinkType createNewEmptyItem() {
            RichHyperlinkType link = new RichHyperlinkType();
            link.getAuthorization().add("");
            return link;
        }
    };
    dashboardLinkEditor.setOutputMarkupId(true);
    add(dashboardLinkEditor);
    GenericMultiValueLabelEditPanel<RichHyperlinkType> additionalMenuItemEditor = new GenericMultiValueLabelEditPanel<RichHyperlinkType>(ID_ADDITIONAL_MENU_ITEM_EDITOR, new PropertyModel<List<RichHyperlinkType>>(getModel(), "additionalMenuLink"), createStringResource("AdminGuiConfigPanel.additionalMenuItemConfig"), LABEL_SIZE, INPUT_SIZE, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createTextModel(final IModel<RichHyperlinkType> model) {
            return new PropertyModel<String>(model, "label");
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<RichHyperlinkType> rowModel) {
            RichHyperlinkConfigPanel contentPanel = new RichHyperlinkConfigPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject(), true) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getAdditionalMenuItemContainer());
                }

                @Override
                public StringResourceModel getTitle() {
                    return createStringResource("AdminGuiConfigPanel.additionalMenuItemDialog.title");
                }
            };
            showDialog(contentPanel, target);
        }

        @Override
        protected RichHyperlinkType createNewEmptyItem() {
            RichHyperlinkType link = new RichHyperlinkType();
            link.getAuthorization().add("");
            return link;
        }
    };
    additionalMenuItemEditor.setOutputMarkupId(true);
    add(additionalMenuItemEditor);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) RichHyperlinkType(com.evolveum.midpoint.xml.ns._public.common.common_3.RichHyperlinkType) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) PropertyModel(org.apache.wicket.model.PropertyModel) List(java.util.List)

Example 3 with GenericMultiValueLabelEditPanel

use of com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel in project midpoint by Evolveum.

the class MultipleAssignmentSelectorPanel method createTenantContainer.

private GenericMultiValueLabelEditPanel createTenantContainer() {
    final GenericMultiValueLabelEditPanel tenantEditor = new GenericMultiValueLabelEditPanel<OrgType>(ID_TENANT_EDITOR, createTenantModel(), createStringResource("MultipleAssignmentSelector.tenant"), LABEL_SIZE, INPUT_SIZE, false) {

        @Override
        protected boolean getLabelVisibility() {
            return false;
        }

        @Override
        protected IModel<String> createTextModel(final IModel<OrgType> model) {
            return new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getName(model.getObject().asPrismObject());
                }

                @Override
                public void setObject(String s) {
                }

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

        @Override
        protected void removeValuePerformed(AjaxRequestTarget target, ListItem<OrgType> item) {
            tenantEditorObject.clear();
            tenantEditorObject.add(new OrgType());
            target.add(getTenantEditorContainer());
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<OrgType> rowModel) {
            List<QName> supportedTypes = new ArrayList<>();
            supportedTypes.add(getPageBase().getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).getTypeName());
            ObjectFilter filter = QueryBuilder.queryFor(OrgType.class, getPageBase().getPrismContext()).item(OrgType.F_TENANT).eq(true).buildFilter();
            ObjectBrowserPanel<OrgType> tenantPanel = new ObjectBrowserPanel<OrgType>(getPageBase().getMainPopupBodyId(), OrgType.class, supportedTypes, false, getPageBase(), filter) {

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, OrgType org) {
                    super.onSelectPerformed(target, org);
                    tenantEditorObject.clear();
                    tenantEditorObject.add(org);
                    target.add(getTenantEditorContainer());
                }
            };
            //                OrgTreeAssignablePanel tenantPanel = new OrgTreeAssignablePanel(
            //                        getPageBase().getMainPopupBodyId(), false, getPageBase()) {
            //
            //                    @Override
            //                    protected void onItemSelect(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
            //                        closeModalWindow(target);
            //                        tenantEditorObject.clear();
            //                        tenantEditorObject.add(selected.getValue());
            //                        target.add(getTenantEditorContainer());                    }
            //                };
            getPageBase().showMainPopup(tenantPanel, target);
        }
    };
    tenantEditor.setOutputMarkupId(true);
    return tenantEditor;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) ArrayList(java.util.ArrayList) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 4 with GenericMultiValueLabelEditPanel

use of com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel in project midpoint by Evolveum.

the class MultipleAssignmentSelectorPanel method createOrgContainer.

private GenericMultiValueLabelEditPanel createOrgContainer() {
    final GenericMultiValueLabelEditPanel orgUnitEditor = new GenericMultiValueLabelEditPanel<OrgType>(ID_ORG_EDITOR, createOrgUnitModel(), createStringResource("MultipleAssignmentSelector.orgUnit"), LABEL_SIZE, INPUT_SIZE, false) {

        @Override
        protected boolean getLabelVisibility() {
            return false;
        }

        @Override
        protected IModel<String> createTextModel(final IModel<OrgType> model) {
            return new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getName(model.getObject().asPrismObject());
                }

                @Override
                public void setObject(String s) {
                }

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

        @Override
        protected void removeValuePerformed(AjaxRequestTarget target, ListItem<OrgType> item) {
            orgEditorObject.clear();
            orgEditorObject.add(new OrgType());
            target.add(getOrgUnitEditorContainer());
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<OrgType> rowModel) {
            List<QName> supportedTypes = new ArrayList<>();
            supportedTypes.add(getPageBase().getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).getTypeName());
            ObjectBrowserPanel<OrgType> orgPanel = new ObjectBrowserPanel<OrgType>(getPageBase().getMainPopupBodyId(), OrgType.class, supportedTypes, false, getPageBase()) {

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, OrgType org) {
                    super.onSelectPerformed(target, org);
                    orgEditorObject.clear();
                    orgEditorObject.add(org);
                    target.add(getOrgUnitEditorContainer());
                }
            };
            getPageBase().showMainPopup(orgPanel, target);
        }
    };
    orgUnitEditor.setOutputMarkupId(true);
    return orgUnitEditor;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) ArrayList(java.util.ArrayList) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 5 with GenericMultiValueLabelEditPanel

use of com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel in project midpoint by Evolveum.

the class BaseAbstractRolePanel method initLayout.

@Override
protected void initLayout() {
    minAssignmentModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            if (abstractRole.getPolicyConstraints() == null) {
                abstractRole.setPolicyConstraints(new PolicyConstraintsType());
            }
            return abstractRole.getPolicyConstraints().getMinAssignees();
        }
    };
    maxAssignmentsModel = new LoadableModel<List<MultiplicityPolicyConstraintType>>(false) {

        @Override
        protected List<MultiplicityPolicyConstraintType> load() {
            if (abstractRole.getPolicyConstraints() == null) {
                abstractRole.setPolicyConstraints(new PolicyConstraintsType());
            }
            return abstractRole.getPolicyConstraints().getMaxAssignees();
        }
    };
    GenericMultiValueLabelEditPanel minAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MIN_ASSIGNMENTS, minAssignmentModel, createStringResource("PageRoleEditor.label.minAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMinAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    minAssignments.setOutputMarkupId(true);
    add(minAssignments);
    GenericMultiValueLabelEditPanel maxAssignments = new GenericMultiValueLabelEditPanel<MultiplicityPolicyConstraintType>(ID_MAX_ASSIGNMENTS, maxAssignmentsModel, createStringResource("PageRoleEditor.label.maxAssignments"), ID_LABEL_SIZE, ID_INPUT_SIZE, true) {

        @Override
        protected IModel<String> createTextModel(IModel<MultiplicityPolicyConstraintType> model) {
            return createMultiplicityPolicyLabel(model);
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<MultiplicityPolicyConstraintType> rowModel) {
            MultiplicityPolicyPanel window = new MultiplicityPolicyPanel(getPageBase().getMainPopupBodyId(), rowModel.getObject()) {

                @Override
                protected void savePerformed(AjaxRequestTarget target) {
                    closeModalWindow(target);
                    target.add(getMaxAssignmentsContainer());
                }
            };
            showDialog(window, target);
        }

        @Override
        protected MultiplicityPolicyConstraintType createNewEmptyItem() {
            return new MultiplicityPolicyConstraintType();
        }
    };
    maxAssignments.setOutputMarkupId(true);
    add(maxAssignments);
}
Also used : PolicyConstraintsType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MultiplicityPolicyPanel(com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel) IModel(org.apache.wicket.model.IModel) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) MultiplicityPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType) List(java.util.List)

Aggregations

GenericMultiValueLabelEditPanel (com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 IModel (org.apache.wicket.model.IModel)6 List (java.util.List)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)2 MultiplicityPolicyPanel (com.evolveum.midpoint.web.page.admin.roles.component.MultiplicityPolicyPanel)2 MultiplicityPolicyConstraintType (com.evolveum.midpoint.xml.ns._public.common.common_3.MultiplicityPolicyConstraintType)2 PolicyConstraintsType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyConstraintsType)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 ResourceAssociationDefinition (com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 RichHyperlinkType (com.evolveum.midpoint.xml.ns._public.common.common_3.RichHyperlinkType)1 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)1 ListView (org.apache.wicket.markup.html.list.ListView)1 PropertyModel (org.apache.wicket.model.PropertyModel)1