Search in sources :

Example 1 with ThemeConstants

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

the class MaxResultsFieldHelper method setUpMaxResultsLookupField.

public LookupField setUpMaxResultsLookupField(LookupField maxResultsLookupField) {
    ThemeConstants theme = themeConstantsManager.getConstants();
    maxResultsLookupField.setWidth(theme.get("cuba.gui.Filter.maxResults.lookup.width"));
    filterHelper.setLookupTextInputAllowed(maxResultsLookupField, false);
    filterHelper.setLookupNullSelectionAllowed(maxResultsLookupField, false);
    List<Integer> maxResultOptions = new ArrayList<>();
    String maxResultOptionsStr = clientConfig.getGenericFilterMaxResultsOptions();
    Iterable<String> split = Splitter.on(",").trimResults().split(maxResultOptionsStr);
    for (String option : split) {
        if ("NULL".equals(option)) {
            filterHelper.setLookupNullSelectionAllowed(maxResultsLookupField, true);
        } else {
            try {
                Integer value = Integer.valueOf(option);
                maxResultOptions.add(value);
            } catch (NumberFormatException ignored) {
            }
        }
    }
    maxResultsLookupField.setOptionsList(maxResultOptions);
    return maxResultsLookupField;
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ArrayList(java.util.ArrayList)

Example 2 with ThemeConstants

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

the class AddConditionWindow method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    ThemeConstants theme = themeConstantsManager.getConstants();
    getDialogOptions().setHeight(theme.get("cuba.gui.addFilterCondition.dialog.height")).setWidth(theme.get("cuba.gui.addFilterCondition.dialog.width")).setResizable(true);
    conditionDescriptorsDs.refresh(params);
    expandTreeRoots();
    tree.setItemClickAction(new AbstractAction("select") {

        @Override
        public void actionPerform(Component component) {
            select();
        }
    });
    FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
    filterHelper.addTextChangeListener(treeFilter, new FilterHelper.TextChangeListener() {

        @Override
        public void textChanged(String text) {
            _search(text);
        }
    });
    filterHelper.addShortcutListener(treeFilter, new FilterHelper.ShortcutListener("search", new KeyCombination(Key.ENTER)) {

        @Override
        public void handleShortcutPressed() {
            search();
        }
    });
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) FilterHelper(com.haulmont.cuba.gui.components.filter.FilterHelper)

Example 3 with ThemeConstants

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

the class FilterSelectWindow method init.

@SuppressWarnings("unchecked")
@Override
public void init(Map<String, Object> params) {
    ThemeConstants theme = themeConstantsManager.getConstants();
    getDialogOptions().setHeight(theme.get("cuba.gui.filterSelect.dialog.height")).setWidth(theme.get("cuba.gui.filterSelect.dialog.width")).setResizable(true);
    filterEntitiesTable.addGeneratedColumn("name", new Table.ColumnGenerator<FilterEntity>() {

        @Override
        public Component generateCell(FilterEntity entity) {
            Label label = componentsFactory.createComponent(Label.class);
            String caption;
            if (Strings.isNullOrEmpty(entity.getCode())) {
                caption = InstanceUtils.getInstanceName(entity);
            } else {
                caption = messages.getMainMessage(entity.getCode());
            }
            label.setValue(caption);
            captionsMap.put(entity, caption);
            return label;
        }
    });
    filterEntities = (List<FilterEntity>) params.get("filterEntities");
    fillDatasource(null);
    filterEntitiesTable.setItemClickAction(new AbstractAction("selectByDblClk") {

        @Override
        public void actionPerform(Component component) {
            select();
        }

        @Override
        public String getCaption() {
            return messages.getMainMessage("filter.filterSelect.select");
        }
    });
    FilterHelper filterHelper = AppBeans.get(FilterHelper.class);
    filterHelper.addTextChangeListener(nameFilterField, new FilterHelper.TextChangeListener() {

        @Override
        public void textChanged(String text) {
            fillDatasource(text);
        }
    });
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) FilterHelper(com.haulmont.cuba.gui.components.filter.FilterHelper)

Example 4 with ThemeConstants

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

the class IconsImpl method getThemeIcon.

protected String getThemeIcon(String iconName) {
    ThemeConstants theme = themeConstantsManager.getConstants();
    String icon = iconName.replace("/", ".");
    String themeIcon = theme.get("icons." + icon);
    if (StringUtils.isEmpty(themeIcon)) {
        themeIcon = theme.get("cuba.web." + icon);
    }
    return themeIcon;
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants)

Example 5 with ThemeConstants

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

the class ScreenXmlParser method replaceAssignParameters.

protected void replaceAssignParameters(Document document) {
    Map<String, String> assignedParams = new HashMap<>();
    List<Element> assignElements = Dom4j.elements(document.getRootElement(), "assign");
    ThemeConstantsManager themeManager = AppBeans.get(ThemeConstantsManager.NAME);
    for (Element assignElement : assignElements) {
        String name = assignElement.attributeValue("name");
        if (StringUtils.isEmpty(name)) {
            throw new RuntimeException("'name' attribute of assign tag is empty");
        }
        String value = assignElement.attributeValue("value");
        if (StringUtils.isEmpty(value)) {
            throw new RuntimeException("'value' attribute of assign tag is empty");
        }
        if (StringUtils.startsWith(value, ThemeConstants.PREFIX)) {
            ThemeConstants theme = themeManager.getConstants();
            value = theme.get(value.substring(ThemeConstants.PREFIX.length()));
        }
        assignedParams.put(name, value);
    }
    if (!assignedParams.isEmpty()) {
        Element layoutElement = document.getRootElement().element("layout");
        if (layoutElement != null) {
            Dom4j.walkAttributesRecursive(layoutElement, (element, attribute) -> {
                String attributeValue = attribute.getValue();
                if (StringUtils.isNotEmpty(attributeValue) && attributeValue.startsWith("${") && attributeValue.endsWith("}")) {
                    String paramKey = attributeValue.substring(2, attributeValue.length() - 1);
                    String assignedValue = assignedParams.get(paramKey);
                    if (assignedValue == null) {
                        throw new RuntimeException("Unable to find value of assign param: " + paramKey);
                    }
                    attribute.setValue(assignedValue);
                }
            });
        }
    }
}
Also used : ThemeConstants(com.haulmont.cuba.gui.theme.ThemeConstants) ThemeConstantsManager(com.haulmont.cuba.gui.theme.ThemeConstantsManager) HashMap(java.util.HashMap) Element(org.dom4j.Element)

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