Search in sources :

Example 1 with QNameObjectTypeChoiceRenderer

use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.

the class DropDownChoicePanelFactory method getPanel.

@Override
protected InputPanel getPanel(PrismPropertyPanelContext<QName> panelCtx) {
    List<QName> typesList;
    if (AssignmentType.F_FOCUS_TYPE.equals(panelCtx.getDefinitionName())) {
        typesList = WebComponentUtil.createFocusTypeList();
    } else if ((ObjectCollectionType.F_TYPE.equals(panelCtx.getDefinitionName()) || GuiObjectListViewType.F_TYPE.equals(panelCtx.getDefinitionName())) && panelCtx.unwrapWrapperModel().getParent().getDefinition() != null && (ObjectCollectionType.class.equals(panelCtx.unwrapWrapperModel().getParent().getDefinition().getTypeClass()) || GuiObjectListViewType.class.equals(panelCtx.unwrapWrapperModel().getParent().getDefinition().getTypeClass()))) {
        typesList = WebComponentUtil.createContainerableTypesQnameList();
    } else {
        typesList = WebComponentUtil.createObjectTypeList();
    }
    DropDownChoicePanel<QName> typePanel = new DropDownChoicePanel<QName>(panelCtx.getComponentId(), panelCtx.getRealValueModel(), Model.ofList(typesList), new QNameObjectTypeChoiceRenderer(), true);
    typePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    typePanel.setOutputMarkupId(true);
    return typePanel;
}
Also used : EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QName(javax.xml.namespace.QName) QNameObjectTypeChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)

Example 2 with QNameObjectTypeChoiceRenderer

use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer 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 3 with QNameObjectTypeChoiceRenderer

use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.

the class ChooseFocusTypeAndRelationDialogPanel method initLayout.

private void initLayout() {
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_FEEDBACK, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    add(warningMessage);
    DropDownFormGroup<QName> type = new DropDownFormGroup<>(ID_OBJECT_TYPE, Model.of(getDefaultObjectType()), Model.ofList(getSupportedObjectTypes()), new QNameObjectTypeChoiceRenderer(), createStringResource("chooseFocusTypeAndRelationDialogPanel.type"), "chooseFocusTypeAndRelationDialogPanel.tooltip.type", "col-md-4", "col-md-8", true);
    type.getInput().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    type.setOutputMarkupId(true);
    type.add(new VisibleBehaviour(this::isFocusTypeSelectorVisible));
    add(type);
    IModel<Map<String, String>> options = new Model(null);
    options.setObject(new HashMap<>());
    ListMultipleChoicePanel<QName> relation = new ListMultipleChoicePanel<>(ID_RELATION, Model.ofList(getDefaultRelations()), new ListModel<>(getSupportedRelations()), WebComponentUtil.getRelationChoicesRenderer(getPageBase()), options);
    relation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    relation.setOutputMarkupId(true);
    add(relation);
    WebMarkupContainer relationRequired = new WebMarkupContainer(ID_RELATION_REQUIRED);
    relationRequired.add(new VisibleBehaviour((this::isRelationRequired)));
    add(relationRequired);
    Label label = new Label(ID_INFO_MESSAGE, getModel());
    label.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
    add(label);
    AjaxButton confirmButton = new AjaxButton(ID_BUTTON_OK, createStringResource("Button.ok")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            DropDownFormGroup<QName> type = getTypePanel(getParent());
            QName typeChosen = type.getModelObject();
            ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
            Collection<QName> relationChosen = relation.getModelObject();
            if (relationChosen.contains(PrismConstants.Q_ANY)) {
                relationChosen = getSupportedRelations();
            }
            ChooseFocusTypeAndRelationDialogPanel.this.okPerformed(typeChosen, relationChosen, target);
            getPageBase().hideMainPopup(target);
        }
    };
    add(confirmButton);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL_OK, createStringResource("Button.cancel")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().hideMainPopup(target);
        }
    };
    add(cancelButton);
    AjaxButton configuredButton = new AjaxButton(ID_CONFIGURE_TASK, new StringResourceModel("ConfigureTaskConfirmationPanel.configure", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            DropDownFormGroup<QName> type = getTypePanel(getParent());
            QName typeChosen = type.getModelObject();
            ListMultipleChoicePanel<QName> relation = getRelationPanel(getParent());
            Collection<QName> relationChosen = relation.getModelObject();
            PrismObject<TaskType> task = getTask(typeChosen, relationChosen, target);
            if (task == null) {
                return;
            }
            ((PageBase) getPage()).hideMainPopup(target);
            WebComponentUtil.dispatchToObjectDetailsPage(task, true, ChooseFocusTypeAndRelationDialogPanel.this);
        }
    };
    configuredButton.add(new VisibleBehaviour(this::isTaskConfigureButtonVisible));
    add(configuredButton);
}
Also used : DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel) QNameObjectTypeChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)

Example 4 with QNameObjectTypeChoiceRenderer

use of com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer in project midpoint by Evolveum.

the class DefinitionScopePanel method initLayout.

protected void initLayout() {
    final TextField nameField = new TextField(ID_NAME, new PropertyModel<>(getModel(), DefinitionScopeDto.F_NAME));
    nameField.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return true;
        }
    });
    add(nameField);
    final TextArea descriptionField = new TextArea(ID_DESCRIPTION, new PropertyModel<>(getModel(), DefinitionScopeDto.F_DESCRIPTION));
    descriptionField.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return true;
        }
    });
    add(descriptionField);
    DropDownChoicePanel objectTypeChooser = new DropDownChoicePanel(ID_OBJECT_TYPE_CHOOSER, new PropertyModel(getModel(), DefinitionScopeDto.F_OBJECT_TYPE), WebComponentUtil.createReadonlyModelFromEnum(DefinitionScopeObjectType.class), new EnumChoiceRenderer<DefinitionScopeObjectType>());
    add(objectTypeChooser);
    add(WebComponentUtil.createHelp(ID_OBJECT_TYPE_HELP));
    TextArea filterTextArea = new TextArea(ID_SEARCH_FILTER, new PropertyModel<String>(getModel(), DefinitionScopeDto.F_SEARCH_FILTER_TEXT));
    filterTextArea.setOutputMarkupId(true);
    add(filterTextArea);
    add(WebComponentUtil.createHelp(ID_SEARCH_FILTER_HELP));
    add(new CheckBox(ID_INCLUDE_ASSIGNMENTS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ASSIGNMENTS)));
    add(new CheckBox(ID_INCLUDE_INDUCEMENTS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_INDUCEMENTS)));
    add(WebComponentUtil.createHelp(ID_ASSIGNMENTS_INDUCEMENTS_HELP));
    add(new CheckBox(ID_INCLUDE_RESOURCES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_RESOURCES)));
    add(new CheckBox(ID_INCLUDE_ROLES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ROLES)));
    add(new CheckBox(ID_INCLUDE_ORGS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ORGS)));
    add(new CheckBox(ID_INCLUDE_SERVICES, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_SERVICES)));
    add(new CheckBox(ID_INCLUDE_USERS, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_USERS)));
    add(WebComponentUtil.createHelp(ID_INCLUDE_TARGET_TYPES_HELP));
    add(new CheckBox(ID_INCLUDE_ENABLED_ITEMS_ONLY, new PropertyModel<>(getModel(), DefinitionScopeDto.F_INCLUDE_ENABLED_ITEMS_ONLY)));
    add(WebComponentUtil.createHelp(ID_INCLUDE_BY_STATUS_HELP));
    List<QName> relationsList = WebComponentUtil.getAllRelations(getPageBase());
    relationsList.add(0, new QName(PrismConstants.NS_QUERY, "any"));
    ListMultipleChoicePanel<QName> relationsPanel = new ListMultipleChoicePanel<QName>(ID_SCOPE_RELATIONS, new ListModel<QName>(getModelObject().getRelationList()), new ListModel<QName>(relationsList), new QNameObjectTypeChoiceRenderer(), null);
    relationsPanel.setOutputMarkupId(true);
    add(relationsPanel);
    add(WebComponentUtil.createHelp(ID_SCOPE_RELATION_HELP));
}
Also used : DefinitionScopeObjectType(com.evolveum.midpoint.web.page.admin.certification.dto.DefinitionScopeObjectType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) QNameObjectTypeChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)

Aggregations

QNameObjectTypeChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameObjectTypeChoiceRenderer)4 QName (javax.xml.namespace.QName)4 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 ListMultipleChoicePanel (com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)1 AutoCompleteReferenceRenderer (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteReferenceRenderer)1 MessagePanel (com.evolveum.midpoint.gui.api.component.result.MessagePanel)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 DropDownFormGroup (com.evolveum.midpoint.web.component.form.DropDownFormGroup)1 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)1 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)1 DefinitionScopeObjectType (com.evolveum.midpoint.web.page.admin.certification.dto.DefinitionScopeObjectType)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1