Search in sources :

Example 1 with SelectableListDataProvider

use of com.evolveum.midpoint.web.component.util.SelectableListDataProvider 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 2 with SelectableListDataProvider

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

the class TaskSubtasksAndThreadsTabPanel method initLayout.

private void initLayout() {
    Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel"));
    add(subtasksLabel);
    TaskTablePanel subtasksPanel = new TaskTablePanel(ID_SUBTASKS_PANEL, createOperationOptions()) {

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

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<TaskType>, String>> columns = super.createDefaultColumns();
            // });
            return columns;
        }

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

        @Override
        @NotNull
        protected TaskInformation getAttachedTaskInformation(SelectableBean<TaskType> selectableTaskBean) {
            return TaskInformationUtil.getOrCreateInfo(selectableTaskBean, rootTaskModel.getObject());
        }
    };
    add(subtasksPanel);
    Label workerThreadsTableLabel = new Label(ID_WORKER_THREADS_TABLE_LABEL, new ResourceModel("TaskStatePanel.workerThreads"));
    add(workerThreadsTableLabel);
    TaskTablePanel workerThreadsTable = new TaskTablePanel(ID_WORKER_THREADS_TABLE, null) {

        @Override
        protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
            return new SelectableListDataProvider<>(TaskSubtasksAndThreadsTabPanel.this, createWorkersModel());
        }

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

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

        @Override
        @NotNull
        protected TaskInformation getAttachedTaskInformation(SelectableBean<TaskType> selectableTaskBean) {
            return TaskInformationUtil.getOrCreateInfo(selectableTaskBean, rootTaskModel.getObject());
        }
    };
    add(workerThreadsTable);
}
Also used : UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 3 with SelectableListDataProvider

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

the class TaskResultPanel method initLayout.

protected void initLayout() {
    IModel<List<OperationResult>> resultModel = new ReadOnlyModel<>(this::createOperationResultList);
    SelectableListDataProvider<SelectableBean<OperationResult>, OperationResult> provider = new SelectableListDataProvider<>(this, resultModel);
    BoxedTablePanel<SelectableBean<OperationResult>> resultTablePanel = new BoxedTablePanel<>(ID_OPERATION_RESULT, provider, initResultColumns());
    resultTablePanel.setOutputMarkupId(true);
    add(resultTablePanel);
    AjaxFallbackLink<Void> showResult = new AjaxFallbackLink<>(ID_SHOW_RESULT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
            if (optionalTarget.isEmpty()) {
                LOGGER.warn("Cannot show result in interactive way, request target not present.");
                return;
            }
            AjaxRequestTarget target = optionalTarget.get();
            OperationResultPopupPanel body = new OperationResultPopupPanel(getPageBase().getMainPopupBodyId(), new Model<>(getTaskOperationResult()));
            body.setOutputMarkupId(true);
            getPageBase().showMainPopup(body, target);
        }
    };
    showResult.add(new VisibleBehaviour(() -> getTaskOperationResult() != null));
    showResult.setOutputMarkupId(true);
    add(showResult);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OperationResultPopupPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPopupPanel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 4 with SelectableListDataProvider

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

the class TaskSubtasksAndThreadsPanel method initLayout.

protected void initLayout() {
    Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel"));
    add(subtasksLabel);
    TaskTablePanel subtasksPanel = new TaskTablePanel(ID_SUBTASKS_PANEL, createOperationOptions()) {

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

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

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<TaskType>, String>> columns = super.createDefaultColumns();
            // });
            return columns;
        }

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

        @Override
        @NotNull
        protected TaskInformation getAttachedTaskInformation(SelectableBean<TaskType> selectableTaskBean) {
            return TaskInformationUtil.getOrCreateInfo(selectableTaskBean, getObjectDetailsModels().getRootTaskModelObject());
        }
    };
    add(subtasksPanel);
    Label workerThreadsTableLabel = new Label(ID_WORKER_THREADS_TABLE_LABEL, new ResourceModel("TaskStatePanel.workerThreads"));
    add(workerThreadsTableLabel);
    TaskTablePanel workerThreadsTable = new TaskTablePanel(ID_WORKER_THREADS_TABLE, null) {

        @Override
        protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
            return new SelectableListDataProvider<>(TaskSubtasksAndThreadsPanel.this, createWorkersModel());
        }

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

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

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

        @Override
        @NotNull
        protected TaskInformation getAttachedTaskInformation(SelectableBean<TaskType> selectableTaskBean) {
            return TaskInformationUtil.getOrCreateInfo(selectableTaskBean, getObjectDetailsModels().getRootTaskModelObject());
        }
    };
    add(workerThreadsTable);
}
Also used : UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) TaskTablePanel(com.evolveum.midpoint.web.page.admin.server.TaskTablePanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) ResourceModel(org.apache.wicket.model.ResourceModel) Component(org.apache.wicket.Component)

Example 5 with SelectableListDataProvider

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

the class ExportingPanel method createTable.

private BoxedTablePanel<SelectableBean<Integer>> createTable(String id, DataTable<?, ?> dataTable) {
    List<? extends IColumn<?, ?>> allColumns = dataTable.getColumns();
    List<Integer> exportableColumnIndex = getExportableColumns(dataTable);
    if (exportableColumnIndex.isEmpty()) {
        throw new IllegalArgumentException("List of exportable columns is empty");
    }
    List<IColumn<SelectableBean<Integer>, String>> columns = new ArrayList<>();
    CheckBoxHeaderColumn<SelectableBean<Integer>> checkboxColumn = new CheckBoxHeaderColumn<>();
    columns.add(checkboxColumn);
    StringResourceModel nameString = getPageBase().createStringResource("ExportingPopupPanel.nameColumn");
    IColumn<SelectableBean<Integer>, String> nameColumn = new AbstractColumn<SelectableBean<Integer>, String>(nameString) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<Integer>>> cellItem, String componentId, IModel<SelectableBean<Integer>> rowModel) {
            IModel stringModel = ((IExportableColumn) allColumns.get(rowModel.getObject().getValue())).getDisplayModel();
            cellItem.add(new Label(componentId, stringModel));
        }
    };
    columns.add(nameColumn);
    SelectableListDataProvider<SelectableBean<Integer>, Integer> provider = new SelectableListDataProvider<SelectableBean<Integer>, Integer>(getPageBase(), Model.ofList(exportableColumnIndex)) {

        @Override
        public Iterator<SelectableBean<Integer>> internalIterator(long first, long count) {
            if (getAvailableData().isEmpty()) {
                return super.internalIterator(first, count);
            } else {
                return getAvailableData().iterator();
            }
        }
    };
    BoxedTablePanel<SelectableBean<Integer>> table = new BoxedTablePanel<SelectableBean<Integer>>(id, provider, columns) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new WebMarkupContainer(headerId);
        }

        @Override
        public String getAdditionalBoxCssClasses() {
            return null;
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            return new WebMarkupContainer(id);
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }

        @Override
        public int getAutoRefreshInterval() {
            return 0;
        }

        @Override
        public boolean isAutoRefreshEnabled() {
            return false;
        }
    };
    table.setOutputMarkupId(true);
    return table;
}
Also used : IExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Item(org.apache.wicket.markup.repeater.Item) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)6 SelectableListDataProvider (com.evolveum.midpoint.web.component.util.SelectableListDataProvider)6 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)3 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)3 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)3 ArrayList (java.util.ArrayList)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 Label (org.apache.wicket.markup.html.basic.Label)3 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 Component (org.apache.wicket.Component)2 AjaxFallbackLink (org.apache.wicket.ajax.markup.html.AjaxFallbackLink)2 ResourceModel (org.apache.wicket.model.ResourceModel)2 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 OpResult (com.evolveum.midpoint.gui.api.component.result.OpResult)1 OperationResultPanel (com.evolveum.midpoint.gui.api.component.result.OperationResultPanel)1 OperationResultPopupPanel (com.evolveum.midpoint.gui.api.component.result.OperationResultPopupPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1