Search in sources :

Example 1 with ThemeConstants

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();
}
Also used : ThemeConstants(io.jmix.ui.theme.ThemeConstants) JmixButton(io.jmix.ui.widget.JmixButton) JmixButton(io.jmix.ui.widget.JmixButton) UUID(java.util.UUID)

Example 2 with ThemeConstants

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;
}
Also used : ThemeConstants(io.jmix.ui.theme.ThemeConstants) JmixResizableTextAreaWrapper(io.jmix.ui.widget.JmixResizableTextAreaWrapper)

Example 3 with ThemeConstants

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;
}
Also used : GuiDialogWindow(io.jmix.ui.component.impl.DialogWindowImpl.GuiDialogWindow) ThemeConstants(io.jmix.ui.theme.ThemeConstants) WindowImplementation(io.jmix.ui.component.impl.WindowImplementation) GuiDialogWindow(io.jmix.ui.component.impl.DialogWindowImpl.GuiDialogWindow)

Example 4 with ThemeConstants

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"));
}
Also used : ThemeConstants(io.jmix.ui.theme.ThemeConstants)

Example 5 with ThemeConstants

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();
}
Also used : PaginationEmptyBinder(io.jmix.ui.component.pagination.data.PaginationEmptyBinder) DataLoadingSettingsBinder(io.jmix.ui.settings.component.binder.DataLoadingSettingsBinder) ShortcutListenerDelegate(io.jmix.ui.widget.ShortcutListenerDelegate) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) FetchPlanRepository(io.jmix.core.FetchPlanRepository) KeyValueMetaClass(io.jmix.core.impl.keyvalue.KeyValueMetaClass) Action(io.jmix.ui.action.Action) Range(io.jmix.core.metamodel.model.Range) ColumnHeaderMode(com.vaadin.v7.ui.Table.ColumnHeaderMode) TablePresentations(io.jmix.ui.presentation.TablePresentations) Preconditions.checkNotNullArgument(io.jmix.core.common.util.Preconditions.checkNotNullArgument) Property(com.vaadin.v7.data.Property) ConverterUtil(com.vaadin.v7.data.util.converter.ConverterUtil) Subscription(io.jmix.core.common.event.Subscription) EntityPreconditions(io.jmix.core.entity.EntityPreconditions) Datatype(io.jmix.core.metamodel.datatype.Datatype) InvocationTargetException(java.lang.reflect.InvocationTargetException) ThemeConstantsManager(io.jmix.ui.theme.ThemeConstantsManager) IconResolver(io.jmix.ui.icon.IconResolver) AggregatableDelegate(io.jmix.ui.component.data.aggregation.impl.AggregatableDelegate) MessageTools(io.jmix.core.MessageTools) BindingState(io.jmix.ui.component.data.BindingState) io.jmix.ui.component(io.jmix.ui.component) java.util(java.util) UiComponentProperties(io.jmix.ui.UiComponentProperties) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) FrameOwner(io.jmix.ui.screen.FrameOwner) BooleanUtils(org.apache.commons.lang3.BooleanUtils) Converter(com.vaadin.v7.data.util.converter.Converter) TableSettings(io.jmix.ui.settings.component.TableSettings) SettingsWrapper(io.jmix.ui.settings.component.SettingsWrapper) Strings(com.google.common.base.Strings) InstanceContainer(io.jmix.ui.model.InstanceContainer) Resource(com.vaadin.server.Resource) DatatypeRegistry(io.jmix.core.metamodel.datatype.DatatypeRegistry) BaseAction(io.jmix.ui.action.BaseAction) Nullable(javax.annotation.Nullable) Actions(io.jmix.ui.Actions) CollectionContainer(io.jmix.ui.model.CollectionContainer) FetchPlan(io.jmix.core.FetchPlan) JmixEnhancedTable(io.jmix.ui.widget.JmixEnhancedTable) TablePresentationsLayout(io.jmix.ui.component.presentation.TablePresentationsLayout) UiControllerUtils(io.jmix.ui.screen.UiControllerUtils) ValueConversionException(io.jmix.ui.component.data.ValueConversionException) Entity(io.jmix.core.Entity) com.vaadin.ui(com.vaadin.ui) MetaClass(io.jmix.core.metamodel.model.MetaClass) ComponentSettingsBinder(io.jmix.ui.settings.component.binder.ComponentSettingsBinder) Preconditions(io.jmix.core.common.util.Preconditions) Formatter(io.jmix.ui.component.formatter.Formatter) BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) InstallTargetHandler(io.jmix.ui.screen.InstallTargetHandler) EventHub(io.jmix.core.common.event.EventHub) EntityValues(io.jmix.core.entity.EntityValues) Messages(io.jmix.core.Messages) ParseException(java.text.ParseException) MetadataTools(io.jmix.core.MetadataTools) Method(java.lang.reflect.Method) EmptyDataUnit(io.jmix.ui.component.data.meta.EmptyDataUnit) JmixValueChangeEvent(io.jmix.ui.widget.compatibility.JmixValueChangeEvent) DataUnit(io.jmix.ui.component.data.DataUnit) ComponentSettings(io.jmix.ui.settings.component.ComponentSettings) AccessManager(io.jmix.core.AccessManager) LookupSelectionChangeNotifier(io.jmix.ui.component.LookupComponent.LookupSelectionChangeNotifier) EntityTableItems(io.jmix.ui.component.data.meta.EntityTableItems) UiEntityContext(io.jmix.ui.accesscontext.UiEntityContext) PaginationDataUnitBinder(io.jmix.ui.component.pagination.data.PaginationDataUnitBinder) Collectors(java.util.stream.Collectors) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) AbstractComponent(com.vaadin.ui.AbstractComponent) JmixButton(io.jmix.ui.widget.JmixButton) AppUI(io.jmix.ui.AppUI) AggregationContainer(io.jmix.ui.widget.data.AggregationContainer) HasValueSource(io.jmix.ui.component.data.HasValueSource) AbstractSelect(com.vaadin.v7.ui.AbstractSelect) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) Aggregations(io.jmix.ui.component.data.aggregation.Aggregations) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) AggregationInputValueChangeContext(io.jmix.ui.widget.JmixEnhancedTable.AggregationInputValueChangeContext) SettingsHelper(io.jmix.ui.settings.SettingsHelper) CssLayout(com.vaadin.ui.CssLayout) io.jmix.ui.component.table(io.jmix.ui.component.table) Function(java.util.function.Function) InitializingBean(org.springframework.beans.factory.InitializingBean) Notifications(io.jmix.ui.Notifications) LOOKUP_ENTER_PRESSED_ACTION_ID(io.jmix.ui.screen.LookupScreen.LOOKUP_ENTER_PRESSED_ACTION_ID) Aggregation(io.jmix.ui.component.data.aggregation.Aggregation) KeyCode(com.vaadin.event.ShortcutAction.KeyCode) UiEntityAttributeContext(io.jmix.ui.accesscontext.UiEntityAttributeContext) CurrentAuthentication(io.jmix.core.security.CurrentAuthentication) ScreenContext(io.jmix.ui.screen.ScreenContext) Logger(org.slf4j.Logger) TableItems(io.jmix.ui.component.data.TableItems) ThemeConstants(io.jmix.ui.theme.ThemeConstants) LOOKUP_ITEM_CLICK_ACTION_ID(io.jmix.ui.screen.LookupScreen.LOOKUP_ITEM_CLICK_ACTION_ID) Metadata(io.jmix.core.Metadata) ComponentSettingsRegistry(io.jmix.ui.settings.ComponentSettingsRegistry) UserSettingsTools(io.jmix.ui.settings.UserSettingsTools) Sizeable(com.vaadin.server.Sizeable) TablePresentation(io.jmix.ui.presentation.model.TablePresentation) SettingsWrapperImpl(io.jmix.ui.settings.component.SettingsWrapperImpl) Consumer(java.util.function.Consumer) VaadinSession(com.vaadin.server.VaadinSession) EntityStates(io.jmix.core.EntityStates) Element(org.dom4j.Element) DataComponents(io.jmix.ui.model.DataComponents) Component(com.vaadin.ui.Component) PaginationDataBinder(io.jmix.ui.component.pagination.data.PaginationDataBinder) ThemeConstants(io.jmix.ui.theme.ThemeConstants) ThemeConstantsManager(io.jmix.ui.theme.ThemeConstantsManager) ShortcutListenerDelegate(io.jmix.ui.widget.ShortcutListenerDelegate) AppUI(io.jmix.ui.AppUI)

Aggregations

ThemeConstants (io.jmix.ui.theme.ThemeConstants)22 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ThemeConstantsManager (io.jmix.ui.theme.ThemeConstantsManager)4 FilterHelper (com.haulmont.cuba.gui.components.filter.FilterHelper)2 Messages (io.jmix.core.Messages)2 Notifications (io.jmix.ui.Notifications)2 AbstractAction (io.jmix.ui.action.AbstractAction)2 JmixButton (io.jmix.ui.widget.JmixButton)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 Strings (com.google.common.base.Strings)1 Security (com.haulmont.cuba.core.global.Security)1 WindowManager (com.haulmont.cuba.gui.WindowManager)1 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)1 Window (com.haulmont.cuba.gui.components.Window)1 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)1 KeyCode (com.vaadin.event.ShortcutAction.KeyCode)1 Resource (com.vaadin.server.Resource)1 Sizeable (com.vaadin.server.Sizeable)1 VaadinSession (com.vaadin.server.VaadinSession)1