Search in sources :

Example 16 with PropertyColumn

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

the class PageAuditLogDetails method initColumns.

private List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<>();
    PropertyColumn<AuditEventRecordType, String> timeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.timestamp"), AuditEventRecordType.F_TIMESTAMP.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
            item.add(new Label(componentId, WebComponentUtil.getLocalizedDate(time, DateLabelComponent.SHORT_SHORT_STYLE)));
        }
    };
    columns.add(timeColumn);
    PropertyColumn<AuditEventRecordType, String> stageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageShortLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventStageType stage = rowModel.getObject().getEventStage();
            String shortStage = "";
            if (AuditEventStageType.EXECUTION.equals(stage)) {
                shortStage = AuditEventStageType.EXECUTION.value().substring(0, 4);
            } else if (AuditEventStageType.REQUEST.equals(stage)) {
                shortStage = AuditEventStageType.REQUEST.value().substring(0, 3);
            }
            item.add(new Label(componentId, shortStage));
        }
    };
    columns.add(stageColumn);
    PropertyColumn<AuditEventRecordType, String> typeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeShortLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            //TODO create some proper short values
            AuditEventTypeType type = rowModel.getObject().getEventType();
            String typeVal = type.value().substring(0, 4);
            item.add(new Label(componentId, typeVal));
        }
    };
    columns.add(typeColumn);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Label(org.apache.wicket.markup.html.basic.Label) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)

Example 17 with PropertyColumn

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

the class ProcessInstancesPanel method createNameColumn.

@NotNull
private IColumn<ProcessInstanceDto, String> createNameColumn() {
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_TASKS_ALL_URL, AuthorizationConstants.AUTZ_UI_TASK_URL)) {
        return new LinkColumn<ProcessInstanceDto>(createStringResource("MyRequestsPanel.name"), "name") {

            @Override
            public void onClick(AjaxRequestTarget target, IModel<ProcessInstanceDto> rowModel) {
                ProcessInstanceDto piDto = rowModel.getObject();
                itemDetailsPerformed(target, piDto.getTaskOid());
            }
        };
    } else {
        return new PropertyColumn<>(createStringResource("MyRequestsPanel.name"), F_NAME);
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with PropertyColumn

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

the class AuditLogViewerPanel method initColumns.

protected List<IColumn<AuditEventRecordType, String>> initColumns() {
    List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
    IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
                    return WebComponentUtil.formatDate(time);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType record = rowModel.getObject();
            try {
                AuditEventRecord.adopt(record, pageBase.getPrismContext());
            } catch (SchemaException e) {
                throw new SystemException("Couldn't adopt event record: " + e, e);
            }
            pageBase.navigateToNext(new PageAuditLogDetails(record));
        }
    };
    columns.add(linkColumn);
    PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = rowModel.getObject();
            createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
        }
    };
    columns.add(initiatorRefColumn);
    if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
        IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
        columns.add(eventStageColumn);
    }
    IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
    columns.add(eventTypeColumn);
    if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
            }
        };
        columns.add(targetRefColumn);
    }
    if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
        PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
                AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
                createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
            }
        };
        columns.add(targetOwnerRefColumn);
    }
    IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
            AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
            String channel = auditEventRecordType.getChannel();
            if (channel != null) {
                QName channelQName = QNameUtil.uriToQName(channel);
                String return_ = channelQName.getLocalPart();
                item.add(new Label(componentId, return_));
            } else {
                item.add(new Label(componentId, ""));
            }
            item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
        }
    };
    columns.add(channelColumn);
    IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
    columns.add(outcomeColumn);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) QName(javax.xml.namespace.QName) PageAuditLogDetails(com.evolveum.midpoint.web.page.admin.reports.PageAuditLogDetails) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Item(org.apache.wicket.markup.repeater.Item) SystemException(com.evolveum.midpoint.util.exception.SystemException) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 19 with PropertyColumn

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

the class PageConnectorHosts method initConnectorHostsColumns.

private List<IColumn<ConnectorHostType, String>> initConnectorHostsColumns() {
    List<IColumn<ConnectorHostType, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<ConnectorHostType>();
    columns.add(column);
    column = new LinkColumn<SelectableBean<ConnectorHostType>>(createStringResource("pageResources.connector.name"), "name", "value.name") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ConnectorHostType>> rowModel) {
            ConnectorHostType host = rowModel.getObject().getValue();
        // resourceDetailsPerformed(target, host.getOid());
        }
    };
    columns.add(column);
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.hostname"), "value.hostname"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.port"), "value.port"));
    columns.add(new PropertyColumn(createStringResource("pageResources.connector.timeout"), "value.timeout"));
    columns.add(new CheckBoxColumn(createStringResource("pageResources.connector.protectConnection"), "value.protectConnection"));
    InlineMenuHeaderColumn menu = new InlineMenuHeaderColumn(initInlineHostsMenu());
    columns.add(menu);
    return columns;
}
Also used : ConnectorHostType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorHostType) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 20 with PropertyColumn

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

the class ObjectListPanel method getCustomColumnsTransformed.

protected List<IColumn<SelectableBean<O>, String>> getCustomColumnsTransformed(List<GuiObjectColumnType> customColumns) {
    List<IColumn<SelectableBean<O>, String>> columns = new ArrayList<IColumn<SelectableBean<O>, String>>();
    if (customColumns == null || customColumns.size() == 0) {
        return columns;
    }
    IColumn<SelectableBean<O>, String> column;
    for (GuiObjectColumnType customColumn : customColumns) {
        if (WebComponentUtil.getElementVisibility(customColumn.getVisibility())) {
            if (customColumns.indexOf(customColumn) == 0) {
                column = createNameColumn(customColumn.getDisplay() != null && customColumn.getDisplay().getLabel() != null ? Model.of(customColumn.getDisplay().getLabel()) : createStringResource(getItemDisplayName(customColumn)), customColumn.getPath().toString());
            } else {
                column = new PropertyColumn(customColumn.getDisplay() != null && customColumn.getDisplay().getLabel() != null ? Model.of(customColumn.getDisplay().getLabel()) : createStringResource(getItemDisplayName(customColumn)), null, SelectableBean.F_VALUE + "." + customColumn.getPath());
            }
            columns.add(column);
        }
    }
    return columns;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Aggregations

PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)21 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)19 ArrayList (java.util.ArrayList)15 IModel (org.apache.wicket.model.IModel)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 Label (org.apache.wicket.markup.html.basic.Label)9 Model (org.apache.wicket.model.Model)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)7 PropertyModel (org.apache.wicket.model.PropertyModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)5 Item (org.apache.wicket.markup.repeater.Item)5 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)2 CheckBoxColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)2 EnumPropertyColumn (com.evolveum.midpoint.web.component.data.column.EnumPropertyColumn)2 InlineMenuHeaderColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn)2