Filter select window displays FilterEntity name, not filter caption #PL-5214

This commit is contained in:
Maxim Gorbunkov 2015-04-10 07:48:59 +00:00
parent b757e5056f
commit 768a7154d0

View File

@ -5,13 +5,13 @@
package com.haulmont.cuba.gui.components.filter.filterselect;
import com.haulmont.cuba.gui.components.AbstractAction;
import com.haulmont.cuba.gui.components.AbstractWindow;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.Table;
import com.google.common.base.Strings;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.theme.ThemeConstants;
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.security.entity.FilterEntity;
import javax.inject.Inject;
@ -36,6 +36,9 @@ public class FilterSelectWindow extends AbstractWindow {
@Inject
protected Table filterEntitiesTable;
@Inject
protected ComponentsFactory componentsFactory;
protected List<FilterEntity> filterEntities;
@SuppressWarnings("unchecked")
@ -47,6 +50,19 @@ public class FilterSelectWindow extends AbstractWindow {
.setWidth(Integer.valueOf(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);
if (Strings.isNullOrEmpty(entity.getCode())) {
label.setValue(InstanceUtils.getInstanceName(entity));
} else {
label.setValue(messages.getMainMessage(entity.getCode()));
}
return label;
}
});
filterEntities = (List<FilterEntity>) params.get("filterEntities");
for (FilterEntity filterEntity : filterEntities) {
filterEntitiesDs.includeItem(filterEntity);