Search in sources :

Example 1 with ObjectTypeSelectPanel

use of com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel 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)

Aggregations

ObjectTypeSelectPanel (com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 DateInput (com.evolveum.midpoint.web.component.DateInput)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 Component (org.apache.wicket.Component)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 FormComponent (org.apache.wicket.markup.html.form.FormComponent)1 TextArea (org.apache.wicket.markup.html.form.TextArea)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 PropertyModel (org.apache.wicket.model.PropertyModel)1