コード例 #1
0
ファイル: Renderer.java プロジェクト: ruKurz/acacia-editor
  /**
   * @see com.alkacon.acacia.client.I_EntityRenderer#renderForm(com.alkacon.vie.shared.I_Entity,
   *     com.google.gwt.user.client.ui.Panel)
   */
  public void renderForm(final I_Entity entity, Panel context) {

    context.addStyleName(ENTITY_CLASS);
    context.getElement().setAttribute("typeof", entity.getTypeName());
    context.getElement().setAttribute("about", entity.getId());
    I_Type entityType = m_vie.getType(entity.getTypeName());
    List<String> attributeNames = entityType.getAttributeNames();
    for (final String attributeName : attributeNames) {
      AttributeHandler handler =
          new AttributeHandler(m_vie, entity, attributeName, m_widgetService);
      I_Type attributeType = entityType.getAttributeType(attributeName);
      I_EntityRenderer renderer =
          m_widgetService.getRendererForAttribute(attributeName, attributeType);
      int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
      String label = m_widgetService.getAttributeLabel(attributeName);
      String help = m_widgetService.getAttributeHelp(attributeName);
      ValuePanel attributeElement = new ValuePanel();
      context.add(attributeElement);
      I_EntityAttribute attribute = entity.getAttribute(attributeName);
      if ((attribute == null) && (minOccurrence > 0)) {
        attribute = createEmptyAttribute(entity, attributeName, minOccurrence);
      }
      if (attribute != null) {
        for (int i = 0; i < attribute.getValueCount(); i++) {
          AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
          attributeElement.add(valueWidget);
          if (attribute.isSimpleValue()) {
            valueWidget.setValueWidget(
                m_widgetService.getAttributeWidget(attributeName),
                attribute.getSimpleValues().get(i));
          } else {
            valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
          }
        }
      } else {
        AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
        attributeElement.add(valueWidget);
      }
      handler.updateButtonVisisbility();
    }
  }
コード例 #2
0
ファイル: Renderer.java プロジェクト: ruKurz/acacia-editor
  /**
   * @see com.alkacon.acacia.client.I_EntityRenderer#renderInline(com.alkacon.vie.shared.I_Entity,
   *     java.lang.String, com.google.gwt.dom.client.Element, int, int)
   */
  public void renderInline(
      I_Entity parentEntity,
      String attributeName,
      Element context,
      int minOccurrence,
      int maxOccurrence) {

    I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
    if (attribute != null) {
      if (attribute.isSimpleValue()) {
        List<Element> elements = m_vie.getAttributeElements(parentEntity, attributeName, context);
        for (int i = 0; i < elements.size(); i++) {
          Element element = elements.get(i);
          I_EditWidget widget =
              m_widgetService.getAttributeWidget(attributeName).initWidget(element, true);
          widget.addValueChangeHandler(new WidgetChangeHandler(parentEntity, attributeName, i));
        }
      } else {
        for (I_Entity entity : attribute.getComplexValues()) {
          renderInline(entity, context);
        }
      }
    }
  }