Search in sources :

Example 1 with ICellPopulator

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

the class ColumnUtils method getDefaultTaskColumns.

public static <T extends ObjectType> List<IColumn<SelectableBean<T>, String>> getDefaultTaskColumns() {
    List<IColumn<SelectableBean<T>, String>> columns = new ArrayList<IColumn<SelectableBean<T>, String>>();
    columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.kind")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
            SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
            PrismProperty<ShadowKindType> pKind = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND)) : null;
            if (pKind != null) {
                cellItem.add(new Label(componentId, WebComponentUtil.createLocalizedModelForEnum(pKind.getRealValue(), cellItem)));
            } else {
                cellItem.add(new Label(componentId));
            }
        }
    });
    columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.intent")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
            SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
            PrismProperty<String> pIntent = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT)) : null;
            if (pIntent != null) {
                cellItem.add(new Label(componentId, pIntent.getRealValue()));
            } else {
                cellItem.add(new Label(componentId));
            }
        }
    });
    columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.objectClass")) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
            SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
            PrismProperty<QName> pObjectClass = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME)) : null;
            if (pObjectClass != null) {
                cellItem.add(new Label(componentId, pObjectClass.getRealValue().getLocalPart()));
            } else {
                cellItem.add(new Label(componentId, ""));
            }
        }
    });
    List<ColumnTypeDto<String>> columnsDefs = Arrays.asList(new ColumnTypeDto<String>("TaskType.executionStatus", TaskType.F_EXECUTION_STATUS.getLocalPart(), SelectableBean.F_VALUE + ".executionStatus", false));
    columns.addAll(ColumnUtils.<SelectableBean<T>>createColumns(columnsDefs));
    return columns;
}
Also used : ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 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 3 with ICellPopulator

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

the class DecisionsPanel method initLayout.

protected void initLayout(UserProfileStorage.TableId tableId, int pageSize) {
    List<IColumn<DecisionDto, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn<>(createStringResource("DecisionsPanel.user"), DecisionDto.F_USER));
    columns.add(new PropertyColumn<>(createStringResource("DecisionsPanel.originalActor"), DecisionDto.F_ORIGINAL_ACTOR));
    columns.add(new PropertyColumn<>(createStringResource("DecisionsPanel.stage"), DecisionDto.F_STAGE));
    columns.add(createOutcomeColumn());
    columns.add(new PropertyColumn<DecisionDto, String>(createStringResource("DecisionsPanel.comment"), DecisionDto.F_COMMENT) {

        @Override
        public void populateItem(Item<ICellPopulator<DecisionDto>> item, String componentId, IModel<DecisionDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            item.add(new AttributeAppender("style", "max-width: 200px; word-wrap: break-word;"));
        }
    });
    columns.add(new PropertyColumn<>(createStringResource("DecisionsPanel.when"), DecisionDto.F_TIME));
    columns.add(new PropertyColumn<>(createStringResource("DecisionsPanel.escalation"), DecisionDto.F_ESCALATION_LEVEL_NUMBER));
    ISortableDataProvider provider = new ListDataProvider<>(this, getModel());
    BoxedTablePanel decisionsTable = new BoxedTablePanel<>(ID_DECISIONS_TABLE, provider, columns, tableId, pageSize);
    add(decisionsTable);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) ArrayList(java.util.ArrayList) ISortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) DecisionDto(com.evolveum.midpoint.web.page.admin.workflow.dto.DecisionDto) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 4 with ICellPopulator

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

the class PageDebugList method initColumns.

private List<IColumn> initColumns(final Class<? extends ObjectType> type) {
    List<IColumn> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<ObjectType>();
    columns.add(column);
    column = new LinkColumn<DebugObjectItem>(createStringResource("pageDebugList.name"), DebugObjectItem.F_NAME, DebugObjectItem.F_NAME) {

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, final IModel<DebugObjectItem> rowModel) {
            TwoValueLinkPanel panel = new TwoValueLinkPanel(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    DebugObjectItem object = rowModel.getObject();
                    if (object == null) {
                        return null;
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(object.getName());
                    if (object.getStatus() != null && object.getStatus() != OperationResultStatusType.SUCCESS && object.getStatus() != OperationResultStatusType.HANDLED_ERROR) {
                        sb.append(" (");
                        sb.append(object.getStatus());
                        sb.append(")");
                    }
                    return sb.toString();
                }
            }, new PropertyModel<String>(rowModel, DebugObjectItem.F_OID)) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    DebugObjectItem object = rowModel.getObject();
                    objectEditPerformed(target, object.getOid(), type);
                }

                @Override
                public boolean isEnabled() {
                    return rowModel.getObject().getOid() != null;
                }
            };
            cellItem.add(panel);
            cellItem.add(new AttributeModifier("class", "col-md-3"));
        }
    };
    columns.add(column);
    columns.add(new PropertyColumn(createStringResource("pageDebugList.description"), DebugObjectItem.F_DESCRIPTION));
    if (ShadowType.class.isAssignableFrom(type)) {
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceName"), DebugObjectItem.F_RESOURCE_NAME));
        columns.add(new PropertyColumn(createStringResource("pageDebugList.resourceType"), DebugObjectItem.F_RESOURCE_TYPE));
    }
    column = new AbstractColumn<DebugObjectItem, String>(new Model(), null) {

        @Override
        public String getCssClass() {
            return "debug-list-buttons";
        }

        @Override
        public void populateItem(Item<ICellPopulator<DebugObjectItem>> cellItem, String componentId, IModel<DebugObjectItem> rowModel) {
            cellItem.add(new DebugButtonPanel<DebugObjectItem>(componentId, rowModel) {

                @Override
                public void deletePerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    deleteSelected(target, model.getObject());
                }

                @Override
                public void exportPerformed(AjaxRequestTarget target, IModel<DebugObjectItem> model) {
                    exportSelected(target, model.getObject());
                }
            });
        }
    };
    columns.add(column);
    column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {

        @Override
        public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
            // we don't need row inline menu
            cellItem.add(new Label(componentId));
        }
    };
    columns.add(column);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) DebugObjectItem(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugObjectItem) TwoValueLinkPanel(com.evolveum.midpoint.web.component.data.column.TwoValueLinkPanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) AttributeModifier(org.apache.wicket.AttributeModifier) 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) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DebugButtonPanel(com.evolveum.midpoint.web.page.admin.configuration.component.DebugButtonPanel)

Example 5 with ICellPopulator

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

the class AbstractRoleMemberPanel method createMembersColumns.

protected List<IColumn<SelectableBean<ObjectType>, String>> createMembersColumns() {
    List<IColumn<SelectableBean<ObjectType>, String>> columns = new ArrayList<>();
    IColumn<SelectableBean<ObjectType>, String> column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.fullName.displayName")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
            SelectableBean<ObjectType> bean = rowModel.getObject();
            ObjectType object = bean.getValue();
            cellItem.add(new Label(componentId, getMemberObjectDisplayName(object)));
        }

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
            return Model.of(getMemberObjectDisplayName(rowModel.getObject().getValue()));
        }
    };
    columns.add(column);
    column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.identifier.description")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
            SelectableBean<ObjectType> bean = rowModel.getObject();
            ObjectType object = bean.getValue();
            cellItem.add(new Label(componentId, getMemberObjectIdentifier(object)));
        }

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
            return Model.of(getMemberObjectIdentifier(rowModel.getObject().getValue()));
        }
    };
    columns.add(column);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) AbstractExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.AbstractExportableColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Item(org.apache.wicket.markup.repeater.Item) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Aggregations

ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)37 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 IModel (org.apache.wicket.model.IModel)25 Label (org.apache.wicket.markup.html.basic.Label)24 ArrayList (java.util.ArrayList)22 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)12 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)10 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)10 Model (org.apache.wicket.model.Model)9 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)5 AttributeModifier (org.apache.wicket.AttributeModifier)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)4 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)4 List (java.util.List)4