/**
   * New instance of condition read from a widget property
   *
   * @param widget
   */
  public EnabledIsBaseOnCondition(Widget widget) {
    Property enabledIsBasedOn =
        widget.findProperty(EnabledConstants.ENABLED_IS_BASE_ON_PROPERTY_NAME);
    if (enabledIsBasedOn != null) {
      this.simplified = !ADVANCED_VALUE.equals(enabledIsBasedOn.getValue());
    } else {
      this.simplified = true;
    }

    Property simplifedProperty =
        widget.findProperty(EnabledConstants.ENABLED_IS_BASE_ON_SIMPLIFED_PROPERTY_NAME);
    if (simplifedProperty != null && StringUtils.isNotBlank(simplifedProperty.getValue())) {
      this.simplifiedCondition = MdfNameFactory.createMdfName(simplifedProperty.getValue());
    } else {
      this.simplifiedCondition = null;
    }

    Property advancedProperty =
        widget.findProperty(EnabledConstants.ENABLED_IS_BASE_ON_ADVANCED_PROPERTY_NAME);
    if (advancedProperty != null) {
      this.advancedCondition = advancedProperty.getValue();
    } else {
      this.advancedCondition = "";
    }
  }
  /** property url should be src attribute with url as value */
  @Override
  public void transform(WidgetTransformerContext context, Property property) throws CoreException {

    String domainAttributValue =
        property
            .getWidget()
            .getPropertyValue(PropertyTypeConstants.DOMAIN_ATTRIBUTE_WITHOUT_VALIDATOR);

    if (domainAttributValue != null && domainAttributValue.length() > 0) {
      Property beanNameProperty =
          BeanPropertyUtils.findBeanNameProperty(context, property.getWidget());
      String beanNamePropertyValue = beanNameProperty.getValue();

      // Create the element <xsp:attribute name="src">...</xsp:attribute>
      Namespace ns = context.getTransformModel().findNamespace(XSP_NAMESPACE_URI);
      Element valElmt =
          context
              .getDocument()
              .createElementNS(ns.getUri(), TransformerConstants.ATTRIBUTE_ELEMENT_NAME);
      valElmt.setPrefix(ns.getPrefix());
      TransformUtils.appendChild(context, valElmt);
      // Create the attribute name="src"
      Attr a = context.getDocument().createAttribute(TransformerConstants.NAME_ATTRIBUTE_NAME);
      a.setValue("src");
      valElmt.setAttributeNode(a);

      // create the <bean:get-property bean="..." property="..."/>
      Namespace beanNamespace = context.getTransformModel().findNamespace(BEAN_URI);
      Element defElmt =
          context.getDocument().createElementNS(beanNamespace.getUri(), BEAN_GET_PROPERTY_ELEMENT);
      defElmt.setPrefix(beanNamespace.getPrefix());
      addAttribute(context, defElmt, BEAN_BEAN_ATTRIBUTE, beanNamePropertyValue);
      addAttribute(context, defElmt, BEAN_PROPERTY_ATTRIBUTE, domainAttributValue);
      valElmt.appendChild(defElmt);

    } else {
      String url = property.getValue();
      if (url != null && url.length() != 0) {
        addAttribute(context, "src", url);
      }
    }
  }
Example #3
0
  /**
   * Gets the text associated with a specific item. This is used in the Header.
   *
   * @param widget The Widget to get the text for
   * @param index The index
   * @return String The text
   */
  protected String getItemText(Widget widget, int index) {
    // The Column contains a ColumnHeader as the first item and a ColumnBody as the second ones
    Widget header = widget.getContents().get(0);
    Property p = header.findProperty(PropertyTypeConstants.COLUMN_NAME);
    String s = "";
    if (p != null) {
      s = p.getValue();
    }

    if (StringUtils.isEmpty(s)) {
      return "            ";
    }

    return s;
  }