Search in sources :

Example 51 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class MyPasswordQuestionsPanel method initLayout.

public void initLayout() {
    // final Label question = new Label (F_QUESTION, mod.getPwdQuestion());
    final Label question = new Label(F_QUESTION, new PropertyModel<PasswordQuestionsDto>(mod, PasswordQuestionsDto.F_MY_QUESTIONS__QUESTIONITSELF));
    question.setOutputMarkupId(true);
    add(question);
    final TextField<String> answer = new TextField<String>(F_ANSWER, new PropertyModel(mod, SecurityQuestionAnswerDTO.F_PASSWORD_QUESTION_ANSWER));
    answer.setRequired(true);
    answer.setOutputMarkupId(true);
    add(answer);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) TextField(org.apache.wicket.markup.html.form.TextField) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 52 with PropertyModel

use of org.apache.wicket.model.PropertyModel 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 53 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class ShoppingCartEditorPanel method initHeaderRow.

@Override
protected void initHeaderRow() {
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    headerRow.add(box);
    box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
    box.add(new Label(ID_DISPLAY_NAME, new PropertyModel<AssignmentEditorDto>(getModel(), AssignmentEditorDto.F_NAME)));
    box.add(new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getModelObject().getTargetRef() != null && getModelObject().getTargetRef().getDescription() != null ? getModelObject().getTargetRef().getDescription() : "";
        }
    }));
    WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
    box.add(iconBox);
    if (getIconBoxAdditionalCssClass() != null) {
        iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
    }
    Label icon = new Label(ID_ICON, "");
    icon.add(new AttributeModifier("class", getIconCssClass()));
    iconBox.add(icon);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 54 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class ACAttributePanel method initLayout.

protected void initLayout(boolean ignoreMandatoryAttributes) {
    Label attributeLabel = new Label(ID_ATTRIBUTE_LABEL, new PropertyModel(getModel(), ACAttributeDto.F_NAME));
    add(attributeLabel);
    WebMarkupContainer required = new WebMarkupContainer(ID_REQUIRED);
    required.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            ACAttributeDto dto = getModel().getObject();
            PrismPropertyDefinition def = dto.getDefinition();
            return def.isMandatory();
        }
    });
    add(required);
    WebMarkupContainer hasOutbound = new WebMarkupContainer(ID_HAS_OUTBOUND);
    hasOutbound.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return hasOutbound();
        }
    });
    add(hasOutbound);
    ListView<ACValueConstructionDto> values = new ListView<ACValueConstructionDto>(ID_VALUES, new PropertyModel<List<ACValueConstructionDto>>(getModel(), ACAttributeDto.F_VALUES)) {

        @Override
        protected void populateItem(ListItem<ACValueConstructionDto> listItem) {
            Form form = findParent(Form.class);
            listItem.add(new ACAttributeValuePanel(ID_VALUE, listItem.getModel(), ignoreMandatoryAttributes, form));
        }
    };
    add(values);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 55 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class ACAttributeValuePanel method initLayout.

private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
    ACValueConstructionDto dto = getModel().getObject();
    PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
    InputPanel input = createTypedInputComponent(ID_INPUT, definition);
    for (FormComponent comp : input.getFormComponents()) {
        comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME));
        if (!ignoreMandatoryAttributes) {
            comp.setRequired(definition.getMinOccurs() > 0);
        }
        comp.add(new AjaxFormComponentUpdatingBehavior("blur") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
            }
        });
    }
    add(input);
    AjaxLink addLink = new AjaxLink(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addPerformed(target);
        }
    };
    add(addLink);
    addLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAddVisible();
        }
    });
    AjaxLink removeLink = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removePerformed(target);
        }
    };
    add(removeLink);
    removeLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isRemoveVisible();
        }
    });
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FormComponent(org.apache.wicket.markup.html.form.FormComponent) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

PropertyModel (org.apache.wicket.model.PropertyModel)70 Label (org.apache.wicket.markup.html.basic.Label)38 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)37 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)29 ArrayList (java.util.ArrayList)22 List (java.util.List)21 IModel (org.apache.wicket.model.IModel)21 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)20 ListItem (org.apache.wicket.markup.html.list.ListItem)17 ListView (org.apache.wicket.markup.html.list.ListView)15 Model (org.apache.wicket.model.Model)13 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)10 TextField (org.apache.wicket.markup.html.form.TextField)10 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)9 QName (javax.xml.namespace.QName)8 Form (org.apache.wicket.markup.html.form.Form)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5