Package org.auraframework.instance

Examples of org.auraframework.instance.ComponentConfig


    @Override
    public ComponentConfig provide() throws QuickFixException {
        BaseComponent<?, ?> component = Aura.getContextService().getCurrentContext().getCurrentComponent();
       
        ComponentConfig config = new ComponentConfig();
        config.setDescriptor(Aura.getDefinitionService().getDefDescriptor("markup://ui:outputText", ComponentDef.class));
        String text = (String)component.getAttributes().getValue("providedAttribute");
        Map<String, Object> attributes = Maps.newHashMap();
        attributes.put("value", text);
        config.setAttributes(attributes);
       
        //Tamper the current component and remove unwanted attributes
        removeAttribute(component, "providedAttribute");
        return config;
    }
View Full Code Here


public class InputOptionProvider implements ComponentConfigProvider {
    @Override
    public ComponentConfig provide() throws QuickFixException {
        BaseComponent<?, ?> component = Aura.getContextService().getCurrentContext().getCurrentComponent();
        AttributeSet attributes = component.getAttributes();
        ComponentConfig componentConfig = new ComponentConfig();
        DefDescriptor<ComponentDef> defDescriptor = DefDescriptorImpl.getInstance(COMPONENT_UI_OUTPUTTEXT,
                ComponentDef.class);

        String type = (String) attributes.getValue("type");
        if (TYPE_UI_INPUTCHECKBOX.equalsIgnoreCase(type)) {
            defDescriptor = DefDescriptorImpl.getInstance(COMPONENT_UI_INPUTCHECKBOX, ComponentDef.class);
        } else if (TYPE_UI_INPUTRADI.equalsIgnoreCase(type)) {
            defDescriptor = DefDescriptorImpl.getInstance(COMPONENT_UI_INPUTRADIO, ComponentDef.class);
        } else if (TYPE_UI_INPUTSELECTOPTION.equalsIgnoreCase(type)) {
            defDescriptor = DefDescriptorImpl.getInstance(COMPONENT_UI_INPUTSELECTOPTION, ComponentDef.class);
        } else {
            Map<String, Object> passingAttrs = new HashMap<String, Object>();
            passingAttrs.put(VALUE_ATTRIBUTE_NAME, "Error in " + component.getDescriptor().getQualifiedName()
                    + ": invalid type " + type);
            componentConfig.setAttributes(passingAttrs);
        }
        componentConfig.setDescriptor(defDescriptor);
        return componentConfig;
    }
View Full Code Here

public class ListProvider implements ComponentConfigProvider {

    @Override
    public ComponentConfig provide() throws QuickFixException {
        BaseComponent<?, ?> component = Aura.getContextService().getCurrentContext().getCurrentComponent();
        ComponentConfig cc = new ComponentConfig();
        Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
        // so now we're relying on the fact that the data provider's model has items on it, thats fantastic.
        m.put("items", component.getAttributes().getValue(new PropertyReferenceImpl("dataProvider.0.m.items", null)));
        cc.setAttributes(m);
        return cc;
    }
View Full Code Here

public class IterationProvider implements ComponentConfigProvider {
    @Override
    public ComponentConfig provide() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();
        ComponentConfig cc = new ComponentConfig();
        List<Component> components = Lists.newArrayList();
        InstanceStack iStack = context.getInstanceStack();
        Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
        m.put("body", components);
        cc.setAttributes(m);

        AttributeSet atts = component.getAttributes();
        Iterable<?> value = atts.getValue("items", Iterable.class);
        if (value != null) {
            List<?> items = Lists.newArrayList(value);
View Full Code Here

    @Override
    public ComponentConfig provide() throws QuickFixException {
        AuraContext context = Aura.getContextService().getCurrentContext();
        BaseComponent<?, ?> component = context.getCurrentComponent();
        InstanceStack iStack = context.getInstanceStack();
        ComponentConfig cc = new ComponentConfig();
        List<Component> components = new ArrayList<Component>();
        Map<String, Object> m = Maps.newHashMapWithExpectedSize(1);
        m.put("body", components);
        cc.setAttributes(m);

        AttributeSet atts = component.getAttributes();
        m.put("template", atts.getValue("body"));
        Object o = atts.getValue("isTrue");
        Boolean isTrue = (Boolean) o;
View Full Code Here

                            descriptor), root.getLocation());
                    }
                }

                if (providerDef.isLocal()) {
                    ComponentConfig config = providerDef.provide(intfDescriptor);
                    if (config != null) {
                        ProviderDef remoteProviderDef = root.getProviderDef();
                        if (remoteProviderDef == null || remoteProviderDef.isLocal()) {
                            hasLocalDependencies = true;
                        }

                        DefDescriptor<ComponentDef> d = config.getDescriptor();
                        if (d != null) {
                            descriptor = d;
                        }

                        try {
                            if (descriptor.getDefType() != DefType.COMPONENT) {
                                throw new AuraRuntimeException(String.format("%s is not a component", descriptor));
                            }

                            ComponentDef c = descriptor.getDef();
                            if (c.isAbstract()) {
                                throw new AuraRuntimeException(String.format("%s cannot be instantiated directly.",
                                        descriptor));
                            }
                           
                            // new component may have its own controllerdef so add that one
                            ControllerDef cd = c.getControllerDef();
                            if (cd != null) {
                                this.valueProviders.put(ValueProviderType.CONTROLLER.getPrefix(), cd);
                            }
                        } catch (DefinitionNotFoundException dnfe) {
                            throw new AuraRuntimeException(String.format("%s did not provide a valid component",
                                    providerDef.getDescriptor()), dnfe);
                        }

                        attributeSet.setRootDefDescriptor(descriptor);

                        Map<String, Object> providedAttributes = config.getAttributes();
                        if (providedAttributes != null) {
                            // if there is a remote provider and attributes were
                            // set, we assume/pray the remote provider does too
                            hasProvidedAttributes = true;
                            attributeSet.startTrackingDirtyValues();
View Full Code Here

        super.validateDefinition();
    }

    @Override
    public ComponentConfig provide(DefDescriptor<? extends RootDefinition> intfDescriptor) throws QuickFixException {
        ComponentConfig config = null;
        LoggingService loggingService = Aura.getLoggingService();
        loggingService.stopTimer(LoggingService.TIMER_AURA);
        loggingService.startTimer("java");
        try {
            if (configProvider != null) {
                config = configProvider.provide();
                loggingService.incrementNum("JavaCallCount");
            } else if (descriptorProvider != null) {
                config = new ComponentConfig();
                config.setDescriptor(descriptorProvider.provide());
                loggingService.incrementNum("JavaCallCount");
            }
        } catch (Exception e) {
            throw AuraExceptionUtil.wrapExecutionException(e, this.location);
        } finally {
View Full Code Here

        return config;
    }

    @Override
    public ComponentConfig provide(ComponentDefRefBuilder ref) throws QuickFixException {
        ComponentConfig config = null;
        LoggingService loggingService = Aura.getLoggingService();
        loggingService.stopTimer(LoggingService.TIMER_AURA);
        loggingService.startTimer("java");

        try {
View Full Code Here

    protected <T> T getValue(Object object, Class<T> retClass) throws QuickFixException {
        if (object != null && ComponentConfig.class.equals(retClass)) {
            if (!(object instanceof Map)) {
                throw new InvalidDefinitionException("Mock Provider expects (descriptor and/or attributes) or (configProvider)", getLocation());
            }
            ComponentConfig config;
           
            String configProvider = (String)((Map<?, ?>) object).get("configProvider");
            //If a config provider is specified, defer provide until later
            if(configProvider!=null && !configProvider.isEmpty()){
                config = null;
            }else{//Else determine the mock component to provide
                config = new ComponentConfig();
                DefDescriptor<ComponentDef> cdd = getDescriptor((String) ((Map<?, ?>) object).get("descriptor"),
                        ComponentDef.class);
                if (cdd != null) {
                    config.setDescriptor(cdd);
                }
                Map<String, Object> attributes = (Map<String, Object>) ((Map<?, ?>) object).get("attributes");
                if (attributes != null) {
                    config.setAttributes(attributes);
                }
            }
            return (T) config;
        } else {
            return super.getValue(object, retClass);
View Full Code Here

                return new Returns<T>(null){
                    @SuppressWarnings("unchecked")
                    @Override
                    public T answer() throws Throwable {
                        String mockProvider = configProvider;
                        ComponentConfig config;
                        if(configProvider.startsWith("java://")){
                            mockProvider = configProvider.substring("java://".length());
                        }
                        try{
                            Class<?> providerClass = Class.forName(mockProvider);
View Full Code Here

TOP

Related Classes of org.auraframework.instance.ComponentConfig

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.