Esempio n. 1
0
  /**
   * Recursively writes a data source Item and its children to a design.
   *
   * @since 7.5.0
   * @param design the element into which to insert the item
   * @param itemId the id of the item to write
   * @param context the DesignContext instance used in writing
   * @return
   */
  @Override
  protected Element writeItem(Element design, Object itemId, DesignContext context) {
    Element element = design.appendElement("node");

    element.attr("text", itemId.toString());

    Resource icon = getItemIcon(itemId);
    if (icon != null) {
      DesignAttributeHandler.writeAttribute(
          "icon", element.attributes(), icon, null, Resource.class);
    }

    if (isSelected(itemId)) {
      element.attr("selected", "");
    }

    Collection<?> children = getChildren(itemId);
    if (children != null) {
      // Yeah... see #5864
      for (Object childItemId : children) {
        writeItem(element, childItemId, context);
      }
    }

    return element;
  }
Esempio n. 2
0
 /**
  * Recursively writes the root items and their children to a design.
  *
  * @since 7.5.0
  * @param design the element into which to insert the items
  * @param context the DesignContext instance used in writing
  */
 @Override
 protected void writeItems(Element design, DesignContext context) {
   for (Object itemId : rootItemIds()) {
     writeItem(design, itemId, context);
   }
 }