Package org.auraframework.def

Examples of org.auraframework.def.AttributeDefRef


    private void setDefaults() throws QuickFixException {
        Map<DefDescriptor<AttributeDef>, AttributeDef> attrs = rootDefDescriptor.getDef().getAttributeDefs();

        for (Map.Entry<DefDescriptor<AttributeDef>, AttributeDef> attr : attrs.entrySet()) {
            AttributeDefRef ref = attr.getValue().getDefaultValue();
            if (ref != null && !attributes.containsKey(attr.getKey())) {
                set(ref);
            }
        }
    }
View Full Code Here


            AttributeDefRefImpl.Builder atBuilder = new AttributeDefRefImpl.Builder();
            atBuilder.setDescriptor(DefDescriptorImpl.getInstance(AttributeDefRefImpl.BODY_ATTRIBUTE_NAME,
                    AttributeDef.class));
            atBuilder.setLocation(getLocation());
            atBuilder.setValue(body);
            AttributeDefRef adr = atBuilder.build();
            builder.facets.add(adr);
        }

        return builder.build();
    }
View Full Code Here

    public HTMLDefRefBuilderImpl setComponentAttribute(String key, Object value) {
        AttributeDefRefImpl.Builder valueBuilder = new AttributeDefRefImpl.Builder();
        valueBuilder.setDescriptor(DefDescriptorImpl.getInstance(key, AttributeDef.class));
        valueBuilder.setValue(value);

        AttributeDefRef adr = valueBuilder.build();
        super.setAttribute(adr.getDescriptor(), adr);
        return this;
    }
View Full Code Here

        public HTMLDefRefBuilderImpl optimize(HTMLDefRefBuilderImpl builder) {
            DefDescriptor<AttributeDef> bodyDesc = DefDescriptorImpl.getInstance("body", AttributeDef.class);
            DefDescriptor<AttributeDef> tagDesc = DefDescriptorImpl.getInstance("tag", AttributeDef.class);
            DefDescriptor<ComponentDef> textDesc = DefDescriptorImpl.getInstance("aura:text", ComponentDef.class);
            DefDescriptor<ComponentDef> expDesc = DefDescriptorImpl.getInstance("aura:expression", ComponentDef.class);
            AttributeDefRef bodyRef = builder.getAttributeValue(bodyDesc);
            Map<DefDescriptor<AttributeDef>, Object> htmlAttributes = builder.htmlAttributes;
            boolean pureHTML = true;
            if (bodyRef != null) {
                for (ComponentDefRef cdr : (List<ComponentDefRef>) bodyRef.getValue()) {
                    if (cdr.getClass().equals(HTMLDefRefBuilderImpl.class)) {
                        if (cdr.getAttributeDefRef("markup") == null) {
                            pureHTML = false;
                            break;
                        }
                    } else if ((!(cdr.getDescriptor().equals(textDesc) || cdr.getDescriptor().equals(expDesc)))
                            || cdr.getLocalId() != null) {
                        pureHTML = false;
                        break;
                    }
                }
            }
            if (builder.getLocalId() != null) {
                pureHTML = false;
            }
            if (pureHTML) {
                Set<String> booleanAttributes = HTMLComponentDefRefHandler.SPECIAL_BOOLEANS;
                for (Map.Entry<DefDescriptor<AttributeDef>, Object> entry : htmlAttributes.entrySet()) {
                    String key = entry.getKey().getName();
                    if (key.toLowerCase().startsWith("on") || key.toLowerCase().equals("href")
                            || booleanAttributes.contains(key.toLowerCase())) {

                        pureHTML = false;
                        break;
                    }
                }
            }

            if (pureHTML) {
                List<Object> markup = Lists.newArrayList();
                String tag = (String) builder.getAttributeValue(tagDesc).getValue();
                add(markup, "<").add(markup, tag);
                if (htmlAttributes != null) {
                    for (Map.Entry<DefDescriptor<AttributeDef>, Object> entry : htmlAttributes.entrySet()) {
                        Object value = entry.getValue();
                        if (value != null) {
                            add(markup, " ").add(markup, entry.getKey().getName()).add(markup, "=").add(markup, "\"");

                            if (value instanceof Expression) {
                                add(markup, value);
                            } else {
                                add(markup, value.toString());
                            }

                            add(markup, "\"");
                        }
                    }
                }

                add(markup, ">");
                if (bodyRef != null) {
                    for (ComponentDefRef cdr : (List<ComponentDefRef>) bodyRef.getValue()) {
                        if (cdr.getClass().equals(HTMLDefRefBuilderImpl.class)) {
                            for (Object childMarkup : (List<Object>) cdr.getAttributeDefRef("markup").getValue()) {
                                add(markup, childMarkup);
                            }
                        } else if (cdr.getDescriptor().equals(textDesc)) {
View Full Code Here

    protected List<AttributeDefRef> getAttributeValueList() throws QuickFixException {
        RootDefinition def = getComponentDef();
        Collection<AttributeDef> defs = def.getAttributeDefs().values();
        List<AttributeDefRef> ret = Lists.newArrayList();
        for (AttributeDef at : defs) {
            AttributeDefRef ref = attributeValues.get(at.getDescriptor());
            if (ref != null) {
                ret.add(ref);
            }
        }
        return ret;
View Full Code Here

            if (value != null) {
                AttributeDefRefImpl.Builder valueBuilder = new AttributeDefRefImpl.Builder();
                valueBuilder.setDescriptor(DefDescriptorImpl.getInstance(key, AttributeDef.class));
                valueBuilder.setValue(value);

                AttributeDefRef adr = valueBuilder.build();
                setAttribute(adr.getDescriptor(), adr);
            } else if (attributeValues != null) {
                DefDescriptor<AttributeDef> attr = DefDescriptorImpl.getInstance(key, AttributeDef.class);
                attributeValues.remove(attr);
            }
            return this;
View Full Code Here

        public Builder setComponentAttribute(String key, Object value) {
            AttributeDefRefImpl.Builder valueBuilder = new AttributeDefRefImpl.Builder();
            valueBuilder.setDescriptor(DefDescriptorImpl.getInstance(key, AttributeDef.class));
            valueBuilder.setValue(value);

            AttributeDefRef adr = valueBuilder.build();
            super.setAttribute(adr.getDescriptor(), adr);
            return this;
        }
View Full Code Here

        if (blacklistedAttributes.containsKey(descriptorName) && blacklistedAttributes.get(descriptorName).contains(attributeDef.getName())) {
            return false;
        }
        if ("aura://String".equals(attributeDef.getTypeDef().getDescriptor().getQualifiedName())) {
            AttributeDefRef valueRef = attributeDef.getDefaultValue();
            if (valueRef == null ||
                    (valueRef.getValue() == null || valueRef.getValue().toString().isEmpty())) {
                return true;
            }
        }
        return attributeDef.isRequired();
    }
View Full Code Here

        super(name);
    }

    public void testComponentAttributeMap() throws Exception {
        Component cmp = vendor.makeComponent("test:child1", "meh");
        AttributeDefRef adr = vendor.makeAttributeDefRef("attr", "some value", new Location("meh", 0));
        cmp.getAttributes().set(Collections.singleton(adr));

        assertEquals(1, cmp.getAttributes().size());

        assertEquals("some value", cmp.getAttributes().getExpression("attr"));

        try {
            AttributeDefRef adr2 = vendor.makeAttributeDefRef("badAttr", "blubber", new Location("meh", 0));
            cmp.getAttributes().set(Collections.singleton(adr2));
            fail("Should have thrown AuraException(Attribute not Defined)");
        } catch (AttributeNotFoundException expected) {
        }
    }
View Full Code Here

    cmp.reinitializeModel();
        assertEquals("some other value", cmp.getModel().getValue(propRef));
    }

  private void setAttribute(Component cmp, String name, String value) throws QuickFixException {
    AttributeDefRef adr = vendor.makeAttributeDefRef(name, value, new Location("meh", 0));
        AttributeSet attributes = cmp.getAttributes();
    attributes.set(Collections.singleton(adr));
  }
View Full Code Here

TOP

Related Classes of org.auraframework.def.AttributeDefRef

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.