annotate flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionRecord.java @ 607:3acc631efdf0

Escape project's names in the project list. flys-client/trunk@2214 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 23 Jun 2011 10:07:52 +0000
parents 53ad6dd2cb2b
children 80626c4a5bbf
rev   line source
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.shared.model;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.Date;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
607
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
5 import com.google.gwt.safehtml.shared.SafeHtml;
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
6 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
7 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
8
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.grid.ListGridRecord;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 * The CollectionRecord is a wrapper to put Collection objects into a ListGrid.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 public class CollectionRecord extends ListGridRecord {
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 /** The artifact collection. */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 protected Collection collection;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 * The default constructor.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * @param collection The artifact collection.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 public CollectionRecord(Collection collection) {
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 this.collection = collection;
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
30
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
31 setCreationTime(collection.getCreationTime());
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
32
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
33 String name = collection.getName();
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
34 setName(name != null && name.length() > 0
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
35 ? name
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
36 : collection.identifier());
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
37
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
38 setTTL(collection.getTTL());
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
39 }
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
40
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
41
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
42 /**
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
43 * Sets the creation time.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
44 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
45 * @param creationTime The creation time.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
46 */
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
47 public void setCreationTime(Date creationTime) {
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
48 setAttribute("creationTime", creationTime);
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 /**
97
0bec0112c8b3 Integrated the ProjectList into the client. Now, the Collections of a user are displayed in the list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3
diff changeset
53 * Returns the date of the creation.
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 *
97
0bec0112c8b3 Integrated the ProjectList into the client. Now, the Collections of a user are displayed in the list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3
diff changeset
55 * @return the creation time.
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 */
97
0bec0112c8b3 Integrated the ProjectList into the client. Now, the Collections of a user are displayed in the list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3
diff changeset
57 public Date getCreationTime() {
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
58 return getAttributeAsDate("creationTime");
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 * Returns the name of the collection.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 * @return the name of the collection.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 */
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
67 public void setName(String name) {
607
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
68 SafeHtmlBuilder b = new SafeHtmlBuilder();
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
69 b.appendEscaped(name);
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
70
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
71 SafeHtml html = b.toSafeHtml();
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
72
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
73 setAttribute("name", html.asString());
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
222
9bd9c24f4935 The CollectionRecord implements a method that returns the Collection objects which is represented by the record now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 97
diff changeset
75
9bd9c24f4935 The CollectionRecord implements a method that returns the Collection objects which is represented by the record now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 97
diff changeset
76
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
77 /**
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
78 * Returns the name of the collection or the uuid if no name is specified.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
79 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
80 * @return the name of the collection.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
81 */
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
82 public String getName() {
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
83 return getAttributeAsString("name");
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
84 }
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
85
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
86
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
87 public void setTTL(long ttl) {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
88 if (ttl == 0) {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
89 setAttribute("ttl", "star_gold");
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
90 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
91 else {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
92 setAttribute("ttl", "star_silver");
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
93 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
94 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
95
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
96
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
97 public String getTTL() {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
98 return getAttribute("ttl");
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
99 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
100
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 226
diff changeset
101
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
102 /**
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
103 * Returns the collection objects itself.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
104 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
105 * @return the collection object.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
106 */
222
9bd9c24f4935 The CollectionRecord implements a method that returns the Collection objects which is represented by the record now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 97
diff changeset
107 public Collection getCollection() {
9bd9c24f4935 The CollectionRecord implements a method that returns the Collection objects which is represented by the record now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 97
diff changeset
108 return collection;
9bd9c24f4935 The CollectionRecord implements a method that returns the Collection objects which is represented by the record now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 97
diff changeset
109 }
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org