Examples of ThemeImpl


Examples of org.apache.myfaces.tobago.context.ThemeImpl

    final ThemeBuilder themeBuilder = new ThemeBuilder(config);
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    final TobagoConfigParser parser = new TobagoConfigParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      final ThemeResources resources = theme.getResources();
      final ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(3, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/tobago-logging.js", resources.getScriptList().get(1).getName());
      Assert.assertEquals("script/tobago-console.js", resources.getScriptList().get(2).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertEquals(0, theme3.getResources().getScriptList().size());
      Assert.assertEquals(0, theme3.getResources().getStyleList().size());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertEquals(0, theme4.getResources().getScriptList().size());
      Assert.assertEquals(0, theme4.getResources().getStyleList().size());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
    }

    themeBuilder.resolveThemes();
    Assert.assertEquals(3, theme.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/tobago-console.js", theme.getResources().getScriptList().get(2).getName());

    Assert.assertNotNull(theme2.getResources());
    Assert.assertEquals(4, theme2.getResources().getScriptList().size());
    Assert.assertEquals(1, theme2.getResources().getStyleList().size());
    Assert.assertEquals("script/tobago.js", theme2.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme2.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/tobago-console.js", theme2.getResources().getScriptList().get(2).getName());
    Assert.assertEquals("script/test.js", theme2.getResources().getScriptList().get(3).getName());

    Assert.assertEquals(4, theme3.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme3.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme3.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/tobago-console.js", theme3.getResources().getScriptList().get(2).getName());
    Assert.assertEquals("script/test.js", theme3.getResources().getScriptList().get(3).getName());

    Assert.assertEquals(4, theme4.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme4.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme4.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/tobago-console.js", theme4.getResources().getScriptList().get(2).getName());
    Assert.assertEquals("script/test.js", theme4.getResources().getScriptList().get(3).getName());
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-1", "my-markup-1"));
    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-1"));
    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-2"));

    Assert.assertEquals(2, fragment.getThemeDefinitions().size());
    final ThemeImpl theme1 = fragment.getThemeDefinitions().get(0);
    Assert.assertEquals("my-theme-1", theme1.getName());
    Assert.assertEquals("My Theme 1", theme1.getDisplayName());
    Assert.assertEquals("/my/path-1", theme1.getResourcePath());
    Assert.assertTrue(theme1.isVersioned());
    Assert.assertTrue(theme1.getRenderersConfig().isMarkupSupported("themeRenderer", "theme-markup"));
    Assert.assertTrue(theme1.getProductionResources().isProduction());
    Assert.assertEquals("script.js", theme1.getProductionResources().getScriptList().get(0).getName());
    Assert.assertEquals("style.css", theme1.getProductionResources().getStyleList().get(0).getName());

    final ThemeImpl theme2 = fragment.getThemeDefinitions().get(1);
    Assert.assertEquals("my-theme-2", theme2.getName());
    Assert.assertEquals("my-theme-1", theme2.getFallbackName());
    Assert.assertEquals("/my/path-2", theme2.getResourcePath());
    Assert.assertFalse(theme2.isVersioned());
    Assert.assertFalse(theme2.getResources().isProduction());
    Assert.assertEquals(0, theme2.getResources().getScriptList().size());
    Assert.assertEquals(0, theme2.getResources().getStyleList().size());
    Assert.assertEquals(0, theme2.getProductionResources().getScriptList().size());
    Assert.assertEquals(0, theme2.getProductionResources().getStyleList().size());
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

    final ThemeBuilder themeBuilder = new ThemeBuilder(config);
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    Enumeration<URL> urls = classLoader.getResources("theme-config.xml");

    final TobagoConfigParser parser = new TobagoConfigParser();
    ThemeImpl theme = null;
    if  (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test", theme.getName());
      Assert.assertNotNull(theme.getResources());
      Assert.assertNotNull(theme.getProductionResources());
      final ThemeResources resources = theme.getResources();
      final ThemeResources productionResources = theme.getProductionResources();

      Assert.assertEquals(2, resources.getScriptList().size());
      Assert.assertEquals("script/tobago.js", resources.getScriptList().get(0).getName());
      Assert.assertEquals("script/tobago-logging.js", resources.getScriptList().get(1).getName());

      Assert.assertEquals(1, productionResources.getScriptList().size());
      themeBuilder.addTheme(theme);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config2.xml");

    ThemeImpl theme2 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme2 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test2", theme2.getName());
      Assert.assertNotNull(theme2.getResources());
      Assert.assertEquals(1, theme2.getResources().getScriptList().size());
      Assert.assertEquals(1, theme2.getResources().getStyleList().size());
      themeBuilder.addTheme(theme2);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config3.xml");

    ThemeImpl theme3 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme3 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test3", theme3.getName());
      Assert.assertEquals(0, theme3.getResources().getScriptList().size());
      Assert.assertEquals(0, theme3.getResources().getStyleList().size());
      themeBuilder.addTheme(theme3);
    } else {
      Assert.fail();
    }

    urls = classLoader.getResources("theme-config4.xml");

    ThemeImpl theme4 = null;
    if (urls.hasMoreElements()) {
      final URL themeUrl = urls.nextElement();
      theme4 = parser.parse(themeUrl).getThemeDefinitions().get(0);
      Assert.assertEquals("test4", theme4.getName());
      Assert.assertEquals(0, theme4.getResources().getScriptList().size());
      Assert.assertEquals(0, theme4.getResources().getStyleList().size());
      themeBuilder.addTheme(theme4);
    } else {
      Assert.fail();
    }

    themeBuilder.resolveThemes();
    Assert.assertEquals(2, theme.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme.getResources().getScriptList().get(1).getName());

    Assert.assertNotNull(theme2.getResources());
    Assert.assertEquals(3, theme2.getResources().getScriptList().size());
    Assert.assertEquals(1, theme2.getResources().getStyleList().size());
    Assert.assertEquals("script/tobago.js", theme2.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme2.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/test.js", theme2.getResources().getScriptList().get(2).getName());

    Assert.assertEquals(3, theme3.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme3.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme3.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/test.js", theme3.getResources().getScriptList().get(2).getName());

    Assert.assertEquals(3, theme4.getResources().getScriptList().size());
    Assert.assertEquals("script/tobago.js", theme4.getResources().getScriptList().get(0).getName());
    Assert.assertEquals("script/tobago-logging.js", theme4.getResources().getScriptList().get(1).getName());
    Assert.assertEquals("script/test.js", theme4.getResources().getScriptList().get(2).getName());


  }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

      case RENDERER:
        currentRenderer = new RendererConfig();
        break;

      case THEME_DEFINITION:
        currentTheme = new ThemeImpl();
        tobagoConfig.addThemeDefinition(currentTheme);
        break;

      case RESOURCES:
        production = Boolean.parseBoolean(attributes.getValue("production"));
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

      }
      map.put(theme.getName(), theme);
    }
    for (final ThemeImpl theme : availableThemes) {
      final String fallbackName = theme.getFallbackName();
      final ThemeImpl fallback = map.get(fallbackName);
      theme.setFallback(fallback);
    }
    for (final ThemeImpl theme : availableThemes) {
      theme.resolveFallbacks();
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

      case RENDERER:
        currentRenderer = new RendererConfig();
        break;

      case THEME_DEFINITION:
        currentTheme = new ThemeImpl();
        tobagoConfig.addThemeDefinition(currentTheme);
        break;

      case RESOURCES:
        production = Boolean.parseBoolean(attributes.getValue("production"));
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

      }
      map.put(theme.getName(), theme);
    }
    for (ThemeImpl theme : availableThemes) {
      String fallbackName = theme.getFallbackName();
      ThemeImpl fallback = map.get(fallbackName);
      theme.setFallback(fallback);
    }
    for (ThemeImpl theme : availableThemes) {
      theme.resolveFallbacks();
    }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
          tobagoConfig = new TobagoConfigParser().parse(themeUrl);
        } else {
          // the old way
          tobagoConfig = new TobagoConfigFragment();
          final ThemeImpl theme = parser.parse(themeUrl);
          tobagoConfig.addThemeDefinition(theme);
        }
        tobagoConfig.setUrl(themeUrl);
        String protocol = themeUrl.getProtocol();
        // tomcat uses jar
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-1", "my-markup-1"));
    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-1"));
    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-2"));

    Assert.assertEquals(2, fragment.getThemeDefinitions().size());
    final ThemeImpl theme1 = fragment.getThemeDefinitions().get(0);
    Assert.assertEquals("my-theme-1", theme1.getName());
    Assert.assertEquals("My Theme 1", theme1.getDisplayName());
    Assert.assertEquals("/my/path-1", theme1.getResourcePath());
    Assert.assertTrue(theme1.isVersioned());
    Assert.assertTrue(theme1.getRenderersConfig().isMarkupSupported("themeRenderer", "theme-markup"));
    Assert.assertTrue(theme1.getProductionResources().isProduction());
    Assert.assertEquals("script.js", theme1.getProductionResources().getScriptList().get(0).getName());
    Assert.assertEquals("style.css", theme1.getProductionResources().getStyleList().get(0).getName());

    final ThemeImpl theme2 = fragment.getThemeDefinitions().get(1);
    Assert.assertEquals("my-theme-2", theme2.getName());
    Assert.assertEquals("my-theme-1", theme2.getFallbackName());
    Assert.assertEquals("/my/path-2", theme2.getResourcePath());
    Assert.assertFalse(theme2.isVersioned());
    Assert.assertFalse(theme2.getResources().isProduction());
    Assert.assertEquals(0, theme2.getResources().getScriptList().size());
    Assert.assertEquals(0, theme2.getResources().getStyleList().size());
    Assert.assertEquals(0, theme2.getProductionResources().getScriptList().size());
    Assert.assertEquals(0, theme2.getProductionResources().getStyleList().size());

    Assert.assertFalse("set-nosniff-header", fragment.getSetNosniffHeader());
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.context.ThemeImpl

      }
      map.put(theme.getName(), theme);
    }
    for (final ThemeImpl theme : availableThemes) {
      final String fallbackName = theme.getFallbackName();
      final ThemeImpl fallback = map.get(fallbackName);
      theme.setFallback(fallback);
    }
    for (final ThemeImpl theme : availableThemes) {
      theme.resolveFallbacks();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.