Package com.alkacon.vie.shared

Examples of com.alkacon.vie.shared.I_EntityAttribute


        context.getElement().setAttribute("typeof", entity.getTypeName());
        context.getElement().setAttribute("about", entity.getId());
        I_Type entityType = m_vie.getType(entity.getTypeName());
        AttributeValueView lastCompactView = null;
        if (entityType.isChoice()) {
            I_EntityAttribute attribute = entity.getAttribute(Type.CHOICE_ATTRIBUTE_NAME);
            assert (attribute != null) && attribute.isComplexValue() : "a choice type must have a choice attribute";
            AttributeHandler handler = new AttributeHandler(m_vie, entity, Type.CHOICE_ATTRIBUTE_NAME, m_widgetService);
            parentHandler.setHandler(attributeIndex, Type.CHOICE_ATTRIBUTE_NAME, handler);
            ValuePanel attributeElement = new ValuePanel();
            for (I_Entity choiceEntity : attribute.getComplexValues()) {
                I_Type choiceType = m_vie.getType(choiceEntity.getTypeName());
                List<I_EntityAttribute> choiceAttributes = choiceEntity.getAttributes();
                assert (choiceAttributes.size() == 1) && choiceAttributes.get(0).isSingleValue() : "each choice entity may only have a single attribute with a single value";
                I_EntityAttribute choiceAttribute = choiceAttributes.get(0);
                I_Type attributeType = choiceType.getAttributeType(choiceAttribute.getAttributeName());
                I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(
                    choiceAttribute.getAttributeName(),
                    attributeType);
                String label = m_widgetService.getAttributeLabel(choiceAttribute.getAttributeName());
                String help = m_widgetService.getAttributeHelp(choiceAttribute.getAttributeName());
                context.add(attributeElement);
                AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
                attributeElement.add(valueWidget);
                if (choiceAttribute.isSimpleValue()) {
                    valueWidget.setValueWidget(
                        m_widgetService.getAttributeFormWidget(choiceAttribute.getAttributeName()),
                        choiceAttribute.getSimpleValue(),
                        m_widgetService.getDefaultAttributeValue(choiceAttribute.getAttributeName()),
                        true);
                    if (m_widgetService.isDisplaySingleLine(choiceAttribute.getAttributeName())) {
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
                    }
                } else {
                    valueWidget.setValueEntity(renderer, choiceAttribute.getComplexValue());
                    if (m_widgetService.isDisplayCompact(choiceAttribute.getAttributeName())) {
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
                    }
                }
                setAttributeChoice(valueWidget, entityType);
            }
            handler.updateButtonVisisbility();
        } else {
            List<String> attributeNames = entityType.getAttributeNames();
            for (String attributeName : attributeNames) {
                int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
                I_EntityAttribute attribute = entity.getAttribute(attributeName);
                if ((attribute == null) && (minOccurrence > 0)) {
                    attribute = createEmptyAttribute(entity, attributeName, minOccurrence);
                }
                I_Type attributeType = entityType.getAttributeType(attributeName);
                ValuePanel attributeElement = new ValuePanel();
View Full Code Here


        I_InlineFormParent formParent,
        I_InlineHtmlUpdateHandler updateHandler,
        int minOccurrence,
        int maxOccurrence) {

        I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
        if (attribute != null) {
            List<Element> elements = m_vie.getAttributeElements(parentEntity, attributeName, formParent.getElement());
            if (!elements.isEmpty()) {
                AttributeHandler handler = new AttributeHandler(m_vie, parentEntity, attributeName, m_widgetService);
                for (int i = 0; i < elements.size(); i++) {
                    Element element = elements.get(i);
                    I_EditWidget widget = m_widgetService.getAttributeInlineWidget(attributeName, element);
                    if (attribute.isSimpleValue() && (widget != null)) {
                        Element tempSpan = DOM.createSpan();
                        tempSpan.setInnerHTML(attribute.getSimpleValues().get(i));
                        String value = tempSpan.getInnerHTML().trim();
                        // verify the current value equals the element content
                        String innerHtml = element.getInnerHTML().trim();
                        if (innerHtml.equals(value)) {
                            widget.addValueChangeHandler(new WidgetChangeHandler(handler, i));
                            formParent.adoptWidget(widget);
                        } else {
                            InlineEntityWidget.createWidgetForEntity(
                                element,
                                formParent,
                                parentEntity,
                                handler,
                                i,
                                updateHandler,
                                m_widgetService);
                        }
                    } else {
                        InlineEntityWidget.createWidgetForEntity(
                            element,
                            formParent,
                            parentEntity,
                            handler,
                            i,
                            updateHandler,
                            m_widgetService);
                    }
                }
            }
            if (attribute.isComplexValue()) {
                for (I_Entity entity : attribute.getComplexValues()) {
                    renderInline(entity, formParent, updateHandler);
                }
            }
        } else {
            List<Element> elements = m_vie.getAttributeElements(parentEntity, attributeName, formParent.getElement());
View Full Code Here

     *
     * @return the entity attribute
     */
    protected I_EntityAttribute createEmptyAttribute(I_Entity parentEntity, String attributeName, int minOccurrence) {

        I_EntityAttribute result = null;
        I_Type attributeType = m_vie.getType(parentEntity.getTypeName()).getAttributeType(attributeName);
        if (attributeType.isSimpleType()) {
            for (int i = 0; i < minOccurrence; i++) {
                parentEntity.addAttributeValue(attributeName, m_widgetService.getDefaultAttributeValue(attributeName));
            }
View Full Code Here

        I_InlineFormParent formParent,
        I_InlineHtmlUpdateHandler updateHandler,
        int minOccurrence,
        int maxOccurrence) {

        I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
        String renderInline = AcaciaConstants.FUNCTION_RENDER_INLINE;
        if (attribute != null) {
            List<I_Entity> values = attribute.getComplexValues();
            List<Element> elements = Vie.getInstance().getAttributeElements(
                parentEntity,
                attributeName,
                formParent.getElement());
            for (int i = 0; i < elements.size(); i++) {
View Full Code Here

            int index = ContentDefinition.extractIndex(attributeName);
            if (index > 0) {
                index--;
            }
            attributeName = entity.getTypeName() + "/" + ContentDefinition.removeIndex(attributeName);
            I_EntityAttribute attribute = entity.getAttribute(attributeName);
            if (!((attribute == null) || (attribute.isComplexValue() && (pathElements.length == 1)))) {
                if (attribute.isSimpleValue()) {
                    if ((pathElements.length == 1) && (attribute.getValueCount() > 0)) {
                        List<String> values = attribute.getSimpleValues();
                        result = values.get(index);
                    }
                } else if (attribute.getValueCount() > (index)) {
                    String[] childPathElements = new String[pathElements.length - 1];
                    for (int i = 1; i < pathElements.length; i++) {
                        childPathElements[i - 1] = pathElements[i];
                    }
                    List<I_Entity> values = attribute.getComplexValues();
                    result = getValueForPath(values.get(index), childPathElements);
                }
            }
        }
        return result;
View Full Code Here

                AttributeHandler handler = new AttributeHandler(m_vie, entity, attributeName, m_widgetService);
                parentHandler.setHandler(attributeIndex, attributeName, handler);
                I_Type attributeType = entityType.getAttributeType(attributeName);
                I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
                int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
                I_EntityAttribute attribute = entity.getAttribute(attributeName);
                // only single complex values may be collapsed
                if (collapsed
                    && (attribute != null)
                    && !attributeType.isSimpleType()
                    && (minOccurrence == 1)
                    && (entityType.getAttributeMaxOccurrence(attributeName) == 1)) {
                    renderer.renderForm(attribute.getComplexValue(), tabPanel, handler, 0);
                } else {
                    String label = m_widgetService.getAttributeLabel(attributeName);
                    String help = m_widgetService.getAttributeHelp(attributeName);
                    ValuePanel attributeElement = new ValuePanel();
                    tabPanel.add(attributeElement);
                    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.getAttributeFormWidget(attributeName),
                                    attribute.getSimpleValues().get(i),
                                    true);
                            } else {
                                valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));

                            }
                            setAttributeChoice(valueWidget, attributeType);
                        }
                    } else {
View Full Code Here

        context.addStyleName(ENTITY_CLASS);
        context.getElement().setAttribute("typeof", entity.getTypeName());
        context.getElement().setAttribute("about", entity.getId());
        I_Type entityType = m_vie.getType(entity.getTypeName());
        if (entityType.isChoice()) {
            I_EntityAttribute attribute = entity.getAttribute(Type.CHOICE_ATTRIBUTE_NAME);
            assert (attribute != null) && attribute.isComplexValue() : "a choice type must have a choice attribute";
            AttributeHandler handler = new AttributeHandler(m_vie, entity, Type.CHOICE_ATTRIBUTE_NAME, m_widgetService);
            parentHandler.setHandler(attributeIndex, Type.CHOICE_ATTRIBUTE_NAME, handler);
            ValuePanel attributeElement = new ValuePanel();
            for (I_Entity choiceEntity : attribute.getComplexValues()) {
                I_Type choiceType = m_vie.getType(choiceEntity.getTypeName());
                List<I_EntityAttribute> choiceAttributes = choiceEntity.getAttributes();
                assert (choiceAttributes.size() == 1) && choiceAttributes.get(0).isSingleValue() : "each choice entity may only have a single attribute with a single value";
                I_EntityAttribute choiceAttribute = choiceAttributes.get(0);
                I_Type attributeType = choiceType.getAttributeType(choiceAttribute.getAttributeName());
                I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(
                    choiceAttribute.getAttributeName(),
                    attributeType);
                String label = m_widgetService.getAttributeLabel(choiceAttribute.getAttributeName());
                String help = m_widgetService.getAttributeHelp(choiceAttribute.getAttributeName());
                context.add(attributeElement);
                AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
                attributeElement.add(valueWidget);
                if (choiceAttribute.isSimpleValue()) {
                    valueWidget.setValueWidget(
                        m_widgetService.getAttributeFormWidget(choiceAttribute.getAttributeName()),
                        choiceAttribute.getSimpleValue(),
                        true);
                } else {
                    valueWidget.setValueEntity(renderer, choiceAttribute.getComplexValue());
                }
                setAttributeChoice(valueWidget, entityType);
            }
            handler.updateButtonVisisbility();
        } else {
            List<String> attributeNames = entityType.getAttributeNames();
            for (String attributeName : attributeNames) {
                int minOccurrence = entityType.getAttributeMinOccurrence(attributeName);
                I_EntityAttribute attribute = entity.getAttribute(attributeName);
                if ((attribute == null) && (minOccurrence > 0)) {
                    attribute = createEmptyAttribute(entity, attributeName, minOccurrence);
                }
                I_Type attributeType = entityType.getAttributeType(attributeName);
                I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
                String label = m_widgetService.getAttributeLabel(attributeName);
                String help = m_widgetService.getAttributeHelp(attributeName);
                ValuePanel attributeElement = new ValuePanel();
                context.add(attributeElement);
                AttributeHandler handler = new AttributeHandler(m_vie, entity, attributeName, m_widgetService);
                parentHandler.setHandler(attributeIndex, attributeName, handler);
                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.getAttributeFormWidget(attributeName),
                                attribute.getSimpleValues().get(i),
                                true);
                        } else {
                            valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
                        }
                        setAttributeChoice(valueWidget, attributeType);
                    }
                } else {
                    AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
View Full Code Here

        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.getAttributeInlineWidget(
                        attributeName,
                        (com.google.gwt.user.client.Element)element);
                    widget.onAttachWidget();
                    RootPanel.detachOnWindowClose(widget.asWidget());
                    widget.addValueChangeHandler(new WidgetChangeHandler(parentEntity, attributeName, i));
                }
            } else {
                for (I_Entity entity : attribute.getComplexValues()) {
                    renderInline(entity, context);
                }
            }
        }
    }
View Full Code Here

        String attributeName,
        I_InlineFormParent formParent,
        int minOccurrence,
        int maxOccurrence) {

        I_EntityAttribute attribute = parentEntity.getAttribute(attributeName);
        if (attribute != null) {
            if (attribute.isSimpleValue()) {
                List<Element> elements = m_vie.getAttributeElements(
                    parentEntity,
                    attributeName,
                    formParent.getElement());
                for (int i = 0; i < elements.size(); i++) {
                    Element element = elements.get(i);
                    I_EditWidget widget = m_widgetService.getAttributeInlineWidget(
                        attributeName,
                        (com.google.gwt.user.client.Element)element);
                    formParent.adoptWidget(widget);
                    widget.addValueChangeHandler(new WidgetChangeHandler(parentEntity, attributeName, i));
                }
            } else {
                for (I_Entity entity : attribute.getComplexValues()) {
                    renderInline(entity, formParent);
                }
            }
        }
View Full Code Here

     *
     * @return the entity attribute
     */
    protected I_EntityAttribute createEmptyAttribute(I_Entity parentEntity, String attributeName, int minOccurrence) {

        I_EntityAttribute result = null;
        I_Type attributeType = m_vie.getType(parentEntity.getTypeName()).getAttributeType(attributeName);
        if (attributeType.isSimpleType()) {
            for (int i = 0; i < minOccurrence; i++) {
                parentEntity.addAttributeValue(attributeName, m_widgetService.getDefaultAttributeValue(attributeName));
            }
View Full Code Here

TOP

Related Classes of com.alkacon.vie.shared.I_EntityAttribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.