use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class BulkEditAction method actionPerform.
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null) {
if (!beforeActionPerformedHandler.beforeActionPerformed())
return;
}
if (!userSession.isSpecificPermitted(BulkEditor.PERMISSION)) {
target.getFrame().showNotification(messages.getMainMessage("accessDenied.message"), Frame.NotificationType.ERROR);
return;
}
if (target.getSelected().isEmpty()) {
target.getFrame().showNotification(messages.getMainMessage("actions.BulkEdit.emptySelection"), Frame.NotificationType.HUMANIZED);
return;
}
if (openType.getOpenMode() == OpenMode.DIALOG) {
ThemeConstantsManager themeManager = AppBeans.get(ThemeConstantsManager.NAME);
ThemeConstants theme = themeManager.getConstants();
target.getFrame().getDialogParams().setWidth(theme.get("cuba.gui.BulkEditAction.editorDialog.width")).setHeight(theme.get("cuba.gui.BulkEditAction.editorDialog.height")).setResizable(true);
}
Map<String, Object> params = ParamsMap.of().pair("metaClass", target.getDatasource().getMetaClass()).pair("selected", target.getSelected()).pair("exclude", exclude).pair("includeProperties", includeProperties != null ? includeProperties : Collections.EMPTY_LIST).pair("fieldValidators", fieldValidators).pair("modelValidators", modelValidators).pair("loadDynamicAttributes", loadDynamicAttributes).create();
Window bulkEditor = target.getFrame().openWindow("bulkEditor", openType, params);
bulkEditor.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
target.getDatasource().refresh();
}
target.requestFocus();
});
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class ExceptionDialog method setStackTraceVisible.
public void setStackTraceVisible(boolean visible) {
isStackTraceVisible = visible;
ThemeConstants theme = App.getInstance().getThemeConstants();
if (visible) {
if (copyButton != null) {
copyButton.setVisible(true);
}
showStackTraceButton.setCaption(messages.getMainMessage("exceptionDialog.hideStackTrace"));
mainLayout.addComponent(stackTraceTextArea);
mainLayout.setExpandRatio(stackTraceTextArea, 1.0f);
mainLayout.setHeight(100, Unit.PERCENTAGE);
setWidth(theme.get("cuba.web.ExceptionDialog.expanded.width"));
setHeight(theme.get("cuba.web.ExceptionDialog.expanded.height"));
setResizable(true);
center();
stackTraceTextArea.focus();
stackTraceTextArea.setCursorPosition(0);
} else {
if (copyButton != null) {
copyButton.setVisible(false);
}
showStackTraceButton.setCaption(messages.getMainMessage("exceptionDialog.showStackTrace"));
mainLayout.setHeight(-1, Unit.PIXELS);
mainLayout.removeComponent(stackTraceTextArea);
setWidth(theme.get("cuba.web.ExceptionDialog.width"));
setHeight(-1, Unit.PERCENTAGE);
setResizable(false);
center();
setWindowMode(WindowMode.NORMAL);
}
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class App method loadTheme.
protected ThemeConstants loadTheme() {
String appWindowTheme = webConfig.getAppWindowTheme();
String userAppTheme = cookies.getCookieValue(APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
if (userAppTheme != null) {
if (!Objects.equals(userAppTheme, appWindowTheme)) {
// check theme support
Set<String> supportedThemes = themeConstantsRepository.getAvailableThemes();
if (supportedThemes.contains(userAppTheme)) {
appWindowTheme = userAppTheme;
}
}
}
ThemeConstants theme = themeConstantsRepository.getConstants(appWindowTheme);
if (theme == null) {
throw new IllegalStateException("Unable to use theme constants '" + appWindowTheme + "'");
}
return theme;
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class WebComponentsHelper method getIcon.
/**
* @deprecated Use {@link com.haulmont.cuba.web.gui.icons.IconResolver} instead.
*/
@Deprecated
@Nullable
public static Resource getIcon(String iconName) {
if (StringUtils.isEmpty(iconName)) {
return null;
}
Configuration configuration = AppBeans.get(Configuration.NAME);
WebConfig webConfig = configuration.getConfig(WebConfig.class);
if (webConfig.getUseFontIcons()) {
String fontIcon;
if (StringUtils.contains(iconName, ":")) {
fontIcon = iconName;
} else {
ThemeConstants themeConstants = App.getInstance().getThemeConstants();
String iconKey = "cuba.web." + StringUtils.replace(iconName, "/", ".");
fontIcon = themeConstants.get(iconKey);
}
try {
Resource resource = getFontIconResource(fontIcon);
if (resource != null) {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon {}", fontIcon);
}
}
return new VersionedThemeResource(iconName);
}
use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.
the class WebComponentsHelper method getResource.
public static Resource getResource(String resURL) {
if (StringUtils.isEmpty(resURL))
return null;
if (resURL.startsWith("file:")) {
return new FileResource(new File(resURL.substring("file:".length())));
} else if (resURL.startsWith("jar:")) {
return new ClassResource(resURL.substring("jar:".length()));
} else if (resURL.startsWith("theme:")) {
String resourceId = resURL.substring("theme:".length());
Configuration configuration = AppBeans.get(Configuration.NAME);
WebConfig webConfig = configuration.getConfig(WebConfig.class);
if (webConfig.getUseFontIcons()) {
String fontIcon;
ThemeConstants themeConstants = App.getInstance().getThemeConstants();
String iconKey = "cuba.web." + StringUtils.replace(resourceId, "/", ".");
fontIcon = themeConstants.get(iconKey);
try {
Resource resource = getFontIconResource(fontIcon);
if (resource != null) {
return resource;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + fontIcon);
}
}
return new VersionedThemeResource(resourceId);
} else if (resURL.contains("icon:")) {
try {
return getFontIconResource(resURL);
} catch (NoSuchFieldException | IllegalAccessException e) {
LoggerFactory.getLogger(WebComponentsHelper.class).warn("Unable to use font icon " + resURL);
}
return null;
} else {
return new VersionedThemeResource(resURL);
}
}
Aggregations