use of com.haulmont.cuba.gui.theme.ThemeConstantsRepository in project cuba by cuba-platform.
the class App method initTheme.
protected void initTheme() throws Exception {
DesktopConfig config = configuration.getConfig(DesktopConfig.class);
String themeName = config.getTheme();
DesktopThemeLoader desktopThemeLoader = AppBeans.get(DesktopThemeLoader.NAME);
theme = desktopThemeLoader.loadTheme(themeName);
theme.init();
ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
ThemeConstants uiTheme = themeRepository.getConstants(themeName);
if (uiTheme == null) {
throw new IllegalStateException("Unable to use theme constants '" + themeName + "'");
}
this.themeConstants = uiTheme;
}
use of com.haulmont.cuba.gui.theme.ThemeConstantsRepository in project cuba by cuba-platform.
the class CubaUIProvider method getTheme.
@Override
public String getTheme(UICreateEvent event) {
// get theme from cookies before app ui initialized for smooth theme enabling
WebConfig webConfig = configuration.getConfig(WebConfig.class);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
String appWindowTheme = webConfig.getAppWindowTheme();
String userAppTheme = getCookieValue(event.getRequest().getCookies(), App.APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
if (userAppTheme != null) {
if (!Objects.equals(userAppTheme, appWindowTheme)) {
// check theme support
ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
Set<String> supportedThemes = themeRepository.getAvailableThemes();
if (supportedThemes.contains(userAppTheme)) {
return userAppTheme;
}
}
}
return super.getTheme(event);
}
use of com.haulmont.cuba.gui.theme.ThemeConstantsRepository in project cuba by cuba-platform.
the class SettingsWindow method init.
@Override
public void init(Map<String, Object> params) {
Boolean changeThemeEnabledParam = (Boolean) params.get("changeThemeEnabled");
if (changeThemeEnabledParam != null) {
changeThemeEnabled = changeThemeEnabledParam;
}
AppWorkArea.Mode mode = userSettingsTools.loadAppWindowMode();
msgTabbed = getMessage("modeTabbed");
msgSingle = getMessage("modeSingle");
modeOptions.setOptionsList(Arrays.asList(msgTabbed, msgSingle));
if (mode == AppWorkArea.Mode.TABBED)
modeOptions.setValue(msgTabbed);
else
modeOptions.setValue(msgSingle);
ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
Set<String> supportedThemes = themeRepository.getAvailableThemes();
appThemeField.setOptionsList(new ArrayList<>(supportedThemes));
String userAppTheme = userSettingsTools.loadAppWindowTheme();
appThemeField.setValue(userAppTheme);
ComboBox vAppThemeField = (ComboBox) WebComponentsHelper.unwrap(appThemeField);
vAppThemeField.setTextInputAllowed(false);
appThemeField.setEditable(changeThemeEnabled);
initTimeZoneFields();
User user = userSession.getUser();
changePasswordBtn.setAction(new BaseAction("changePassw").withCaption(getMessage("changePassw")).withHandler(event -> {
Window passwordDialog = openWindow("sec$User.changePassword", OpenType.DIALOG, ParamsMap.of("currentPasswordRequired", true));
passwordDialog.addCloseListener(actionId -> {
// move focus back to window
changePasswordBtn.requestFocus();
});
}));
if (!user.equals(userSession.getCurrentOrSubstitutedUser()) || ExternalUserCredentials.isLoggedInWithExternalAuth(userSession)) {
changePasswordBtn.setEnabled(false);
}
Map<String, Locale> locales = globalConfig.getAvailableLocales();
TreeMap<String, Object> options = new TreeMap<>();
for (Map.Entry<String, Locale> entry : locales.entrySet()) {
options.put(entry.getKey(), messages.getTools().localeToString(entry.getValue()));
}
appLangField.setOptionsMap(options);
appLangField.setValue(userManagementService.loadOwnLocale());
Action commitAction = new BaseAction("commit").withCaption(messages.getMainMessage("actions.Ok")).withShortcut(clientConfig.getCommitShortcut()).withHandler(event -> commit());
addAction(commitAction);
okBtn.setAction(commitAction);
cancelBtn.setAction(new BaseAction("cancel").withCaption(messages.getMainMessage("actions.Cancel")).withHandler(event -> cancel()));
initDefaultScreenField();
}
Aggregations