mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
integrate MessageProvider and enums
This commit is contained in:
parent
9c0f810490
commit
8ac56a6296
@ -11,11 +11,14 @@ package com.haulmont.cuba.web.gui.data;
|
||||
|
||||
import com.itmill.toolkit.data.Item;
|
||||
import com.itmill.toolkit.data.Property;
|
||||
import com.haulmont.cuba.core.global.MessageProvider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
public class EnumerationContainer implements com.itmill.toolkit.data.Container {
|
||||
private List<Enum> values;
|
||||
|
||||
@ -77,9 +80,14 @@ public class EnumerationContainer implements com.itmill.toolkit.data.Container {
|
||||
|
||||
private static class EnumerationItem implements Item {
|
||||
private Object item;
|
||||
private String name;
|
||||
|
||||
public EnumerationItem(Object itemId) {
|
||||
this.item = itemId;
|
||||
String nameKey = item.getClass().getSimpleName() + "." + item.toString();
|
||||
|
||||
name = MessageProvider.getMessage(item.getClass(), nameKey);
|
||||
if (StringUtils.isEmpty(name)) name = item.toString();
|
||||
}
|
||||
|
||||
public Property getItemProperty(Object id) {
|
||||
@ -100,7 +108,7 @@ public class EnumerationContainer implements com.itmill.toolkit.data.Container {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return item.toString();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user