Search in sources :

Example 16 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class CubaPickerField method initLayout.

protected void initLayout() {
    container = new CubaCssActionsLayout();
    container.setPrimaryStyleName("c-pickerfield-layout");
    field.setWidth(100, Unit.PERCENTAGE);
    Page current = Page.getCurrent();
    if (current != null) {
        WebBrowser browser = current.getWebBrowser();
        if (browser != null && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari())) {
            ie9InputWrapper = new CssLayout();
            ie9InputWrapper.setWidth(100, Unit.PERCENTAGE);
            ie9InputWrapper.setPrimaryStyleName("ie9-input-wrap");
            ie9InputWrapper.addComponent(field);
            container.addComponent(ie9InputWrapper);
        } else {
            container.addComponent(field);
        }
    } else {
        container.addComponent(field);
    }
    if (App.isBound()) {
        ThemeConstants theme = App.getInstance().getThemeConstants();
        setWidth(theme.get("cuba.web.CubaPickerField.width"));
    }
    setFocusDelegate(field);
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants)

Example 17 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class Param method createBooleanField.

protected Component createBooleanField(final ValueProperty valueProperty) {
    Messages messages = AppBeans.get(Messages.NAME);
    ThemeConstants theme = AppBeans.get(ThemeConstantsManager.class).getConstants();
    LookupField field = componentsFactory.createComponent(LookupField.class);
    field.setWidth(theme.get("cuba.gui.filter.Param.booleanLookup.width"));
    Map<String, Object> values = new HashMap<>();
    values.put(messages.getMainMessage("filter.param.boolean.true"), Boolean.TRUE);
    values.put(messages.getMainMessage("filter.param.boolean.false"), Boolean.FALSE);
    field.setOptionsMap(values);
    field.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty));
    field.setValue(_getValue(valueProperty));
    return field;
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ThemeConstantsManager(com.haulmont.cuba.gui.theme.ThemeConstantsManager)

Example 18 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class Param method createEntityLookup.

protected Component createEntityLookup(final ValueProperty valueProperty) {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    MetaClass metaClass = metadata.getSession().getClassNN(javaClass);
    ThemeConstants theme = AppBeans.get(ThemeConstantsManager.class).getConstants();
    PersistenceManagerService persistenceManager = AppBeans.get(PersistenceManagerService.NAME);
    LookupType type = null;
    if (property != null && property.getRange().isClass()) {
        type = (LookupType) metadata.getTools().getMetaAnnotationAttributes(property.getAnnotations(), Lookup.class).get("type");
    }
    boolean useLookupScreen = type != null ? type == LookupType.SCREEN : persistenceManager.useLookupScreen(metaClass.getName());
    if (useLookupScreen) {
        if (inExpr) {
            ListEditor listEditor = componentsFactory.createComponent(ListEditor.class);
            listEditor.setItemType(ListEditor.ItemType.ENTITY);
            listEditor.setEntityName(metaClass.getName());
            initListEditor(listEditor, valueProperty);
            return listEditor;
        } else {
            PickerField picker = componentsFactory.createComponent(PickerField.class);
            picker.setMetaClass(metaClass);
            picker.setWidth(theme.get("cuba.gui.filter.Param.textComponent.width"));
            picker.setFrame(datasource.getDsContext().getFrameContext().getFrame());
            picker.addLookupAction();
            picker.addClearAction();
            picker.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty));
            picker.setValue(_getValue(valueProperty));
            return picker;
        }
    } else {
        CollectionDatasource<Entity<Object>, Object> optionsDataSource = createOptionsDataSource(metaClass);
        if (inExpr) {
            ListEditor listEditor = componentsFactory.createComponent(ListEditor.class);
            listEditor.setItemType(ListEditor.ItemType.ENTITY);
            listEditor.setEntityName(metaClass.getName());
            listEditor.setUseLookupField(true);
            listEditor.setEntityWhereClause(entityWhere);
            initListEditor(listEditor, valueProperty);
            return listEditor;
        } else {
            final LookupPickerField lookup = componentsFactory.createComponent(LookupPickerField.class);
            lookup.addClearAction();
            lookup.setWidth(theme.get("cuba.gui.filter.Param.textComponent.width"));
            lookup.setOptionsDatasource(optionsDataSource);
            // noinspection unchecked
            optionsDataSource.addCollectionChangeListener(e -> lookup.setValue(null));
            lookup.addValueChangeListener(e -> _setValue(e.getValue(), valueProperty));
            lookup.setValue(_getValue(valueProperty));
            return lookup;
        }
    }
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) ThemeConstantsManager(com.haulmont.cuba.gui.theme.ThemeConstantsManager) LookupType(com.haulmont.cuba.core.entity.annotation.LookupType) PersistenceManagerService(com.haulmont.cuba.core.app.PersistenceManagerService) ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) MetaClass(com.haulmont.chile.core.model.MetaClass) Lookup(com.haulmont.cuba.core.entity.annotation.Lookup)

Example 19 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants 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;
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) DesktopThemeLoader(com.haulmont.cuba.desktop.theme.DesktopThemeLoader) ThemeConstantsRepository(com.haulmont.cuba.gui.theme.ThemeConstantsRepository)

Example 20 with ThemeConstants

use of com.haulmont.cuba.gui.theme.ThemeConstants in project cuba by cuba-platform.

the class PresentationEditor method initLayout.

protected void initLayout() {
    ThemeConstants theme = App.getInstance().getThemeConstants();
    VerticalLayout root = new VerticalLayout();
    root.setWidthUndefined();
    root.setSpacing(true);
    setContent(root);
    messages = AppBeans.get(Messages.class);
    nameField = new TextField(messages.getMainMessage("PresentationsEditor.name"));
    nameField.setWidth(theme.get("cuba.web.PresentationEditor.name.width"));
    nameField.setValue(getPresentationCaption());
    root.addComponent(nameField);
    autoSaveField = new CheckBox();
    autoSaveField.setCaption(messages.getMainMessage("PresentationsEditor.autoSave"));
    autoSaveField.setValue(BooleanUtils.isTrue(presentation.getAutoSave()));
    root.addComponent(autoSaveField);
    defaultField = new CheckBox();
    defaultField.setCaption(messages.getMainMessage("PresentationsEditor.default"));
    defaultField.setValue(presentation.getId().equals(component.getDefaultPresentationId()));
    root.addComponent(defaultField);
    if (allowGlobalPresentations) {
        globalField = new CheckBox();
        globalField.setCaption(messages.getMainMessage("PresentationsEditor.global"));
        globalField.setValue(!isNew && presentation.getUser() == null);
        root.addComponent(globalField);
    }
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidthUndefined();
    root.addComponent(buttons);
    root.setComponentAlignment(buttons, Alignment.MIDDLE_LEFT);
    Button commitButton = new CubaButton(messages.getMainMessage("PresentationsEditor.save"));
    commitButton.addClickListener(event -> {
        if (validate()) {
            commit();
            close();
        }
    });
    buttons.addComponent(commitButton);
    Button closeButton = new CubaButton(messages.getMainMessage("PresentationsEditor.close"));
    closeButton.addClickListener(event -> {
        close();
    });
    buttons.addComponent(closeButton);
    nameField.focus();
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) Messages(com.haulmont.cuba.core.global.Messages) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton) CubaButton(com.haulmont.cuba.web.toolkit.ui.CubaButton)

Aggregations

ThemeConstants (com.haulmont.cuba.gui.theme.ThemeConstants)24 ThemeConstantsManager (com.haulmont.cuba.gui.theme.ThemeConstantsManager)4 Configuration (com.haulmont.cuba.core.global.Configuration)3 WebConfig (com.haulmont.cuba.web.WebConfig)3 VersionedThemeResource (com.haulmont.cuba.web.toolkit.VersionedThemeResource)3 Entity (com.haulmont.cuba.core.entity.Entity)2 Messages (com.haulmont.cuba.core.global.Messages)2 FilterHelper (com.haulmont.cuba.gui.components.filter.FilterHelper)2 FileResource (com.vaadin.server.FileResource)2 Resource (com.vaadin.server.Resource)2 File (java.io.File)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 PersistenceManagerService (com.haulmont.cuba.core.app.PersistenceManagerService)1 Lookup (com.haulmont.cuba.core.entity.annotation.Lookup)1 LookupType (com.haulmont.cuba.core.entity.annotation.LookupType)1 FileStorageException (com.haulmont.cuba.core.global.FileStorageException)1 DesktopThemeLoader (com.haulmont.cuba.desktop.theme.DesktopThemeLoader)1 Table (com.haulmont.cuba.gui.components.Table)1 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)1 ThemeConstantsRepository (com.haulmont.cuba.gui.theme.ThemeConstantsRepository)1