Search in sources :

Example 6 with ObjectBrowserPanel

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

the class ReferenceValueSearchPopupPanel method customizationPopoverForm.

@Override
protected void customizationPopoverForm(MidpointForm midpointForm) {
    FeedbackAlerts feedback = new FeedbackAlerts(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    midpointForm.add(feedback);
    PropertyModel<String> oidModel = new PropertyModel<>(getModel(), "oid") {

        @Override
        public void setObject(String object) {
            super.setObject(object);
            if (StringUtils.isBlank(object)) {
                ReferenceValueSearchPopupPanel.this.getModelObject().asReferenceValue().setObject(null);
                ReferenceValueSearchPopupPanel.this.getModelObject().setTargetName(null);
                ReferenceValueSearchPopupPanel.this.getModelObject().setRelation(null);
            }
        }
    };
    TextField<String> oidField = new TextField<>(ID_OID, oidModel);
    oidField.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    oidField.setOutputMarkupId(true);
    oidField.add(new EnableBehaviour(this::isItemPanelEnabled));
    midpointForm.add(oidField);
    ReferenceAutocomplete nameField = new ReferenceAutocomplete(ID_NAME, Model.of(getModelObject()), new AutoCompleteReferenceRenderer(), getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isAllowedNotFoundObjectRef() {
            return ReferenceValueSearchPopupPanel.this.isAllowedNotFoundObjectRef();
        }

        @Override
        protected <O extends ObjectType> Class<O> getReferenceTargetObjectType() {
            if (getModelObject() != null && getModelObject().getType() != null) {
                return (Class<O>) WebComponentUtil.qnameToClass(PrismContext.get(), getModelObject().getType());
            }
            return super.getReferenceTargetObjectType();
        }
    };
    feedback.setFilter(new ComponentFeedbackMessageFilter(nameField));
    nameField.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateModel(nameField.getBaseFormComponent().getModelObject(), midpointForm, target);
        }
    });
    nameField.setOutputMarkupId(true);
    nameField.add(new EnableBehaviour(this::isItemPanelEnabled));
    midpointForm.add(nameField);
    DropDownChoicePanel<QName> type = new DropDownChoicePanel<>(ID_TYPE, new PropertyModel<>(getModel(), "type"), Model.ofList(getSupportedTargetList()), new QNameObjectTypeChoiceRenderer(), true);
    type.setOutputMarkupId(true);
    type.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getSupportedTargetList().size() > 1 && isItemPanelEnabled();
        }
    });
    type.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    type.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ObjectReferenceType ref = nameField.getAutoCompleteConverter(ObjectReferenceType.class, null).convertToObject(nameField.getBaseFormComponent().getValue(), WebComponentUtil.getCurrentLocale());
            updateModel(ref, midpointForm, target);
            target.add(oidField);
            target.add(ReferenceValueSearchPopupPanel.this);
        }
    });
    midpointForm.add(type);
    WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
    midpointForm.add(relationContainer);
    relationContainer.add(new VisibleBehaviour(() -> getAllowedRelations().size() > 0));
    List<QName> allowedRelations = new ArrayList<>(getAllowedRelations());
    DropDownChoicePanel<QName> relation = new DropDownChoicePanel<>(ID_RELATION, new PropertyModel<>(getModel(), "relation"), Model.ofList(allowedRelations), new QNameObjectTypeChoiceRenderer(), true);
    relation.setOutputMarkupId(true);
    relation.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getAllowedRelations().size() > 1 && isItemPanelEnabled();
        }
    });
    relation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    relationContainer.add(relation);
    AjaxButton selectObject = new AjaxButton(ID_SELECT_OBJECT_BUTTON, createStringResource("ReferenceValueSearchPopupPanel.selectObject")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<QName> supportedTypes = getSupportedTargetList();
            if (CollectionUtils.isEmpty(supportedTypes)) {
                supportedTypes = WebComponentUtil.createObjectTypeList();
            }
            ObjectBrowserPanel<O> objectBrowserPanel = new ObjectBrowserPanel<>(getPageBase().getMainPopupBodyId(), null, supportedTypes, false, getPageBase(), null) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, O object) {
                    getPageBase().hideMainPopup(target);
                    if (ReferenceValueSearchPopupPanel.this.getModel().getObject() == null) {
                        ReferenceValueSearchPopupPanel.this.getModel().setObject(new ObjectReferenceType());
                    }
                    ReferenceValueSearchPopupPanel.this.getModelObject().setOid(object.getOid());
                    ReferenceValueSearchPopupPanel.this.getModelObject().setTargetName(object.getName());
                    ReferenceValueSearchPopupPanel.this.getModelObject().setType(object.asPrismObject().getComplexTypeDefinition().getTypeName());
                    target.add(oidField);
                    target.add(nameField);
                    target.add(type);
                }
            };
            getPageBase().showMainPopup(objectBrowserPanel, target);
        }
    };
    selectObject.add(new VisibleBehaviour(() -> getPageBase().getMainPopup().getContentComponent() == null));
    midpointForm.add(selectObject);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AutoCompleteReferenceRenderer(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteReferenceRenderer) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) QNameObjectTypeChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)

Example 7 with ObjectBrowserPanel

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

the class TargetUserSelectorComponent method initUserSelectionPopup.

private void initUserSelectionPopup(StringResourceModel title, boolean multiselect, AjaxRequestTarget target) {
    List<QName> supportedTypes = new ArrayList<>();
    supportedTypes.add(pageBase.getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).getTypeName());
    ObjectBrowserPanel<UserType> focusBrowser = new ObjectBrowserPanel<UserType>(pageBase.getMainPopupBodyId(), UserType.class, supportedTypes, multiselect, pageBase, null, getSelectedObjects()) {

        @Override
        protected void addPerformed(AjaxRequestTarget target, QName type, List<UserType> selected) {
            super.addPerformed(target, type, selected);
            List<PrismObject<UserType>> userList = new ArrayList<>();
            for (UserType user : selected) {
                userList.add(user.asPrismObject());
            }
            getRoleCatalogStorage().setTargetUserList(userList);
            target.add(pageBase);
        }

        @Override
        public StringResourceModel getTitle() {
            return title;
        }
    };
    pageBase.showMainPopup(focusBrowser, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 8 with ObjectBrowserPanel

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

the class MultipleAssignmentSelectorPanel method createTenantContainer.

private GenericMultiValueLabelEditPanel createTenantContainer() {
    final GenericMultiValueLabelEditPanel tenantEditor = new GenericMultiValueLabelEditPanel<OrgType>(ID_TENANT_EDITOR, createTenantModel(), createStringResource("MultipleAssignmentSelector.tenant"), LABEL_SIZE, INPUT_SIZE, false) {

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

        @Override
        protected IModel<String> createTextModel(final IModel<OrgType> model) {
            return new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getName(model.getObject().asPrismObject());
                }

                @Override
                public void setObject(String s) {
                }

                @Override
                public void detach() {
                }
            };
        }

        @Override
        protected void removeValuePerformed(AjaxRequestTarget target, ListItem<OrgType> item) {
            tenantEditorObject.clear();
            tenantEditorObject.add(new OrgType());
            target.add(getTenantEditorContainer());
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<OrgType> rowModel) {
            List<QName> supportedTypes = new ArrayList<>();
            supportedTypes.add(getPageBase().getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).getTypeName());
            ObjectFilter filter = QueryBuilder.queryFor(OrgType.class, getPageBase().getPrismContext()).item(OrgType.F_TENANT).eq(true).buildFilter();
            ObjectBrowserPanel<OrgType> tenantPanel = new ObjectBrowserPanel<OrgType>(getPageBase().getMainPopupBodyId(), OrgType.class, supportedTypes, false, getPageBase(), filter) {

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, OrgType org) {
                    super.onSelectPerformed(target, org);
                    tenantEditorObject.clear();
                    tenantEditorObject.add(org);
                    target.add(getTenantEditorContainer());
                }
            };
            //                OrgTreeAssignablePanel tenantPanel = new OrgTreeAssignablePanel(
            //                        getPageBase().getMainPopupBodyId(), false, getPageBase()) {
            //
            //                    @Override
            //                    protected void onItemSelect(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
            //                        closeModalWindow(target);
            //                        tenantEditorObject.clear();
            //                        tenantEditorObject.add(selected.getValue());
            //                        target.add(getTenantEditorContainer());                    }
            //                };
            getPageBase().showMainPopup(tenantPanel, target);
        }
    };
    tenantEditor.setOutputMarkupId(true);
    return tenantEditor;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) ArrayList(java.util.ArrayList) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 9 with ObjectBrowserPanel

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

the class MultipleAssignmentSelectorPanel method createOrgContainer.

private GenericMultiValueLabelEditPanel createOrgContainer() {
    final GenericMultiValueLabelEditPanel orgUnitEditor = new GenericMultiValueLabelEditPanel<OrgType>(ID_ORG_EDITOR, createOrgUnitModel(), createStringResource("MultipleAssignmentSelector.orgUnit"), LABEL_SIZE, INPUT_SIZE, false) {

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

        @Override
        protected IModel<String> createTextModel(final IModel<OrgType> model) {
            return new IModel<String>() {

                @Override
                public String getObject() {
                    return WebComponentUtil.getName(model.getObject().asPrismObject());
                }

                @Override
                public void setObject(String s) {
                }

                @Override
                public void detach() {
                }
            };
        }

        @Override
        protected void removeValuePerformed(AjaxRequestTarget target, ListItem<OrgType> item) {
            orgEditorObject.clear();
            orgEditorObject.add(new OrgType());
            target.add(getOrgUnitEditorContainer());
        }

        @Override
        protected void editValuePerformed(AjaxRequestTarget target, IModel<OrgType> rowModel) {
            List<QName> supportedTypes = new ArrayList<>();
            supportedTypes.add(getPageBase().getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).getTypeName());
            ObjectBrowserPanel<OrgType> orgPanel = new ObjectBrowserPanel<OrgType>(getPageBase().getMainPopupBodyId(), OrgType.class, supportedTypes, false, getPageBase()) {

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, OrgType org) {
                    super.onSelectPerformed(target, org);
                    orgEditorObject.clear();
                    orgEditorObject.add(org);
                    target.add(getOrgUnitEditorContainer());
                }
            };
            getPageBase().showMainPopup(orgPanel, target);
        }
    };
    orgUnitEditor.setOutputMarkupId(true);
    return orgUnitEditor;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) GenericMultiValueLabelEditPanel(com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel) ArrayList(java.util.ArrayList) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 10 with ObjectBrowserPanel

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

the class ValueChoosePanel method editValuePerformed.

protected <O extends ObjectType> void editValuePerformed(AjaxRequestTarget target) {
    List<QName> supportedTypes = getSupportedTypes();
    ObjectFilter filter = createChooseQuery() == null ? null : createChooseQuery().getFilter();
    if (CollectionUtils.isEmpty(supportedTypes)) {
        supportedTypes = WebComponentUtil.createObjectTypeList();
    }
    Class<O> defaultType = getDefaultType(supportedTypes);
    ObjectBrowserPanel<O> objectBrowserPanel = new ObjectBrowserPanel<O>(getPageBase().getMainPopupBodyId(), defaultType, supportedTypes, false, getPageBase(), filter) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSelectPerformed(AjaxRequestTarget target, O object) {
            getPageBase().hideMainPopup(target);
            ValueChoosePanel.this.choosePerformed(target, object);
        }

        @Override
        protected Set<Function<Search, SearchItem>> getSpecialSearchItemFunctions() {
            return ValueChoosePanel.this.getSpecialSearchItemFunctions();
        }
    };
    getPageBase().showMainPopup(objectBrowserPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Function(java.util.function.Function) QName(javax.xml.namespace.QName) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter)

Aggregations

ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 QName (javax.xml.namespace.QName)11 ArrayList (java.util.ArrayList)8 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)6 ListItem (org.apache.wicket.markup.html.list.ListItem)6 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)4 List (java.util.List)4 IModel (org.apache.wicket.model.IModel)4 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)3 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)2 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)2 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)2 AssignmentTablePanel (com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel)2 DelegationEditorPanel (com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel)2 GenericMultiValueLabelEditPanel (com.evolveum.midpoint.web.component.form.multivalue.GenericMultiValueLabelEditPanel)2