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;
}
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();
}
});
}
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);
}
});
}
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;
}
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);
}
});
}
}
}
Aggregations