Example usage for org.springframework.web.servlet.support RequestContextUtils getTheme

List of usage examples for org.springframework.web.servlet.support RequestContextUtils getTheme

Introduction

In this page you can find the example usage for org.springframework.web.servlet.support RequestContextUtils getTheme.

Prototype

@Nullable
public static Theme getTheme(HttpServletRequest request) 

Source Link

Document

Retrieves the current theme from the given request, using the ThemeResolver and ThemeSource bound to the request by the DispatcherServlet.

Usage

From source file:org.openmrs.module.custombranding.CustomBrandingUtils.java

private static String getDefaultThemePath(HttpServletRequest request) {
    String theme = RequestContextUtils.getTheme(request).getName();
    String fileSysLocation = request.getRealPath("/") + "WEB-INF" + File.separator;
    String themeFilePath = "";
    if (versionGreater(OpenmrsConstants.OPENMRS_VERSION_SHORT, "1.6")) {
        themeFilePath = fileSysLocation + "classes" + File.separator + "themes" + File.separator
                + "defaults.properties";
    } else {/*from w w  w.j  av a2 s . c  o  m*/
        themeFilePath = fileSysLocation + "classes" + File.separator + "standard_" + theme + ".properties";
    }
    return themeFilePath;
}

From source file:org.openmrs.module.custombranding.CustomBrandingUtils.java

private static String getThemePath(HttpServletRequest request) {
    String theme = RequestContextUtils.getTheme(request).getName();
    String fileSysLocation = request.getRealPath("/") + "WEB-INF" + File.separator;
    String themeFilePath = "";
    if (versionGreater(OpenmrsConstants.OPENMRS_VERSION_SHORT, "1.6")) {
        if (theme.trim().equals("")) {
            theme = "defaults";
        }//www  . j ava2  s .c  o  m
        themeFilePath = fileSysLocation + "classes" + File.separator + "themes" + File.separator + theme
                + ".properties";
    } else {
        themeFilePath = fileSysLocation + "classes" + File.separator + "standard_" + theme + ".properties";
    }
    return themeFilePath;
}

From source file:net.sourceforge.subsonic.controller.AbstractChartController.java

private Color getColor(String code, HttpServletRequest request) {
    Theme theme = RequestContextUtils.getTheme(request);
    Locale locale = RequestContextUtils.getLocale(request);
    String colorHex = theme.getMessageSource().getMessage(code, new Object[0], locale);
    return new Color(Integer.parseInt(colorHex, 16));
}

From source file:com.epam.cme.storefront.breadcrumb.impl.DefaultResourceBreadcrumbBuilder.java

protected MessageSource getMessageSource() {
    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .getRequestAttributes();//from  w w  w .j  a v  a2  s . co m
    if (requestAttributes != null) {
        final HttpServletRequest request = requestAttributes.getRequest();
        final Theme theme = RequestContextUtils.getTheme(request);
        if (theme != null) {
            return theme.getMessageSource();
        }
    }

    return null;
}

From source file:jetx.ext.springmvc.SpringMvcFunctions.java

/**
 * ?Theme/*from ww w.  jav a2  s  .c om*/
 */
public static Theme getTheme(JetPageContext ctx) {
    HttpServletRequest request = ExtendUtils.getHttpServletRequest(ctx);
    return RequestContextUtils.getTheme(request);
}