private void _readColorSchemes(
      Element themeElement,
      Map<String, ColorScheme> colorSchemes,
      ContextReplace themeContextReplace) {

    List<Element> colorSchemeElements = themeElement.elements("color-scheme");

    for (Element colorSchemeElement : colorSchemeElements) {
      ContextReplace colorSchemeContextReplace = (ContextReplace) themeContextReplace.clone();

      String id = colorSchemeElement.attributeValue("id");

      colorSchemeContextReplace.addValue("color-scheme-id", id);

      ColorScheme colorSchemeModel = colorSchemes.get(id);

      if (colorSchemeModel == null) {
        colorSchemeModel = new ColorSchemeImpl(id);
      }

      String name =
          GetterUtil.getString(
              colorSchemeElement.attributeValue("name"), colorSchemeModel.getName());

      name = colorSchemeContextReplace.replace(name);

      boolean defaultCs =
          GetterUtil.getBoolean(
              colorSchemeElement.elementText("default-cs"), colorSchemeModel.isDefaultCs());

      String cssClass =
          GetterUtil.getString(
              colorSchemeElement.elementText("css-class"), colorSchemeModel.getCssClass());

      cssClass = colorSchemeContextReplace.replace(cssClass);

      colorSchemeContextReplace.addValue("css-class", cssClass);

      String colorSchemeImagesPath =
          GetterUtil.getString(
              colorSchemeElement.elementText("color-scheme-images-path"),
              colorSchemeModel.getColorSchemeImagesPath());

      colorSchemeImagesPath = colorSchemeContextReplace.replace(colorSchemeImagesPath);

      colorSchemeContextReplace.addValue("color-scheme-images-path", colorSchemeImagesPath);

      colorSchemeModel.setName(name);
      colorSchemeModel.setDefaultCs(defaultCs);
      colorSchemeModel.setCssClass(cssClass);
      colorSchemeModel.setColorSchemeImagesPath(colorSchemeImagesPath);

      colorSchemes.put(id, colorSchemeModel);
    }
  }
Example #2
0
  public void setLookAndFeel(Theme theme, ColorScheme colorScheme) {
    _theme = theme;
    _colorScheme = colorScheme;

    if ((theme != null) && (colorScheme != null)) {
      String themeStaticResourcePath = theme.getStaticResourcePath();

      String cdnBaseURL = getCDNBaseURL();

      setPathColorSchemeImages(
          cdnBaseURL + themeStaticResourcePath + colorScheme.getColorSchemeImagesPath());

      String dynamicResourcesHost = getCDNDynamicResourcesHost();

      if (Validator.isNull(dynamicResourcesHost)) {
        String portalURL = getPortalURL();

        if (getServerName() != null) {
          try {
            portalURL = PortalUtil.getPortalURL(getLayout(), this);
          } catch (Exception e) {
            _log.error(e, e);
          }
        }

        dynamicResourcesHost = portalURL;
      }

      setPathThemeCss(dynamicResourcesHost + themeStaticResourcePath + theme.getCssPath());

      setPathThemeImages(cdnBaseURL + themeStaticResourcePath + theme.getImagesPath());
      setPathThemeJavaScript(cdnBaseURL + themeStaticResourcePath + theme.getJavaScriptPath());
      setPathThemeRoot(themeStaticResourcePath + theme.getRootPath());
      setPathThemeTemplates(cdnBaseURL + themeStaticResourcePath + theme.getTemplatesPath());
    }
  }