Package org.auraframework.def

Examples of org.auraframework.def.BaseComponentDef


            RootDefinition rootDef = (RootDefinition) definition;
            for (AttributeDef attribute : rootDef.getAttributeDefs().values()) {
                attributes.add(new AttributeModel(attribute));
            }
            if (definition instanceof BaseComponentDef) {
                BaseComponentDef cmpDef = (BaseComponentDef) definition;
                for (RegisterEventDef reg : cmpDef.getRegisterEventDefs().values()) {
                    events.add(new AttributeModel(reg));
                }
                for (EventHandlerDef handler : cmpDef.getHandlerDefs()) {
                    handledEvents.add(new AttributeModel(handler));
                }
                for (DefDescriptor<InterfaceDef> intf : cmpDef.getInterfaces()) {
                    interfaces.add(intf.getNamespace() + ":" + intf.getName());
                }
                DefDescriptor<?> superDesc = cmpDef.getExtendsDescriptor();
                if (superDesc != null) {
                    theSuper = superDesc.getNamespace() + ":" + superDesc.getName();
                } else {
                    theSuper = null;
                }
                isAbstract = cmpDef.isAbstract();
                isExtensible = cmpDef.isExtensible();

            } else if (definition instanceof EventDef) {
                EventDef eventDef = (EventDef) definition;
                DefDescriptor<?> superDesc = eventDef.getExtendsDescriptor();
                if (superDesc != null) {
View Full Code Here


    @Override
    public void write(Object value, Map<String, Object> componentAttributes, Appendable out) throws IOException {
        try {
            InstanceService instanceService = Aura.getInstanceService();
            RenderingService renderingService = Aura.getRenderingService();
            BaseComponentDef def = (BaseComponentDef) value;

            ComponentDef templateDef = def.getTemplateDef();
            Map<String, Object> attributes = Maps.newHashMap();

            StringBuilder sb = new StringBuilder();
            writeHtmlStyles(AuraServlet.getStyles(), sb);
            attributes.put("auraStyleTags", sb.toString());
            AuraContext context = Aura.getContextService().getCurrentContext();

            DefDescriptor<StyleDef> styleDefDesc = templateDef.getStyleDescriptor();
            if (styleDefDesc != null) {
                attributes.put("auraInlineStyle", styleDefDesc.getDef().getCode());
            }

            String contextPath = context.getContextPath();
            Mode mode = context.getMode();

            if (mode.allowLocalRendering() && def.isLocallyRenderable()) {
                DefType defType = def.getDescriptor().getDefType();
                BaseComponent<?, ?> cmp = null;

                if (defType == DefType.APPLICATION) {
                    cmp = (BaseComponent<?, ?>) instanceService.getInstance((ApplicationDef) def, componentAttributes);
                } else {
                    cmp = (BaseComponent<?, ?>) instanceService.getInstance((ComponentDef) def, componentAttributes);
                }

                attributes.put("body", Lists.<BaseComponent<?, ?>> newArrayList(cmp));
                attributes.put("bodyClass", "");
                attributes.put("defaultBodyClass", "");
                attributes.put("autoInitialize", "false");
            } else {
                if (ManifestUtil.isManifestEnabled()) {
                    attributes.put("manifest", ManifestUtil.getManifestUrl());
                }

                sb.setLength(0);
                writeHtmlScripts(AuraServlet.getBaseScripts(context), sb);
                attributes.put("auraBaseScriptTags", sb.toString());

                sb.setLength(0);
                writeHtmlScripts(AuraServlet.getNamespacesScripts(context), true, sb);
                attributes.put("auraNamespacesScriptTags", sb.toString());

                if(mode != Mode.PROD && mode != Mode.PRODDEBUG &&
                        Aura.getContextService().getCurrentContext().getIsDebugToolEnabled()) {
                    attributes.put("auraInitBlock", "<script>var debugWindow=window.open('/aura/debug.cmp','Aura Debug Tool','width=900,height=305,scrollbars=0,location=0,toolbar=0,menubar=0');$A.util.setDebugToolWindow(debugWindow);</script>");


                }

                Map<String, Object> auraInit = Maps.newHashMap();
                if (componentAttributes != null && !componentAttributes.isEmpty()) {
                    auraInit.put("attributes", componentAttributes);
                }
                auraInit.put("descriptor", def.getDescriptor());
                auraInit.put("deftype", def.getDescriptor().getDefType());
                auraInit.put("host", contextPath);

                StringBuilder contextWriter = new StringBuilder();
                Aura.getSerializationService().write(context, null, AuraContext.class, contextWriter, "HTML");
                auraInit.put("context", new Literal(contextWriter.toString()));
View Full Code Here

        builder.setDescriptor(descriptor);
        builder.setLocation(descriptor.getQualifiedName(), -1);

        DefDescriptor<ComponentDef> compDesc = DefDescriptorImpl.getAssociateDescriptor(descriptor, ComponentDef.class,
                DefDescriptor.MARKUP_PREFIX);
        BaseComponentDef componentDef = null;
        if (compDesc.exists()) {
            componentDef = compDesc.getDef();
        } else {
            DefDescriptor<ApplicationDef> appDesc = DefDescriptorImpl.getAssociateDescriptor(descriptor,
                    ApplicationDef.class, DefDescriptor.MARKUP_PREFIX);
            componentDef = appDesc.getDef();
        }

        if (componentDef == null) {
            DefDescriptor<ComponentDef> layoutDesc = DefDescriptorImpl.getAssociateDescriptor(descriptor,
                    ComponentDef.class, "layout");
            componentDef = layoutDesc.getDef();
        }

        Map<String, ActionDef> flattened = Maps.newHashMap();

        for (DefDescriptor<ControllerDef> delegate : componentDef.getControllerDefDescriptors()) {
            ControllerDef c = delegate.getDef();
            for (Map.Entry<String, ? extends ActionDef> e : c.getActionDefs().entrySet()) {
                ActionDef a = flattened.get(e.getKey());
                if (a != null) {
                    // TODO: server and client actions by same name, map needs
View Full Code Here

            AuraContext context = Aura.getContextService().getCurrentContext();
            InstanceService instanceService = Aura.getInstanceService();
            RenderingService renderingService = Aura.getRenderingService();
            BaseComponent<?, ?> cmp = (BaseComponent<?, ?>) value;
            BaseComponentDef def = cmp.getDescriptor().getDef();

            ComponentDef templateDef = def.getTemplateDef();
            Map<String, Object> attributes = Maps.newHashMap();

            StringBuilder sb = new StringBuilder();
            writeHtmlStyles(AuraServlet.getStyles(), sb);
            attributes.put("auraStyleTags", sb.toString());
            sb.setLength(0);
            writeHtmlScripts(AuraServlet.getScripts(), sb);
            DefDescriptor<StyleDef> styleDefDesc = templateDef.getStyleDescriptor();
            if (styleDefDesc != null) {
                attributes.put("auraInlineStyle", styleDefDesc.getDef().getCode());
            }

            String contextPath = context.getContextPath();
            Mode mode = context.getMode();

            if (mode.allowLocalRendering() && def.isLocallyRenderable()) {

                DefType defType = def.getDescriptor().getDefType();

                if (defType == DefType.APPLICATION) {
                    cmp = (BaseComponent<?, ?>) instanceService.getInstance((ApplicationDef) def, componentAttributes);
                } else {
                    cmp = (BaseComponent<?, ?>) instanceService.getInstance((ComponentDef) def, componentAttributes);
                }

                attributes.put("body", Lists.<BaseComponent<?, ?>> newArrayList(cmp));
                attributes.put("bodyClass", "");
                attributes.put("autoInitialize", "false");

                Component template = instanceService.getInstance(templateDef.getDescriptor(), attributes);

                renderingService.render(template, out);
            } else {

                attributes.put("auraScriptTags", sb.toString());
                Map<String, Object> auraInit = Maps.newHashMap();
                if (componentAttributes != null && !componentAttributes.isEmpty()) {
                    auraInit.put("attributes", componentAttributes);
                }
                auraInit.put("descriptor", def.getDescriptor());
                auraInit.put("deftype", def.getDescriptor().getDefType());
                auraInit.put("host", contextPath);

                attributes.put("autoInitialize", "false");
                attributes.put("autoInitializeSync", "true");
View Full Code Here

                    stack.remove(descriptor);
                    throw new DefinitionNotFoundException(descriptor, l, stack.toString());
                }
                // get client libs
                if (cc.clientLibs != null && cd.def instanceof BaseComponentDef) {
                    BaseComponentDef baseComponent = (BaseComponentDef) cd.def;
                    baseComponent.addClientLibs(cc.clientLibs);
                }
            }

            Set<DefDescriptor<?>> newDeps = Sets.newHashSet();
            cd.def.appendDependencies(newDeps);
View Full Code Here

    public void render(BaseComponent<?, ?> component, Appendable out) throws QuickFixException, IOException {
        Aura.getContextService().assertEstablished();

        BaseComponent<?, ?> renderable = null;
        BaseComponent<?, ?> tmpRenderable = component;
        BaseComponentDef componentDef = null;
        RendererDef rendererDef = null;

        while (tmpRenderable != null) {
            componentDef = tmpRenderable.getDescriptor().getDef();
            if (rendererDef == null) {
                rendererDef = componentDef.getLocalRendererDef();
                if (rendererDef == null && componentDef.getRendererDescriptor() != null) {
                    break;
                }
                renderable = tmpRenderable;
            }
View Full Code Here

        createSuper();
        context.getInstanceStack().clearAttributeName("$");

        validateAttributes();

        BaseComponentDef def = getComponentDef();

        def.retrieveLabels();

        DefDescriptor<RendererDef> rendererDesc = def.getRendererDescriptor();
        if ((rendererDesc != null && rendererDesc.getDef().isLocal())) {
            hasLocalDependencies = true;
        }
        context.registerComponent(this);
    }
View Full Code Here

    public void serialize(Json json) throws IOException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> oldComponent = context.setCurrentComponent(this);

        try {
            BaseComponentDef def = getComponentDef();

            json.writeMapBegin();
            //
            // Be very careful here. descriptor != def.getDescriptor().
            // This is 'case normalizing', as the client is actually case
            // sensitive for descriptors (ugh!).
            //
            json.writeMapEntry("componentDef", def.getDescriptor());
            if (!descriptor.equals(originalDescriptor)) {
                json.writeMapEntry("original", originalDescriptor);
            }
            json.writeMapEntry("creationPath", getPath());

            if ((attributeSet.getValueProvider() == null || hasProvidedAttributes) && !attributeSet.isEmpty()) {
                json.writeMapEntry("attributes", attributeSet);
            }

            if (def.getRendererDescriptor() != null) {
                RendererDef rendererDef = def.getRendererDescriptor().getDef();
                if (rendererDef.isLocal()) {
                    StringWriter sw = new StringWriter();
                    rendererDef.render(this, sw);
                    // Not writing directly to json.appendable because then it wouldn't get escaped.
                    // ideally Json would have a FilterWriter that escapes that we could use here.
View Full Code Here

    @Override
    public void reinitializeModel() throws QuickFixException {
        //
        // This is a visitor pattern, implemented here with a hardwire.
        //
        BaseComponentDef def = descriptor.getDef();
        if (componentArrType == null) {
            componentArrType = Aura.getDefinitionService().getDefDescriptor("aura://Aura.Component[]", TypeDef.class);
        }
       
        if(componentDefRefArrayType == null) {
          componentDefRefArrayType = Aura.getDefinitionService().getDefDescriptor("aura://Aura.ComponentDefRef[]", TypeDef.class);
        }

        createModel();

        I zuper = getSuper();
        if (zuper != null) {
            zuper.reinitializeModel();
        }
        //
        // Walk all attributes, pushing the reinitialize model in to those as well.
        //
        for (Map.Entry<DefDescriptor<AttributeDef>, AttributeDef> foo : def.getAttributeDefs().entrySet()) {
            AttributeDef attr = foo.getValue();
            DefDescriptor<?> typeDesc;
            if (attr instanceof AttributeDefImpl) {
                AttributeDefImpl attri = (AttributeDefImpl) attr;
                typeDesc = attri.getTypeDesc();
View Full Code Here

            DocumentationDef docDef = rootDef.getDocumentationDef();
            doc = docDef != null ? new DocumentationDefModel(docDef) : null;

            if (definition instanceof BaseComponentDef) {
                BaseComponentDef cmpDef = (BaseComponentDef) definition;
                for (RegisterEventDef reg : cmpDef.getRegisterEventDefs().values()) {
                    if (ReferenceTreeModel.hasAccess(reg)) {
                        events.add(new AttributeModel(reg));
                    }
                }

                for (EventHandlerDef handler : cmpDef.getHandlerDefs()) {
                    handledEvents.add(new AttributeModel(handler));
                }

                for (DefDescriptor<InterfaceDef> intf : cmpDef.getInterfaces()) {
                    if (ReferenceTreeModel.hasAccess(intf.getDef())) {
                        interfaces.add(intf.getNamespace() + ":" + intf.getName());
                    }
                }

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

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

            } else if (definition instanceof EventDef) {
                EventDef eventDef = (EventDef) definition;
                DefDescriptor<?> superDesc = eventDef.getExtendsDescriptor();
                if (superDesc != null) {
View Full Code Here

TOP

Related Classes of org.auraframework.def.BaseComponentDef

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.