Package de.sciss.util

Examples of de.sciss.util.ParamSpace$Translator


        Messages messages = mockMessages();
        Locale locale = Locale.ENGLISH;
        Class propertyType = Map.class;
        TranslatorSource ts = mockTranslatorSource();
        FormSupport fs = mockFormSupport();
        Translator translator = mockTranslator("maptrans", Map.class);
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "My Label";
        String message = "Formatted Message";
        AnnotationProvider ap = mockAnnotationProvider(null);

        train_findByType(ts, propertyType, translator);

        train_getFormValidationId(fs, "myform");

        train_contains(messages, "myform-myfield-maptrans-message", true);
        train_getMessageFormatter(messages, "myform-myfield-maptrans-message", formatter);

        train_getLabel(field, label);
        train_format(formatter, message, label);

        translator.render(field, message, writer, fs);

        replay();

        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, null, fs);
View Full Code Here


        ComponentResources resources = mockComponentResources();
        FieldComponent field = mockFieldComponent();
        Messages messages = mockMessages();
        TranslatorSource ts = mockTranslatorSource();
        FormSupport fs = mockFormSupport();
        Translator translator = mockTranslator("map", Map.class);
        Messages globalMessages = mockMessages();
        MessageFormatter formatter = mockMessageFormatter();
        MarkupWriter writer = mockMarkupWriter();
        String label = "My Label";
        String message = "Formatted Message";

        train_getComponent(resources, field);
        train_getId(resources, "myfield");
        train_getContainerMessages(resources, messages);

        train_get(ts, "map", translator);

        train_getFormValidationId(fs, "myform");

        train_contains(messages, "myform-myfield-map-message", false);
        train_contains(messages, "myfield-map-message", false);
        train_getMessageKey(translator, "mykey");
        train_getMessageFormatter(globalMessages, "mykey", formatter);

        train_getLabel(field, label);
        train_format(formatter, message, label);

        translator.render(field, message, writer, fs);

        replay();

        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, globalMessages, fs);
View Full Code Here

        return newMock(FieldTranslator.class);
    }

    protected final Translator mockTranslator(String name, Class type)
    {
        Translator translator = mockTranslator();

        train_getName(translator, name);
        train_getType(translator, type);

        return translator;
View Full Code Here

        Defense.notNull(locale, "locale");


        if (propertyType == null) return null;

        Translator translator = translatorSource.findByType(propertyType);

        if (translator == null) return null;

        return createTranslator(field, overrideId, overrideMessages, locale, translator);
    }
View Full Code Here

        Defense.notNull(resources, "resources");
        Defense.notBlank(translatorName, "translatorName");

        Field field = (Field) resources.getComponent();

        Translator translator = translatorSource.get(translatorName);

        return createTranslator(field, resources.getId(), resources.getContainerMessages(), resources.getLocale(),
                                translator);
    }
View Full Code Here

    }

    @Test
    public void found_translator_by_name()
    {
        Translator translator = mockTranslator("mock", String.class);

        replay();

        TranslatorSource source = new TranslatorSourceImpl(newConfiguration(String.class, translator));
View Full Code Here

    }

    @Test
    public void key_and_type_mismatch()
    {
        Translator t = mockTranslator();

        train_getType(t, Long.class);

        replay();
View Full Code Here

    }

    @Test
    public void name_collision_with_standard_translators()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator("fred", Long.class);

        Map<Class, Translator> configuration = CollectionFactory.newMap();
        configuration.put(Integer.class, t1);
        configuration.put(Long.class, t2);
View Full Code Here

    }

    @Test
    public void get_alternate_translator_by_name()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator();

        Map<Class, Translator> configuration = newConfiguration(Integer.class, t1);

        Map<String, Translator> alternates = CollectionFactory.newMap();
        alternates.put("barney", t2);
View Full Code Here

    }

    @Test
    public void name_collision_between_standard_and_alternate_translator()
    {
        Translator t1 = mockTranslator("fred", Integer.class);
        Translator t2 = mockTranslator();

        Map<Class, Translator> configuration = newConfiguration(Integer.class, t1);

        Map<String, Translator> alternates = CollectionFactory.newMap();
        alternates.put("fred", t2);
View Full Code Here

TOP

Related Classes of de.sciss.util.ParamSpace$Translator

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.