Search in sources :

Example 16 with ItemWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper in project midpoint by Evolveum.

the class BaseCollectionPanel method initLayout.

@Override
protected void initLayout() {
    SingleContainerPanel panel = new SingleContainerPanel<CollectionRefSpecificationType>(ID_PANEL, createModel(getObjectWrapperModel(), ObjectCollectionType.F_BASE_COLLECTION), CollectionRefSpecificationType.COMPLEX_TYPE) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
            if (ItemPath.create(ObjectCollectionType.F_BASE_COLLECTION, CollectionRefSpecificationType.F_BASE_COLLECTION_REF).isSuperPathOrEquivalent(itemWrapper.getPath())) {
                return ItemVisibility.HIDDEN;
            }
            return ItemVisibility.AUTO;
        }
    };
    add(panel);
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel)

Example 17 with ItemWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper in project midpoint by Evolveum.

the class TaskBasicPanel method initLayout.

protected void initLayout() {
    SingleContainerPanel mainPanel = new SingleContainerPanel(ID_MAIN_PANEL, getObjectWrapperModel(), getPanelConfiguration()) {

        @Override
        protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
            return getBasicTabVisibility(itemWrapper.getPath());
        }

        @Override
        protected ItemEditabilityHandler getEditabilityHandler() {
            return wrapper -> getBasicTabEditability(wrapper.getPath());
        }

        @Override
        protected IModel<PrismContainerWrapper> createVirtualContainerModel(VirtualContainersSpecificationType virtualContainer) {
            if (isDeprecatedVirtualContainer(virtualContainer)) {
                return null;
            }
            return super.createVirtualContainerModel(virtualContainer);
        }
    };
    add(mainPanel);
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) AbstractObjectMainPanel(com.evolveum.midpoint.gui.impl.page.admin.AbstractObjectMainPanel) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel) PanelDisplay(com.evolveum.midpoint.web.application.PanelDisplay) Arrays(java.util.Arrays) ItemEditabilityHandler(com.evolveum.midpoint.gui.api.prism.wrapper.ItemEditabilityHandler) PanelType(com.evolveum.midpoint.web.application.PanelType) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) Collection(java.util.Collection) VirtualContainersSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualContainersSpecificationType) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) ItemVisibility(com.evolveum.midpoint.web.component.prism.ItemVisibility) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) TaskDetailsModel(com.evolveum.midpoint.gui.impl.page.admin.task.TaskDetailsModel) List(java.util.List) ContainerPanelConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType) RefreshableTabPanel(com.evolveum.midpoint.web.page.admin.server.RefreshableTabPanel) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) IModel(org.apache.wicket.model.IModel) Collections(java.util.Collections) PanelInstance(com.evolveum.midpoint.web.application.PanelInstance) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel) VirtualContainersSpecificationType(com.evolveum.midpoint.xml.ns._public.common.common_3.VirtualContainersSpecificationType)

Example 18 with ItemWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper in project midpoint by Evolveum.

the class RoleManagementContentPanel method initLayout.

@Override
protected void initLayout() {
    SingleContainerPanel panel = new SingleContainerPanel(ID_MAIN_PANEL, PrismContainerWrapperModel.fromContainerWrapper(getObjectWrapperModel(), ItemPath.create(SystemConfigurationType.F_ROLE_MANAGEMENT)), RoleManagementConfigurationType.COMPLEX_TYPE) {

        @Override
        protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
            ItemPath path = itemWrapper.getPath();
            if (path == null || path.isEmpty()) {
                return ItemVisibility.AUTO;
            }
            QName name;
            if (path.size() == 1) {
                name = path.firstToQName();
            } else {
                name = path.rest().firstToQName();
            }
            boolean hide = RoleManagementConfigurationType.F_RELATIONS.equals(name);
            return hide ? ItemVisibility.HIDDEN : ItemVisibility.AUTO;
        }
    };
    add(panel);
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) QName(javax.xml.namespace.QName) SingleContainerPanel(com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 19 with ItemWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper in project midpoint by Evolveum.

the class ResourceAttributeRefPanelFactory method getChoicesList.

private List<ItemName> getChoicesList(PrismPropertyPanelContext<ItemPathType> ctx) {
    PrismPropertyWrapper<?> wrapper = ctx.unwrapWrapperModel();
    // attribute/ref
    if (wrapper == null) {
        return Collections.emptyList();
    }
    // attribute value
    if (wrapper.getParent() == null) {
        return Collections.emptyList();
    }
    // attribute
    ItemWrapper<?, ?> attributeWrapper = wrapper.getParent().getParent();
    if (attributeWrapper == null) {
        return Collections.emptyList();
    }
    PrismContainerValueWrapper<?> itemWrapper = attributeWrapper.getParent();
    if (itemWrapper == null) {
        return Collections.emptyList();
    }
    if (!(itemWrapper instanceof ConstructionValueWrapper)) {
        return Collections.emptyList();
    }
    ConstructionValueWrapper constructionWrapper = (ConstructionValueWrapper) itemWrapper;
    try {
        ResourceSchema schema = constructionWrapper.getRefinedSchema();
        if (schema == null) {
            return new ArrayList<>();
        }
        ResourceObjectDefinition rOcd = schema.findObjectDefinition(constructionWrapper.getKind(), constructionWrapper.getIntent());
        if (rOcd == null) {
            return Collections.emptyList();
        }
        if (ConstructionType.F_ASSOCIATION.equivalent(attributeWrapper.getItemName())) {
            Collection<ResourceAssociationDefinition> associationDefs = rOcd.getAssociationDefinitions();
            return associationDefs.stream().map(ResourceAssociationDefinition::getName).collect(Collectors.toList());
        }
        Collection<? extends ResourceAttributeDefinition<?>> attrDefs = rOcd.getAttributeDefinitions();
        return attrDefs.stream().map(a -> a.getItemName()).collect(Collectors.toList());
    } catch (SchemaException e) {
        LOGGER.warn("Cannot get resource attribute definitions");
    }
    return Collections.emptyList();
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) ArrayList(java.util.ArrayList) PrismPropertyWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismPropertyWrapper) ConstructionValueWrapper(com.evolveum.midpoint.gui.impl.prism.wrapper.ConstructionValueWrapper) IModel(org.apache.wicket.model.IModel) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Serializable(java.io.Serializable) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition) List(java.util.List) Component(org.springframework.stereotype.Component) ItemName(com.evolveum.midpoint.prism.path.ItemName) PostConstruct(javax.annotation.PostConstruct) AutoCompleteQNamePanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ConstructionValueWrapper(com.evolveum.midpoint.gui.impl.prism.wrapper.ConstructionValueWrapper) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ArrayList(java.util.ArrayList) ResourceAssociationDefinition(com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)

Example 20 with ItemWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper in project midpoint by Evolveum.

the class PrismContainerValuePanel method prepareNewContainers.

private void prepareNewContainers(AjaxRequestTarget target, List<PrismContainerDefinition<?>> containers) {
    Task task = getPageBase().createSimpleTask("Create child containers");
    WrapperContext ctx = new WrapperContext(task, task.getResult());
    ctx.setCreateIfEmpty(true);
    containers.forEach(container -> {
        try {
            ItemWrapper iw = getPageBase().createItemWrapper(container, getModelObject(), ctx);
            if (iw != null) {
                getModelObject().addItem(iw);
            }
        } catch (SchemaException e) {
            OperationResult result = ctx.getResult();
            result.recordFatalError(createStringResource("PrismContainerValuePanel.message.prepareNewContainers.fatalError", container).getString(), e);
            getPageBase().showResult(ctx.getResult());
        }
    });
    refreshPanel(target);
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)23 ArrayList (java.util.ArrayList)9 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)8 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)7 SingleContainerPanel (com.evolveum.midpoint.gui.impl.prism.panel.SingleContainerPanel)7 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 DisplayNamePanel (com.evolveum.midpoint.gui.api.component.DisplayNamePanel)5 MultivalueContainerDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel)5 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ItemVisibility (com.evolveum.midpoint.web.component.prism.ItemVisibility)5 QName (javax.xml.namespace.QName)5 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)4 List (java.util.List)4 IModel (org.apache.wicket.model.IModel)4 ResourceAttributePanel (com.evolveum.midpoint.gui.impl.prism.panel.ResourceAttributePanel)3 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)2 Task (com.evolveum.midpoint.task.api.Task)2