Search in sources :

Example 36 with SelectableBean

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

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

the class TaskResultTabPanel method initResultColumns.

private List<IColumn<SelectableBean<OperationResult>, String>> initResultColumns() {
    List<IColumn<SelectableBean<OperationResult>, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.token"), createPropertyExpression("token")));
    columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.operation"), createPropertyExpression("operation")));
    columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.status"), createPropertyExpression("status")));
    columns.add(new AbstractColumn<SelectableBean<OperationResult>, String>(createStringResource("pageTaskEdit.opResult.timestamp")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<OperationResult>>> cellItem, String componentId, IModel<SelectableBean<OperationResult>> rowModel) {
            Label label = new Label(componentId, (IModel<String>) () -> {
                Long resultEndTime = rowModel.getObject().getValue().getEnd();
                return resultEndTime != null && resultEndTime > 0 ? WebComponentUtil.getShortDateTimeFormattedValue(new Date(resultEndTime), getPageBase()) : "";
            });
            cellItem.add(label);
        }
    });
    columns.add(new AbstractColumn<SelectableBean<OperationResult>, String>(createStringResource("pageTaskEdit.opResult.message"), createPropertyExpression("message")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<OperationResult>>> cellItem, String componentId, IModel<SelectableBean<OperationResult>> rowModel) {
            Label label = new Label(componentId, (IModel<String>) () -> WebComponentUtil.nl2br(rowModel.getObject().getValue().getMessage()));
            label.setEscapeModelStrings(false);
            cellItem.add(label);
        }
    });
    // columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.message"), "message"));
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 38 with SelectableBean

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

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

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

the class SearchPropertiesConfigPanel method initTable.

private void initTable(WebMarkupContainer configPanel) {
    List<IColumn<SelectableBean<ValueSearchFilterItem>, String>> columns = getTableColumns();
    BoxedTablePanel<SelectableBean<ValueSearchFilterItem>> table = new BoxedTablePanel<SelectableBean<ValueSearchFilterItem>>(ID_PROPERTIES_TABLE, 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) {
            AjaxButton addRowButton = new AjaxButton(id) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget ajaxRequestTarget) {
                    propertyAddedPerformed(ajaxRequestTarget);
                }
            };
            addRowButton.setOutputMarkupId(true);
            addRowButton.add(AttributeAppender.append("class", "btn btn-sm btn-default fa fa-plus"));
            addRowButton.add(AttributeAppender.append("style", "color: green;"));
            return addRowButton;
        }

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

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

        @Override
        public boolean isAutoRefreshEnabled() {
            return false;
        }
    };
    table.setOutputMarkupId(true);
    configPanel.add(table);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) 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) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ValueSearchFilterItem(com.evolveum.midpoint.web.component.search.filter.ValueSearchFilterItem)

Aggregations

SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)39 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)37 IModel (org.apache.wicket.model.IModel)37 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)32 ArrayList (java.util.ArrayList)31 Label (org.apache.wicket.markup.html.basic.Label)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)16 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)15 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)14 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)12 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)12 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 Item (org.apache.wicket.markup.repeater.Item)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 List (java.util.List)8 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)7