Example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel

Introduction

In this page you can find the example usage for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel.

Prototype

AbstractReadOnlyModel

Source Link

Usage

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.capability.CapabilityPanel.java

License:Apache License

@Override
protected void initLayout() {
    this.model = loadModel();

    final ListDataProvider<CapabilityDto> capabilityProvider = new ListDataProvider<CapabilityDto>(this,
            new PropertyModel<List<CapabilityDto>>(model, CapabilityStepDto.F_CAPABILITIES));

    WebMarkupContainer tableBody = new WebMarkupContainer(ID_CAPABILITY_TABLE);
    tableBody.setOutputMarkupId(true);/* ww w  . ja va2s  . c  om*/
    add(tableBody);

    DataView<CapabilityDto> capabilityDataView = new DataView<CapabilityDto>(ID_CAPABILITY_ROW,
            capabilityProvider) {

        @Override
        protected void populateItem(final Item<CapabilityDto> capabilityRow) {
            final CapabilityDto dto = capabilityRow.getModelObject();

            Label label = new Label(ID_CAPABILITY_NAME, new PropertyModel<>(dto, CapabilityDto.F_VALUE));
            capabilityRow.add(label);

            AjaxLink deleteLink = new AjaxLink(ID_CAPABILITY_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteCapabilityPerformed(target, dto);
                }
            };
            capabilityRow.add(deleteLink);

            capabilityRow.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<Object>() {

                @Override
                public Object getObject() {
                    if (capabilityRow.getModelObject().isSelected()) {
                        return "success";
                    }

                    return null;
                }
            }));
        }
    };
    tableBody.add(capabilityDataView);

    AjaxLink addLink = new AjaxLink(ID_CAPABILITY_ADD) {
        @Override
        public void onClick(AjaxRequestTarget target) {
            addCapabilityPerformed(target);
        }
    };
    add(addLink);

    //TODO - continue here in 2.4
    //        ModalWindow dialog = new ChooseTypeDialog<CapabilityDto>(DIALOG_SELECT_CAPABILITY, CapabilityDto.class){
    //
    //            @Override
    //            protected void chooseOperationPerformed(AjaxRequestTarget target, CapabilityDto capability){
    //                choosePerformed(target, capability);
    //            }
    //
    //            @Override
    //            public BaseSortableDataProvider getDataProvider(){
    //                return capabilityProvider;
    //            }
    //        };
    //        add(dialog);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.AttributeEditorUtils.java

License:Apache License

static void addMatchingRuleFields(final BasePanel<? extends ResourceItemDefinitionType> editor,
        final NonEmptyModel<Boolean> readOnlyModel) {

    // normalizes unqualified QNames
    final IModel<QName> matchingRuleModel = new IModel<QName>() {
        @Override/*w  w  w .  ja  va  2s  . com*/
        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);

}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.ExpressionVariableEditorDialog.java

License:Apache License

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);/*from   w ww.jav  a2s.c o  m*/
    content.add(form);

    //TODO - shouldn't this be some AutoCompleteField? If yer, where do we get value?
    TextFormGroup name = new TextFormGroup(ID_NAME,
            new PropertyModel<String>(model,
                    ExpressionVariableDefinitionTypeDto.F_VARIABLE + ".name.localPart"),
            createStringResource("ExpressionVariableEditor.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(name);

    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION,
            new PropertyModel<String>(model, ExpressionVariableDefinitionTypeDto.F_VARIABLE + ".description"),
            createStringResource("ExpressionVariableEditor.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE,
            false);
    form.add(description);

    TextFormGroup path = new TextFormGroup(ID_PATH,
            new PropertyModel<String>(model, ExpressionVariableDefinitionTypeDto.F_PATH),
            createStringResource("ExpressionVariableEditor.label.path"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(path);

    DropDownFormGroup objectReference = new DropDownFormGroup<>(ID_OBJECT_REFERENCE,
            new PropertyModel<ObjectReferenceType>(model,
                    ExpressionVariableDefinitionTypeDto.F_VARIABLE + ".objectRef"),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createObjectReferenceList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return createReferenceDisplayString(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            }, createStringResource("ExpressionVariableEditor.label.objectRef"), ID_LABEL_SIZE, ID_INPUT_SIZE,
            false);
    form.add(objectReference);

    TextAreaFormGroup value = new TextAreaFormGroup(ID_VALUE,
            new PropertyModel<String>(model, ExpressionVariableDefinitionTypeDto.F_VALUE),
            createStringResource("ExpressionVariableEditor.label.value"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(value);

    AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL,
            createStringResource("ExpressionVariableEditor.button.cancel")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);

    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE,
            createStringResource("ExpressionVariableEditor.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    form.add(save);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog.java

License:Apache License

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);/*from w  w w. j  a va2s. c  o  m*/
    content.add(form);

    ListView repeater = new ListView<PropertyLimitationsTypeDto>(ID_REPEATER, model) {

        @Override
        protected void populateItem(final ListItem<PropertyLimitationsTypeDto> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LIMITATIONS_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);

            Label linkLabel = new Label(ID_LIMITATIONS_LABEL, createLimitationsLabelModel(item));
            linkContainer.add(linkLabel);

            AjaxLink delete = new AjaxLink(ID_LIMITATION_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteLimitationPerformed(target, item);
                }
            };
            linkContainer.add(delete);

            WebMarkupContainer limitationBody = new WebMarkupContainer(ID_BODY);
            limitationBody.setOutputMarkupId(true);
            limitationBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                limitationBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST
                                && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(limitationBody);
            initLimitationBody(limitationBody, item);

        }
    };
    repeater.setOutputMarkupId(true);
    form.add(repeater);

    initButtons(form);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog.java

License:Apache License

private IModel<String> createLimitationsLabelModel(final ListItem<PropertyLimitationsTypeDto> item) {
    return new AbstractReadOnlyModel<String>() {

        @Override/*  w w  w .j  av  a  2  s  . c o m*/
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            PropertyLimitationsTypeDto dto = item.getModelObject();
            sb.append("#").append(item.getIndex() + 1).append(" - ");

            if (dto.isModel()) {
                sb.append(LayerType.MODEL).append(", ");
            }
            if (dto.isPresentation()) {
                sb.append(LayerType.PRESENTATION).append(", ");
            }
            if (dto.isSchema()) {
                sb.append(LayerType.SCHEMA).append(", ");
            }
            sb.append(":");

            if (dto.getLimitationObject().getAccess() != null) {
                PropertyAccessType access = dto.getLimitationObject().getAccess();

                if (access.isRead() != null && access.isRead()) {
                    sb.append(getString("LimitationsEditorDialog.label.read")).append(", ");
                }
                if (access.isAdd() != null && access.isAdd()) {
                    sb.append(getString("LimitationsEditorDialog.label.add")).append(", ");
                }
                if (access.isModify() != null && access.isModify()) {
                    sb.append(getString("LimitationsEditorDialog.label.modify")).append(", ");
                }
            }

            return sb.toString();
        }
    };
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog.java

License:Apache License

private IModel<String> createCollapseItemId(final ListItem<PropertyLimitationsTypeDto> item,
        final boolean appendSelector) {
    return new AbstractReadOnlyModel<String>() {

        @Override/*from   w w  w.ja  v a2s.c  o  m*/
        public String getObject() {
            StringBuilder sb = new StringBuilder();

            if (appendSelector) {
                sb.append("#");
            }

            sb.append("collapse").append(item.getId());

            return sb.toString();
        }
    };
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.MappingEditorDialog.java

License:Apache License

public void initLayout(WebMarkupContainer content) {
    Form form = new Form(ID_MAIN_FORM);
    form.setOutputMarkupId(true);/*  www .j  a v a  2s .c  o  m*/
    content.add(form);

    TextFormGroup name = new TextFormGroup(ID_NAME,
            new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".name"),
            createStringResource("MappingEditorDialog.label.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(name);

    TextAreaFormGroup description = new TextAreaFormGroup(ID_DESCRIPTION,
            new PropertyModel<String>(model, MappingTypeDto.F_MAPPING + ".description"),
            createStringResource("MappingEditorDialog.label.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(description);

    CheckFormGroup authoritative = new CheckFormGroup(ID_AUTHORITATIVE,
            new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".authoritative"),
            createStringResource("MappingEditorDialog.label.authoritative"),
            "SchemaHandlingStep.mapping.tooltip.authoritative", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    form.add(authoritative);

    CheckFormGroup exclusive = new CheckFormGroup(ID_EXCLUSIVE,
            new PropertyModel<Boolean>(model, MappingTypeDto.F_MAPPING + ".exclusive"),
            createStringResource("MappingEditorDialog.label.exclusive"),
            "SchemaHandlingStep.mapping.tooltip.exclusive", true, ID_LABEL_SIZE, ID_INPUT_SIZE);
    form.add(exclusive);

    DropDownFormGroup strength = new DropDownFormGroup<>(ID_STRENGTH,
            new PropertyModel<MappingStrengthType>(model, MappingTypeDto.F_MAPPING + ".strength"),
            WebMiscUtil.createReadonlyModelFromEnum(MappingStrengthType.class),
            new EnumChoiceRenderer<MappingStrengthType>(this),
            createStringResource("MappingEditorDialog.label.strength"),
            "SchemaHandlingStep.mapping.tooltip.strength", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(strength);

    MultiValueDropDownPanel channel = new MultiValueDropDownPanel<String>(ID_CHANNEL,
            new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".channel"), true) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebMiscUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new IChoiceRenderer<String>() {

                @Override
                public Object getDisplayValue(String object) {
                    String[] fields = object.split("#");
                    String label = fields[1];

                    return getString("Channel." + label);
                }

                @Override
                public String getIdValue(String object, int index) {
                    return Integer.toString(index);
                }
            };
        }
    };
    form.add(channel);

    MultiValueDropDownPanel exceptChannel = new MultiValueDropDownPanel<String>(ID_EXCEPT_CHANNEL,
            new PropertyModel<List<String>>(model, MappingTypeDto.F_MAPPING + ".exceptChannel"), true) {

        @Override
        protected String createNewEmptyItem() {
            return "";
        }

        @Override
        protected IModel<List<String>> createChoiceList() {
            return new AbstractReadOnlyModel<List<String>>() {

                @Override
                public List<String> getObject() {
                    return WebMiscUtil.getChannelList();
                }
            };
        }

        @Override
        protected IChoiceRenderer<String> createRenderer() {
            return new IChoiceRenderer<String>() {

                @Override
                public Object getDisplayValue(String object) {
                    String[] fields = object.split("#");
                    String label = fields[1];

                    return getString("Channel." + label);
                }

                @Override
                public String getIdValue(String object, int index) {
                    return Integer.toString(index);
                }
            };
        }
    };
    form.add(exceptChannel);

    //TODO - create some nice ItemPathType editor in near future
    MultiValueTextPanel source = new MultiValueTextPanel<>(ID_SOURCE,
            new PropertyModel<List<String>>(model, MappingTypeDto.F_SOURCE));
    form.add(source);

    //TODO - create some nice ItemPathType editor in near future
    TextFormGroup target = new TextFormGroup(ID_TARGET,
            new PropertyModel<String>(model, MappingTypeDto.F_TARGET),
            createStringResource("MappingEditorDialog.label.target"),
            "SchemaHandlingStep.mapping.tooltip.target", true, ID_LABEL_SIZE, ID_INPUT_SIZE, isInbound);
    target.setOutputMarkupId(true);
    form.add(target);

    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    feedback.setOutputMarkupPlaceholderTag(true);
    form.add(feedback);

    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> expressionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(
            ID_EXPRESSION_TYPE,
            new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_EXPRESSION_TYPE),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class),
            new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this),
            createStringResource("MappingEditorDialog.label.expressionType"),
            "SchemaHandlingStep.mapping.tooltip.expressionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id,
                IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices,
                IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionType.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpression();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION_POLICY_REF));
        }
    });
    form.add(expressionType);

    DropDownFormGroup expressionLanguage = new DropDownFormGroup<>(ID_EXPRESSION_LANG,
            new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_EXPRESSION_LANG),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class),
            new EnumChoiceRenderer<ExpressionUtil.Language>(this),
            createStringResource("MappingEditorDialog.label.language"),
            "SchemaHandlingStep.mapping.tooltip.expressionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    expressionLanguage.setOutputMarkupId(true);
    expressionLanguage.setOutputMarkupPlaceholderTag(true);
    expressionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getExpressionType());

        }
    });
    form.add(expressionLanguage);
    expressionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });

    DropDownFormGroup<ObjectReferenceType> expressionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(
            ID_EXPRESSION_POLICY_REF,
            new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_EXPRESSION_POLICY_REF),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return policyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            }, createStringResource("MappingEditorDialog.label.passPolicyRef"),
            "SchemaHandlingStep.mapping.tooltip.expressionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE,
            false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices,
                IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    expressionGeneratePolicy.setOutputMarkupId(true);
    expressionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    expressionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE
                    .equals(model.getObject().getExpressionType());
        }
    });
    expressionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_EXPRESSION));
        }
    });
    form.add(expressionGeneratePolicy);

    TextAreaFormGroup expression = new TextAreaFormGroup(ID_EXPRESSION,
            new PropertyModel<String>(model, MappingTypeDto.F_EXPRESSION),
            createStringResource("MappingEditorDialog.label.expression"),
            "SchemaHandlingStep.mapping.tooltip.expression", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false,
            CODE_ROW_COUNT);
    expression.setOutputMarkupId(true);
    form.add(expression);

    DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType> conditionType = new DropDownFormGroup<ExpressionUtil.ExpressionEvaluatorType>(
            ID_CONDITION_TYPE,
            new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, MappingTypeDto.F_CONDITION_TYPE),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class),
            new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this),
            createStringResource("MappingEditorDialog.label.conditionType"),
            "SchemaHandlingStep.mapping.tooltip.conditionType", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false) {

        @Override
        protected DropDownChoice createDropDown(String id,
                IModel<List<ExpressionUtil.ExpressionEvaluatorType>> choices,
                IChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionType.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateCondition();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_LANG));
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION_POLICY_REF));
        }
    });
    form.add(conditionType);

    DropDownFormGroup conditionLanguage = new DropDownFormGroup<>(ID_CONDITION_LANG,
            new PropertyModel<ExpressionUtil.Language>(model, MappingTypeDto.F_CONDITION_LANG),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class),
            new EnumChoiceRenderer<ExpressionUtil.Language>(this),
            createStringResource("MappingEditorDialog.label.language"),
            "SchemaHandlingStep.mapping.tooltip.conditionLanguage", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    conditionLanguage.setOutputMarkupId(true);
    conditionLanguage.setOutputMarkupPlaceholderTag(true);
    conditionLanguage.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getConditionType());
        }
    });
    conditionLanguage.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionLanguage();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionLanguage);

    DropDownFormGroup<ObjectReferenceType> conditionGeneratePolicy = new DropDownFormGroup<ObjectReferenceType>(
            ID_CONDITION_POLICY_REF,
            new PropertyModel<ObjectReferenceType>(model, MappingTypeDto.F_CONDITION_POLICY_REF),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return policyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            }, createStringResource("MappingEditorDialog.label.passPolicyRef"),
            "SchemaHandlingStep.mapping.tooltip.conditionValuePolicyRef", true, ID_LABEL_SIZE, ID_INPUT_SIZE,
            false) {

        @Override
        protected DropDownChoice createDropDown(String id, IModel<List<ObjectReferenceType>> choices,
                IChoiceRenderer<ObjectReferenceType> renderer, boolean required) {
            return new DropDownChoice<>(id, getModel(), choices, renderer);
        }
    };
    conditionGeneratePolicy.setOutputMarkupId(true);
    conditionGeneratePolicy.setOutputMarkupPlaceholderTag(true);
    conditionGeneratePolicy.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getConditionType());
        }
    });
    conditionGeneratePolicy.getInput().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateConditionGeneratePolicy();
            target.add(get(getContentId() + ":" + ID_MAIN_FORM + ":" + ID_CONDITION));
        }
    });
    form.add(conditionGeneratePolicy);

    TextAreaFormGroup condition = new TextAreaFormGroup(ID_CONDITION,
            new PropertyModel<String>(model, MappingTypeDto.F_CONDITION),
            createStringResource("MappingEditorDialog.label.condition"),
            "SchemaHandlingStep.mapping.tooltip.condition", true, ID_LABEL_SIZE, ID_INPUT_SIZE, false,
            CODE_ROW_COUNT);
    condition.setOutputMarkupId(true);
    form.add(condition);

    Label channelTooltip = new Label(ID_T_CHANNEL);
    channelTooltip.add(new InfoTooltipBehavior(true));
    form.add(channelTooltip);

    Label exceptChannelTooltip = new Label(ID_T_EXCEPT_CHANNEL);
    exceptChannelTooltip.add(new InfoTooltipBehavior(true));
    form.add(exceptChannelTooltip);

    Label sourceTooltip = new Label(ID_T_SOURCE);
    sourceTooltip.add(new InfoTooltipBehavior(true));
    form.add(sourceTooltip);

    AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL,
            createStringResource("MappingEditorDialog.button.cancel")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);

    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE,
            createStringResource("MappingEditorDialog.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    form.add(save);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceAssociationEditor.java

License:Apache License

@Override
protected void initLayout() {
    Label label = new Label(ID_LABEL, new AbstractReadOnlyModel<String>() {

        @Override/*from   w w w.  ja v  a2s  .  c  o  m*/
        public String getObject() {
            ResourceObjectAssociationType association = getModelObject();

            if (association.getDisplayName() == null && association.getRef() == null) {
                return getString("ResourceAssociationEditor.label.new");
            } else {
                if (association.getRef().getItemPath() != null) {
                    return getString("ResourceAssociationEditor.label.edit",
                            association.getRef().getItemPath().toString());
                }
                return getString("ResourceAssociationEditor.label.edit", "");
            }
        }
    });
    add(label);

    DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(getModel(), "kind"),
            WebMiscUtil.createReadonlyModelFromEnum(ShadowKindType.class),
            new EnumChoiceRenderer<ShadowKindType>(this));
    kind.setNullValid(false);
    add(kind);

    MultiValueTextPanel intent = new MultiValueTextPanel<>(ID_INTENT,
            new PropertyModel<List<String>>(getModel(), "intent"));
    add(intent);

    DropDownChoice direction = new DropDownChoice<>(ID_DIRECTION,
            new PropertyModel<ResourceObjectAssociationDirectionType>(getModel(), "direction"),
            WebMiscUtil.createReadonlyModelFromEnum(ResourceObjectAssociationDirectionType.class),
            new EnumChoiceRenderer<ResourceObjectAssociationDirectionType>(this));
    direction.setNullValid(true);
    add(direction);

    DropDownChoice associationAttribute = new DropDownChoice<>(ID_ASSOCIATION_ATTRIBUTE,
            new PropertyModel<QName>(getModel(), "associationAttribute"),
            new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return loadObjectReferences(false);
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return prepareReferenceDisplayValue(object);
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    associationAttribute.setNullValid(true);
    add(associationAttribute);

    DropDownChoice valueAttribute = new DropDownChoice<>(ID_VALUE_ATTRIBUTE,
            new PropertyModel<QName>(getModel(), "valueAttribute"), new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return loadObjectReferences(false);
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return prepareReferenceDisplayValue(object);
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    valueAttribute.setNullValid(true);
    add(valueAttribute);

    CheckBox explicitRefIntegrity = new CheckBox(ID_EXPLICIT_REF_INTEGRITY,
            new PropertyModel<Boolean>(getModel(), "explicitReferentialIntegrity"));
    add(explicitRefIntegrity);

    QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_ASSOCIATION_ATTRIBUTE_PANEL,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            "SchemaHandlingStep.association.label.associationName",
            "SchemaHandlingStep.association.tooltip.associationLocalPart",
            "SchemaHandlingStep.association.label.associationNamespace",
            "SchemaHandlingStep.association.tooltip.associationNamespace");
    nonSchemaRefPanel.setOutputMarkupId(true);
    nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);
    add(nonSchemaRefPanel);

    TextField displayName = new TextField<>(ID_DISPLAY_NAME,
            new PropertyModel<String>(getModel(), "displayName"));
    add(displayName);

    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    add(description);

    AjaxLink limitations = new AjaxLink(ID_BUTTON_LIMITATIONS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);

    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG,
            new PropertyModel<Boolean>(getModel(), "exclusiveStrong"));
    add(exclusiveStrong);

    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<Boolean>(getModel(), "tolerant"));
    add(tolerant);

    MultiValueTextPanel tolerantVP = new MultiValueTextPanel<>(ID_TOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "tolerantValuePattern"));
    add(tolerantVP);

    MultiValueTextPanel intolerantVP = new MultiValueTextPanel<>(ID_INTOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "intolerantValuePattern"));
    add(intolerantVP);

    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    fetchStrategy.setNullValid(true);
    add(fetchStrategy);

    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE,
            new PropertyModel<QName>(getModel(), "matchingRule"), new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return WebMiscUtil.getMatchingRuleList();
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return object.getLocalPart();
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    matchingRule.setNullValid(true);
    add(matchingRule);

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceObjectAssociationType association = getModel().getObject();

            if (association == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(association.getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setOutputMarkupId(true);
    outboundLabel.setEnabled(false);
    add(outboundLabel);

    AjaxSubmitButton outbound = new AjaxSubmitButton(ID_BUTTON_OUTBOUND) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    Label kindTooltip = new Label(ID_T_KIND);
    kindTooltip.add(new InfoTooltipBehavior());
    add(kindTooltip);

    Label intentTooltip = new Label(ID_T_INTENT);
    intentTooltip.add(new InfoTooltipBehavior());
    add(intentTooltip);

    Label directionTooltip = new Label(ID_T_DIRECTION);
    directionTooltip.add(new InfoTooltipBehavior());
    add(directionTooltip);

    Label assAttributeTooltip = new Label(ID_T_ASSOCIATION_ATTRIBUTE);
    assAttributeTooltip.add(new InfoTooltipBehavior());
    add(assAttributeTooltip);

    Label valueAttributeTooltip = new Label(ID_T_VALUE_ATTRIBUTE);
    valueAttributeTooltip.add(new InfoTooltipBehavior());
    add(valueAttributeTooltip);

    Label integrityTooltip = new Label(ID_T_EXPLICIT_REF_INTEGRITY);
    integrityTooltip.add(new InfoTooltipBehavior());
    add(integrityTooltip);

    Label limitationsTooltip = new Label(ID_T_LIMITATIONS);
    limitationsTooltip.add(new InfoTooltipBehavior());
    add(limitationsTooltip);

    Label exclusiveStrongTooltip = new Label(ID_T_EXCLUSIVE_STRONG);
    exclusiveStrongTooltip.add(new InfoTooltipBehavior());
    add(exclusiveStrongTooltip);

    Label tolerantTooltip = new Label(ID_T_TOLERANT);
    tolerantTooltip.add(new InfoTooltipBehavior());
    add(tolerantTooltip);

    Label tolerantVPTooltip = new Label(ID_T_TOLERANT_VP);
    tolerantVPTooltip.add(new InfoTooltipBehavior());
    add(tolerantVPTooltip);

    Label intolerantVPTooltip = new Label(ID_T_INTOLERANT_VP);
    intolerantVPTooltip.add(new InfoTooltipBehavior());
    add(intolerantVPTooltip);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label matchingRuleTooltip = new Label(ID_T_MATCHING_RULE);
    matchingRuleTooltip.add(new InfoTooltipBehavior());
    add(matchingRuleTooltip);

    Label outboundTooltip = new Label(ID_T_OUTBOUND);
    outboundTooltip.add(new InfoTooltipBehavior());
    add(outboundTooltip);

    Label inboundTooltip = new Label(ID_T_INBOUND);
    inboundTooltip.add(new InfoTooltipBehavior());
    add(inboundTooltip);

    initModals();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceAttributeEditor.java

License:Apache License

@Override
protected void initLayout() {
    Label label = new Label(ID_LABEL, new AbstractReadOnlyModel<String>() {

        @Override//w  w w  .j av a  2s .  co  m
        public String getObject() {
            ResourceAttributeDefinitionType attribute = getModelObject();

            if (attribute.getRef() == null || attribute.getRef().equals(new ItemPathType())) {
                return getString("ResourceAttributeEditor.label.new");
            } else {
                return getString("ResourceAttributeEditor.label.edit",
                        ItemPathUtil.getOnlySegmentQName(attribute.getRef()).getLocalPart());
            }
        }
    });
    add(label);

    QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            "SchemaHandlingStep.attribute.label.attributeName",
            "SchemaHandlingStep.attribute.tooltip.attributeLocalPart",
            "SchemaHandlingStep.attribute.label.attributeNamespace",
            "SchemaHandlingStep.attribute.tooltip.attributeNamespace");

    nonSchemaRefPanel.setOutputMarkupId(true);
    nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);
    nonSchemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return nonSchemaRefValueAllowed;
        }
    });
    add(nonSchemaRefPanel);

    WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL);
    schemaRefPanel.setOutputMarkupId(true);
    schemaRefPanel.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !nonSchemaRefValueAllowed;
        }

    });
    add(schemaRefPanel);

    Label refTooltip = new Label(ID_T_REF);
    refTooltip.add(new InfoTooltipBehavior());
    refTooltip.setOutputMarkupId(true);
    refTooltip.setOutputMarkupId(true);
    schemaRefPanel.add(refTooltip);

    DropDownChoice refSelect = new DropDownChoice<ItemPathType>(ID_REFERENCE_SELECT,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            new AbstractReadOnlyModel<List<ItemPathType>>() {

                @Override
                public List<ItemPathType> getObject() {
                    return loadObjectReferences();
                }
            }, new IChoiceRenderer<ItemPathType>() {

                @Override
                public Object getDisplayValue(ItemPathType object) {
                    return prepareReferenceDisplayValue(object);
                }

                @Override
                public String getIdValue(ItemPathType object, int index) {
                    return Integer.toString(index);
                }
            }) {

        @Override
        protected boolean isSelected(ItemPathType object, int index, String selected) {
            if (getModelObject() == null || getModelObject().equals(new ItemPathType())) {
                return false;
            }

            QName referenceQName = ItemPathUtil.getOnlySegmentQName(getModelObject());
            QName optionQName = ItemPathUtil.getOnlySegmentQName(object);

            return referenceQName.equals(optionQName);
        }
    };
    refSelect.setNullValid(false);

    refSelect.setOutputMarkupId(true);
    refSelect.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(refSelect);

    CheckBox allowNonSchema = new CheckBox(ID_REFERENCE_ALLOW,
            new PropertyModel<Boolean>(this, "nonSchemaRefValueAllowed"));
    allowNonSchema.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_NON_SCHEMA_REF_PANEL), get(ID_SCHEMA_REF_PANEL));
        }
    });
    add(allowNonSchema);

    TextField displayName = new TextField<>(ID_DISPLAY_NAME,
            new PropertyModel<String>(getModel(), "displayName"));
    add(displayName);

    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    add(description);

    AjaxLink limitations = new AjaxLink(ID_BUTTON_LIMITATIONS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);

    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG,
            new PropertyModel<Boolean>(getModel(), "exclusiveStrong"));
    add(exclusiveStrong);

    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<Boolean>(getModel(), "tolerant"));
    add(tolerant);

    MultiValueTextPanel tolerantVP = new MultiValueTextPanel<>(ID_TOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "tolerantValuePattern"));
    add(tolerantVP);

    MultiValueTextPanel intolerantVP = new MultiValueTextPanel<>(ID_INTOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "intolerantValuePattern"));
    add(intolerantVP);

    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    fetchStrategy.setNullValid(true);
    add(fetchStrategy);

    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE,
            new PropertyModel<QName>(getModel(), "matchingRule"), new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return WebMiscUtil.getMatchingRuleList();
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return object.getLocalPart();
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    matchingRule.setNullValid(true);
    add(matchingRule);

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceAttributeDefinitionType attributeDefinition = getModel().getObject();

            if (attributeDefinition == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(attributeDefinition.getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_BUTTON_OUTBOUND) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    Label allowTooltip = new Label(ID_T_ALLOW);
    allowTooltip.add(new InfoTooltipBehavior());
    add(allowTooltip);

    Label limitationsTooltip = new Label(ID_T_LIMITATIONS);
    limitationsTooltip.add(new InfoTooltipBehavior());
    add(limitationsTooltip);

    Label exclusiveStrongTooltip = new Label(ID_T_EXCLUSIVE_STRONG);
    exclusiveStrongTooltip.add(new InfoTooltipBehavior());
    add(exclusiveStrongTooltip);

    Label tolerantTooltip = new Label(ID_T_TOLERANT);
    tolerantTooltip.add(new InfoTooltipBehavior());
    add(tolerantTooltip);

    Label tolerantVPTooltip = new Label(ID_T_TOLERANT_VP);
    tolerantVPTooltip.add(new InfoTooltipBehavior());
    add(tolerantVPTooltip);

    Label intolerantVPTooltip = new Label(ID_T_INTOLERANT_VP);
    intolerantVPTooltip.add(new InfoTooltipBehavior());
    add(intolerantVPTooltip);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label matchingRuleTooltip = new Label(ID_T_MATCHING_RULE);
    matchingRuleTooltip.add(new InfoTooltipBehavior());
    add(matchingRuleTooltip);

    Label outboundTooltip = new Label(ID_T_OUTBOUND);
    outboundTooltip.add(new InfoTooltipBehavior());
    add(outboundTooltip);

    Label inboundTooltip = new Label(ID_T_INBOUND);
    inboundTooltip.add(new InfoTooltipBehavior());
    add(inboundTooltip);

    initModals();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceCredentialsEditor.java

License:Apache License

@Override
protected void initLayout() {
    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "password.fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    add(fetchStrategy);/*from   ww  w. j a v a 2s.c  o m*/

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceCredentialsDefinitionType credentials = getModel().getObject();

            if (credentials == null || credentials.getPassword() == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(credentials.getPassword().getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_OUTBOUND_BUTTON) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "password.inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    DropDownChoice passwordPolicy = new DropDownChoice<>(ID_PASS_POLICY,
            new PropertyModel<ObjectReferenceType>(getModel(), "password.passwordPolicyRef"),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return passPolicyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            });
    add(passwordPolicy);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label outTooltip = new Label(ID_T_OUT);
    outTooltip.add(new InfoTooltipBehavior());
    add(outTooltip);

    Label inTooltip = new Label(ID_T_IN);
    inTooltip.add(new InfoTooltipBehavior());
    add(inTooltip);

    Label passPolicyTooltip = new Label(ID_T_PASS_POLICY);
    passPolicyTooltip.add(new InfoTooltipBehavior());
    add(passPolicyTooltip);

    initModals();
}