Search in sources :

Example 1 with MultivalueContainerListPanelWithDetailsPanel

use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel 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 MultivalueContainerListPanelWithDetailsPanel

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

the class AssignmentPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isCreateNewObjectVisible() {
            return isNewObjectButtonVisible(getFocusObject());
        }

        @Override
        protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
            return AssignmentPanel.this.getModel();
        }

        @Override
        protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
            AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
        }

        protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
            if (AssignmentPanel.this.getModelObject() == null) {
                return new ArrayList<>();
            }
            return initBasicColumns();
        }

        @Override
        protected List<Component> createToolbarButtonsList(String idButton) {
            List<Component> bar = new ArrayList<>();
            AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newAssignmentClickPerformed(target);
                }
            };
            newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
            bar.add(newObjectButton);
            newObjectButton.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return isNewObjectButtonVisible(getFocusObject());
                }

                @Override
                public boolean isEnabled() {
                    return !isAssignmentsLimitReached();
                }
            });
            return bar;
        }

        @Override
        public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
            int countAddedAssignments = 0;
            for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
                if (ValueStatus.ADDED.equals(assignment.getStatus())) {
                    countAddedAssignments++;
                }
            }
            boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
            if (isLimitReached) {
                warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            super.deleteItemPerformed(target, toDeleteList);
        }

        @Override
        protected AssignmentListProvider createProvider() {
            PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
            return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
        }

        @Override
        protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
            return createMultivalueContainerDetailsPanel(item);
        }

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

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
            return createSearchableItems(containerDef);
        }

        @Override
        public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
            super.refreshTable(ajaxRequestTarget);
            AssignmentPanel.this.refreshTable(ajaxRequestTarget);
        }

        @Override
        protected boolean isCollectionViewPanel() {
            return config != null && config.getListView() != null;
        }

        @Override
        protected CompiledObjectCollectionView getObjectCollectionView() {
            if (config == null) {
                return super.getObjectCollectionView();
            }
            GuiObjectListViewType listView = config.getListView();
            if (listView == null) {
                return null;
            }
            CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
            if (collectionRefSpecificationType == null) {
                return null;
            }
            Task task = getPageBase().createSimpleTask("Compile collection");
            OperationResult result = task.getResult();
            try {
                return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return null;
        }
    };
    multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) PageStorage(com.evolveum.midpoint.web.session.PageStorage) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 3 with MultivalueContainerListPanelWithDetailsPanel

use of com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel 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)

Example 4 with MultivalueContainerListPanelWithDetailsPanel

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

the class ResourceSchemaHandlingTabPanel method initLayout.

private void initLayout() {
    MidpointForm<?> form = new MidpointForm<>(ID_FORM);
    add(form);
    MultivalueContainerListPanelWithDetailsPanel<ResourceObjectTypeDefinitionType> objectTypesPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_TABLE, ResourceObjectTypeDefinitionType.class) {

        @Override
        protected MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> item) {
            return createMultivalueContainerDetailsPanel(ID_ITEM_DETAILS, item.getModel());
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return false;
        }

        @Override
        protected IModel<PrismContainerWrapper<ResourceObjectTypeDefinitionType>> getContainerModel() {
            return PrismContainerWrapperModel.fromContainerWrapper(ResourceSchemaHandlingTabPanel.this.getModel(), SchemaHandlingType.F_OBJECT_TYPE);
        }

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

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> createDefaultColumns() {
            List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> columns = new ArrayList<>();
            columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DISPLAY_NAME, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_KIND, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_INTENT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DEFAULT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            List<InlineMenuItem> menuActionsList = getMultivalueContainerListPanel().getDefaultMenuActions();
            columns.add(new InlineMenuButtonColumn(menuActionsList, getPageBase()) {

                private static final long serialVersionUID = 1L;

                @Override
                public String getCssClass() {
                    return " col-md-1 ";
                }
            });
            return columns;
        }
    };
    form.add(objectTypesPanel);
}
Also used : InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ResourceObjectTypeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 5 with MultivalueContainerListPanelWithDetailsPanel

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

the class ListMappingPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<MappingType> table = new MultivalueContainerListPanelWithDetailsPanel<MappingType>(ID_TABLE, MappingType.class) {

        @Override
        protected MultivalueContainerDetailsPanel<MappingType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<MappingType>> item) {
            return new MultivalueContainerDetailsPanel<>(MultivalueContainerListPanelWithDetailsPanel.ID_ITEM_DETAILS, item.getModel(), true) {

                @Override
                protected DisplayNamePanel<MappingType> createDisplayNamePanel(String displayNamePanelId) {
                    ItemRealValueModel<MappingType> displayNameModel = new ItemRealValueModel<>(item.getModel());
                    return new DisplayNamePanel<>(displayNamePanelId, displayNameModel) {

                        @Override
                        protected IModel<String> createHeaderModel() {
                            IModel<String> headerModel = super.createHeaderModel();
                            if (StringUtils.isEmpty(headerModel.getObject())) {
                                return getPageBase().createStringResource("feedbackMessagePanel.message.undefined");
                            }
                            return headerModel;
                        }
                    };
                }

                @Override
                protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
                    if (itemWrapper.getPath().isSubPathOrEquivalent(ItemPath.create(ItemPath.EMPTY_PATH, MappingType.F_METADATA_MAPPING))) {
                        return ItemVisibility.HIDDEN;
                    }
                    return ItemVisibility.AUTO;
                }
            };
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<MappingType>> getContainerModel() {
            return ListMappingPanel.this.getModel();
        }

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

        @Override
        protected List<IColumn<PrismContainerValueWrapper<MappingType>, String>> createDefaultColumns() {
            List<IColumn<PrismContainerValueWrapper<MappingType>, String>> columns = new ArrayList<>();
            columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_ENABLED, AbstractItemWrapperColumn.ColumnType.VALUE, getPageBase()));
            columns.add(new AbstractColumn<>(createStringResource("ListMappingPanel.mappingDescription")) {

                @Override
                public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<MappingType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<MappingType>> rowModel) {
                    cellItem.add(new Label(componentId, WebComponentUtil.createMappingDescription(rowModel)));
                }
            });
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {

                private static final long serialVersionUID = 1L;

                @Override
                public InlineMenuItemAction initAction() {
                    return new ColumnMenuAction() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            deleteItemPerformed(target, getPerformedSelectedItems(getRowModel()));
                        }
                    };
                }
            };
            items.add(item);
            item = new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return new ColumnMenuAction() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            editItemPerformed(target, getRowModel(), getSelectedItems());
                            target.add(getFeedbackPanel());
                        }
                    };
                }
            };
            items.add(item);
            columns.add(new InlineMenuButtonColumn(items, getPageBase()) {

                @Override
                public String getCssClass() {
                    return "col-xs-1";
                }
            });
            return columns;
        }

        @Override
        protected IColumn<PrismContainerValueWrapper<MappingType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
            return new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_NAME, AbstractItemWrapperColumn.ColumnType.LINK, getPageBase()) {

                @Override
                protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<MappingType>> model) {
                    itemDetailsPerformed(target, model);
                }
            };
        }

        @Override
        protected IColumn<PrismContainerValueWrapper<MappingType>, String> createCheckboxColumn() {
            return new CheckBoxHeaderColumn<>();
        }

        @Override
        protected PrismContainerDefinition<MappingType> getTypeDefinitionForSearch() {
            return getPrismContext().getSchemaRegistry().findContainerDefinitionByType(MappingType.COMPLEX_TYPE);
        }
    };
    add(table);
}
Also used : MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismPropertyWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) ItemRealValueModel(com.evolveum.midpoint.gui.impl.factory.panel.ItemRealValueModel) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) ListItem(org.apache.wicket.markup.html.list.ListItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)7 ArrayList (java.util.ArrayList)7 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 List (java.util.List)5 IModel (org.apache.wicket.model.IModel)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)4 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3 InlineMenuButtonColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 PageStorage (com.evolveum.midpoint.web.session.PageStorage)3 QName (javax.xml.namespace.QName)3 Label (org.apache.wicket.markup.html.basic.Label)3 DisplayNamePanel (com.evolveum.midpoint.gui.api.component.DisplayNamePanel)2 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