Search in sources :

Example 6 with ICellPopulator

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

the class MyAssignmentsPanel method initLayout.

private void initLayout() {
    List<IColumn<AssignmentItemDto, String>> columns = new ArrayList<IColumn<AssignmentItemDto, String>>();
    columns.add(new IconColumn<AssignmentItemDto>(null) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return OperationResultStatusPresentationProperties.FATAL_ERROR.getIcon() + " fa-lg";
                    }
                    return item.getType().getIconCssClass();
                }
            };
        }

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

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                    switch(item.getType()) {
                        case CONSTRUCTION:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.accountConstruction");
                        case ORG_UNIT:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.orgUnit");
                        case ROLE:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.role");
                        default:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                }
            };
        }
    });
    columns.add(new AbstractColumn<AssignmentItemDto, String>(createStringResource("MyAssignmentsPanel.assignment.displayName")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AssignmentItemDto>> cellItem, String componentId, final IModel<AssignmentItemDto> rowModel) {
            AssignmentHeaderPanel panel = new AssignmentHeaderPanel(componentId, rowModel);
            panel.add(new AttributeModifier("class", "dash-assignment-header"));
            cellItem.add(panel);
        }
    });
    ISortableDataProvider provider = new ListDataProvider(this, getModel());
    TablePanel accountsTable = new TablePanel<AssignmentItemDto>(ID_ASSIGNMETNS_TABLE, provider, columns);
    accountsTable.setShowPaging(false);
    add(accountsTable);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) IModel(org.apache.wicket.model.IModel) AssignmentHeaderPanel(com.evolveum.midpoint.web.component.assignment.AssignmentHeaderPanel) ArrayList(java.util.ArrayList) ISortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider) AttributeModifier(org.apache.wicket.AttributeModifier) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 7 with ICellPopulator

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

the class PageCreatedReports method initColumns.

//TODO - consider adding Author name, File Type and ReportType to columns
private List<IColumn<SelectableBean<ReportOutputType>, String>> initColumns(final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior) {
    List<IColumn<SelectableBean<ReportOutputType>, String>> columns = new ArrayList<>();
    IColumn column;
    column = new CheckBoxHeaderColumn();
    columns.add(column);
    column = new PropertyColumn(createStringResource("pageCreatedReports.table.name"), "name", "value.name");
    columns.add(column);
    column = new PropertyColumn(createStringResource("pageCreatedReports.table.description"), "value.description");
    columns.add(column);
    column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(createStringResource("pageCreatedReports.table.time"), "createTimestamp") {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> rowModel) {
            cellItem.add(new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {

                @Override
                public Date getObject() {
                    ReportOutputType object = rowModel.getObject().getValue();
                    MetadataType metadata = object != null ? object.getMetadata() : null;
                    if (metadata == null) {
                        return null;
                    }
                    return XmlTypeConverter.toDate(metadata.getCreateTimestamp());
                }
            }, DateLabelComponent.LONG_MEDIUM_STYLE));
        }
    };
    columns.add(column);
    column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(new Model(), null) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> model) {
            DownloadButtonPanel panel = new DownloadButtonPanel(componentId) {

                @Override
                protected void deletePerformed(AjaxRequestTarget target) {
                    deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SINGLE, model.getObject().getValue());
                }

                @Override
                protected void downloadPerformed(AjaxRequestTarget target) {
                    currentReport = model.getObject().getValue();
                    PageCreatedReports.this.downloadPerformed(target, model.getObject().getValue(), ajaxDownloadBehavior);
                }
            };
            cellItem.add(panel);
        }
    };
    columns.add(column);
    column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {

        @Override
        public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
            cellItem.add(new Label(componentId));
        }
    };
    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) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) InlineMenuable(com.evolveum.midpoint.web.component.data.column.InlineMenuable) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DownloadButtonPanel(com.evolveum.midpoint.web.page.admin.reports.component.DownloadButtonPanel) 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) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 8 with ICellPopulator

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

the class CertDecisionHelper method createDetailedInfoColumn.

<T extends CertCaseOrWorkItemDto> IColumn<T, String> createDetailedInfoColumn(final PageBase page) {
    IColumn column;
    column = new IconColumn<CertCaseOrWorkItemDto>(page.createStringResource("")) {

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

                @Override
                public String getObject() {
                    return "fa fa-fw fa-info-circle text-info";
                }
            };
        }

        @Override
        public void populateItem(Item<ICellPopulator<CertCaseOrWorkItemDto>> item, String componentId, IModel<CertCaseOrWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertCaseOrWorkItemDto aCase = rowModel.getObject();
            String handlerUri;
            if (aCase instanceof CertWorkItemDto) {
                handlerUri = aCase.getHandlerUri();
            } else {
                handlerUri = ((PageCertCampaign) page).getCampaignHandlerUri();
            }
            CertGuiHandler handler = CertGuiHandlerRegistry.instance().getHandler(handlerUri);
            if (handler != null) {
                String title = handler.getCaseInfoButtonTitle(rowModel, page);
                item.add(AttributeModifier.replace("title", title));
                item.add(new TooltipBehavior());
            }
        }
    };
    return column;
}
Also used : IModel(org.apache.wicket.model.IModel) CertGuiHandler(com.evolveum.midpoint.web.page.admin.certification.handlers.CertGuiHandler) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto)

Example 9 with ICellPopulator

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

the class CertDecisionHelper method createTypeColumn.

<T extends CertCaseOrWorkItemDto> IColumn<T, String> createTypeColumn(final WhichObject which, final PageBase page) {
    IColumn column;
    column = new IconColumn<CertCaseOrWorkItemDto>(page.createStringResource("")) {

        @Override
        protected IModel<String> createIconModel(IModel<CertCaseOrWorkItemDto> rowModel) {
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(which, rowModel);
            String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
            return new Model<>(icon);
        }

        private ObjectTypeGuiDescriptor getObjectTypeDescriptor(WhichObject which, IModel<CertCaseOrWorkItemDto> rowModel) {
            QName targetType = rowModel.getObject().getObjectType(which);
            return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(targetType));
        }

        @Override
        public void populateItem(Item<ICellPopulator<CertCaseOrWorkItemDto>> item, String componentId, IModel<CertCaseOrWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(which, rowModel);
            if (guiDescriptor != null) {
                item.add(AttributeModifier.replace("title", page.createStringResource(guiDescriptor.getLocalizationKey())));
                item.add(new TooltipBehavior());
            }
        }
    };
    return column;
}
Also used : IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CertCaseOrWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor)

Example 10 with ICellPopulator

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

the class PageCertDecisions method initColumns.

//	private void addVisibleOnWarningBehavior(Component c) {
//		c.add(new VisibleEnableBehaviour() {
//			@Override
//			public boolean isVisible() {
//				return PageCertDecisions.this.getFeedbackMessages().hasMessage(FeedbackMessage.WARNING);
//			}
//		});
//	}
private List<IColumn<CertWorkItemDto, String>> initColumns() {
    List<IColumn<CertWorkItemDto, String>> columns = new ArrayList<>();
    IColumn<CertWorkItemDto, String> column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = helper.createTypeColumn(OBJECT, this);
    columns.add(column);
    column = helper.createObjectNameColumn(this, "PageCertDecisions.table.objectName");
    columns.add(column);
    column = helper.createTypeColumn(TARGET, this);
    columns.add(column);
    column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
    columns.add(column);
    column = helper.createDetailedInfoColumn(this);
    columns.add(column);
    column = helper.createConflictingNameColumn(this, "PageCertDecisions.table.conflictingTargetName");
    columns.add(column);
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CERTIFICATION_ALL_URL, AuthorizationConstants.AUTZ_UI_CERTIFICATION_CAMPAIGN_URL)) {
        column = new LinkColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME, CertWorkItemDto.F_CAMPAIGN_NAME) {

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
                super.populateItem(item, componentId, rowModel);
                AccessCertificationCampaignType campaign = rowModel.getObject().getCampaign();
                if (campaign != null && campaign.getDescription() != null) {
                    item.add(AttributeModifier.replace("title", campaign.getDescription()));
                    item.add(new TooltipBehavior());
                }
            }

            @Override
            public void onClick(AjaxRequestTarget target, IModel<CertWorkItemDto> rowModel) {
                CertWorkItemDto dto = rowModel.getObject();
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, dto.getCampaignRef().getOid());
                navigateToNext(PageCertCampaign.class, parameters);
            }
        };
    } else {
        column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME) {

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

                    @Override
                    public Object getObject() {
                        return rowModel.getObject().getCampaignName();
                    }
                }));
            }
        };
    }
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignStage")) {

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

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    return dto.getCampaignStageNumber() + "/" + dto.getCampaignStageCount();
                }
            }));
            String stageName = rowModel.getObject().getCurrentStageName();
            if (stageName != null) {
                item.add(AttributeModifier.replace("title", stageName));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.escalation")) {

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

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    Integer n = dto.getEscalationLevelNumber();
                    return n != null ? String.valueOf(n) : null;
                }
            }));
            String info = rowModel.getObject().getEscalationLevelInfo();
            if (info != null) {
                item.add(AttributeModifier.replace("title", info));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.requested"), SearchingUtils.CURRENT_REVIEW_REQUESTED_TIMESTAMP, CertWorkItemDto.F_REVIEW_REQUESTED) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertWorkItemDto dto = rowModel.getObject();
            Date started = dto.getStageStarted();
            if (started != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(started, DateLabelComponent.LONG_MEDIUM_STYLE)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.deadline"), SearchingUtils.CURRENT_REVIEW_DEADLINE, CertWorkItemDto.F_DEADLINE_AS_STRING) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            XMLGregorianCalendar deadline = rowModel.getObject().getCertCase().getCurrentStageDeadline();
            if (deadline != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.formatDate(deadline)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    final AvailableResponses availableResponses = new AvailableResponses(getPage());
    final int responses = availableResponses.getResponseKeys().size();
    column = new MultiButtonColumn<CertWorkItemDto>(new Model(), responses + 1) {

        @Override
        public String getCaption(int id) {
            return availableResponses.getCaption(id);
        }

        @Override
        public boolean isButtonEnabled(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return !decisionEquals(model, availableResponses.getResponseValues().get(id));
            } else {
                return false;
            }
        }

        @Override
        public boolean isButtonVisible(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return true;
            } else {
                return !availableResponses.isAvailable(model.getObject().getResponse());
            }
        }

        @Override
        public String getButtonColorCssClass(int id) {
            if (id < responses) {
                return getDecisionButtonColor(getRowModel(), availableResponses.getResponseValues().get(id));
            } else {
                return BUTTON_COLOR_CLASS.DANGER.toString();
            }
        }

        @Override
        public void clickPerformed(int id, AjaxRequestTarget target, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                // should be always the case
                recordActionPerformed(target, model.getObject(), availableResponses.getResponseValues().get(id));
            }
        }
    };
    columns.add(column);
    column = new DirectlyEditablePropertyColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.comment"), CertWorkItemDto.F_COMMENT) {

        @Override
        public void onBlur(AjaxRequestTarget target, IModel model) {
            // TODO determine somehow if the model.comment was really changed
            recordActionPerformed(target, (CertWorkItemDto) model.getObject(), null);
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu(availableResponses)));
    return columns;
}
Also used : ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType) IModel(org.apache.wicket.model.IModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Date(java.util.Date) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) 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)

Aggregations

ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)15 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)14 Label (org.apache.wicket.markup.html.basic.Label)10 IModel (org.apache.wicket.model.IModel)10 ArrayList (java.util.ArrayList)9 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)6 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)5 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)4 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 Model (org.apache.wicket.model.Model)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 DateLabelComponent (com.evolveum.midpoint.web.component.DateLabelComponent)2 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)2 InlineMenuable (com.evolveum.midpoint.web.component.data.column.InlineMenuable)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2 CertCaseOrWorkItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseOrWorkItemDto)2 CertWorkItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto)2