Search in sources :

Example 31 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class MultiTypesMemberPopupTabPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_SELECT_PANEL);
    typePanel.setOutputMarkupId(true);
    add(typePanel);
    DropDownChoicePanel<ObjectTypes> typeSelect = new DropDownChoicePanel<ObjectTypes>(ID_TYPE, new LoadableModel<ObjectTypes>() {

        @Override
        protected ObjectTypes load() {
            return defaultObjectType;
        }
    }, Model.ofList(getSupportedTypesList()), new EnumChoiceRenderer<>(this));
    typeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            defaultObjectType = typeSelect.getModel().getObject();
            MultiTypesMemberPopupTabPanel.this.addOrReplace(initObjectListPanel());
            target.add(MultiTypesMemberPopupTabPanel.this);
        }
    });
    typePanel.add(typeSelect);
    add(typePanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior)

Example 32 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class ObjectBrowserPanel method initLayout.

private void initLayout() {
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    add(warningMessage);
    List<ObjectTypes> supported = new ArrayList<>();
    for (QName qname : supportedTypes) {
        supported.add(ObjectTypes.getObjectTypeFromTypeQName(qname));
    }
    WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
    typePanel.setOutputMarkupId(true);
    typePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return supportedTypes.size() != 1;
        }
    });
    add(typePanel);
    DropDownChoice<ObjectTypes> typeSelect = new DropDownChoice<>(ID_TYPE, typeModel, new ListModel<>(supported), new EnumChoiceRenderer<>(this));
    typeSelect.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
            listPanel = createObjectListPanel(typeModel.getObject(), multiselect);
            addOrReplace(listPanel);
            target.add(listPanel);
        }
    });
    typePanel.add(typeSelect);
    ObjectTypes objType = defaultType != null ? ObjectTypes.getObjectType(defaultType) : null;
    ObjectListPanel<O> listPanel = createObjectListPanel(objType, multiselect);
    add(listPanel);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedRealObjects();
            ObjectTypes type = ObjectBrowserPanel.this.typeModel.getObject();
            QName qname = type != null ? type.getTypeQName() : null;
            ObjectBrowserPanel.this.addPerformed(target, qname, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("Button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            getPageBase().hideMainPopup(ajaxRequestTarget);
        }
    };
    add(cancelButton);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 33 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class TypedAssignablePanel method initAssignmentParametersPanel.

protected void initAssignmentParametersPanel() {
    DropDownChoicePanel<ObjectTypes> typeSelect = new DropDownChoicePanel<>(ID_TYPE, typeModel, Model.ofList(getObjectTypesList()), new EnumChoiceRenderer<>());
    typeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_TABLES_CONTAINER));
            target.add(addOrReplace(createCountContainer()));
        }
    });
    typeSelect.setOutputMarkupId(true);
    add(typeSelect);
    WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
    relationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return TypedAssignablePanel.this.isRelationPanelVisible() && !ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    relationContainer.setOutputMarkupId(true);
    add(relationContainer);
    DropDownChoicePanel<RelationTypes> relationSelector = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION, WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class), Model.of(RelationTypes.MEMBER), TypedAssignablePanel.this, false);
    relationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    relationSelector.setOutputMarkupId(true);
    relationSelector.setOutputMarkupPlaceholderTag(true);
    relationContainer.add(relationSelector);
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    kindContainer.setOutputMarkupId(true);
    add(kindContainer);
    DropDownChoicePanel kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND, WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(ShadowKindType.ACCOUNT), TypedAssignablePanel.this, false);
    kindSelector.setOutputMarkupId(true);
    kindSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName()) && getSelectedResourceCount() > 0;
        }
    });
    kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(TypedAssignablePanel.this);
        }
    });
    kindSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    kindSelector.setOutputMarkupPlaceholderTag(true);
    kindContainer.add(kindSelector);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    intentContainer.setOutputMarkupId(true);
    add(intentContainer);
    DropDownChoicePanel<?> intentSelector = new DropDownChoicePanel<>(ID_INTENT, intentValueModel, intentValues);
    intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    intentSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(TypedAssignablePanel.this);
        }
    });
    intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    intentSelector.setOutputMarkupId(true);
    intentSelector.setOutputMarkupPlaceholderTag(true);
    intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName()) && getSelectedResourceCount() > 0;
        }
    });
    intentContainer.add(intentSelector);
    WebMarkupContainer orgTreeViewContainer = new WebMarkupContainer(ID_ORG_TREE_VIEW_CONTAINER);
    orgTreeViewContainer.setOutputMarkupId(true);
    orgTreeViewContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            boolean res = OrgType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
            return res;
        }
    });
    add(orgTreeViewContainer);
    CheckBox orgTreeViewCheckbox = new CheckBox(ID_ORG_TREE_VIEW, orgTreeViewModel);
    orgTreeViewCheckbox.add(new AjaxEventBehavior("change") {

        @Override
        protected void onEvent(AjaxRequestTarget ajaxRequestTarget) {
            orgTreeViewModel.setObject(!orgTreeViewModel.getObject());
            ajaxRequestTarget.add(TypedAssignablePanel.this);
        }
    });
    orgTreeViewCheckbox.setOutputMarkupId(true);
    orgTreeViewContainer.add(orgTreeViewCheckbox);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) RelationTypes(com.evolveum.midpoint.schema.constants.RelationTypes) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 34 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class PageAdminObjectDetails method changeArchetypeButtonClicked.

private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
    AssignmentPopup changeArchetypePopup = new AssignmentPopup(getMainPopupBodyId(), null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
            OperationResult result = new OperationResult(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
            if (newAssignmentsList.size() > 1) {
                result.recordWarning(getString("PageAdminObjectDetails.change.archetype.more.than.one.selected"));
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            AssignmentType oldArchetypAssignment = getOldArchetypeAssignment(result);
            if (oldArchetypAssignment == null) {
                showResult(result);
                target.add(PageAdminObjectDetails.this.getFeedbackPanel());
                return;
            }
            try {
                ObjectDelta<O> delta = getPrismContext().deltaFor(getCompileTimeClass()).item(AssignmentHolderType.F_ASSIGNMENT).delete(oldArchetypAssignment.clone()).asObjectDelta(getObjectWrapper().getOid());
                delta.addModificationAddContainer(AssignmentHolderType.F_ASSIGNMENT, newAssignmentsList.iterator().next());
                Task task = createSimpleTask(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
                getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
            } catch (Exception e) {
                LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage(), e);
                result.recordFatalError(getString("PageAdminObjectDetails.change.archetype.failed", e.getMessage()), e);
            }
            result.computeStatusIfUnknown();
            showResult(result);
            target.add(PageAdminObjectDetails.this.getFeedbackPanel());
            refresh(target);
        }

        @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 = getObjectWrapper().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);
    showMainPopup(changeArchetypePopup, target);
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) IModel(org.apache.wicket.model.IModel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Example 35 with ObjectTypes

use of com.evolveum.midpoint.schema.constants.ObjectTypes in project midpoint by Evolveum.

the class DefaultGuiConfigurationCompiler method compileDefaultCollectionViews.

private List<CompiledObjectCollectionView> compileDefaultCollectionViews(Collection<Class<?>> classes) {
    List<CompiledObjectCollectionView> compiledObjectCollectionViews = new ArrayList<>();
    for (Class<?> clazz : classes) {
        CollectionInstance collectionInstance = clazz.getAnnotation(CollectionInstance.class);
        if (collectionInstance == null) {
            continue;
        }
        ObjectTypes objectType = ObjectTypes.getObjectType(collectionInstance.applicableForType());
        CompiledObjectCollectionView defaultCollectionView = new CompiledObjectCollectionView(objectType.getTypeQName(), collectionInstance.identifier());
        defaultCollectionView.setDisplay(createDisplayType(collectionInstance.display()));
        compiledObjectCollectionViews.add(defaultCollectionView);
        defaultCollectionView.setDefaultView(true);
        if (collectionInstance.applicableForOperation().length == 1) {
            defaultCollectionView.setApplicableForOperation(collectionInstance.applicableForOperation()[0]);
        }
    }
    return compiledObjectCollectionViews;
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Aggregations

ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)46 QName (javax.xml.namespace.QName)16 ArrayList (java.util.ArrayList)11 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)6 List (java.util.List)6 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)5 AssignmentPopup (com.evolveum.midpoint.gui.api.component.AssignmentPopup)4 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)3 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)3 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)3