Search in sources :

Example 1 with SelectableBeanImpl

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

the class PageCertDefinitions method createInlineMenu.

private List<InlineMenuItem> createInlineMenu() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.createCampaign")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBean<AccessCertificationDefinitionType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    createCampaignPerformed(target, campaign);
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_START_MENU_ITEM);
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.showCampaigns")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<AccessCertificationDefinitionType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    showCampaignsPerformed(target, campaign);
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder("fa fa-files-o");
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.deleteDefinition")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<AccessCertificationDefinitionType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    deleteConfirmation(target, campaign);
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menu;
}
Also used : AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 2 with SelectableBeanImpl

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

the class ChildCasesTabPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    MainObjectListPanel<CaseType> table = new MainObjectListPanel<CaseType>(ID_CHILD_CASES_PANEL, CaseType.class, Collections.emptyList()) {

        @Override
        protected List<IColumn<SelectableBean<CaseType>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<IColumn<SelectableBean<CaseType>, String>>();
            IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
            columns.add(column);
            columns.add(ColumnUtils.createCaseActorsColumn(ChildCasesTabPanel.this.getPageBase()));
            column = new PropertyColumn<SelectableBeanImpl<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {

                @Override
                public String getCssClass() {
                    return "col-sm-2 col-md-1";
                }
            };
            columns.add(column);
            column = new AbstractExportableColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.workitems")) {

                @Override
                public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, IModel<SelectableBean<CaseType>> model) {
                    cellItem.add(new Label(componentId, model.getObject().getValue() != null && model.getObject().getValue().getWorkItem() != null ? model.getObject().getValue().getWorkItem().size() : null));
                }

                @Override
                public IModel<String> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
                    return Model.of(rowModel.getObject().getValue() != null && rowModel.getObject().getValue().getWorkItem() != null ? Integer.toString(rowModel.getObject().getValue().getWorkItem().size()) : "");
                }

                @Override
                public String getCssClass() {
                    return "col-md-2 col-lg-1";
                }
            };
            columns.add(column);
            return (List) columns;
        }

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

        @Override
        protected ISelectableDataProvider<CaseType, SelectableBean<CaseType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> getChildCasesQuery(), null);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_CASE_CHILD_CASES_TAB;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return new ArrayList<>();
        }

        @Override
        protected IColumn<SelectableBean<CaseType>, String> createCheckboxColumn() {
            return null;
        }
    };
    table.setOutputMarkupId(true);
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 3 with SelectableBeanImpl

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

the class TreeTablePanel method createTreeChildrenMenu.

private List<InlineMenuItem> createTreeChildrenMenu(TreeSelectableBean<OrgType> org) {
    List<InlineMenuItem> items = new ArrayList<>();
    boolean isAllowModify = isAllowModify(org.getValue());
    boolean isAllowRead = isAllowRead(org.getValue());
    InlineMenuItem item;
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MOVE_ACTION_URI)) {
        item = new InlineMenuItem(createStringResource("TreeTablePanel.move")) {

            private static final long serialVersionUID = 1L;

            @Override
            public InlineMenuItemAction initAction() {
                return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        moveRootPerformed(org, target);
                    }
                };
            }
        };
        items.add(item);
    }
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MAKE_ROOT_ACTION_URI)) {
        item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot")) {

            private static final long serialVersionUID = 1L;

            @Override
            public InlineMenuItemAction initAction() {
                return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        makeRootPerformed(org, target);
                    }
                };
            }
        };
        items.add(item);
    }
    item = new InlineMenuItem(createStringResource("TreeTablePanel.delete")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteNodePerformed(org, target);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowDelete(org.getValue()));
        }
    };
    items.add(item);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    recomputeRootPerformed(org, target);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowModify);
        }
    };
    items.add(item);
    InlineMenuItem editMenuItem = new InlineMenuItem(createStringResource("TreeTablePanel.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(org);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowModify);
        }
    };
    items.add(editMenuItem);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(org);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(!editMenuItem.getVisible().getObject() && isAllowRead);
        }
    };
    items.add(item);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    try {
                        initObjectForAdd(ObjectTypeUtil.createObjectRef(org.getValue(), getPageBase().getPrismContext()), target);
                    } catch (SchemaException e) {
                        throw new SystemException(e.getMessage(), e);
                    }
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowRead && isAllowAddNew());
        }
    };
    items.add(item);
    return items;
}
Also used : IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 4 with SelectableBeanImpl

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

the class ChildCasesPanel method initLayout.

protected void initLayout() {
    setOutputMarkupId(true);
    MainObjectListPanel<CaseType> table = new MainObjectListPanel<CaseType>(ID_CHILD_CASES_PANEL, CaseType.class, Collections.emptyList()) {

        @Override
        protected List<IColumn<SelectableBean<CaseType>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<IColumn<SelectableBean<CaseType>, String>>();
            IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
            columns.add(column);
            columns.add(ColumnUtils.createCaseActorsColumn(ChildCasesPanel.this.getPageBase()));
            column = new PropertyColumn<SelectableBeanImpl<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {

                @Override
                public String getCssClass() {
                    return "col-sm-2 col-md-1";
                }
            };
            columns.add(column);
            column = new AbstractExportableColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.workitems")) {

                @Override
                public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, IModel<SelectableBean<CaseType>> model) {
                    cellItem.add(new Label(componentId, model.getObject().getValue() != null && model.getObject().getValue().getWorkItem() != null ? model.getObject().getValue().getWorkItem().size() : null));
                }

                @Override
                public IModel<String> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
                    return Model.of(rowModel.getObject().getValue() != null && rowModel.getObject().getValue().getWorkItem() != null ? Integer.toString(rowModel.getObject().getValue().getWorkItem().size()) : "");
                }

                @Override
                public String getCssClass() {
                    return "col-md-2 col-lg-1";
                }
            };
            columns.add(column);
            return (List) columns;
        }

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

        @Override
        protected ISelectableDataProvider<CaseType, SelectableBean<CaseType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> getChildCasesQuery(), null);
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_CASE_CHILD_CASES_TAB;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return new ArrayList<>();
        }

        @Override
        protected IColumn<SelectableBean<CaseType>, String> createCheckboxColumn() {
            return null;
        }
    };
    table.setOutputMarkupId(true);
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 5 with SelectableBeanImpl

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

the class InternalsLoggedInUsersPanel method initLayout.

private void initLayout() {
    MainObjectListPanel<F> table = new MainObjectListPanel(ID_TABLE, FocusType.class, null) {

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
            if (WebComponentUtil.hasDetailsPage(object.getClass())) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, object.getOid());
                getPageBase().navigateToNext(WebComponentUtil.getObjectDetailsPage(object.getClass()), parameters);
            }
        }

        @Override
        protected List<IColumn<SelectableBean<F>, String>> createDefaultColumns() {
            return InternalsLoggedInUsersPanel.this.initColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return initInlineMenu();
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected ISelectableDataProvider<UserSessionManagementType, SelectableBean<F>> createProvider() {
            LoadableModel<List<UserSessionManagementType>> principals = new LoadableModel<List<UserSessionManagementType>>(true) {

                @Override
                protected List<UserSessionManagementType> load() {
                    return loadLoggedInPrincipals();
                }
            };
            return new SelectableListDataProvider<SelectableBean<F>, UserSessionManagementType>(InternalsLoggedInUsersPanel.this, principals) {

                @Override
                protected SelectableBean<F> createObjectWrapper(UserSessionManagementType principal) {
                    SelectableBeanImpl<F> user = new SelectableBeanImpl<>((F) principal.getFocus());
                    user.setActiveSessions(principal.getActiveSessions());
                    user.setNodes(principal.getNode());
                    return user;
                }
            };
        }

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

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            return new ArrayList<>();
        }

        @Override
        protected boolean enableSavePageSize() {
            return false;
        }
    };
    add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) UserSessionManagementType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.UserSessionManagementType) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.apache.wicket.Component)

Aggregations

SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)18 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)12 ArrayList (java.util.ArrayList)12 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)9 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)9 IModel (org.apache.wicket.model.IModel)9 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)6 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)4 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)3 List (java.util.List)3 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)2