annotate gwt-client/src/main/java/org/dive4elements/river/client/shared/model/CollectionRecord.java @ 8871:78cd6572778d

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 12:02:58 +0100
parents ea9eef426962
children
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.shared.model;
3
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 import java.util.Date;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
607
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
13 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
14 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
15
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 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
17
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 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 * 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
21 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 * @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
23 */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 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
25
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /** The artifact collection. */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 protected Collection collection;
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 * The default constructor.
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 * @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
34 */
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public CollectionRecord(Collection collection) {
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 this.collection = collection;
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
37
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
38 setCreationTime(collection.getCreationTime());
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 String name = collection.getName();
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
41 setName(name != null && name.length() > 0
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
42 ? name
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
43 : 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
44
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
45 setTTL(collection.getTTL());
226
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
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
48
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
49 /**
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
50 * Sets the creation time.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
51 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
52 * @param creationTime The creation time.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
53 */
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
54 public void setCreationTime(Date creationTime) {
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
55 setAttribute("creationTime", creationTime);
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 /**
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
60 * 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
61 *
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
62 * @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
63 */
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
64 public Date getCreationTime() {
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
65 return getAttributeAsDate("creationTime");
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 /**
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 * 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
71 *
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 * @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
73 */
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
74 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
75 SafeHtmlBuilder b = new SafeHtmlBuilder();
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
76 b.appendEscaped(name);
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
77
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
78 SafeHtml html = b.toSafeHtml();
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
79
3acc631efdf0 Escape project's names in the project list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 587
diff changeset
80 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
81 }
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
82
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
83
226
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 * 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
86 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
87 * @return the name of the collection.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
88 */
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
89 public String getName() {
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
90 return getAttributeAsString("name");
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
91 }
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
92
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
93
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
94 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
95 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
96 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
97 }
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 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
99 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
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 }
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
102
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
103
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
104 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
105 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
106 }
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
107
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
108
226
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
109 /**
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
110 * Returns the collection objects itself.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
111 *
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
112 * @return the collection object.
a13382876e5d The project list is sorted now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 222
diff changeset
113 */
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
114 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
115 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
116 }
3
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 }
9cf5a40b62c7 Added an interface and a default implementation of a Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org