Search in sources :

Example 1 with ProjectionsListProvider

use of com.evolveum.midpoint.web.component.util.ProjectionsListProvider in project midpoint by Evolveum.

the class FocusProjectionsPanel method initLayout.

protected void initLayout() {
    IModel<Integer> deadShadows = new ReadOnlyModel<>(this::countDeadShadows);
    Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
    label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
    add(label);
    MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class, getPanelConfiguration()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
            return new ProjectionsListProvider(FocusProjectionsPanel.this, getSearchModel(), loadShadowModel()) {

                @Override
                protected PageStorage getPageStorage() {
                    PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    if (storage == null) {
                        storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    }
                    return storage;
                }
            };
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            List<QName> supportedTypes = Arrays.asList(ResourceType.COMPLEX_TYPE);
            PageBase pageBase = FocusProjectionsPanel.this.getPageBase();
            ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
                    FocusProjectionsPanel.this.addSelectedAccountPerformed(target, selected);
                    target.add(getPageBase().getFeedbackPanel());
                }
            };
            resourceSelectionPanel.setOutputMarkupId(true);
            pageBase.showMainPopup(resourceSelectionPanel, target);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            PrismObjectDefinition<F> def = FocusProjectionsPanel.this.getObjectWrapperModel().getObject().getObject().getDefinition();
            PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
            return (ref.canRead() && ref.canAdd());
        }

        @Override
        protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
            return null;
        }

        @Override
        protected TableId getTableId() {
            return TableId.FOCUS_PROJECTION_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
            return initBasicColumns();
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return createShadowMenu();
        }

        @Override
        public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
            loadShadowIfNeeded(rowModel, target);
            if (listItems != null) {
                listItems.forEach(value -> {
                    if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
                        loadFullShadow((PrismObjectValueWrapper) value, target);
                    }
                });
            }
            super.editItemPerformed(target, rowModel, listItems);
        }

        @Override
        protected Search createSearch(Class<ShadowType> type) {
            Search search = super.createSearch(type);
            PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
            if (defaultDeadItem != null) {
                defaultDeadItem.setVisible(false);
            }
            addDeadSearchItem(search);
            return search;
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
            return defs;
        }

        @Override
        protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
            return FocusProjectionsPanel.this.getMultivalueContainerDetailsPanel(item);
        }
    };
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ProjectionsListProvider(com.evolveum.midpoint.web.component.util.ProjectionsListProvider) List(java.util.List) ArrayList(java.util.ArrayList) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 2 with ProjectionsListProvider

use of com.evolveum.midpoint.web.component.util.ProjectionsListProvider in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout() {
    IModel<Integer> deadShadows = new ReadOnlyModel<>(() -> countDeadShadows());
    Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
    label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
    add(label);
    MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
            return new ProjectionsListProvider(FocusProjectionsTabPanel.this, getSearchModel(), loadShadowModel()) {

                @Override
                protected PageStorage getPageStorage() {
                    PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    if (storage == null) {
                        storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    }
                    return storage;
                }
            };
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            List<QName> supportedTypes = new ArrayList<>(1);
            supportedTypes.add(ResourceType.COMPLEX_TYPE);
            PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
            ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
                    FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
                }
            };
            resourceSelectionPanel.setOutputMarkupId(true);
            pageBase.showMainPopup(resourceSelectionPanel, target);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
            PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
            return (ref.canRead() && ref.canAdd());
        }

        @Override
        protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
            return null;
        }

        @Override
        protected TableId getTableId() {
            return UserProfileStorage.TableId.FOCUS_PROJECTION_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
            return initBasicColumns();
        }

        @Override
        public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
            loadShadowIfNeeded(rowModel, target);
            if (listItems != null) {
                listItems.forEach(value -> {
                    if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
                        ((PageAdminFocus) getPage()).loadFullShadow((PrismObjectValueWrapper) value, target);
                    }
                });
            }
            super.editItemPerformed(target, rowModel, listItems);
        }

        @Override
        protected Search createSearch(Class<ShadowType> type) {
            Search search = super.createSearch(type);
            PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
            if (defaultDeadItem != null) {
                defaultDeadItem.setVisible(false);
            }
            addDeadSearchItem(search);
            return search;
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
            return defs;
        }

        @Override
        protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
            return FocusProjectionsTabPanel.this.getMultivalueContainerDetailsPanel(item);
        }
    };
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : PageAdminFocus(com.evolveum.midpoint.web.page.admin.PageAdminFocus) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ProjectionsListProvider(com.evolveum.midpoint.web.component.util.ProjectionsListProvider) List(java.util.List) ArrayList(java.util.ArrayList) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)2 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 ProjectionsListProvider (com.evolveum.midpoint.web.component.util.ProjectionsListProvider)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 PageStorage (com.evolveum.midpoint.web.session.PageStorage)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 QName (javax.xml.namespace.QName)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 Label (org.apache.wicket.markup.html.basic.Label)2 ListItem (org.apache.wicket.markup.html.list.ListItem)2 IModel (org.apache.wicket.model.IModel)2 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 PageAdminFocus (com.evolveum.midpoint.web.page.admin.PageAdminFocus)1