Search in sources :

Example 1 with GuiChannel

use of com.evolveum.midpoint.gui.impl.GuiChannel in project midpoint by Evolveum.

the class ProvenanceAcquisitionHeaderPanel method initLayout.

private void initLayout() {
    LinkedReferencePanel<ObjectReferenceType> source = new LinkedReferencePanel<>(ID_SOURCE, new ReadOnlyModel<>(() -> {
        ProvenanceAcquisitionType acquisitionType = getModelObject();
        if (acquisitionType == null) {
            return null;
        }
        ObjectReferenceType ref = acquisitionType.getResourceRef();
        if (ref != null && ref.getOid() != null) {
            return ref;
        }
        ObjectReferenceType originRef = acquisitionType.getOriginRef();
        if (originRef != null && originRef.getOid() != null) {
            return originRef;
        }
        return null;
    }));
    add(source);
    source.add(new VisibleBehaviour(() -> isNotEmpty(getModelObject().getResourceRef()) || isNotEmpty(getModelObject().getOriginRef())));
    ReadOnlyModel<GuiChannel> channelModel = new ReadOnlyModel<>(() -> GuiChannel.findChannel(getModelObject().getChannel()));
    WebMarkupContainer channelIcon = new WebMarkupContainer(ID_CHANNEL_ICON);
    add(channelIcon);
    channelIcon.add(AttributeAppender.replace("class", new PropertyModel<>(channelModel, "iconCssClass")));
    Label channel = new Label(ID_CHANNEL, getPageBase().createStringResource(channelModel.getObject()));
    add(channel);
    channel.add(new VisibleBehaviour(() -> getModelObject() != null && (getModelObject().getOriginRef() == null || getModelObject().getOriginRef().getOid() == null) && (getModelObject().getResourceRef() == null || getModelObject().getResourceRef().getOid() == null)));
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ProvenanceAcquisitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) LinkedReferencePanel(com.evolveum.midpoint.web.component.data.LinkedReferencePanel) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) GuiChannel(com.evolveum.midpoint.gui.impl.GuiChannel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 2 with GuiChannel

use of com.evolveum.midpoint.gui.impl.GuiChannel in project midpoint by Evolveum.

the class AuditLogViewerPanel method createColumns.

protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createColumns() {
    List<IColumn<SelectableBean<AuditEventRecordType>, String>> columns = new ArrayList<>();
    LinkColumn<SelectableBean<AuditEventRecordType>> initiatorRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.initiatorRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            return new ReadOnlyModel<>(() -> {
                AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                if (auditEventRecordType == null) {
                    return null;
                }
                return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getInitiatorRef(), getPageBase(), true);
            });
        }

        @Override
        public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
            dispatchToObjectDetailsPage(auditEventRecordType.getInitiatorRef(), getPageBase(), false);
        }

        @Override
        public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            return unwrapModel(rowModel) != null;
        }
    };
    columns.add(initiatorRefColumn);
    if (!isObjectHistoryPanel()) {
        IColumn<SelectableBean<AuditEventRecordType>, String> eventStageColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventStageLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                AuditEventRecordType record = unwrapModel(rowModel);
                if (record == null) {
                    return new Model<>();
                }
                return WebComponentUtil.createLocalizedModelForEnum(record.getEventStage(), AuditLogViewerPanel.this);
            }
        };
        columns.add(eventStageColumn);
    }
    IColumn<SelectableBean<AuditEventRecordType>, String> eventTypeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.eventTypeLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            AuditEventRecordType record = unwrapModel(rowModel);
            if (record == null) {
                return Model.of();
            }
            return WebComponentUtil.createLocalizedModelForEnum(record.getEventType(), AuditLogViewerPanel.this);
        }
    };
    columns.add(eventTypeColumn);
    if (!isObjectHistoryPanel()) {
        LinkColumn<SelectableBean<AuditEventRecordType>> targetRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                return new ReadOnlyModel<>(() -> {
                    AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                    if (auditEventRecordType == null) {
                        return null;
                    }
                    return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetRef(), getPageBase(), true);
                });
            }

            @Override
            public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                return unwrapModel(rowModel) != null && !AuditEventTypeType.DELETE_OBJECT.equals(unwrapModel(rowModel).getEventType());
            }

            @Override
            public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                dispatchToObjectDetailsPage(auditEventRecordType.getTargetRef(), getPageBase(), false);
            }
        };
        columns.add(targetRefColumn);
    }
    if (!isObjectHistoryPanel()) {
        LinkColumn<SelectableBean<AuditEventRecordType>> targetOwnerRefColumn = new LinkColumn<>(createStringResource("AuditEventRecordType.targetOwnerRef"), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {

            private static final long serialVersionUID = 1L;

            @Override
            protected IModel<String> createLinkModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                return new ReadOnlyModel<>(() -> {
                    AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                    if (auditEventRecordType == null) {
                        return null;
                    }
                    return WebModelServiceUtils.resolveReferenceName(auditEventRecordType.getTargetOwnerRef(), getPageBase(), true);
                });
            }

            @Override
            public void onClick(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                dispatchToObjectDetailsPage(auditEventRecordType.getTargetOwnerRef(), getPageBase(), false);
            }

            @Override
            public boolean isEnabled(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                return unwrapModel(rowModel) != null;
            }
        };
        columns.add(targetOwnerRefColumn);
    }
    IColumn<SelectableBean<AuditEventRecordType>, String> channelColumn = new PropertyColumn<>(createStringResource("AuditEventRecordType.channel"), AuditEventRecordType.F_CHANNEL.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_CHANNEL.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<AuditEventRecordType>>> item, String componentId, IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            IModel<String> channelModel = new ReadOnlyModel<String>(() -> {
                AuditEventRecordType auditEventRecordType = unwrapModel(rowModel);
                if (auditEventRecordType == null) {
                    // TODO might we return null?
                    return "";
                }
                String channel = auditEventRecordType.getChannel();
                for (GuiChannel chan : GuiChannel.values()) {
                    if (chan.getUri().equals(channel)) {
                        // WebComponentUtil.createLocalizedModelForEnum(chan, AuditLogViewerPanel.this);
                        return getPageBase().createStringResource(chan).getString();
                    }
                }
                return "";
            });
            // if (channelValue != null) {
            // item.add(new Label(componentId, WebComponentUtil.createLocalizedModelForEnum(channelValue, AuditLogViewerPanel.this)));
            // } else {
            // item.add(new Label(componentId, ""));
            // }
            item.add(new Label(componentId, channelModel));
            item.add(new AttributeModifier("style", new Model<>("width: 10%;")));
        }
    };
    columns.add(channelColumn);
    IColumn<SelectableBean<AuditEventRecordType>, String> outcomeColumn = new PropertyColumn<>(createStringResource("PageAuditLogViewer.outcomeLabel"), AuditEventRecordType.F_OUTCOME.getLocalPart(), SelectableBeanImpl.F_VALUE + "." + AuditEventRecordType.F_OUTCOME.getLocalPart()) {

        private static final long serialVersionUID = 1L;

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<AuditEventRecordType>> rowModel) {
            AuditEventRecordType record = unwrapModel(rowModel);
            if (record == null) {
                return null;
            }
            return WebComponentUtil.createLocalizedModelForEnum(record.getOutcome(), AuditLogViewerPanel.this);
        }
    };
    columns.add(outcomeColumn);
    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) GuiChannel(com.evolveum.midpoint.gui.impl.GuiChannel) AttributeModifier(org.apache.wicket.AttributeModifier) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) 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) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Model(org.apache.wicket.model.Model)

Aggregations

ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 GuiChannel (com.evolveum.midpoint.gui.impl.GuiChannel)2 Label (org.apache.wicket.markup.html.basic.Label)2 LinkedReferencePanel (com.evolveum.midpoint.web.component.data.LinkedReferencePanel)1 LinkColumn (com.evolveum.midpoint.web.component.data.column.LinkColumn)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 AuditEventRecordType (com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 ProvenanceAcquisitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProvenanceAcquisitionType)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Item (org.apache.wicket.markup.repeater.Item)1 IModel (org.apache.wicket.model.IModel)1 Model (org.apache.wicket.model.Model)1 PropertyModel (org.apache.wicket.model.PropertyModel)1