Package org.auraframework.service

Examples of org.auraframework.service.DefinitionService


    public AuraComponentServiceImplTest(String name) {
        super(name);
    }

    public void testAuraComponentService() {
        DefinitionService ds = Aura.getDefinitionService();
        assertTrue(ds instanceof DefinitionServiceImpl);
    }
View Full Code Here


    @Override
    public void writeElement(ThemeDef def, Appendable out) throws IOException {
        try {
            Map<String, Object> attributes = ImmutableMap.<String, Object>of("def", def);
            DefinitionService defService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> tmplDesc = defService.getDefDescriptor("auradev:saveTheme", ComponentDef.class);
            Component tmpl = Aura.getInstanceService().getInstance(tmplDesc, attributes);
            Aura.getRenderingService().render(tmpl, out);
        } catch (QuickFixException x) {
            throw new AuraError(x);
        }
View Full Code Here

    }

    @Override
    public ComponentConfig provide() throws QuickFixException {
        String name = getUniqueName();
        DefinitionService ds = Aura.getDefinitionService();
        DefDescriptor<ComponentDef> newDesc = ds.getDefDescriptor("builderComponent:"+name, ComponentDef.class);
        ComponentDefRefBuilder contents = Aura.getBuilderService().getComponentDefRefBuilder();
        contents.setDescriptor(ds.getDefDescriptor("componentTest:builderInjected", ComponentDef.class));
        ComponentDefBuilder builder = Aura.getBuilderService().getComponentDefBuilder();
        builder.setDescriptor(newDesc);
        builder.setDescription("A custom built component");
        List<ComponentDefRef> body = Lists.newArrayList();
        body.add(contents.build());
        builder.setFacet("body", body);
        ds.getDefRegistry().addLocalDef(builder.build());
        ComponentConfig cc = new ComponentConfig();
        cc.setDescriptor(newDesc);
        return cc;
    }
View Full Code Here

        super(name);
    }

    public void testGetNamespaceSource() {
        MasterDefRegistry reg = Aura.getContextService().getCurrentContext().getDefRegistry();
        DefinitionService defService = Aura.getDefinitionService();
        DefDescriptor<NamespaceDef> descriptor = defService.getDefDescriptor("test", NamespaceDef.class);
        Source<NamespaceDef> src = reg.getSource(descriptor);
        assertNotNull(src);

        descriptor = DefDescriptorImpl.getInstance("nonExistantNamespace", NamespaceDef.class);
        src = reg.getSource(descriptor);
View Full Code Here

        src = reg.getSource(descriptor);
        assertNull(src);
    }

    public void testGetNamespaceDef() throws Exception {
        DefinitionService defService = Aura.getDefinitionService();
        DefDescriptor<NamespaceDef> descriptor = defService.getDefDescriptor("aura", NamespaceDef.class);
        NamespaceDef def = descriptor.getDef();
        assertNotNull(def);

        descriptor = defService.getDefDescriptor("nonExistantNamespace", NamespaceDef.class);
        try {
            descriptor.getDef();
            fail("Expected Exception when trying to compile non-existent NamespaceDef");
        } catch (Exception e) {
            checkExceptionFull(e, DefinitionNotFoundException.class,
                    "No NAMESPACE named markup://nonExistantNamespace found");
        }

        descriptor = defService.getDefDescriptor("namespaceDefTest", NamespaceDef.class);
        def = descriptor.getDef();
        assertNotNull(def);
        assertEquals("red", def.getStyleTokens().get("FOO"));
    }
View Full Code Here

        assertEquals("red", def.getStyleTokens().get("FOO"));
    }

    /* tokens functionality deprecated by themes */
    public void _testStyleTokens() throws Exception {
        DefinitionService defService = Aura.getDefinitionService();
        StyleDef styleDef = defService.getDefinition("namespaceDefTest.testStyleTokens", StyleDef.class);
        assertEquals(
                ".namespaceDefTestTestStyleTokens {background-color:red; color:FOOL; border-color:black; " +
                        "background:-webkit-linear-gradient(top, hsl(0, 80%, 70%), #bada55); " +
                        "background:linear-gradient(to bottom, hsl(0, 80%, 70%), #bada55)}",
                styleDef.getCode());
View Full Code Here

    public void writeElement(ComponentDef def, Appendable out) throws IOException {
        try {
            Map<String, Object> attributes = Maps.newHashMap();
            attributes.put("def", def);
            InstanceService instanceService = Aura.getInstanceService();
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> tmplDesc = definitionService.getDefDescriptor("auradev:saveComponent",
                    ComponentDef.class);
            Component tmpl = instanceService.getInstance(tmplDesc, attributes);
            Aura.getRenderingService().render(tmpl, out);
        } catch (QuickFixException x) {
            throw new AuraError(x);
View Full Code Here

    public void writeElement(ApplicationDef def, Appendable out) throws IOException {
        try {
            Map<String, Object> attributes = Maps.newHashMap();
            attributes.put("def", def);
            InstanceService instanceService = Aura.getInstanceService();
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> tmplDesc = definitionService.getDefDescriptor("auradev:saveApplication",
                    ComponentDef.class);
            Component tmpl = instanceService.getInstance(tmplDesc, attributes);
            Aura.getRenderingService().render(tmpl, out);
        } catch (QuickFixException x) {
            throw new AuraError(x);
View Full Code Here

        }

        AuraContext context = getContext("is");

        try {
            DefinitionService definitionService = Aura.getDefinitionService();
            DefDescriptor<ComponentDef> descriptor = definitionService.getDefDescriptor(tag,
                    ComponentDef.class);

            Map<String, Object> actionAttributes = Maps.newHashMap();
            Map<String, String> actionEventHandlers = Maps.newHashMap();

            ComponentDef componentDef = descriptor.getDef();
            if(attributes!=null) {
              for (Map.Entry<String, Object> entry : attributes.entrySet()) {
                  String key = entry.getKey();

                  AttributeDef attributeDef = componentDef.getAttributeDef(key);
                  if (attributeDef != null) {
                      String name = attributeDef.getName();
                      actionAttributes.put(name, entry.getValue());
                  } else {
                      RegisterEventDef eventDef = componentDef.getRegisterEventDefs().get(key);
                      if (eventDef != null) {
                          // Emit component.addHandler() wired to special global scope value provider
                          String name = eventDef.getAttributeName();
                          actionEventHandlers.put(name, (String) entry.getValue());
                      } else {
                          throw new AuraRuntimeException(String.format("Unknown attribute or event %s - %s", tag, key));
                      }
                  }
              }
            }

            try {

                StringBuilder jsonEventHandlers = null;
                if (!actionEventHandlers.isEmpty()) {
                    // serialize registered event handlers into js object
                    jsonEventHandlers = new StringBuilder();
                    Json.serialize(actionEventHandlers, jsonEventHandlers);
                }

                StringBuilder init = new StringBuilder();

                if (useAsync) {
                    // uses newComponentAsync to create component
                    StringBuilder jsonAttributes = new StringBuilder();
                    Json.serialize(actionAttributes, jsonAttributes);

                    // set event handlers to either js "undefined" or object of event and handler names
                    String eventHandlers = jsonEventHandlers != null ? jsonEventHandlers.toString() : "undefined";
                    String def = String.format(COMPONENT_DEF_TEMPLATE, tag, jsonAttributes.toString(), localId);
                    String newComponentScript = String.format(ASYNC_INJECTION_TEMPLATE, def, locatorDomId, eventHandlers);

                    init.append(newComponentScript);

                } else {
                    // config printed onto HTML page

                    // mark injectee component as loaded
                    // only when not using async because component defs will be printed onto HTML
                    definitionService.updateLoaded(descriptor);

                    ControllerDef componentControllerDef = definitionService.getDefDescriptor("aura://ComponentController",
                            ControllerDef.class).getDef();

                    Map<String, Object> paramValues = Maps.newHashMap();
                    paramValues.put("name", descriptor.getQualifiedName());
                    paramValues.put("attributes", actionAttributes);
View Full Code Here

    private static boolean isSupportedClient(Client client) {
        return client == null || (client.getType() != Type.IE6 && client.getType() != Type.OTHER);
    }

    private DefDescriptor<ApplicationDef> getApplicationDescriptor(String application) {
        DefinitionService definitionService = Aura.getDefinitionService();
        return definitionService.getDefDescriptor(application, ApplicationDef.class);
    }
View Full Code Here

TOP

Related Classes of org.auraframework.service.DefinitionService

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.