Package org.auraframework.def

Examples of org.auraframework.def.EventDef


                }
                isAbstract = cmpDef.isAbstract();
                isExtensible = cmpDef.isExtensible();

            } else if (definition instanceof EventDef) {
                EventDef eventDef = (EventDef) definition;
                DefDescriptor<?> superDesc = eventDef.getExtendsDescriptor();
                if (superDesc != null) {
                    theSuper = superDesc.getNamespace() + ":" + superDesc.getName();
                } else {
                    theSuper = null;
                }

                type = eventDef.getEventType().name();
                isExtensible = true;
                isAbstract = false;
            } else if (definition instanceof LibraryDef) {
                theSuper = null;
                isExtensible = false;
View Full Code Here


    }

    @Override
    public void serialize(Json json) throws IOException {
        try {
            EventDef eventDef = descriptor.getDef();
            json.writeMapBegin();
            json.writeMapEntry("eventDef", eventDef);
            json.writeMapEntry("attributeName", attName);
            json.writeMapEntry("isGlobal", isGlobal);
            json.writeMapEnd();
View Full Code Here

     */
    @Override
    public void validateReferences() throws QuickFixException {
        super.validateReferences();
       
        EventDef event = getEventDescriptor().getDef();
        if (event == null) {
            throw new InvalidDefinitionException("Cannot register event of type " + getEventDescriptor(), getLocation());
        }
       
        if (!event.getEventType().canBeFired()) {
            throw new InvalidDefinitionException("Cannot fire event of type: " + getEventDescriptor(), getLocation());
        }
       
        AuraContext context = Aura.getContextService().getCurrentContext();
        DefDescriptor<?> referencingDesc = context.getCurrentCallingDescriptor();
View Full Code Here

    public void validateReferences() throws QuickFixException {
        super.validateReferences();

        // MasterDefRegistry reg =
        // Aura.getContextService().getCurrentContext().getDefRegistry();
        EventDef locationChangeDef = getLocationChangeEventDescriptor().getDef();
        if (!locationChangeDef.isInstanceOf(Aura.getDefinitionService().getDefDescriptor("aura:locationChange",
                EventDef.class))) {
            throw new InvalidDefinitionException(String.format("%s must extend aura:locationChange",
                    locationChangeDef.getDescriptor()), getLocation());
        }

        for (DefDescriptor<ThemeDef> themeDescriptor : themeDescriptors) {
            // the theme must not be a component theme. otherwise, it would allow users to circumvent var
            // cross-reference validation (regular themes enforce that cross references are defined in the same file,
View Full Code Here

        }
    }

    @Override
    public void validateReferences() throws QuickFixException {
      EventDef event = null;
        if (name == null && descriptor != null) {
            event = descriptor.getDef();
            if (event == null) {
                throw new InvalidReferenceException(String.format("aura:handler has invalid event attribute value: %s",
                        descriptor), getLocation());
            }
           
            if (!event.getEventType().equals(EventType.APPLICATION)) {
                throw new InvalidReferenceException(
                        "A aura:handler that specifies an event=\"\" attribute must handle an application event. Either change the aura:event to have type=\"APPLICATION\" or alternately change the aura:handler to specify a name=\"\" attribute.",
                        getLocation());
            }
        } else if (name != null && descriptor == null && value == null) {
            RootDefinition parentDef = parentDescriptor.getDef();
            Map<String, RegisterEventDef> events = parentDef.getRegisterEventDefs();
            RegisterEventDef registerEvent = events.get(name);
            if (registerEvent == null) {
                throw new InvalidReferenceException(String.format("aura:handler has invalid name attribute value: %s",
                        name), getLocation());
            }
           
            event = registerEvent.getDescriptor().getDef();
            if (!event.getEventType().equals(EventType.COMPONENT)) {
                throw new InvalidReferenceException(
                        "A aura:handler that specifies a name=\"\" attribute must handle a component event. Either change the aura:event to have type=\"COMPONENT\" or alternately change the aura:handler to specify an event=\"\" attribute.",
                        getLocation());
            }
        }
View Full Code Here

            throw new AuraUnhandledException("unhandled exception", e);
        }
    }

    protected EventDef getSuperDef() throws QuickFixException {
        EventDef ret = null;
        if (getExtendsDescriptor() != null) {
            ret = getExtendsDescriptor().getDef();
        }
        return ret;
    }
View Full Code Here

    }

    @Override
    public void validateReferences() throws QuickFixException {
        if (extendsDescriptor != null) {
            EventDef extended = getExtendsDescriptor().getDef();
            if (extended == null) {
                throw new InvalidDefinitionException(String.format("Event %s cannot extend %s", getDescriptor(),
                        getExtendsDescriptor()), getLocation());
            }
           
            if (extended.getEventType() != getEventType()) {
                throw new InvalidDefinitionException(String.format("Event %s cannot extend %s", getDescriptor(),
                        getExtendsDescriptor()), getLocation());
            }
           
            MasterDefRegistry registry = Aura.getDefinitionService().getDefRegistry();
View Full Code Here

    @Override
    public boolean isInstanceOf(DefDescriptor<? extends RootDefinition> other) {
        if (other.equals(descriptor)) {
            return true;
        }
        EventDef zuper = null;
        try {
            zuper = getSuperDef();
            if (zuper != null) {
                return zuper.isInstanceOf(other);
            }
        } catch (QuickFixException e) {
            throw new AuraUnhandledException("Unable to find super-class", e);
        }
        return false;
View Full Code Here

                isAbstract = cmpDef.isAbstract();
                isExtensible = cmpDef.isExtensible();

            } else if (definition instanceof EventDef) {
                EventDef eventDef = (EventDef) definition;
                DefDescriptor<?> superDesc = eventDef.getExtendsDescriptor();
                if (superDesc != null) {
                    theSuper = superDesc.getNamespace() + ":" + superDesc.getName();
                } else {
                    theSuper = null;
                }

                type = eventDef.getEventType().name();
                isExtensible = true;
                isAbstract = false;
            } else if (definition instanceof LibraryDef) {
                theSuper = null;
                isExtensible = false;
View Full Code Here

    public void testAbstractEvent() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<EventDef> descriptor = DefDescriptorImpl.getInstance("aura:testevent", EventDef.class);
        StringSource<EventDef> source = new StringSource<>(descriptor,
                "<aura:event type='component' abstract='true'></aura:event>", "myID", Format.XML);
        EventDef ed = parser.parse(descriptor, source);
        try {
            ed.validateDefinition();
            fail("Should have thrown AuraRuntimeException for creating an abstract event");
        } catch (Exception e) {
            checkExceptionContains(e, InvalidDefinitionException.class,
                    "Invalid attribute \"abstract\"");
        }
View Full Code Here

TOP

Related Classes of org.auraframework.def.EventDef

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.