Search in sources :

Example 1 with RelationTypes

use of com.evolveum.midpoint.schema.constants.RelationTypes in project midpoint by Evolveum.

the class TypedAssignablePanel method getSelectedRelation.

private QName getSelectedRelation() {
    // noinspection unchecked
    DropDownChoicePanel<RelationTypes> relationPanel = (DropDownChoicePanel<RelationTypes>) get(ID_RELATION_CONTAINER).get(ID_RELATION);
    RelationTypes relation = relationPanel.getModel().getObject();
    if (relation == null) {
        return WebComponentUtil.getDefaultRelationOrFail();
    }
    return relation.getRelation();
}
Also used : RelationTypes(com.evolveum.midpoint.schema.constants.RelationTypes) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel)

Example 2 with RelationTypes

use of com.evolveum.midpoint.schema.constants.RelationTypes in project midpoint by Evolveum.

the class TypedAssignablePanel method initAssignmentParametersPanel.

protected void initAssignmentParametersPanel() {
    DropDownChoicePanel<ObjectTypes> typeSelect = new DropDownChoicePanel<>(ID_TYPE, typeModel, Model.ofList(getObjectTypesList()), new EnumChoiceRenderer<>());
    typeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_TABLES_CONTAINER));
            target.add(addOrReplace(createCountContainer()));
        }
    });
    typeSelect.setOutputMarkupId(true);
    add(typeSelect);
    WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
    relationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return TypedAssignablePanel.this.isRelationPanelVisible() && !ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    relationContainer.setOutputMarkupId(true);
    add(relationContainer);
    DropDownChoicePanel<RelationTypes> relationSelector = WebComponentUtil.createEnumPanel(RelationTypes.class, ID_RELATION, WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class), Model.of(RelationTypes.MEMBER), TypedAssignablePanel.this, false);
    relationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    relationSelector.setOutputMarkupId(true);
    relationSelector.setOutputMarkupPlaceholderTag(true);
    relationContainer.add(relationSelector);
    WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
    kindContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    kindContainer.setOutputMarkupId(true);
    add(kindContainer);
    DropDownChoicePanel kindSelector = WebComponentUtil.createEnumPanel(ShadowKindType.class, ID_KIND, WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), Model.of(ShadowKindType.ACCOUNT), TypedAssignablePanel.this, false);
    kindSelector.setOutputMarkupId(true);
    kindSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName()) && getSelectedResourceCount() > 0;
        }
    });
    kindSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(TypedAssignablePanel.this);
        }
    });
    kindSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    kindSelector.setOutputMarkupPlaceholderTag(true);
    kindContainer.add(kindSelector);
    WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
    intentContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
        }
    });
    intentContainer.setOutputMarkupId(true);
    add(intentContainer);
    DropDownChoicePanel<?> intentSelector = new DropDownChoicePanel<>(ID_INTENT, intentValueModel, intentValues);
    intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    intentSelector.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(TypedAssignablePanel.this);
        }
    });
    intentSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    intentSelector.setOutputMarkupId(true);
    intentSelector.setOutputMarkupPlaceholderTag(true);
    intentSelector.getBaseFormComponent().add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return ResourceType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName()) && getSelectedResourceCount() > 0;
        }
    });
    intentContainer.add(intentSelector);
    WebMarkupContainer orgTreeViewContainer = new WebMarkupContainer(ID_ORG_TREE_VIEW_CONTAINER);
    orgTreeViewContainer.setOutputMarkupId(true);
    orgTreeViewContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            boolean res = OrgType.COMPLEX_TYPE.equals(typeModel.getObject().getTypeQName());
            return res;
        }
    });
    add(orgTreeViewContainer);
    CheckBox orgTreeViewCheckbox = new CheckBox(ID_ORG_TREE_VIEW, orgTreeViewModel);
    orgTreeViewCheckbox.add(new AjaxEventBehavior("change") {

        @Override
        protected void onEvent(AjaxRequestTarget ajaxRequestTarget) {
            orgTreeViewModel.setObject(!orgTreeViewModel.getObject());
            ajaxRequestTarget.add(TypedAssignablePanel.this);
        }
    });
    orgTreeViewCheckbox.setOutputMarkupId(true);
    orgTreeViewContainer.add(orgTreeViewCheckbox);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) RelationTypes(com.evolveum.midpoint.schema.constants.RelationTypes) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

RelationTypes (com.evolveum.midpoint.schema.constants.RelationTypes)2 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)2 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1