Search in sources :

Example 36 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class AbstractRoleMemberPanel method initMemberTable.

private void initMemberTable(TableId tableId, Form form) {
    WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
    memberContainer.setOutputMarkupId(true);
    memberContainer.setOutputMarkupPlaceholderTag(true);
    form.add(memberContainer);
    MainObjectListPanel<ObjectType> childrenListPanel = new MainObjectListPanel<ObjectType>(ID_MEMBER_TABLE, ObjectType.class, tableId, getSearchOptions(), getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
            detailsPerformed(target, object);
        }

        @Override
        protected boolean isClickable(IModel<SelectableBean<ObjectType>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
                return false;
            }
            Class<?> objectClass = rowModel.getObject().getValue().getClass();
            return WebComponentUtil.hasDetailsPage(objectClass);
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            AbstractRoleMemberPanel.this.createFocusMemberPerformed(null, target);
        }

        @Override
        protected List<IColumn<SelectableBean<ObjectType>, String>> createColumns() {
            return createMembersColumns();
        }

        @Override
        protected IColumn<SelectableBean<ObjectType>, String> createActionsColumn() {
            return new InlineMenuHeaderColumn(createMembersHeaderInlineMenu());
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return new ArrayList<>();
        }

        @Override
        protected ObjectQuery createContentQuery() {
            ObjectQuery q = super.createContentQuery();
            ObjectQuery members = AbstractRoleMemberPanel.this.createContentQuery();
            List<ObjectFilter> filters = new ArrayList<>();
            if (q != null && q.getFilter() != null) {
                filters.add(q.getFilter());
            }
            if (members != null && members.getFilter() != null) {
                filters.add(members.getFilter());
            }
            if (filters.size() == 1) {
                return ObjectQuery.createObjectQuery(filters.iterator().next());
            }
            return ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
        }
    };
    childrenListPanel.setOutputMarkupId(true);
    memberContainer.add(childrenListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) 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 37 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class PageUsers method initColumns.

private List<IColumn<SelectableBean<UserType>, String>> initColumns() {
    List<IColumn<SelectableBean<UserType>, String>> columns = new ArrayList<IColumn<SelectableBean<UserType>, String>>();
    IColumn<SelectableBean<UserType>, String> column = new PropertyColumn(createStringResource("UserType.givenName"), UserType.F_GIVEN_NAME.getLocalPart(), SelectableBean.F_VALUE + ".givenName");
    columns.add(column);
    column = new PropertyColumn(createStringResource("UserType.familyName"), UserType.F_FAMILY_NAME.getLocalPart(), SelectableBean.F_VALUE + ".familyName");
    columns.add(column);
    column = new PropertyColumn(createStringResource("UserType.fullName"), UserType.F_FULL_NAME.getLocalPart(), SelectableBean.F_VALUE + ".fullName");
    columns.add(column);
    column = new PropertyColumn(createStringResource("UserType.emailAddress"), null, SelectableBean.F_VALUE + ".emailAddress");
    columns.add(column);
    column = new AbstractExportableColumn<SelectableBean<UserType>, String>(createStringResource("pageUsers.accounts")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<UserType>>> cellItem, String componentId, IModel<SelectableBean<UserType>> model) {
            cellItem.add(new Label(componentId, model.getObject().getValue() != null ? model.getObject().getValue().getLinkRef().size() : null));
        }

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<UserType>> rowModel) {
            return Model.of(rowModel.getObject().getValue() != null ? Integer.toString(rowModel.getObject().getValue().getLinkRef().size()) : "");
        }
    };
    columns.add(column);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) 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 IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class CertDecisionHelper method createObjectNameColumn.

<T extends CertCaseOrWorkItemDto> IColumn<T, String> createObjectNameColumn(final PageBase page, final String headerKey) {
    IColumn column;
    column = new LinkColumn<CertCaseOrWorkItemDto>(page.createStringResource(headerKey), SearchingUtils.OBJECT_NAME, CertCaseOrWorkItemDto.F_OBJECT_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<CertCaseOrWorkItemDto> rowModel) {
            CertCaseOrWorkItemDto dto = rowModel.getObject();
            dispatchToObjectDetailsPage(dto.getCertCase().getObjectRef(), page, false);
        }
    };
    return column;
}
Also used : CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Example 39 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class PageCertCampaigns method initColumns.

private List<IColumn<CertCampaignListItemDto, String>> initColumns() {
    List<IColumn<CertCampaignListItemDto, String>> columns = new ArrayList<>();
    IColumn column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = new LinkColumn<CertCampaignListItemDto>(createStringResource("PageCertCampaigns.table.name"), AccessCertificationCampaignType.F_NAME.getLocalPart(), CertCampaignListItemDto.F_NAME) {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<CertCampaignListItemDto> rowModel) {
            campaignDetailsPerformed(target, rowModel.getObject().getOid());
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.description"), CertCampaignListItemDto.F_DESCRIPTION);
    columns.add(column);
    column = new EnumPropertyColumn(createStringResource("PageCertCampaigns.table.state"), CertCampaignListItemDto.F_STATE) {

        @Override
        protected String translate(Enum en) {
            return createStringResourceStatic(getPage(), en).getString();
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stage"), CertCampaignListItemDto.F_CURRENT_STAGE_NUMBER);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.escalationLevel"), CertCampaignListItemDto.F_ESCALATION_LEVEL_NUMBER);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.stages"), CertCampaignListItemDto.F_NUMBER_OF_STAGES);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaigns.table.deadline"), CertCampaignListItemDto.F_DEADLINE_AS_STRING);
    columns.add(column);
    column = new SingleButtonColumn<CertCampaignListItemDto>(new Model(), null) {

        @Override
        public boolean isButtonEnabled(IModel<CertCampaignListItemDto> model) {
            final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            String button = determineAction(campaign);
            return button != null;
        }

        @Override
        public boolean isButtonVisible(IModel<CertCampaignListItemDto> model) {
            final AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            return campaign.getState() != AccessCertificationCampaignStateType.IN_REMEDIATION && campaign.getState() != AccessCertificationCampaignStateType.CLOSED;
        }

        @Override
        public String getCaption() {
            AccessCertificationCampaignType campaign = getRowModel().getObject().getCampaign();
            String button = determineAction(campaign);
            if (button != null) {
                return PageCertCampaigns.this.createStringResource(button).getString();
            } else {
                return "";
            }
        }

        @Override
        public String getButtonCssColorClass() {
            return DoubleButtonColumn.BUTTON_COLOR_CLASS.PRIMARY.toString();
        }

        @Override
        public String getButtonCssSizeClass() {
            return DoubleButtonColumn.BUTTON_SIZE_CLASS.SMALL.toString();
        }

        @Override
        public void clickPerformed(AjaxRequestTarget target, IModel<CertCampaignListItemDto> model) {
            AccessCertificationCampaignType campaign = model.getObject().getCampaign();
            String action = determineAction(campaign);
            switch(action) {
                case OP_START_CAMPAIGN:
                case OP_OPEN_NEXT_STAGE:
                    openNextStagePerformed(target, campaign);
                    break;
                case OP_CLOSE_STAGE:
                    closeStageConfirmation(target, model.getObject());
                    break;
                case OP_START_REMEDIATION:
                    startRemediationPerformed(target, campaign);
                    break;
                // not used
                case OP_CLOSE_CAMPAIGN:
                default:
                    throw new IllegalStateException("Unknown action: " + action);
            }
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu()));
    return columns;
}
Also used : InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) EnumPropertyColumn(com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 40 with IColumn

use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.

the class PageTasks method initTaskColumns.

private List<IColumn<TaskDto, String>> initTaskColumns() {
    List<IColumn<TaskDto, String>> columns = new ArrayList<IColumn<TaskDto, String>>();
    IColumn column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = createTaskNameColumn(this, "pageTasks.task.name");
    columns.add(column);
    columns.add(createTaskCategoryColumn(this, "pageTasks.task.category"));
    columns.add(new IconColumn<TaskDto>(createStringResource("")) {

        @Override
        protected IModel<String> createIconModel(IModel<TaskDto> rowModel) {
            ObjectReferenceType ref = rowModel.getObject().getObjectRef();
            if (ref == null || ref.getType() == null) {
                return Model.of("");
            }
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
            String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
            return new Model<>(icon);
        }

        private ObjectTypeGuiDescriptor getObjectTypeDescriptor(QName type) {
            return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
        }

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, IModel<TaskDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            ObjectReferenceType ref = rowModel.getObject().getObjectRef();
            if (ref != null && ref.getType() != null) {
                ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
                if (guiDescriptor != null) {
                    item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
                    item.add(new TooltipBehavior());
                }
            }
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.objectRef")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createObjectRef(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createObjectRef(rowModel));
        }
    });
    columns.add(createTaskExecutionStatusColumn(this, "pageTasks.task.execution"));
    columns.add(new PropertyColumn<TaskDto, String>(createStringResource("pageTasks.task.executingAt"), "executingAt"));
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.progress")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> cellItem, String componentId, final IModel<TaskDto> rowModel) {
            cellItem.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createProgress(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createProgress(rowModel));
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.currentRunTime")) {

        @Override
        public void populateItem(final Item<ICellPopulator<TaskDto>> item, final String componentId, final IModel<TaskDto> rowModel) {
            DateLabelComponent dateLabel = new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {

                @Override
                public Date getObject() {
                    Date date = createCurrentRuntime(rowModel);
                    TaskDto task = rowModel.getObject();
                    if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
                        ((DateLabelComponent) item.get(componentId)).setBefore("closed at ");
                    } else if (date != null) {
                        ((DateLabelComponent) item.get(componentId)).setBefore(DurationFormatUtils.formatDurationWords(date.getTime(), true, true));
                    }
                    return date;
                }
            }, DateLabelComponent.MEDIUM_MEDIUM_STYLE);
            item.add(dateLabel);
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            TaskDto task = rowModel.getObject();
            Date date = createCurrentRuntime(rowModel);
            String displayValue = "";
            if (date != null) {
                if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
                    displayValue = "closed at " + WebComponentUtil.getLocalizedDate(date, DateLabelComponent.LONG_MEDIUM_STYLE);
                } else {
                    displayValue = DurationFormatUtils.formatDurationWords(date.getTime(), true, true);
                }
            }
            return Model.of(displayValue);
        }
    });
    columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.scheduledToRunAgain")) {

        @Override
        public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    return createScheduledToRunAgain(rowModel);
                }
            }));
        }

        @Override
        public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
            return Model.of(createScheduledToRunAgain(rowModel));
        }
    });
    columns.add(new IconColumn<TaskDto>(createStringResource("pageTasks.task.status")) {

        @Override
        protected IModel<String> createTitleModel(final IModel<TaskDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    TaskDto dto = rowModel.getObject();
                    if (dto != null && dto.getStatus() != null) {
                        return createStringResourceStatic(PageTasks.this, dto.getStatus()).getString();
                    } else {
                        return createStringResourceStatic(PageTasks.this, OperationResultStatus.UNKNOWN).getString();
                    }
                }
            };
        }

        @Override
        protected IModel<String> createIconModel(final IModel<TaskDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getStatus() != null) {
                        return OperationResultStatusPresentationProperties.parseOperationalResultStatus(rowModel.getObject().getStatus().createStatusType()).getIcon() + " fa-lg";
                    } else
                        return OperationResultStatusPresentationProperties.UNKNOWN.getIcon() + " fa-lg";
                }
            };
        }
    });
    IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<TaskDto>(createTasksInlineMenu(false), 2, PageTasks.this) {

        @Override
        protected int getHeaderNumberOfButtons() {
            return 2;
        }

        @Override
        protected List<InlineMenuItem> getHeaderMenuItems() {
            return createTasksInlineMenu(true);
        }
    };
    columns.add(menuColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Aggregations

IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)58 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 ArrayList (java.util.ArrayList)33 IModel (org.apache.wicket.model.IModel)28 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)21 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)19 Label (org.apache.wicket.markup.html.basic.Label)19 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)14 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)13 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)13 Model (org.apache.wicket.model.Model)12 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)8 Item (org.apache.wicket.markup.repeater.Item)8 PropertyModel (org.apache.wicket.model.PropertyModel)8 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)7 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)7 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)6