예제 #1
0
  /**
   * @return Returns proper {@link PropertyModel} based on different types like {@link
   *     com.evolveum.midpoint.prism.polystring.PolyString} or {@link
   *     com.evolveum.midpoint.xml.ns._public.common.common_2a.ProtectedStringType}
   */
  private IModel createValueModel() {
    FieldToken token = model.getObject().getField().getToken();
    PrismPropertyDefinition definition = token.getDefinition();

    final String baseExpression = "value.value"; // pointing to prism property real value

    if (ProtectedStringType.COMPLEX_TYPE.equals(definition.getTypeName())) {
      return new PropertyModel<String>(model, baseExpression + ".clearValue");
    } else if (SchemaConstants.T_POLY_STRING_TYPE.equals(definition.getTypeName())) {
      return new PropertyModel<String>(model, baseExpression + ".orig");
    }

    return new PropertyModel(model, baseExpression);
  }
예제 #2
0
  protected void initLayout() {
    final ValueModel valueModel = model.getObject();
    FieldDisplayType display = valueModel.getDefaultDisplay();

    // todo help
    Label label =
        new Label("label", new StringResourceModel(display.getLabel(), null, display.getLabel()));
    label.add(
        new AttributeModifier(
            "style",
            new AbstractReadOnlyModel<String>() {

              @Override
              public String getObject() {
                if (valueModel.getVisibleValueIndex() > 0) {
                  return "visibility: hidden;";
                }
                return null;
              }
            }));

    if (StringUtils.isNotEmpty(display.getTooltip())) {
      label.add(
          new AttributeModifier(
              "title", new StringResourceModel(display.getTooltip(), null, display.getTooltip())));
    }
    add(label);

    FieldToken fieldToken = valueModel.getField().getToken();
    UiWidget widget = initWidget(fieldToken.getWidget(), display.getProperty());
    add(widget);

    FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setFilter(new ComponentFeedbackMessageFilter(widget.getBaseFormComponent()));
    feedback.setOutputMarkupId(true);
    add(feedback);

    AjaxLink addButton =
        new AjaxLink("addButton") {

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

          @Override
          public boolean isVisible() {
            return valueModel.isAddButtonVisible();
          }
        });
    add(addButton);

    AjaxLink removeButton =
        new AjaxLink("removeButton") {

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

          @Override
          public boolean isVisible() {
            return valueModel.isRemoveButtonVisible();
          }
        });
    add(removeButton);
  }