Search in sources :

Example 21 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class TaskErrorsPanel method initLayoutNew.

private void initLayoutNew() {
    var provider = new SelectableBeanContainerDataProvider<OperationExecutionType>(this, Model.of(), null, true) {

        @Override
        protected String getDefaultSortParam() {
            return TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP;
        }

        @Override
        protected SortOrder getDefaultSortOrder() {
            return SortOrder.DESCENDING;
        }

        @Override
        public SelectableBean<OperationExecutionType> createDataObjectWrapper(OperationExecutionType obj) {
            return new TaskErrorSelectableBeanImpl(obj);
        }

        @Override
        public ObjectQuery getQuery() {
            return createContentQuery(getObjectWrapper().getOid(), getPageBase());
        }

        @NotNull
        @Override
        protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
            if (sortParam != null && sortParam.getProperty() != null) {
                OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                ItemPath ordering;
                if (sortParam.getProperty().equals(TaskErrorSelectableBeanImpl.F_ERROR_TIMESTAMP)) {
                    ordering = ItemPath.create(OperationExecutionType.F_TIMESTAMP);
                } else if (sortParam.getProperty().equals("name")) {
                    // TODO why is this "name" and not TaskErrorSelectableBeanImplNew.F_OBJECT_REF_NAME?
                    ordering = ItemPath.create(PrismConstants.T_PARENT, ObjectType.F_NAME);
                } else {
                    // TODO this is actually not used
                    ordering = ItemPath.create(new QName(SchemaConstantsGenerated.NS_COMMON, sortParam.getProperty()));
                }
                return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ordering, order));
            } else {
                return Collections.emptyList();
            }
        }

        @Override
        public Class<OperationExecutionType> getType() {
            return OperationExecutionType.class;
        }
    };
    BoxedTablePanel<?> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsNew());
    table.setOutputMarkupId(true);
    add(table);
}
Also used : QName(javax.xml.namespace.QName) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) TaskErrorSelectableBeanImpl(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImpl) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 22 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel 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 23 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel 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)

Example 24 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class PageTasks method initLayout.

private void initLayout() {
    refreshPanel = new AutoRefreshPanel(ID_REFRESH_PANEL, refreshModel, this, false);
    add(refreshPanel);
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    List<IColumn<TaskDto, String>> taskColumns = initTaskColumns();
    TaskDtoProviderOptions options = TaskDtoProviderOptions.minimalOptions();
    options.setGetNextRunStartTime(true);
    options.setUseClusterInformation(true);
    options.setResolveObjectRef(true);
    TaskDtoProvider provider = new TaskDtoProvider(PageTasks.this, options) {

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            TasksStorage storage = getSessionStorage().getTasks();
            storage.setPaging(paging);
        }

        @Override
        public TaskDto createTaskDto(PrismObject<TaskType> task, Task opTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
            TaskDto dto = super.createTaskDto(task, opTask, result);
            addInlineMenuToTaskRow(dto);
            return dto;
        }
    };
    provider.setQuery(createTaskQuery());
    BoxedTablePanel<TaskDto> taskTable = new BoxedTablePanel(ID_TASK_TABLE, provider, taskColumns, UserProfileStorage.TableId.PAGE_TASKS_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_PANEL)) {

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(headerId, ID_TABLE_HEADER, PageTasks.this, searchModel);
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            String fileName = "TaskType_" + createStringResource("MainObjectListPanel.exportFileName").getString();
            CSVDataExporter csvDataExporter = new CSVDataExporter();
            ResourceStreamResource resource = (new ResourceStreamResource() {

                protected IResourceStream getResourceStream() {
                    return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getTaskTable().getDataTable());
                }
            }).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
            AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
            exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
            return exportDataLink;
        }
    };
    taskTable.setOutputMarkupId(true);
    TasksStorage storage = getSessionStorage().getTasks();
    taskTable.setCurrentPage(storage.getPaging());
    mainForm.add(taskTable);
    List<IColumn<NodeDto, String>> nodeColumns = initNodeColumns();
    BoxedTablePanel nodeTable = new BoxedTablePanel(ID_NODE_TABLE, new NodeDtoProvider(PageTasks.this) {

        @Override
        public NodeDto createNodeDto(PrismObject<NodeType> node) {
            NodeDto dto = super.createNodeDto(node);
            addInlineMenuToNodeRow(dto);
            return dto;
        }
    }, nodeColumns, UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL));
    nodeTable.setOutputMarkupId(true);
    nodeTable.setShowPaging(false);
    mainForm.add(nodeTable);
    initDiagnosticButtons();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) Form(org.apache.wicket.markup.html.form.Form) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) AutoRefreshPanel(com.evolveum.midpoint.web.component.refresh.AutoRefreshPanel) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TasksStorage(com.evolveum.midpoint.web.session.TasksStorage) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink)

Example 25 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class PageAuditLogDetails method initAuditLogHistoryPanel.

private void initAuditLogHistoryPanel(WebMarkupContainer eventPanel) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(PageAuditLogDetails.this) {

        private static final long serialVersionUID = 1L;

        public Map<String, Object> getParameters() {
            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put(TASK_IDENTIFIER_PARAMETER, recordModel.getObject().getTaskIdentifier());
            return parameters;
        }
    };
    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_HISTORY_PANEL, provider, initColumns(), UserProfileStorage.TableId.TASK_EVENTS_TABLE, TASK_EVENTS_TABLE_SIZE) {

        @Override
        protected Item<AuditEventRecordType> customizeNewRowItem(final Item<AuditEventRecordType> item, final IModel<AuditEventRecordType> rowModel) {
            if (rowModel.getObject().getTimestamp().equals(recordModel.getObject().getTimestamp())) {
                item.add(new AttributeAppender("style", "background-color: #eee; border-color: #d6d6d6; color: #000"));
            }
            item.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    PageAuditLogDetails.this.rowItemClickPerformed(target, item, rowModel);
                }
            });
            return item;
        }
    };
    table.getFooterMenu().setVisible(false);
    table.getFooterCountLabel().setVisible(false);
    //TODO hidden temporarily
    table.setVisible(false);
    table.setOutputMarkupId(true);
    table.setAdditionalBoxCssClasses("without-box-header-top-border");
    eventPanel.addOrReplace(table);
}
Also used : IModel(org.apache.wicket.model.IModel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)39 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)12 IModel (org.apache.wicket.model.IModel)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)9 ArrayList (java.util.ArrayList)9 Item (org.apache.wicket.markup.repeater.Item)9 QName (javax.xml.namespace.QName)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 List (java.util.List)5 Label (org.apache.wicket.markup.html.basic.Label)5 Form (org.apache.wicket.markup.html.form.Form)5 ListItem (org.apache.wicket.markup.html.list.ListItem)5 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)4 ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)4