Search in sources :

Example 6 with DropDownChoicePanel

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

the class AssignmentEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    WebMarkupContainer propertyContainer = new WebMarkupContainer(ID_PROPERTY_CONTAINER);
    propertyContainer.setOutputMarkupId(true);
    body.add(propertyContainer);
    WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
    descriptionContainer.setOutputMarkupId(true);
    descriptionContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION));
        }
    });
    body.add(descriptionContainer);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    description.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    descriptionContainer.add(description);
    WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
    relationContainer.setOutputMarkupId(true);
    relationContainer.setOutputMarkupPlaceholderTag(true);
    relationContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION))) {
                return false;
            }
            AssignmentEditorDto dto = getModel().getObject();
            if (dto != null) {
                if (AssignmentEditorDtoType.ORG_UNIT.equals(dto.getType()) || AssignmentEditorDtoType.SERVICE.equals(dto.getType()) || AssignmentEditorDtoType.ROLE.equals(dto.getType())) {
                    return true;
                }
            }
            return false;
        }
    });
    body.add(relationContainer);
    addRelationDropDown(relationContainer);
    WebMarkupContainer focusTypeContainer = new WebMarkupContainer(ID_FOCUS_TYPE_CONTAINER);
    focusTypeContainer.setOutputMarkupId(true);
    focusTypeContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE));
        }
    });
    body.add(focusTypeContainer);
    ObjectTypeSelectPanel<FocusType> focusType = new ObjectTypeSelectPanel<>(ID_FOCUS_TYPE, new PropertyModel<>(getModel(), AssignmentEditorDto.F_FOCUS_TYPE), FocusType.class);
    focusTypeContainer.add(focusType);
    Label relationLabel = new Label(ID_RELATION_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (getModel() == null || getModel().getObject() == null) {
                return getString("AssignmentEditorPanel.relation.notSpecified");
            }
            AssignmentEditorDto object = getModel().getObject();
            String propertyKey = RelationTypes.class.getSimpleName() + "." + (object.getTargetRef() == null || object.getTargetRef().getRelation() == null ? RelationTypes.MEMBER : RelationTypes.getRelationType(object.getTargetRef().getRelation()));
            return createStringResource(propertyKey).getString();
        }
    });
    relationLabel.setOutputMarkupId(true);
    relationLabel.setOutputMarkupPlaceholderTag(true);
    relationLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isCreatingNewAssignment();
        }
    });
    relationContainer.add(relationLabel);
    WebMarkupContainer tenantRefContainer = createTenantContainer();
    tenantRefContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF));
        }
    });
    body.add(tenantRefContainer);
    WebMarkupContainer orgRefContainer = createOrgContainer();
    orgRefContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
        }
    });
    body.add(orgRefContainer);
    propertyContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF)) || isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
        }
    });
    WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK);
    body.add(activationBlock);
    WebMarkupContainer adminStatusContainer = new WebMarkupContainer(ID_ADMIN_STATUS_CONTAINER);
    adminStatusContainer.setOutputMarkupId(true);
    adminStatusContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
        }
    });
    activationBlock.add(adminStatusContainer);
    DropDownChoicePanel administrativeStatus = WebComponentUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS, new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "." + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
    administrativeStatus.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    adminStatusContainer.add(administrativeStatus);
    WebMarkupContainer validFromContainer = new WebMarkupContainer(ID_VALID_FROM_CONTAINER);
    validFromContainer.setOutputMarkupId(true);
    validFromContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM));
        }
    });
    activationBlock.add(validFromContainer);
    DateInput validFrom = new DateInput(ID_VALID_FROM, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    validFromContainer.add(validFrom);
    WebMarkupContainer validToContainer = new WebMarkupContainer(ID_VALID_TO_CONTAINER);
    validToContainer.setOutputMarkupId(true);
    validToContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO));
        }
    });
    activationBlock.add(validToContainer);
    DateInput validTo = new DateInput(ID_VALID_TO, createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    validTo.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    validToContainer.add(validTo);
    activationBlock.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            // enabled activation in assignments for now.
            return true;
        }
    });
    WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
    targetContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (!isItemAllowed(new ItemPath(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET))) {
                return false;
            }
            AssignmentEditorDto dto = getModel().getObject();
            return !AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(targetContainer);
    Label target = new Label(ID_TARGET, createTargetModel());
    targetContainer.add(target);
    WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER);
    constructionContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(constructionContainer);
    AjaxLink showEmpty = new AjaxLink(ID_SHOW_EMPTY) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            showEmptyPerformed(target);
        }
    };
    constructionContainer.add(showEmpty);
    Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel());
    showEmptyLabel.setOutputMarkupId(true);
    showEmpty.add(showEmptyLabel);
    initAttributesLayout(constructionContainer);
    Component metadataPanel;
    if (UserDtoStatus.ADD.equals(getModel().getObject().getStatus()) || getModelObject().getOldValue().asContainerable() == null) {
        metadataPanel = new WebMarkupContainer(ID_METADATA_CONTAINER);
    } else {
        metadataPanel = new MetadataPanel(ID_METADATA_CONTAINER, new AbstractReadOnlyModel<MetadataType>() {

            @Override
            public MetadataType getObject() {
                return getModelObject().getOldValue().getValue().getMetadata();
            }
        }, "", "row");
    }
    metadataPanel.setOutputMarkupId(true);
    metadataPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !UserDtoStatus.ADD.equals(getModel().getObject().getStatus());
        }
    });
    body.add(metadataPanel);
    addAjaxOnUpdateBehavior(body);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ObjectTypeSelectPanel(com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) TextArea(org.apache.wicket.markup.html.form.TextArea) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DateInput(com.evolveum.midpoint.web.component.DateInput) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 7 with DropDownChoicePanel

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

the class LimitationsEditorDialog method initLimitationBody.

private void initLimitationBody(final WebMarkupContainer body, ListItem<PropertyLimitationsTypeDto> item) {
    CheckFormGroup schema = new CheckFormGroup(ID_LAYER_SCHEMA, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_SCHEMA), createStringResource("LimitationsEditorDialog.label.schema"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    schema.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(schema);
    CheckFormGroup model = new CheckFormGroup(ID_LAYER_MODEL, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_MODEL), createStringResource("LimitationsEditorDialog.label.model"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    model.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(model);
    CheckFormGroup presentation = new CheckFormGroup(ID_LAYER_PRESENTATION, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_PRESENTATION), createStringResource("LimitationsEditorDialog.label.presentation"), ID_LABEL_SIZE, ID_INPUT_SIZE);
    presentation.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(presentation);
    DropDownChoicePanel add = new DropDownChoicePanel(ID_ACCESS_ADD, getAddPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> addInput = add.getBaseFormComponent();
    addInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    addInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    DropDownChoicePanel read = new DropDownChoicePanel(ID_ACCESS_READ, getReadPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> readInput = read.getBaseFormComponent();
    readInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    readInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    DropDownChoicePanel modify = new DropDownChoicePanel(ID_ACCESS_MODIFY, getModifyPropertyAccessModel(item.getModel()), WebComponentUtil.createReadonlyModelFromEnum(PropertyAccess.class), false);
    FormComponent<PropertyAccess> modifyInput = modify.getBaseFormComponent();
    modifyInput.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    modifyInput.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    body.add(add);
    body.add(read);
    body.add(modify);
    TextFormGroup minOccurs = new TextFormGroup(ID_MIN_OCCURS, new PropertyModel<String>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".minOccurs"), createStringResource("LimitationsEditorDialog.label.minOccurs"), "SchemaHandlingStep.limitations.tooltip.minOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
    minOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(minOccurs);
    TextFormGroup maxOccurs = new TextFormGroup(ID_MAX_OCCURS, new PropertyModel<String>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".maxOccurs"), createStringResource("LimitationsEditorDialog.label.maxOccurs"), "SchemaHandlingStep.limitations.tooltip.maxOccurs", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false, false);
    maxOccurs.getField().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(maxOccurs);
    CheckFormGroup ignore = new CheckFormGroup(ID_IGNORE, new PropertyModel<Boolean>(item.getModelObject(), PropertyLimitationsTypeDto.F_LIMITATION + ".ignore"), createStringResource("LimitationsEditorDialog.label.ignore"), "SchemaHandlingStep.limitations.tooltip.ignore", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    ignore.getCheck().add(prepareAjaxOnComponentTagUpdateBehavior());
    body.add(ignore);
    Label layersTooltip = new Label(ID_T_LAYERS);
    layersTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(layersTooltip);
    Label propertyTooltip = new Label(ID_T_PROPERTY);
    propertyTooltip.add(new InfoTooltipBehavior(true) {

        @Override
        public String getModalContainer(Component component) {
            return body.getMarkupId();
        }
    });
    body.add(propertyTooltip);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) Label(org.apache.wicket.markup.html.basic.Label) CheckFormGroup(com.evolveum.midpoint.web.component.form.CheckFormGroup) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) Component(org.apache.wicket.Component)

Example 8 with DropDownChoicePanel

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

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

the class LoggingConfigPanel method initLoggerColumns.

private List<IColumn<LoggerConfiguration, String>> initLoggerColumns() {
    List<IColumn<LoggerConfiguration, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<LoggerConfiguration>();
    columns.add(column);
    //name editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.logger"), "name") {

        @Override
        protected Component createInputPanel(String componentId, final IModel<LoggerConfiguration> model) {
            if (model.getObject() instanceof StandardLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "logger"), WebComponentUtil.createReadonlyModelFromEnum(StandardLoggerType.class), new EnumChoiceRenderer<StandardLoggerType>());
                FormComponent<StandardLoggerType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<StandardLoggerType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else if (model.getObject() instanceof ComponentLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "component"), WebComponentUtil.createReadonlyModelFromEnum(LoggingComponentType.class), new EnumChoiceRenderer<LoggingComponentType>());
                FormComponent<LoggingComponentType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<LoggingComponentType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else {
                TextPanel textPanel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
                FormComponent input = textPanel.getBaseFormComponent();
                addAjaxFormComponentUpdatingBehavior(input);
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                input.add(new NotNullValidator<StandardLoggerType>("message.emptyString"));
                return textPanel;
            }
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    //level editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersLevel"), "level") {

        @Override
        protected Component createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, getPropertyExpression()), WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
            FormComponent<LoggingLevelType> input = dropDownChoicePanel.getBaseFormComponent();
            input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            input.add(new NotNullValidator<LoggingLevelType>("message.emptyLevel"));
            addAjaxFormComponentUpdatingBehavior(input);
            return dropDownChoicePanel;
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            LoggerConfiguration configuration = rowModel.getObject();
            return WebComponentUtil.createLocalizedModelForEnum(configuration.getLevel(), getPageBase());
        }
    });
    //appender editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersAppender"), "appenders") {

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            final LoggerConfiguration configuration = rowModel.getObject();
            if (configuration.getAppenders().isEmpty()) {
                return createStringResource("LoggingConfigPanel.appenders.Inherit");
            } else {
                return new LoadableModel<String>() {

                    @Override
                    protected String load() {
                        StringBuilder builder = new StringBuilder();
                        for (String appender : configuration.getAppenders()) {
                            if (configuration.getAppenders().indexOf(appender) != 0) {
                                builder.append(", ");
                            }
                            builder.append(appender);
                        }
                        return builder.toString();
                    }
                };
            }
        }

        @Override
        protected InputPanel createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            IModel<Map<String, String>> options = new Model(null);
            Map<String, String> optionsMap = new HashMap<String, String>();
            optionsMap.put("nonSelectedText", createStringResource("LoggingConfigPanel.appenders.Inherit").getString());
            options.setObject(optionsMap);
            ListMultipleChoicePanel panel = new ListMultipleChoicePanel<>(componentId, new PropertyModel<List<String>>(model, getPropertyExpression()), createNewLoggerAppendersListModel(), new StringChoiceRenderer(null), options);
            FormComponent<AppenderConfigurationType> input = panel.getBaseFormComponent();
            input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
            addAjaxFormComponentUpdatingBehavior(input);
            return panel;
        }

        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    return columns;
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) ArrayList(java.util.ArrayList) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) LoggerConfiguration(com.evolveum.midpoint.web.page.admin.configuration.dto.LoggerConfiguration) StandardLoggerType(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLoggerType) StandardLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLogger) IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) NotNullValidator(com.evolveum.midpoint.web.component.input.validator.NotNullValidator) ComponentLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.ComponentLogger) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) LoggingComponentType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingComponentType) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)9 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 PropertyModel (org.apache.wicket.model.PropertyModel)4 Component (org.apache.wicket.Component)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 FormComponent (org.apache.wicket.markup.html.form.FormComponent)3 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)2 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)2 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)2 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 Label (org.apache.wicket.markup.html.basic.Label)2 ObjectTypeSelectPanel (com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel)1 ItemPathDto (com.evolveum.midpoint.gui.api.component.path.ItemPathDto)1 ItemPathPanel (com.evolveum.midpoint.gui.api.component.path.ItemPathPanel)1