Search in sources :

Example 6 with MainObjectListPanel

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

the class PageArchetypes method initLayout.

private void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<ArchetypeType> table = new MainObjectListPanel<ArchetypeType>(ID_TABLE, ArchetypeType.class) {

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

        @Override
        protected IColumn<SelectableBean<ArchetypeType>, String> createCheckboxColumn() {
            return null;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) ArchetypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.ArchetypeType) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm)

Example 7 with MainObjectListPanel

use of com.evolveum.midpoint.gui.api.component.MainObjectListPanel 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 8 with MainObjectListPanel

use of com.evolveum.midpoint.gui.api.component.MainObjectListPanel 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)

Example 9 with MainObjectListPanel

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

the class ResourceTasksPanel method initLayout.

protected void initLayout() {
    final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<>(ID_TASKS_TABLE, TaskType.class, null) {

        private static final long serialVersionUID = 1L;

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

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

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

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) {
            if (collectionView == null) {
                collectionView = getObjectCollectionView();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionView);
            try {
                PrismContext prismContext = getPrismContext();
                PrismObjectDefinition<TaskType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(TaskType.COMPLEX_TYPE);
                PrismObject<TaskType> obj = def.instantiate();
                TaskType newTask = obj.asObjectable();
                ObjectReferenceType resourceRef = new ObjectReferenceType();
                resourceRef.setOid(ResourceTasksPanel.this.getModelObject().getOid());
                resourceRef.setType(ResourceType.COMPLEX_TYPE);
                newTask.setObjectRef(resourceRef);
                WebComponentUtil.initNewObjectWithReference(getPageBase(), newTask, archetypeRef);
            } catch (SchemaException ex) {
                getPageBase().getFeedbackMessages().error(ResourceTasksPanel.this, ex.getUserFriendlyMessage());
                target.add(getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
            return ColumnUtils.getDefaultTaskColumns();
        }

        @Override
        protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
            List<CompiledObjectCollectionView> newObjectInfluencesList = super.getNewObjectInfluencesList();
            List<CompiledObjectCollectionView> filteredInfluencesList = new ArrayList<>();
            if (newObjectInfluencesList != null) {
                newObjectInfluencesList.forEach(influence -> {
                    if (influence.getCollection() != null && influence.getCollection().getCollectionRef() != null && ArrayUtils.contains(resourceTaskArchetypeOids, influence.getCollection().getCollectionRef().getOid())) {
                        filteredInfluencesList.add(influence);
                    }
                });
            }
            return filteredInfluencesList;
        }
    };
    tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
    add(tasksPanel);
    AjaxButton runNow = new AjaxButton(ID_RUN_NOW, getPageBase().createStringResource("pageTaskEdit.button.runNow")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedRealObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.runNowPerformed(oids, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(runNow);
    AjaxButton resume = new AjaxButton(ID_RESUME, getPageBase().createStringResource("pageTaskEdit.button.resume")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.resumeTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(resume);
    AjaxButton suspend = new AjaxButton(ID_SUSPEND, getPageBase().createStringResource("pageTaskEdit.button.suspend")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.suspendTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(suspend);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) PrismContext(com.evolveum.midpoint.prism.PrismContext) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 10 with MainObjectListPanel

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

the class PageRoles method initLayout.

protected void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<RoleType> table = new MainObjectListPanel<RoleType>(ID_TABLE, RoleType.class) {

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

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            FocusListInlineMenuHelper<RoleType> listInlineMenuHelper = new FocusListInlineMenuHelper<RoleType>(RoleType.class, PageRoles.this, this) {

                private static final long serialVersionUID = 1L;

                protected boolean isShowConfirmationDialog(ColumnMenuAction action) {
                    return PageRoles.this.isShowConfirmationDialog(action);
                }

                protected IModel<String> getConfirmationMessageModel(ColumnMenuAction action, String actionName) {
                    return PageRoles.this.getConfirmationMessageModel(action, actionName);
                }
            };
            return listInlineMenuHelper.createRowActions(getType());
        }

        // @Override
        // protected List<IColumn<SelectableBean<RoleType>, String>> createDefaultColumns() {
        // return ColumnUtils.getDefaultRoleColumns();
        // }
        @Override
        protected List<ItemPath> getFixedSearchItems() {
            List<ItemPath> fixedSearchItems = new ArrayList<>();
            fixedSearchItems.add(ObjectType.F_NAME);
            fixedSearchItems.add(AbstractRoleType.F_DISPLAY_NAME);
            fixedSearchItems.add(AbstractRoleType.F_IDENTIFIER);
            return fixedSearchItems;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)26 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)24 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)22 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)18 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)15 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)14 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)14 ArrayList (java.util.ArrayList)14 Form (org.apache.wicket.markup.html.form.Form)14 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)12 IModel (org.apache.wicket.model.IModel)9 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)5 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)5 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)3 FocusListInlineMenuHelper (com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper)3