Revision e6af66a6
Added by Alexander Oppermann over 9 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/model/User.java | ||
---|---|---|
7 | 7 |
import java.util.List; |
8 | 8 |
import java.util.Map; |
9 | 9 |
|
10 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
11 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
12 |
|
|
13 | 10 |
public class User implements Serializable { |
14 | 11 |
|
15 | 12 |
/** |
16 |
*
|
|
13 |
* |
|
17 | 14 |
*/ |
18 | 15 |
private static final long serialVersionUID = 1L; |
19 |
private String name; |
|
20 |
private Map<String, String> prop; |
|
16 |
private final String name;
|
|
17 |
private final Map<String, String> prop;
|
|
21 | 18 |
|
22 | 19 |
public User(String name) { |
23 | 20 |
this.name = name; |
... | ... | |
43 | 40 |
} |
44 | 41 |
return getItemId; |
45 | 42 |
} |
43 |
|
|
44 |
/** |
|
45 |
* @param itemId |
|
46 |
*/ |
|
47 |
public Object getItem(Object itemId) { |
|
48 |
String item = itemId.toString(); |
|
49 |
for (Map.Entry<String, String> entry : prop.entrySet()) { |
|
50 |
if(item.equalsIgnoreCase(entry.getValue())) { |
|
51 |
return entry.getValue(); |
|
52 |
} |
|
53 |
} |
|
54 |
return null; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* @param itemId |
|
59 |
* @param propertyId |
|
60 |
*/ |
|
61 |
public Object getContainerProperty(Object itemId, Object propertyId) { |
|
62 |
if(prop.containsKey(propertyId) && prop.containsValue(itemId)){ |
|
63 |
for (Map.Entry<String, String> entry : prop.entrySet()) { |
|
64 |
if(propertyId.toString().equalsIgnoreCase(entry.getKey())) { |
|
65 |
return entry.getKey(); |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
return null; |
|
70 |
} |
|
46 | 71 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/model/Users.java | ||
---|---|---|
7 | 7 |
import com.vaadin.data.Container; |
8 | 8 |
import com.vaadin.data.Item; |
9 | 9 |
import com.vaadin.data.Property; |
10 |
import com.vaadin.data.util.ObjectProperty; |
|
10 | 11 |
|
11 | 12 |
public class Users implements Container { |
12 | 13 |
/** |
13 |
*
|
|
14 |
* |
|
14 | 15 |
*/ |
15 | 16 |
private static final long serialVersionUID = 1L; |
16 |
private List<User> users; |
|
17 |
private final List<User> users;
|
|
17 | 18 |
|
18 | 19 |
public Users() { |
19 | 20 |
|
... | ... | |
33 | 34 |
@Override |
34 | 35 |
public Item getItem(Object itemId) { |
35 | 36 |
String tool = "string"; |
36 |
String bar = "foo";
|
|
37 |
String bar = "foo"; |
|
37 | 38 |
return null; |
38 | 39 |
} |
39 | 40 |
|
40 | 41 |
@Override |
41 | 42 |
public Collection<?> getContainerPropertyIds() { |
42 |
// TODO Auto-generated method stub
|
|
43 |
Collection<String> c = new ArrayList<String>();
|
|
43 | 44 |
for(User user:users){ |
44 |
return user.getPropertyId();
|
|
45 |
c.addAll(user.getPropertyId());
|
|
45 | 46 |
} |
46 |
return null;
|
|
47 |
return c;
|
|
47 | 48 |
} |
48 | 49 |
|
49 | 50 |
@Override |
50 | 51 |
public Collection<?> getItemIds() { |
52 |
Collection<String> c = new ArrayList<String>(); |
|
51 | 53 |
for(User user:users){ |
52 |
return user.getItemId();
|
|
54 |
c.addAll(user.getItemId());
|
|
53 | 55 |
} |
54 |
return null;
|
|
56 |
return c;
|
|
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
@Override |
58 | 60 |
public Property getContainerProperty(Object itemId, Object propertyId) { |
59 | 61 |
// TODO Auto-generated method stub |
60 |
return null; |
|
62 |
ObjectProperty<String> property = new ObjectProperty<String>((String)itemId); |
|
63 |
return property; |
|
61 | 64 |
} |
62 | 65 |
|
63 | 66 |
@Override |
Also available in: Unified diff
improving UsersContainer