Search in sources :

Example 1 with MetadataPanel

use of com.evolveum.midpoint.web.component.assignment.MetadataPanel in project midpoint by Evolveum.

the class PrismObjectPanel method createMetadataPanel.

protected void createMetadataPanel(IModel<ObjectWrapper<O>> model, ListItem<ContainerWrapper> item, PrismContainerPanel containerPanel) {
    //check if metadata container exists for
    //the current item and create metadata panel if yes
    Component metadataPanel;
    //becomes visible only in case metadata exists
    Model<Boolean> metadataVisibility = Model.of(false);
    ItemPath metadataContainerPath = item.getModelObject().isMain() ? new ItemPath(ObjectType.F_METADATA) : new ItemPath(item.getModelObject().getPath(), ObjectType.F_METADATA);
    if (model.getObject().findContainerWrapper(metadataContainerPath) != null) {
        ContainerWrapper<MetadataType> metadataContainer = model.getObject().findContainerWrapper(metadataContainerPath);
        metadataVisibility.setObject(true);
        String containerName = item.getModelObject().isMain() ? "Object" : StringUtils.capitalize(item.getModelObject().getPath().last().toString());
        metadataPanel = new MetadataPanel(ID_CONTAINER_METADATA, new AbstractReadOnlyModel<MetadataType>() {

            @Override
            public MetadataType getObject() {
                return metadataContainer.getItem().getRealValue();
            }
        }, containerName, "");
    } else {
        metadataPanel = new WebMarkupContainer(ID_CONTAINER_METADATA);
    }
    metadataPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return containerPanel.isVisible() && metadataVisibility.getObject() && model.getObject().isShowMetadata() && !ContainerStatus.ADDING.equals(model.getObject().getStatus());
        }
    });
    metadataPanel.setOutputMarkupId(true);
    item.add(metadataPanel);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) MetadataPanel(com.evolveum.midpoint.web.component.assignment.MetadataPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 MetadataPanel (com.evolveum.midpoint.web.component.assignment.MetadataPanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 MetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType)1 Component (org.apache.wicket.Component)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1