Search in sources :

Example 1 with TypedAssignablePanel

use of com.evolveum.midpoint.gui.api.component.TypedAssignablePanel in project midpoint by Evolveum.

the class AssignmentTablePanel method createAssignmentMenu.

protected List<InlineMenuItem> createAssignmentMenu() {
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item;
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ASSIGN_ACTION_URL)) {
        item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.assign"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                TypedAssignablePanel panel = new TypedAssignablePanel(getPageBase().getMainPopupBodyId(), RoleType.class, true, getPageBase()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    protected void addPerformed(AjaxRequestTarget target, List selected) {
                        super.addPerformed(target, selected);
                        addSelectedAssignablePerformed(target, selected, getPageBase().getMainPopup().getId());
                        reloadMainFormButtons(target);
                    }
                };
                panel.setOutputMarkupId(true);
                getPageBase().showMainPopup(panel, target);
            }
        });
        items.add(item);
        item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.assignOrg"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                int count = WebModelServiceUtils.countObjects(OrgType.class, null, getPageBase());
                if (count > 0) {
                    OrgTreeAssignablePanel orgTreePanel = new OrgTreeAssignablePanel(getPageBase().getMainPopupBodyId(), true, getPageBase()) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void assignSelectedOrgPerformed(List<OrgType> selectedOrgs, AjaxRequestTarget target) {
                            // TODO Auto-generated method stub
                            addSelectedAssignablePerformed(target, (List) selectedOrgs, getPageBase().getMainPopup().getId());
                            reloadMainFormButtons(target);
                        }
                    };
                    orgTreePanel.setOutputMarkupId(true);
                    getPageBase().showMainPopup(orgTreePanel, target);
                } else {
                    warn(createStringResource("AssignmentTablePanel.menu.assignOrg.noorgs").getString());
                    target.add(getPageBase().getFeedbackPanel());
                }
            }
        });
        items.add(item);
        items.add(new InlineMenuItem());
    }
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL)) {
        item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.unassign"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                AssignmentTablePanel.this.deleteAssignmentPerformed(target);
            }
        });
        items.add(item);
    }
    item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.showAllAssignments"), new InlineMenuItemAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showAllAssignments(target);
        }
    });
    items.add(item);
    return items;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) TypedAssignablePanel(com.evolveum.midpoint.gui.api.component.TypedAssignablePanel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) List(java.util.List) ArrayList(java.util.ArrayList) OrgTreeAssignablePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreeAssignablePanel)

Aggregations

TypedAssignablePanel (com.evolveum.midpoint.gui.api.component.TypedAssignablePanel)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)1 OrgTreeAssignablePanel (com.evolveum.midpoint.web.page.admin.orgs.OrgTreeAssignablePanel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1