Search in sources :

Example 11 with QNameChoiceRenderer

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

the class AttributeEditorUtils method addMatchingRuleFields.

static void addMatchingRuleFields(final BasePanel<? extends ResourceItemDefinitionType> editor, final NonEmptyModel<Boolean> readOnlyModel) {
    // normalizes unqualified QNames
    final IModel<QName> matchingRuleModel = new IModel<QName>() {

        @Override
        public QName getObject() {
            QName rawRuleName = editor.getModelObject().getMatchingRule();
            if (rawRuleName == null) {
                return null;
            }
            try {
                MatchingRule<?> rule = editor.getPageBase().getMatchingRuleRegistry().getMatchingRule(rawRuleName, null);
                return rule.getName();
            } catch (SchemaException e) {
                // we could get here if invalid QName is specified - but we don't want to throw an exception in that case
                LoggingUtils.logUnexpectedException(LOGGER, "Invalid matching rule name encountered in resource wizard: {} -- continuing", e, rawRuleName);
                return rawRuleName;
            }
        }

        @Override
        public void setObject(QName value) {
            editor.getModelObject().setMatchingRule(value);
        }

        @Override
        public void detach() {
        }
    };
    final List<QName> matchingRuleList = WebComponentUtil.getMatchingRuleList();
    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE, matchingRuleModel, new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return matchingRuleList;
        }
    }, new QNameChoiceRenderer());
    matchingRule.setNullValid(true);
    matchingRule.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            QName ruleName = matchingRuleModel.getObject();
            return ruleName == null || WebComponentUtil.getMatchingRuleList().contains(ruleName);
        }

        @Override
        public boolean isEnabled() {
            return !readOnlyModel.getObject();
        }
    });
    editor.add(matchingRule);
    Label unknownMatchingRule = new Label(ID_UNKNOWN_MATCHING_RULE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return editor.getString("ResourceAttributeEditor.label.unknownMatchingRule", matchingRuleModel.getObject());
        }
    });
    unknownMatchingRule.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            QName ruleName = matchingRuleModel.getObject();
            return ruleName != null && !WebComponentUtil.getMatchingRuleList().contains(ruleName);
        }
    });
    editor.add(unknownMatchingRule);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) Label(org.apache.wicket.markup.html.basic.Label) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 12 with QNameChoiceRenderer

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

the class AuditLogViewerPanel method initParametersPanel.

private void initParametersPanel(Form mainForm) {
    WebMarkupContainer parametersPanel = new WebMarkupContainer(ID_PARAMETERS_PANEL);
    parametersPanel.setOutputMarkupId(true);
    mainForm.add(parametersPanel);
    PropertyModel<XMLGregorianCalendar> fromModel = new PropertyModel<XMLGregorianCalendar>(auditSearchDto, AuditSearchDto.F_FROM);
    DatePanel from = new DatePanel(ID_FROM, fromModel);
    DateValidator dateFromValidator = WebComponentUtil.getRangeValidator(mainForm, new ItemPath(AuditSearchDto.F_FROM));
    dateFromValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage");
    dateFromValidator.setDateFrom((DateTimeField) from.getBaseFormComponent());
    for (FormComponent<?> formComponent : from.getFormComponents()) {
        formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    }
    from.setOutputMarkupId(true);
    parametersPanel.add(from);
    PropertyModel<XMLGregorianCalendar> toModel = new PropertyModel<XMLGregorianCalendar>(auditSearchDto, AuditSearchDto.F_TO);
    DatePanel to = new DatePanel(ID_TO, toModel);
    DateValidator dateToValidator = WebComponentUtil.getRangeValidator(mainForm, new ItemPath(AuditSearchDto.F_FROM));
    dateToValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage");
    dateToValidator.setDateTo((DateTimeField) to.getBaseFormComponent());
    for (FormComponent<?> formComponent : to.getFormComponents()) {
        formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    }
    to.setOutputMarkupId(true);
    parametersPanel.add(to);
    PropertyModel<ItemPathDto> changedItemModel = new PropertyModel<ItemPathDto>(auditSearchDto, AuditSearchDto.F_CHANGED_ITEM);
    ItemPathPanel changedItemPanel = new ItemPathPanel(ID_CHANGED_ITEM, changedItemModel, pageBase);
    //        changedItemPanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    //        changedItemPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    changedItemPanel.setOutputMarkupId(true);
    parametersPanel.add(changedItemPanel);
    PropertyModel<String> hostIdentifierModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_HOST_IDENTIFIER);
    TextPanel<String> hostIdentifier = new TextPanel<>(ID_HOST_IDENTIFIER, hostIdentifierModel);
    hostIdentifier.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    hostIdentifier.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    hostIdentifier.setOutputMarkupId(true);
    parametersPanel.add(hostIdentifier);
    ListModel<AuditEventTypeType> eventTypeListModel = new ListModel<AuditEventTypeType>(Arrays.asList(AuditEventTypeType.values()));
    PropertyModel<AuditEventTypeType> eventTypeModel = new PropertyModel<AuditEventTypeType>(auditSearchDto, AuditSearchDto.F_EVENT_TYPE);
    DropDownChoicePanel<AuditEventTypeType> eventType = new DropDownChoicePanel<AuditEventTypeType>(ID_EVENT_TYPE, eventTypeModel, eventTypeListModel, new EnumChoiceRenderer<AuditEventTypeType>(), true);
    eventType.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    eventType.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    eventType.setOutputMarkupId(true);
    parametersPanel.add(eventType);
    WebMarkupContainer eventStage = new WebMarkupContainer(ID_EVENT_STAGE);
    eventStage.add(visibilityByKey(visibilityMap, EVENT_STAGE_LABEL_VISIBILITY));
    eventStage.setOutputMarkupId(true);
    parametersPanel.add(eventStage);
    ListModel<AuditEventStageType> eventStageListModel = new ListModel<AuditEventStageType>(Arrays.asList(AuditEventStageType.values()));
    PropertyModel<AuditEventStageType> eventStageModel = new PropertyModel<AuditEventStageType>(auditSearchDto, AuditSearchDto.F_EVENT_STAGE);
    DropDownChoicePanel<AuditEventStageType> eventStageField = new DropDownChoicePanel<AuditEventStageType>(ID_EVENT_STAGE_FIELD, eventStageModel, eventStageListModel, new EnumChoiceRenderer<AuditEventStageType>(), true);
    eventStageField.add(visibilityByKey(visibilityMap, EVENT_STAGE_FIELD_VISIBILITY));
    eventStageField.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    eventStageField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    eventStageField.setOutputMarkupId(true);
    eventStage.add(eventStageField);
    ListModel<OperationResultStatusType> outcomeListModel = new ListModel<OperationResultStatusType>(Arrays.asList(OperationResultStatusType.values()));
    PropertyModel<OperationResultStatusType> outcomeModel = new PropertyModel<OperationResultStatusType>(auditSearchDto, AuditSearchDto.F_OUTCOME);
    DropDownChoicePanel<OperationResultStatusType> outcome = new DropDownChoicePanel<OperationResultStatusType>(ID_OUTCOME, outcomeModel, outcomeListModel, new EnumChoiceRenderer<OperationResultStatusType>(), true);
    outcome.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    outcome.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    outcome.setOutputMarkupId(true);
    parametersPanel.add(outcome);
    List<String> channelList = WebComponentUtil.getChannelList();
    List<QName> channelQnameList = new ArrayList<QName>();
    for (int i = 0; i < channelList.size(); i++) {
        String channel = channelList.get(i);
        if (channel != null) {
            QName channelQName = QNameUtil.uriToQName(channel);
            channelQnameList.add(channelQName);
        }
    }
    ListModel<QName> channelListModel = new ListModel<QName>(channelQnameList);
    PropertyModel<QName> channelModel = new PropertyModel<QName>(auditSearchDto, AuditSearchDto.F_CHANNEL);
    DropDownChoicePanel<QName> channel = new DropDownChoicePanel<QName>(ID_CHANNEL, channelModel, channelListModel, new QNameChoiceRenderer(), true);
    channel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    channel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    channel.setOutputMarkupId(true);
    parametersPanel.add(channel);
    List<Class<? extends ObjectType>> allowedClasses = new ArrayList<>();
    allowedClasses.add(UserType.class);
    MultiValueChoosePanel<ObjectType> chooseInitiatorPanel = new SingleValueChoosePanel<ObjectReferenceType, ObjectType>(ID_INITIATOR_NAME, allowedClasses, objectReferenceTransformer, new PropertyModel<ObjectReferenceType>(auditSearchDto, AuditSearchDto.F_INITIATOR_NAME));
    parametersPanel.add(chooseInitiatorPanel);
    WebMarkupContainer targetOwnerName = new WebMarkupContainer(ID_TARGET_OWNER_NAME);
    targetOwnerName.add(visibilityByKey(visibilityMap, TARGET_OWNER_LABEL_VISIBILITY));
    parametersPanel.add(targetOwnerName);
    MultiValueChoosePanel<ObjectType> chooseTargerOwnerPanel = new SingleValueChoosePanel<ObjectReferenceType, ObjectType>(ID_TARGET_OWNER_NAME_FIELD, allowedClasses, objectReferenceTransformer, new PropertyModel<ObjectReferenceType>(auditSearchDto, AuditSearchDto.F_TARGET_OWNER_NAME));
    chooseTargerOwnerPanel.add(visibilityByKey(visibilityMap, TARGET_OWNER_FIELD_VISIBILITY));
    targetOwnerName.add(chooseTargerOwnerPanel);
    WebMarkupContainer targetName = new WebMarkupContainer(ID_TARGET_NAME);
    targetName.add(visibilityByKey(visibilityMap, TARGET_NAME_LABEL_VISIBILITY));
    parametersPanel.add(targetName);
    List<Class<? extends ObjectType>> allowedClassesAll = new ArrayList<>();
    allowedClassesAll.addAll(ObjectTypes.getAllObjectTypes());
    MultiValueChoosePanel<ObjectType> chooseTargetPanel = new MultiValueChoosePanel<ObjectType>(ID_TARGET_NAME_FIELD, new PropertyModel<List<ObjectType>>(auditSearchDto, AuditSearchDto.F_TARGET_NAMES_OBJECTS), allowedClassesAll);
    chooseTargetPanel.setOutputMarkupId(true);
    chooseTargetPanel.add(visibilityByKey(visibilityMap, TARGET_NAME_FIELD_VISIBILITY));
    targetName.add(chooseTargetPanel);
    AjaxSubmitButton ajaxButton = new AjaxSubmitButton(ID_SEARCH_BUTTON, createStringResource("BasicSearchPanel.search")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            auditLogStorage.setSearchDto(searchDto);
            auditLogStorage.setPageNumber(0);
            Form mainForm = (Form) getParent().getParent();
            addOrReplaceTable(mainForm);
            getFeedbackPanel().getFeedbackMessages().clear();
            target.add(getFeedbackPanel());
            target.add(mainForm);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    WebMarkupContainer valueRefTargetNameContainer = new WebMarkupContainer(ID_VALUE_REF_TARGET_NAMES);
    valueRefTargetNameContainer.add(visibilityByKey(visibilityMap, TARGET_NAME_LABEL_VISIBILITY));
    parametersPanel.add(valueRefTargetNameContainer);
    MultiValueChoosePanel<ObjectType> chooseValueRefTargetNamePanel = new MultiValueChoosePanel<ObjectType>(ID_VALUE_REF_TARGET_NAMES_FIELD, new PropertyModel<List<ObjectType>>(auditSearchDto, AuditSearchDto.F_VALUE_REF_TARGET_NAME), allowedClassesAll);
    chooseValueRefTargetNamePanel.setOutputMarkupId(true);
    chooseValueRefTargetNamePanel.add(visibilityByKey(visibilityMap, VALUE_REF_TARGET_NAME_FIELD_VISIBILITY));
    valueRefTargetNameContainer.add(chooseValueRefTargetNamePanel);
    ajaxButton.setOutputMarkupId(true);
    parametersPanel.add(ajaxButton);
}
Also used : ArrayList(java.util.ArrayList) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) DatePanel(com.evolveum.midpoint.web.component.input.DatePanel) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) ItemPathPanel(com.evolveum.midpoint.gui.api.component.path.ItemPathPanel) MultiValueChoosePanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueChoosePanel) DateValidator(com.evolveum.midpoint.web.util.DateValidator) OperationResultStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType) ItemPathDto(com.evolveum.midpoint.gui.api.component.path.ItemPathDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) Form(org.apache.wicket.markup.html.form.Form) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ListModel(org.apache.wicket.model.util.ListModel) AuditEventTypeType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType) CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 13 with QNameChoiceRenderer

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

the class TypedAssignablePanel method initLayout.

private void initLayout(Class<T> type, final boolean multiselect) {
    DropDownChoice<QName> typeSelect = new DropDownChoice(ID_TYPE, typeModel, new ListModel(WebComponentUtil.createAssignableTypesList()), new QNameChoiceRenderer());
    typeSelect.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_TABLES_CONTAINER));
            target.add(addOrReplace(createCountContainer()));
        }
    });
    typeSelect.setOutputMarkupId(true);
    add(typeSelect);
    WebMarkupContainer tablesContainer = new WebMarkupContainer(ID_TABLES_CONTAINER);
    tablesContainer.setOutputMarkupId(true);
    add(tablesContainer);
    PopupObjectListPanel<T> listRolePanel = createObjectListPanel(ID_ROLE_TABLE, ID_SELECTED_ROLES, RoleType.COMPLEX_TYPE);
    tablesContainer.add(listRolePanel);
    PopupObjectListPanel<T> listResourcePanel = createObjectListPanel(ID_RESOURCE_TABLE, ID_SELECTED_RESOURCES, ResourceType.COMPLEX_TYPE);
    tablesContainer.add(listResourcePanel);
    PopupObjectListPanel<T> listOrgPanel = createObjectListPanel(ID_ORG_TABLE, ID_SELECTED_ORGS, OrgType.COMPLEX_TYPE);
    tablesContainer.add(listOrgPanel);
    PopupObjectListPanel<T> listServicePanel = createObjectListPanel(ID_SERVICE_TABLE, ID_SELECTED_SERVICES, ServiceType.COMPLEX_TYPE);
    tablesContainer.add(listServicePanel);
    WebMarkupContainer countContainer = createCountContainer();
    add(countContainer);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ASSIGN, createStringResource("userBrowserDialog.button.addButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<T> selected = getSelectedData(ID_ROLE_TABLE);
            selected.addAll(getSelectedData(ID_RESOURCE_TABLE));
            selected.addAll(getSelectedData(ID_ORG_TABLE));
            selected.addAll(getSelectedData(ID_SERVICE_TABLE));
            TypedAssignablePanel.this.addPerformed(target, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
}
Also used : QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ListModel(org.apache.wicket.model.util.ListModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)13 QName (javax.xml.namespace.QName)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)11 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)8 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)7 List (java.util.List)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 Label (org.apache.wicket.markup.html.basic.Label)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)4 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)4 ArrayList (java.util.ArrayList)4 Form (org.apache.wicket.markup.html.form.Form)4 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)3 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)3 CheckBox (org.apache.wicket.markup.html.form.CheckBox)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)2 MultiValueTextPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel)2 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)2 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)2