Search in sources :

Example 36 with BoxedTablePanel

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

the class StatisticsPanel method initLayout.

protected void initLayout() {
    contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
    contentsPanel.setOutputMarkupId(true);
    add(contentsPanel);
    ListView<ProvisioningStatisticsLineDto> provisioningLines = new ListView<>(ID_PROVISIONING_STATISTICS_LINES, new PropertyModel<>(getModel(), StatisticsDto.F_PROVISIONING_LINES)) {

        protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item) {
            ListDataProvider<ProvisioningStatisticsOperationDto> provider = new ListDataProvider<>(StatisticsPanel.this, new PropertyModel<>(item.getModel(), ProvisioningStatisticsLineDto.F_OPERATIONS));
            BoxedTablePanel<ProvisioningStatisticsOperationDto> provisioningTable = new BoxedTablePanel<>(ID_PROVISIONING_OPERATIONS, provider, createProvisioningStatisticsColumns()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected WebMarkupContainer createHeader(String headerId) {
                    return new ProvisioningStatisticsHeaderFragment(headerId, ID_PROVISIONING_TITLE, StatisticsPanel.this, item.getModel());
                }

                @Override
                protected Item<ProvisioningStatisticsOperationDto> customizeNewRowItem(Item<ProvisioningStatisticsOperationDto> item, IModel<ProvisioningStatisticsOperationDto> model) {
                    item.add(AttributeModifier.append("class", new ReadOnlyModel<>(() -> {
                        if (model.getObject() != null && OperationResultStatusType.FATAL_ERROR == model.getObject().getStatus()) {
                            return "bg-red disabled color-palette";
                        }
                        return null;
                    })));
                    return item;
                }

                @Override
                protected boolean hideFooterIfSinglePage() {
                    return true;
                }
            };
            provisioningTable.setOutputMarkupId(true);
            provisioningTable.add(new VisibleBehaviour(() -> hasAnyOperation(item.getModelObject())));
            item.add(provisioningTable);
        }
    };
    contentsPanel.add(provisioningLines);
    ListDataProvider<MappingsLineDto> mappingsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_MAPPINGS_LINES));
    BoxedTablePanel<MappingsLineDto> mappingsLines = new BoxedTablePanel<>(ID_MAPPINGS_STATISTICS_LINES, mappingsProvider, createMappingsColumn()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new TableHeaderFragment(headerId, ID_MAPPINGS_TITLE, StatisticsPanel.this, createStringResource("Title.MappingsStatistics"));
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }
    };
    mappingsLines.setOutputMarkupId(true);
    contentsPanel.add(mappingsLines);
    ListDataProvider<NotificationsLineDto> notificationsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_NOTIFICATIONS_LINES));
    BoxedTablePanel<NotificationsLineDto> notificationsLines = new BoxedTablePanel<>(ID_NOTIFICATIONS_STATISTICS_LINES, notificationsProvider, createNotificationColumns()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new TableHeaderFragment(headerId, ID_NOTIFICATIONS_TITLE, StatisticsPanel.this, createStringResource("Title.NotificationsStatistics"));
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }
    };
    notificationsLines.setOutputMarkupId(true);
    contentsPanel.add(notificationsLines);
    Label lastMessage = new Label(ID_LAST_MESSAGE, new PropertyModel<>(getModel(), StatisticsDto.F_LAST_MESSAGE));
    contentsPanel.add(lastMessage);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) ListView(org.apache.wicket.markup.html.list.ListView) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 37 with BoxedTablePanel

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

the class TaskResultTabPanel method initLayout.

private void initLayout() {
    IModel<List<OperationResult>> resultModel = new ReadOnlyModel<>(() -> 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<Void>(ID_SHOW_RESULT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
            if (!optionalTarget.isPresent()) {
                LOGGER.warn("Cannot show result in interactive way, request target not present.");
                return;
            }
            AjaxRequestTarget target = optionalTarget.get();
            PrismObjectWrapper<TaskType> taskWrapper = TaskResultTabPanel.this.getModelObject();
            TaskType taskType = taskWrapper.getObject().asObjectable();
            OperationResult opResult = OperationResult.createOperationResult(taskType.getResult());
            OpResult result = opResult != null ? OpResult.getOpResult(getPageBase(), opResult) : null;
            OperationResultPanel body = new OperationResultPanel(getPageBase().getMainPopupBodyId(), new Model<>(result));
            body.add(new VisibleBehaviour(() -> opResult != null));
            body.setOutputMarkupId(true);
            getPageBase().showMainPopup(body, target);
        }
    };
    showResult.setOutputMarkupId(true);
    add(showResult);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 38 with BoxedTablePanel

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

the class TaskErrorsTabPanel method initLayoutOld.

private void initLayoutOld() {
    SelectableBeanObjectDataProvider<? extends ObjectType> provider = new SelectableBeanObjectDataProvider<>(this, null) {

        @Override
        public SelectableBean<ObjectType> createDataObjectWrapper(ObjectType obj) {
            return new TaskErrorSelectableBeanImplOld<>(obj, getModelObject().getOid());
        }

        @Override
        public ObjectQuery getQuery() {
            return createContentQuery(getModelObject().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(TaskErrorSelectableBeanImplOld.F_ERROR_TIMESTAMP)) {
                    ordering = ItemPath.create("operationExecution", "timestamp");
                } else {
                    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<ObjectType> getType() {
            return ObjectType.class;
        }
    };
    BoxedTablePanel<TaskErrorSelectableBeanImplOld<ObjectType>> table = new BoxedTablePanel<>(ID_TASK_ERRORS, provider, initColumnsOld());
    table.setOutputMarkupId(true);
    add(table);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) QName(javax.xml.namespace.QName) SelectableBeanObjectDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) TaskErrorSelectableBeanImplOld(com.evolveum.midpoint.web.page.admin.server.dto.TaskErrorSelectableBeanImplOld) 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 39 with BoxedTablePanel

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

the class AssignmentsInfoDialog method initLayout.

public void initLayout(PageBase pageBase) {
    List<IColumn<AssignmentInfoDto, String>> columns = initColumns();
    ListDataProvider<AssignmentInfoDto> provider = new ListDataProvider<>(pageBase, getModel());
    WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
    content.setOutputMarkupId(true);
    add(content);
    BoxedTablePanel<AssignmentInfoDto> table = new BoxedTablePanel<AssignmentInfoDto>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    content.add(table);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.selectButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<AssignmentInfoDto> allAssignmentInfoDtos = AssignmentsInfoDialog.this.getModelObject();
            List<AssignmentInfoDto> selectedDtos = allAssignmentInfoDtos.stream().filter(AssignmentInfoDto::isSelected).collect(Collectors.toList());
            AssignmentsInfoDialog.this.addButtonClicked(target, selectedDtos);
        }
    };
    addButton.setVisible(enableMultiSelect());
    content.add(addButton);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("AssignmentPreviewDialog.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            getPageBase().hideMainPopup(ajaxRequestTarget);
        }
    };
    cancelButton.add(new VisibleBehaviour(() -> showCancelButton()));
    content.add(cancelButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

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