Search in sources :

Example 61 with SelectableBean

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

the class ColumnUtils method getDefaultOrgColumns.

public static <T extends ObjectType> List<IColumn<SelectableBean<T>, String>> getDefaultOrgColumns(PageBase pageBase) {
    List<IColumn<SelectableBean<T>, String>> columns = new ArrayList<>();
    columns.addAll((Collection) getDefaultAbstractRoleColumns(false));
    columns.add(new LinkColumn<>(createStringResource("ObjectType.parentOrgRef")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
            RepeatingView links = new RepeatingView(componentId);
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getValue() != null && rowModel.getObject().getValue().getParentOrgRef() != null && !rowModel.getObject().getValue().getParentOrgRef().isEmpty()) {
                for (ObjectReferenceType parentRef : rowModel.getObject().getValue().getParentOrgRef()) {
                    if (parentRef.getOid() == null) {
                        continue;
                    }
                    Model name = Model.of(WebModelServiceUtils.resolveReferenceName(parentRef, pageBase, true));
                    if (name.getObject() == null) {
                        continue;
                    }
                    links.add(new LinkPanel(links.newChildId(), name) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick() {
                            PageParameters parameters = new PageParameters();
                            parameters.add(OnePageParameterEncoder.PARAMETER, parentRef.getOid());
                            pageBase.navigateToNext(PageOrgUnit.class, parameters);
                        }

                        @Override
                        public boolean isEnabled() {
                            return parentRef.getTargetName() != null;
                        }
                    });
                }
            }
            cellItem.add(links);
        }

        @Override
        public void onClick(IModel<SelectableBean<T>> rowModel) {
            super.onClick(rowModel);
        }
    });
    columns.add((IColumn) getAbstractRoleColumnForProjection());
    return columns;
}
Also used : RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) 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) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 62 with SelectableBean

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

the class ColumnUtils method getDefaultCaseColumns.

public static List<IColumn<SelectableBean<CaseType>, String>> getDefaultCaseColumns(PageBase pageBase, boolean isDashboard) {
    List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<>();
    IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
    columns.add(column);
    column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.objectRef")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> item, String componentId, IModel<SelectableBean<CaseType>> rowModel) {
            item.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    CaseType caseModelObject = rowModel.getObject().getValue();
                    if (caseModelObject == null) {
                        return "";
                    }
                    AssignmentHolderType objectRef = WebComponentUtil.getObjectFromAddDeltyForCase(caseModelObject);
                    if (objectRef != null) {
                        return WebComponentUtil.getEffectiveName(objectRef, AbstractRoleType.F_DISPLAY_NAME);
                    } else if (caseModelObject.getObjectRef() != null && StringUtils.isNotEmpty(caseModelObject.getObjectRef().getOid())) {
                        if (caseModelObject.getObjectRef().getObject() != null) {
                            return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef().getObject(), AbstractRoleType.F_DISPLAY_NAME);
                        } else {
                            try {
                                return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef(), AbstractRoleType.F_DISPLAY_NAME, pageBase, pageBase.getClass().getSimpleName() + "." + "loadCaseObjectRefName");
                            } catch (Exception ex) {
                                LOGGER.error("Unable find the object for reference: {}", caseModelObject.getObjectRef());
                            }
                        }
                    }
                    return "";
                }
            }));
        }
    };
    columns.add(column);
    if (!isDashboard) {
        columns.add(createCaseActorsColumn(pageBase));
    }
    column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.openTimestamp"), MetadataType.F_CREATE_TIMESTAMP.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
            CaseType object = rowModel.getObject().getValue();
            MetadataType metadata = object != null ? object.getMetadata() : null;
            XMLGregorianCalendar createdCal = metadata != null ? metadata.getCreateTimestamp() : null;
            final Date created;
            if (createdCal != null) {
                created = createdCal.toGregorianCalendar().getTime();
            // cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(created, DateLabelComponent.LONG_MEDIUM_STYLE)));
            // cellItem.add(new TooltipBehavior());
            } else {
                created = null;
            }
            cellItem.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getShortDateTimeFormattedValue(created, pageBase);
                }
            }));
        }

        @Override
        public String getCssClass() {
            return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
        }
    };
    columns.add(column);
    if (!isDashboard) {
        column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.closeTimestamp"), CaseType.F_CLOSE_TIMESTAMP.getLocalPart(), "value.closeTimestamp") {

            @Override
            public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
                CaseType object = rowModel.getObject().getValue();
                XMLGregorianCalendar closedCal = object != null ? object.getCloseTimestamp() : null;
                final Date closed;
                if (closedCal != null) {
                    closed = closedCal.toGregorianCalendar().getTime();
                    cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(closed, DateLabelComponent.LONG_MEDIUM_STYLE)));
                    cellItem.add(new TooltipBehavior());
                } else {
                    closed = null;
                }
                cellItem.add(new Label(componentId, new IModel<String>() {

                    @Override
                    public String getObject() {
                        return WebComponentUtil.getShortDateTimeFormattedValue(closed, pageBase);
                    }
                }));
            }

            @Override
            public String getCssClass() {
                return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
            }
        };
        columns.add(column);
    }
    column = new CountIconColumn<SelectableBean<CaseType>>(createStringResource("CaseType.outcome")) {

        @Override
        protected Map<DisplayType, Integer> getIconDisplayType(IModel<SelectableBean<CaseType>> rowModel) {
            Map<DisplayType, Integer> map = new HashMap<>();
            CaseType caseType = rowModel.getObject().getValue();
            if (ObjectTypeUtil.hasArchetype(caseType, SystemObjectsType.ARCHETYPE_OPERATION_REQUEST.value())) {
                ObjectQuery queryFilter = pageBase.getPrismContext().queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(caseType.getOid()).build();
                List<PrismObject<CaseType>> childs = WebModelServiceUtils.searchObjects(CaseType.class, queryFilter, new OperationResult("search_case_child"), pageBase);
                for (PrismObject<CaseType> child : childs) {
                    processCaseOutcome(child.asObjectable(), map, false);
                }
            } else {
                processCaseOutcome(caseType, map, true);
            }
            return map;
        }

        @Override
        public String getCssClass() {
            return "col-lg-1";
        }
    };
    columns.add(column);
    column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {

        @Override
        public String getCssClass() {
            return "col-lg-1";
        }

        @Override
        public IModel<?> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
            IModel<String> dataModel = (IModel<String>) super.getDataModel(rowModel);
            if (StringUtils.isNotBlank(dataModel.getObject())) {
                String key = CaseType.COMPLEX_TYPE.getLocalPart() + "." + CaseType.F_STATE.getLocalPart() + "." + dataModel.getObject();
                return new StringResourceModel(key, pageBase).setModel(new Model<String>()).setDefaultValue(dataModel.getObject());
            }
            return dataModel;
        }
    };
    columns.add(column);
    if (!isDashboard) {
        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-lg-1";
            }
        };
        columns.add(column);
    }
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Example 63 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean 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.getObjectWrapper().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 64 with SelectableBean

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

the class PageAdminObjectDetails method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getMainPopupBodyId(), null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            OperationResult result = new OperationResult(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
            if (newAssignmentsList.size() > 1) {
                result.recordWarning(getString("PageAdminObjectDetails.change.archetype.more.than.one.selected"));
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            AssignmentType oldArchetypAssignment = getOldArchetypeAssignment(result);
            if (oldArchetypAssignment == null) {
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            try {
                ObjectDelta<O> delta = getPrismContext().deltaFor(getCompileTimeClass()).item(AssignmentHolderType.F_ASSIGNMENT).delete(oldArchetypAssignment.clone()).asObjectDelta(getObjectWrapper().getOid());
                delta.addModificationAddContainer(AssignmentHolderType.F_ASSIGNMENT, newAssignmentsList.iterator().next());
                Task task = createSimpleTask(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
                getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
            } catch (Exception e) {
                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage(), e);
                result.recordFatalError(getString("PageAdminObjectDetails.change.archetype.failed", e.getMessage()), e);
            }
            result.computeStatusIfUnknown();
            showResult(result);
            target.add(PageAdminObjectDetails.this.getFeedbackPanel());
            refresh(target);
        }

        @Override
        protected List<ITab> createAssignmentTabs(AssignmentObjectRelation assignmentObjectRelation) {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(getPageBase().createStringResource("ObjectTypes.ARCHETYPE"), new VisibleBehaviour(() -> true)) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new FocusTypeAssignmentPopupTabPanel<ArchetypeType>(panelId, ObjectTypes.ARCHETYPE, null) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
                            PrismContainerWrapper<AssignmentType> assignmentsWrapper = null;
                            try {
                                assignmentsWrapper = getObjectWrapper().findContainer(FocusType.F_ASSIGNMENT);
                            } catch (SchemaException e) {
                                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
                            }
                            return assignmentsWrapper;
                        }

                        @Override
                        protected List<QName> getSupportedRelations() {
                            return Collections.singletonList(SchemaConstants.ORG_DEFAULT);
                        }

                        @Override
                        protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ArchetypeType>> rowModel) {
                            target.add(getObjectListPanel());
                            tabLabelPanelUpdate(target);
                        }

                        @Override
                        protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<ArchetypeType>> rowModel) {
                            if (rowModel == null) {
                                return Model.of(false);
                            }
                            List selectedObjects = getSelectedObjectsList();
                            return Model.of(selectedObjects == null || selectedObjects.size() == 0 || (rowModel.getObject() != null && rowModel.getObject().isSelected()));
                        }

                        @Override
                        protected ObjectTypes getObjectType() {
                            return ObjectTypes.ARCHETYPE;
                        }

                        @Override
                        protected ObjectQuery addFilterToContentQuery() {
                            ObjectQuery query = super.addFilterToContentQuery();
                            if (query == null) {
                                query = getPrismContext().queryFactory().createQuery();
                            }
                            List<String> archetypeOidsList = getArchetypeOidsListToAssign();
                            ObjectFilter filter = getPrismContext().queryFor(ArchetypeType.class).id(archetypeOidsList.toArray(new String[0])).buildFilter();
                            query.addFilter(filter);
                            return query;
                        }
                    };
                }
            });
            return tabs;
        }

        @Override
        protected IModel<String> getWarningMessageModel() {
            return createStringResource("PageAdminObjectDetails.button.changeArchetype.warningMessage");
        }
    };
    changeArchetypePopup.setOutputMarkupPlaceholderTag(true);
    showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Example 65 with SelectableBean

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

the class TaskResultPanel 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"), OperationResultType.F_TOKEN.getLocalPart(), createPropertyExpression("token")));
    columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.operation"), OperationResultType.F_OPERATION.getLocalPart(), createPropertyExpression("operation")));
    columns.add(new PropertyColumn<>(createStringResource("pageTaskEdit.opResult.status"), OperationResultType.F_STATUS.getLocalPart(), createPropertyExpression("status")));
    columns.add(new AbstractColumn<>(createStringResource("pageTaskEdit.opResult.timestamp"), OperationResultType.F_END.getLocalPart()) {

        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<>(createStringResource("pageTaskEdit.opResult.message"), OperationResultType.F_MESSAGE.getLocalPart()) {

        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);
        }
    });
    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)

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