Example usage for com.liferay.portal.kernel.theme ThemeDisplay setLookAndFeel

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay setLookAndFeel

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay setLookAndFeel.

Prototype

public void setLookAndFeel(Theme theme, ColorScheme colorScheme) 

Source Link

Usage

From source file:com.liferay.journal.search.test.JournalArticleIndexerSummaryTest.java

License:Open Source License

protected ThemeDisplay createThemeDisplay(HttpServletRequest httpServletRequest,
        HttpServletResponse httpServletResponse) throws Exception {

    ThemeDisplay themeDisplay = new ThemeDisplay();

    themeDisplay.setCompany(CompanyLocalServiceUtil.getCompany(_group.getCompanyId()));
    themeDisplay.setLayout(LayoutTestUtil.addLayout(_group));

    LayoutSet layoutSet = _group.getPublicLayoutSet();

    themeDisplay.setLayoutSet(layoutSet);

    Theme theme = ThemeLocalServiceUtil.getTheme(_group.getCompanyId(), layoutSet.getThemeId());

    themeDisplay.setLookAndFeel(theme, null);

    themeDisplay.setRealUser(_user);/*from   w  w  w.  j  a  v a2s  .  c  o m*/
    themeDisplay.setRequest(httpServletRequest);
    themeDisplay.setResponse(httpServletResponse);
    themeDisplay.setTimeZone(TimeZoneUtil.getDefault());
    themeDisplay.setUser(_user);

    return themeDisplay;
}

From source file:com.liferay.mobile.device.rules.rule.group.action.ThemeModificationActionHandler.java

License:Open Source License

@Override
public void applyAction(MDRAction mdrAction, HttpServletRequest request, HttpServletResponse response) {

    long companyId = _portal.getCompanyId(request);

    UnicodeProperties typeSettingsProperties = mdrAction.getTypeSettingsProperties();

    String themeId = GetterUtil.getString(typeSettingsProperties.getProperty("themeId"));

    Theme theme = _themeLocalService.fetchTheme(companyId, themeId);

    if (theme == null) {
        theme = _themeLocalService.getTheme(companyId, themeId);
    }/* w ww  . j av  a 2 s .co  m*/

    if (theme == null) {
        return;
    }

    request.setAttribute(WebKeys.THEME, theme);

    String colorSchemeId = GetterUtil.getString(typeSettingsProperties.getProperty("colorSchemeId"));

    ColorScheme colorScheme = _themeLocalService.fetchColorScheme(companyId, themeId, colorSchemeId);

    if (colorScheme == null) {
        colorScheme = _themeLocalService.getColorScheme(companyId, themeId, colorSchemeId);
    }

    request.setAttribute(WebKeys.COLOR_SCHEME, colorScheme);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    themeDisplay.setLookAndFeel(theme, colorScheme);
}