use of io.jmix.ui.theme.ThemeConstants in project jmix by jmix-framework.
the class PresentationEditor method initLayout.
protected void initLayout() {
ThemeConstants theme = App.getInstance().getThemeConstants();
VerticalLayout root = new VerticalLayout();
root.setWidthUndefined();
root.setSpacing(true);
root.setMargin(false);
setContent(root);
nameField = new TextField(messages.getMessage("PresentationsEditor.name"));
nameField.setWidth(theme.get("jmix.ui.PresentationEditor.name.width"));
nameField.setValue(getPresentationCaption());
root.addComponent(nameField);
autoSaveField = new CheckBox();
autoSaveField.setCaption(messages.getMessage("PresentationsEditor.autoSave"));
autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
root.addComponent(autoSaveField);
defaultField = new CheckBox();
defaultField.setCaption(messages.getMessage("PresentationsEditor.default"));
defaultField.setValue(Objects.equals(EntityValues.<UUID>getId(presentation), (component.getDefaultPresentationId())));
root.addComponent(defaultField);
if (allowGlobalPresentations) {
globalField = new CheckBox();
globalField.setCaption(messages.getMessage("PresentationsEditor.global"));
globalField.setValue(!isNew && presentation.getUsername() == null);
root.addComponent(globalField);
}
HorizontalLayout buttons = new HorizontalLayout();
buttons.setMargin(false);
buttons.setSpacing(true);
buttons.setWidthUndefined();
root.addComponent(buttons);
root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
Button commitButton = new JmixButton(messages.getMessage("PresentationsEditor.save"));
commitButton.addClickListener(event -> {
if (validate()) {
commit();
forceClose();
}
});
buttons.addComponent(commitButton);
Button closeButton = new JmixButton(messages.getMessage("PresentationsEditor.close"));
closeButton.addClickListener(event -> forceClose());
buttons.addComponent(closeButton);
nameField.focus();
}
use of io.jmix.ui.theme.ThemeConstants in project jmix by jmix-framework.
the class AbbreviatedCellClickListener method createContent.
protected JmixResizableTextAreaWrapper createContent(JmixTextArea textArea) {
JmixResizableTextAreaWrapper content = new JmixResizableTextAreaWrapper(textArea);
content.setResizableDirection(ResizeDirection.BOTH);
ThemeConstants theme = App.getInstance().getThemeConstants();
content.setWidth(theme.get("jmix.ui.Table.abbreviatedPopupWidth"));
content.setHeight(theme.get("jmix.ui.Table.abbreviatedPopupHeight"));
return content;
}
use of io.jmix.ui.theme.ThemeConstants in project jmix by jmix-framework.
the class ScreensImpl method createWindow.
protected Window createWindow(@SuppressWarnings("unused") WindowInfo windowInfo, Class<? extends Screen> screenClass, ScreenOpenDetails openDetails) {
Window window;
OpenMode openMode = openDetails.getOpenMode();
switch(openMode) {
case ROOT:
// todo we should update UI theme and its properties only when RootWindow is attached to UI
ui.beforeTopLevelWindowInit();
window = createRootWindow(windowInfo);
break;
case THIS_TAB:
case NEW_TAB:
window = createTabWindow(windowInfo);
break;
case DIALOG:
DialogWindow dialogWindow = createDialogWindow(windowInfo);
if (openDetails.isForceDialog()) {
ThemeConstants theme = ui.getApp().getThemeConstants();
dialogWindow.setDialogWidth(theme.get("jmix.ui.WebWindowManager.forciblyDialog.width"));
dialogWindow.setDialogHeight(theme.get("jmix.ui.WebWindowManager.forciblyDialog.height"));
dialogWindow.setResizable(true);
} else {
DialogMode dialogMode = screenClass.getAnnotation(DialogMode.class);
if (dialogMode != null) {
dialogWindow.setModal(dialogMode.modal());
dialogWindow.setCloseable(dialogMode.closeable());
dialogWindow.setResizable(dialogMode.resizable());
dialogWindow.setCloseOnClickOutside(dialogMode.closeOnClickOutside());
if (StringUtils.isNotEmpty(dialogMode.width())) {
dialogWindow.setDialogWidth(dialogMode.width());
}
if (StringUtils.isNotEmpty(dialogMode.height())) {
dialogWindow.setDialogHeight(dialogMode.height());
}
dialogWindow.setWindowMode(dialogMode.windowMode());
}
}
window = dialogWindow;
break;
default:
throw new UnsupportedOperationException("Unsupported launch mode " + openMode);
}
WindowContextImpl windowContext = createWindowContext(window, openDetails);
((WindowImplementation) window).setContext(windowContext);
return window;
}
use of io.jmix.ui.theme.ThemeConstants in project jmix by jmix-framework.
the class SaveSetWindow method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
ThemeConstants themeConstants = App.getInstance().getThemeConstants();
folderSelect.setWidth(themeConstants.get("cuba.web.save-set-window.folderSelect.width"));
}
use of io.jmix.ui.theme.ThemeConstants in project jmix by jmix-framework.
the class AbstractTable method initComponent.
protected void initComponent(T component) {
component.setMultiSelect(false);
component.setValidationVisible(false);
component.setShowBufferedSourceException(false);
component.setCustomCellValueFormatter(this::formatCellValue);
component.addValueChangeListener(this::tableSelectionChanged);
component.setSpecificVariablesHandler(this::handleSpecificVariables);
component.setIconProvider(this::getItemIcon);
component.setBeforePaintListener(this::beforeComponentPaint);
component.addColumnReorderListener(this::onColumnReorder);
component.setSortAscendingLabel(messages.getMessage("tableSort.ascending"));
component.setSortResetLabel(messages.getMessage("tableSort.reset"));
component.setSortDescendingLabel(messages.getMessage("tableSort.descending"));
component.setSelectAllLabel(messages.getMessage("tableColumnSelector.selectAll"));
component.setDeselectAllLabel(messages.getMessage("tableColumnSelector.deselectAll"));
int defaultRowHeaderWidth = 16;
ThemeConstantsManager themeConstantsManager = applicationContext.getBean(ThemeConstantsManager.class, ThemeConstantsManager.class);
ThemeConstants theme = themeConstantsManager.getConstants();
if (theme != null) {
defaultRowHeaderWidth = theme.getInt("jmix.ui.Table.defaultRowHeaderWidth", 16);
}
component.setColumnWidth(ROW_HEADER_PROPERTY_ID, defaultRowHeaderWidth);
contextMenuPopup.setParent(component);
component.setContextMenuPopup(contextMenuPopup);
shortcutsDelegate.setAllowEnterShortcut(false);
component.addShortcutListener(new ShortcutListenerDelegate("tableEnter", KeyCode.ENTER, null).withHandler((sender, target) -> {
T tableImpl = AbstractTable.this.component;
AppUI ui = (AppUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(AbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
if (target == this.component) {
if (enterPressAction != null) {
enterPressAction.actionPerform(this);
} else {
handleClickAction();
}
}
}));
component.addShortcutListener(new ShortcutListenerDelegate("tableSelectAll", KeyCode.A, new int[] { com.vaadin.event.ShortcutAction.ModifierKey.CTRL }).withHandler((sender, target) -> {
if (target == this.component) {
selectAll();
}
}));
component.addItemClickListener(event -> {
if (event.isDoubleClick() && event.getItem() != null) {
T tableImpl = AbstractTable.this.component;
AppUI ui = (AppUI) tableImpl.getUI();
if (!ui.isAccessibleForUser(tableImpl)) {
LoggerFactory.getLogger(AbstractTable.class).debug("Ignore click attempt because Table is inaccessible for user");
return;
}
handleClickAction();
}
});
component.setAfterUnregisterComponentHandler(this::onAfterUnregisterComponent);
component.setBeforeRefreshRowCacheHandler(this::onBeforeRefreshRowCache);
component.setSelectable(true);
component.setTableFieldFactory(createFieldFactory());
component.setColumnCollapsingAllowed(true);
component.setColumnReorderingAllowed(true);
setEditable(false);
componentComposition = new TableComposition();
componentComposition.setTable(component);
componentComposition.setPrimaryStyleName("jmix-table-composition");
componentComposition.addComponent(component);
component.setCellStyleGenerator(createStyleGenerator());
component.addColumnCollapseListener(this::handleColumnCollapsed);
// force default sizes
componentComposition.setHeightUndefined();
componentComposition.setWidthUndefined();
setClientCaching();
initEmptyState();
}
Aggregations