Search in sources :

Example 16 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class MainObjectListPanel method createNewObjectButton.

private Component createNewObjectButton(String buttonId) {
    DisplayType newObjectButtonDisplayType = getNewObjectButtonStandardDisplayType();
    CompositedIconBuilder builder = new CompositedIconBuilder();
    builder.setBasicIcon(WebComponentUtil.getIconCssClass(newObjectButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(newObjectButtonDisplayType));
    CompiledObjectCollectionView view = getObjectCollectionView();
    if (ObjectCollectionViewUtil.isArchetypedCollectionView(view)) {
        IconType plusIcon = new IconType();
        plusIcon.setCssClass(GuiStyleConstants.CLASS_ADD_NEW_OBJECT);
        plusIcon.setColor("green");
        builder.appendLayerIcon(plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
    }
    String iconTitle = WebComponentUtil.getDisplayTypeTitle(newObjectButtonDisplayType);
    AjaxCompositedIconButton createNewObjectButton = new AjaxCompositedIconButton(buttonId, builder.build(), createStringResource(StringUtils.isEmpty(iconTitle) ? "MainObjectListPanel.newObject" : iconTitle)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (isCollectionViewPanelForCompiledView()) {
                CompiledObjectCollectionView collectionView = getObjectCollectionView();
                // HACK TODO clenup and think about generic mechanism for this
                if (isCollectionViewWithoutMorePossibleNewType(collectionView)) {
                    newObjectPerformed(target, null, collectionView);
                    return;
                }
            }
            if (!showNewObjectCreationPopup()) {
                newObjectPerformed(target, null, getObjectCollectionView());
                return;
            }
            NewObjectCreationPopup buttonsPanel = new NewObjectCreationPopup(getPageBase().getMainPopupBodyId(), new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
                    getPageBase().hideMainPopup(target);
                    MainObjectListPanel.this.newObjectPerformed(target, relationSpec, collectionViews);
                }
            };
            getPageBase().showMainPopup(buttonsPanel, target);
        }
    };
    createNewObjectButton.add(new VisibleBehaviour(this::isCreateNewObjectEnabled));
    createNewObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
    return createNewObjectButton;
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) WebPage(org.apache.wicket.markup.html.WebPage) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)

Example 17 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class PageCreateFromTemplate method loadButtonDescriptions.

protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
    return new LoadableModel<>(false) {

        @Override
        protected MultiFunctinalButtonDto load() {
            List<CompositedIconButtonDto> additionalButtons = new ArrayList<>();
            Collection<CompiledObjectCollectionView> compiledObjectCollectionViews = getCompiledGuiProfile().findAllApplicableArchetypeViews(getType(), OperationTypeType.ADD);
            if (CollectionUtils.isNotEmpty(compiledObjectCollectionViews)) {
                compiledObjectCollectionViews.forEach(collection -> {
                    CompositedIconButtonDto buttonDesc = new CompositedIconButtonDto();
                    buttonDesc.setCompositedIcon(createCompositedIcon(collection));
                    buttonDesc.setOrCreateDefaultAdditionalButtonDisplayType(collection.getDisplay());
                    buttonDesc.setCollectionView(collection);
                    additionalButtons.add(buttonDesc);
                });
            }
            if (isGenericNewButtonVisible()) {
                CompositedIconButtonDto defaultButton = new CompositedIconButtonDto();
                DisplayType defaultButtonDisplayType = getDefaultButtonDisplayType();
                defaultButton.setAdditionalButtonDisplayType(defaultButtonDisplayType);
                CompositedIconBuilder defaultButtonIconBuilder = new CompositedIconBuilder();
                defaultButtonIconBuilder.setBasicIcon(WebComponentUtil.getIconCssClass(defaultButtonDisplayType), IconCssStyle.IN_ROW_STYLE).appendColorHtmlValue(WebComponentUtil.getIconColor(defaultButtonDisplayType));
                defaultButton.setCompositedIcon(defaultButtonIconBuilder.build());
                additionalButtons.add(defaultButton);
            }
            MultiFunctinalButtonDto multifunctionalButton = new MultiFunctinalButtonDto();
            multifunctionalButton.setAdditionalButtons(additionalButtons);
            return multifunctionalButton;
        }
    };
}
Also used : CompositedIconButtonDto(com.evolveum.midpoint.web.component.CompositedIconButtonDto) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)

Example 18 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class PageCreateFromTemplate method initLayout.

private void initLayout() {
    MultiCompositedButtonPanel buttonsPanel = new MultiCompositedButtonPanel(ID_TEMPLATE, new PropertyModel<>(loadButtonDescriptions(), MultiFunctinalButtonDto.F_ADDITIONAL_BUTTONS)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionViews);
            try {
                WebComponentUtil.initNewObjectWithReference(getPageBase(), getType(), archetypeRef);
            } catch (SchemaException ex) {
                getPageBase().getFeedbackMessages().error(PageCreateFromTemplate.this, ex.getUserFriendlyMessage());
                target.add(getPageBase().getFeedbackPanel());
            }
        }
    };
    add(buttonsPanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebPage(org.apache.wicket.markup.html.WebPage) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) MultiCompositedButtonPanel(com.evolveum.midpoint.web.component.MultiCompositedButtonPanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation)

Example 19 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class ResourceTasksPanel method initLayout.

protected void initLayout() {
    final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<>(ID_TASKS_TABLE, TaskType.class, null) {

        private static final long serialVersionUID = 1L;

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

        @Override
        protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> createResourceTasksQuery(), null);
        }

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

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) {
            if (collectionView == null) {
                collectionView = getObjectCollectionView();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionView);
            try {
                PrismContext prismContext = getPrismContext();
                PrismObjectDefinition<TaskType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(TaskType.COMPLEX_TYPE);
                PrismObject<TaskType> obj = def.instantiate();
                TaskType newTask = obj.asObjectable();
                ObjectReferenceType resourceRef = new ObjectReferenceType();
                resourceRef.setOid(ResourceTasksPanel.this.getModelObject().getOid());
                resourceRef.setType(ResourceType.COMPLEX_TYPE);
                newTask.setObjectRef(resourceRef);
                WebComponentUtil.initNewObjectWithReference(getPageBase(), newTask, archetypeRef);
            } catch (SchemaException ex) {
                getPageBase().getFeedbackMessages().error(ResourceTasksPanel.this, ex.getUserFriendlyMessage());
                target.add(getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
            return ColumnUtils.getDefaultTaskColumns();
        }

        @Override
        protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
            List<CompiledObjectCollectionView> newObjectInfluencesList = super.getNewObjectInfluencesList();
            List<CompiledObjectCollectionView> filteredInfluencesList = new ArrayList<>();
            if (newObjectInfluencesList != null) {
                newObjectInfluencesList.forEach(influence -> {
                    if (influence.getCollection() != null && influence.getCollection().getCollectionRef() != null && ArrayUtils.contains(resourceTaskArchetypeOids, influence.getCollection().getCollectionRef().getOid())) {
                        filteredInfluencesList.add(influence);
                    }
                });
            }
            return filteredInfluencesList;
        }
    };
    tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
    add(tasksPanel);
    AjaxButton runNow = new AjaxButton(ID_RUN_NOW, getPageBase().createStringResource("pageTaskEdit.button.runNow")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedRealObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.runNowPerformed(oids, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(runNow);
    AjaxButton resume = new AjaxButton(ID_RESUME, getPageBase().createStringResource("pageTaskEdit.button.resume")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.resumeTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(resume);
    AjaxButton suspend = new AjaxButton(ID_SUSPEND, getPageBase().createStringResource("pageTaskEdit.button.suspend")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
            if (!tasks.isEmpty()) {
                OperationResult result = TaskOperationUtils.suspendTasks(tasks, getPageBase());
                getPageBase().showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(suspend);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) PrismContext(com.evolveum.midpoint.prism.PrismContext) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 20 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class AbstractRoleMemberPanel method initMemberTable.

private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
    WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
    memberContainer.setOutputMarkupId(true);
    memberContainer.setOutputMarkupPlaceholderTag(true);
    form.add(memberContainer);
    // TODO QName defines a relation value which will be used for new member creation
    MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions()) {

        private static final long serialVersionUID = 1L;

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

        @Override
        protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
            List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
            columns.add(createRelationColumn());
            return columns;
        }

        @Override
        protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
                return false;
            }
            Class<?> objectClass = rowModel.getObject().getValue().getClass();
            return WebComponentUtil.hasDetailsPage(objectClass);
        }

        @Override
        protected boolean showNewObjectCreationPopup() {
            return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
        }

        @Override
        protected List<Component> createToolbarButtonsList(String buttonId) {
            List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
            AjaxIconButton assignButton = createAssignButton(buttonId);
            buttonsList.add(1, assignButton);
            return buttonsList;
        }

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

        @Override
        protected String getStorageKey() {
            return AbstractRoleMemberPanel.this.createStorageKey();
        }

        protected PageStorage getPageStorage(String storageKey) {
            return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
        }

        @Override
        protected Search<AH> createSearch(Class<AH> type) {
            return createMemberSearch(type);
        }

        @Override
        protected SelectableBeanObjectDataProvider<AH> createProvider() {
            SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
            provider.setIsMemberPanel(true);
            provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
            return provider;
        }

        @Override
        public void refreshTable(AjaxRequestTarget target) {
            if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
                clearCache();
            }
            if (reloadPageOnRefresh()) {
                throw new RestartResponseException(getPage().getClass());
            } else {
                super.refreshTable(target);
            }
        }

        @Override
        protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
            List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
            if (refList == null) {
                refList = new ArrayList<>();
            }
            if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
                refList.addAll(relation.getArchetypeRefs());
            }
            ObjectReferenceType membershipRef = new ObjectReferenceType();
            membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
            membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
            membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
            refList.add(membershipRef);
            return refList;
        }

        @Override
        protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
            return loadMultiFunctionalButtonModel(true);
        }

        @Override
        protected String getTitleForNewObjectButton() {
            return createStringResource("TreeTablePanel.menu.createMember").getString();
        }
    };
    childrenListPanel.setOutputMarkupId(true);
    memberContainer.add(childrenListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) MultiFunctinalButtonDto(com.evolveum.midpoint.web.component.MultiFunctinalButtonDto) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) RestartResponseException(org.apache.wicket.RestartResponseException) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) Component(org.apache.wicket.Component)

Aggregations

CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)41 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)13 WebPage (org.apache.wicket.markup.html.WebPage)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)6 ArrayList (java.util.ArrayList)6 MultiCompositedButtonPanel (com.evolveum.midpoint.web.component.MultiCompositedButtonPanel)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 MultiFunctinalButtonDto (com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Form (org.apache.wicket.markup.html.form.Form)3