Package com.alkacon.acacia.client.ui

Examples of com.alkacon.acacia.client.ui.AttributeValueView


        context.addStyleName(ENTITY_CLASS);
        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();
View Full Code Here


        String label = m_widgetService.getAttributeLabel(attributeName);
        String help = m_widgetService.getAttributeHelp(attributeName);
        if (attribute != null) {
            I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeName, attributeType);
            for (int i = 0; i < attribute.getValueCount(); i++) {
                AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
                if (attributeType.isChoice() && (entityType.getAttributeMaxOccurrence(attributeName) == 1)) {
                    valueWidget.setCollapsed(true);
                }
                attributeElement.add(valueWidget);
                if (attribute.isSimpleValue()) {
                    valueWidget.setValueWidget(
                        m_widgetService.getAttributeFormWidget(attributeName),
                        attribute.getSimpleValues().get(i),
                        m_widgetService.getDefaultAttributeValue(attributeName),
                        true);
                    // check for compact view setting
                    if (m_widgetService.isDisplayCompact(attributeName)) {
                        // widget should be displayed in compact view, using only 50% of the available width
                        if (lastCompactView == null) {
                            // set mode to first column
                            valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
                            lastCompactView = valueWidget;
                        } else {
                            // previous widget is displayed as first column, set second column mode
                            valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SECOND_COLUMN);
                            lastCompactView = null;
                        }
                    } else {
                        if (lastCompactView != null) {
                            // previous widget was set to first column mode,
                            // revert that as the current widget will be displayed in a new line
                            lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
                            lastCompactView = null;
                        }
                        if (m_widgetService.isDisplaySingleLine(attributeName)) {
                            valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
                        }
                    }
                } else {
                    valueWidget.setValueEntity(renderer, attribute.getComplexValues().get(i));
                    if (lastCompactView != null) {
                        // previous widget was set to first column mode,
                        // revert that as the current widget will be displayed in a new line
                        lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
                        lastCompactView = null;
                    }
                    if (m_widgetService.isDisplayCompact(attributeName)) {
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
                    }
                }
                setAttributeChoice(valueWidget, attributeType);
            }
        } else {
            AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
            attributeElement.add(valueWidget);
            if (attributeType.isSimpleType()) {
                // create a deactivated widget, to add the attribute on click
                valueWidget.setValueWidget(
                    m_widgetService.getAttributeFormWidget(attributeName),
                    "",
                    m_widgetService.getDefaultAttributeValue(attributeName),
                    false);
                // check for compact view setting
                if (m_widgetService.isDisplayCompact(attributeName)) {
                    // widget should be displayed in compact view, using only 50% of the available width
                    if (lastCompactView == null) {
                        // set mode to first column
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_FIRST_COLUMN);
                        lastCompactView = valueWidget;
                    } else {
                        // previous widget is displayed as first column, set second column mode
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SECOND_COLUMN);
                        lastCompactView = null;
                    }
                } else {
                    if (lastCompactView != null) {
                        // previous widget was set to first column mode,
                        // revert that as the current widget will be displayed in a new line
                        lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
                        lastCompactView = null;
                    }
                    if (m_widgetService.isDisplaySingleLine(attributeName)) {
                        valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_SINGLE_LINE);
                    }
                }
            } else {
                if (lastCompactView != null) {
                    // previous widget was set to first column mode,
                    // revert that as the current widget will be displayed in a new line
                    lastCompactView.setCompactMode(AttributeValueView.COMPACT_MODE_WIDE);
                    lastCompactView = null;
                }
                if (m_widgetService.isDisplayCompact(attributeName)) {
                    valueWidget.setCompactMode(AttributeValueView.COMPACT_MODE_NESTED);
                }
            }
            setAttributeChoice(valueWidget, attributeType);
        }
        handler.updateButtonVisisbility();
View Full Code Here

    /**
     * @see com.alkacon.geranium.client.dnd.I_DNDController#onDrop(com.alkacon.geranium.client.dnd.I_Draggable, com.alkacon.geranium.client.dnd.I_DropTarget, com.alkacon.geranium.client.dnd.DNDHandler)
     */
    public void onDrop(I_Draggable draggable, I_DropTarget target, DNDHandler handler) {

        AttributeValueView attributeValue = (AttributeValueView)draggable;
        int targetIndex = target.getPlaceholderIndex();
        if (targetIndex > m_startPosition) {
            targetIndex--;
        }
        attributeValue.getHandler().moveAttributeValue(attributeValue, m_startPosition, targetIndex);
        removeDragOverlay();
        clearTargets(handler);
        // remove the drag helper reference from handler, to avoid helper.removeFromParent() call
        handler.setDragHelper(null);
    }
View Full Code Here

                    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 {
                        AttributeValueView valueWidget = new AttributeValueView(handler, label, help);
                        attributeElement.add(valueWidget);
                        if (attributeType.isSimpleType()) {
                            // create a deactivated widget, to add the attribute on click
                            valueWidget.setValueWidget(
                                m_widgetService.getAttributeFormWidget(attributeName),
                                m_widgetService.getDefaultAttributeValue(attributeName),
                                false);
                        }
                        setAttributeChoice(valueWidget, attributeType);
View Full Code Here

                    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);
                    attributeElement.add(valueWidget);
                    if (attributeType.isSimpleType()) {
                        // create a deactivated widget, to add the attribute on click
                        valueWidget.setValueWidget(
                            m_widgetService.getAttributeFormWidget(attributeName),
                            m_widgetService.getDefaultAttributeValue(attributeName),
                            false);
                    }
                    setAttributeChoice(valueWidget, attributeType);
View Full Code Here

                } else {
                    valueIndex = reference.getValueIndex() + 1;
                    m_entity.insertAttributeValue(m_attributeName, value, valueIndex);

                }
                AttributeValueView valueWidget = reference;
                if (reference.hasValue()) {
                    valueWidget = new AttributeValueView(
                        this,
                        m_widgetService.getAttributeLabel(m_attributeName),
                        m_widgetService.getAttributeHelp(m_attributeName));
                    if (valueIndex == -1) {
                        ((FlowPanel)reference.getParent()).add(valueWidget);
                    } else {
                        ((FlowPanel)reference.getParent()).insert(valueWidget, valueIndex);
                    }

                }
                valueWidget.setValueWidget(widget, value, true);
            } else {
                I_Entity value = m_vie.createEntity(null, m_attributeType.getId());
                insertValueAfterReference(value, reference);
            }
        }
View Full Code Here

        }
        FlowPanel parent = (FlowPanel)valueView.getParent();

        valueView.removeFromParent();
        m_attributeValueViews.remove(valueView);
        AttributeValueView valueWidget = null;
        if (isChoiceHandler()) {
            removeHandlers(currentPosition);
            I_Entity value = m_entity.getAttribute(m_attributeName).getComplexValues().get(currentPosition);
            m_entity.removeAttributeValue(m_attributeName, currentPosition);
            m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
            String attributeChoice = getChoiceName(targetPosition);
            I_Type optionType = getAttributeType().getAttributeType(attributeChoice);
            valueWidget = new AttributeValueView(
                this,
                m_widgetService.getAttributeLabel(attributeChoice),
                m_widgetService.getAttributeHelp(attributeChoice));
            parent.insert(valueWidget, targetPosition);
            insertHandlers(targetPosition);
            if (optionType.isSimpleType()) {
                valueWidget.setValueWidget(
                    m_widgetService.getAttributeFormWidget(attributeChoice),
                    value.getAttribute(attributeChoice).getSimpleValue(),
                    true);
            } else {
                valueWidget.setValueEntity(
                    m_widgetService.getRendererForAttribute(attributeChoice, getAttributeType()),
                    value.getAttribute(attributeChoice).getComplexValue());
            }

            List<ChoiceMenuEntryBean> menuEntries = Renderer.getChoiceEntries(getAttributeType(), true);
            for (ChoiceMenuEntryBean menuEntry : menuEntries) {
                valueWidget.addChoice(m_widgetService, menuEntry);
            }
        } else if (getAttributeType().isSimpleType()) {
            String value = m_entity.getAttribute(m_attributeName).getSimpleValues().get(currentPosition);
            m_entity.removeAttributeValue(m_attributeName, currentPosition);
            m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
            valueWidget = new AttributeValueView(
                this,
                m_widgetService.getAttributeLabel(m_attributeName),
                m_widgetService.getAttributeHelp(m_attributeName));
            parent.insert(valueWidget, targetPosition);
            valueWidget.setValueWidget(m_widgetService.getAttributeFormWidget(m_attributeName), value, true);
        } else {
            removeHandlers(currentPosition);
            I_Entity value = m_entity.getAttribute(m_attributeName).getComplexValues().get(currentPosition);
            m_entity.removeAttributeValue(m_attributeName, currentPosition);
            m_entity.insertAttributeValue(m_attributeName, value, targetPosition);
            valueWidget = new AttributeValueView(
                this,
                m_widgetService.getAttributeLabel(m_attributeName),
                m_widgetService.getAttributeHelp(m_attributeName));
            parent.insert(valueWidget, targetPosition);
            insertHandlers(targetPosition);
            valueWidget.setValueEntity(
                m_widgetService.getRendererForAttribute(m_attributeName, getAttributeType()),
                value);

        }
        HighlightingHandler.getInstance().setFocusHighlighted(valueWidget);
View Full Code Here

     */
    public void setErrorMessage(int valueIndex, String message, TabbedPanel<?> tabbedPanel) {

        if (!m_attributeValueViews.isEmpty()) {
            FlowPanel parent = (FlowPanel)m_attributeValueViews.get(0).getParent();
            AttributeValueView valueView = (AttributeValueView)parent.getWidget(valueIndex);
            valueView.setErrorMessage(message);
            if (tabbedPanel != null) {
                int tabIndex = tabbedPanel.getTabIndex(valueView.getElement());
                if (tabIndex > -1) {
                    Widget tab = tabbedPanel.getTabWidget(tabIndex);
                    tab.setTitle("This tab has errors.");
                    tab.getParent().removeStyleName(I_LayoutBundle.INSTANCE.form().hasWarning());
                    tab.getParent().addStyleName(I_LayoutBundle.INSTANCE.form().hasError());
View Full Code Here

     */
    public void setWarningMessage(int valueIndex, String message, TabbedPanel<?> tabbedPanel) {

        if (!m_attributeValueViews.isEmpty()) {
            FlowPanel parent = (FlowPanel)m_attributeValueViews.get(0).getParent();
            AttributeValueView valueView = (AttributeValueView)parent.getWidget(valueIndex);
            valueView.setWarningMessage(message);
            if (tabbedPanel != null) {
                int tabIndex = tabbedPanel.getTabIndex(valueView.getElement());
                if (tabIndex > -1) {
                    Widget tab = tabbedPanel.getTabWidget(tabIndex);
                    tab.setTitle("This tab has warnings.");
                    tab.getParent().addStyleName(I_LayoutBundle.INSTANCE.form().hasWarning());
                }
View Full Code Here

        String attributeChoice = choicePath.get(0);
        I_Type optionType = getAttributeType().getAttributeType(attributeChoice);

        I_Entity choiceEntity = m_vie.createEntity(null, getAttributeType().getId());
        AttributeValueView valueWidget = reference;
        if (reference.hasValue()) {
            valueWidget = new AttributeValueView(
                this,
                m_widgetService.getAttributeLabel(attributeChoice),
                m_widgetService.getAttributeHelp(attributeChoice));
        }

        List<ChoiceMenuEntryBean> menuEntries = Renderer.getChoiceEntries(getAttributeType(), true);
        for (ChoiceMenuEntryBean menuEntry : menuEntries) {
            valueWidget.addChoice(m_widgetService, menuEntry);
        }
        int valueIndex = reference.getValueIndex() + 1;
        m_entity.insertAttributeValue(m_attributeName, choiceEntity, valueIndex);
        ((FlowPanel)reference.getParent()).insert(valueWidget, valueIndex);
        insertHandlers(valueWidget.getValueIndex());

        if (optionType.isSimpleType()) {
            String value = m_widgetService.getDefaultAttributeValue(attributeChoice);
            I_FormEditWidget widget = m_widgetService.getAttributeFormWidget(attributeChoice);
            choiceEntity.addAttributeValue(attributeChoice, value);
            valueWidget.setValueWidget(widget, value, true);
        } else {
            I_Entity value = m_vie.createEntity(null, optionType.getId());
            choiceEntity.addAttributeValue(attributeChoice, value);
            List<String> remainingAttributeNames = tail(choicePath);
            createNestedEntitiesForChoicePath(value, remainingAttributeNames);
            I_EntityRenderer renderer = m_widgetService.getRendererForAttribute(attributeChoice, optionType);
            valueWidget.setValueEntity(renderer, value);
        }
        updateButtonVisisbility();

    }
View Full Code Here

TOP

Related Classes of com.alkacon.acacia.client.ui.AttributeValueView

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.