Search in sources :

Example 1 with AssignmentPopupDto

use of com.evolveum.midpoint.gui.api.component.AssignmentPopupDto in project midpoint by Evolveum.

the class AssignmentHolderOperationalButtonsPanel method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getPageBase().getMainPopupBodyId(), Model.of(new AssignmentPopupDto(null))) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            addArchetypePerformed(target, newAssignmentsList);
        }

        @Override
        protected List<ITab> createAssignmentTabs(AssignmentObjectRelation assignmentObjectRelation) {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(getPageBase().createStringResource("ObjectTypes.ARCHETYPE"), new VisibleBehaviour(() -> true)) {

                private static final long serialVersionUID = 1L;

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new FocusTypeAssignmentPopupTabPanel<ArchetypeType>(panelId, ObjectTypes.ARCHETYPE, null) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
                            PrismContainerWrapper<AssignmentType> assignmentsWrapper = null;
                            try {
                                assignmentsWrapper = AssignmentHolderOperationalButtonsPanel.this.getModelObject().findContainer(FocusType.F_ASSIGNMENT);
                            } catch (SchemaException e) {
                                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
                            }
                            return assignmentsWrapper;
                        }

                        @Override
                        protected List<QName> getSupportedRelations() {
                            return Collections.singletonList(SchemaConstants.ORG_DEFAULT);
                        }

                        @Override
                        protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ArchetypeType>> rowModel) {
                            target.add(getObjectListPanel());
                            tabLabelPanelUpdate(target);
                        }

                        @Override
                        protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<ArchetypeType>> rowModel) {
                            if (rowModel == null) {
                                return Model.of(false);
                            }
                            List selectedObjects = getSelectedObjectsList();
                            return Model.of(selectedObjects == null || selectedObjects.size() == 0 || (rowModel.getObject() != null && rowModel.getObject().isSelected()));
                        }

                        @Override
                        protected ObjectTypes getObjectType() {
                            return ObjectTypes.ARCHETYPE;
                        }

                        @Override
                        protected ObjectQuery addFilterToContentQuery() {
                            ObjectQuery query = super.addFilterToContentQuery();
                            if (query == null) {
                                query = getPrismContext().queryFactory().createQuery();
                            }
                            List<String> archetypeOidsList = getArchetypeOidsListToAssign();
                            ObjectFilter filter = getPrismContext().queryFor(ArchetypeType.class).id(archetypeOidsList.toArray(new String[0])).buildFilter();
                            query.addFilter(filter);
                            return query;
                        }
                    };
                }
            });
            return tabs;
        }

        @Override
        protected IModel<String> getWarningMessageModel() {
            return createStringResource("PageAdminObjectDetails.button.changeArchetype.warningMessage");
        }
    };
    changeArchetypePopup.setOutputMarkupPlaceholderTag(true);
    getPageBase().showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ArrayList(java.util.ArrayList) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) AssignmentPopupDto(com.evolveum.midpoint.gui.api.component.AssignmentPopupDto) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)1 AssignmentPopupDto (com.evolveum.midpoint.gui.api.component.AssignmentPopupDto)1 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)1 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)1 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 IModel (org.apache.wicket.model.IModel)1