comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionGrid.java @ 4:89976499e013

Implemented a ProjectList and added a mockup that displays two collections in that list. flys-client/trunk@1312 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Feb 2011 14:52:49 +0000
parents
children 0bec0112c8b3
comparison
equal deleted inserted replaced
3:9cf5a40b62c7 4:89976499e013
1 package de.intevation.flys.client.client.ui;
2
3 import java.util.Date;
4
5 import com.google.gwt.core.client.GWT;
6 import com.google.gwt.i18n.client.DateTimeFormat;
7
8 import com.smartgwt.client.widgets.Canvas;
9 import com.smartgwt.client.widgets.IButton;
10 import com.smartgwt.client.widgets.Label;
11 import com.smartgwt.client.widgets.grid.ListGrid;
12 import com.smartgwt.client.widgets.grid.ListGridRecord;
13
14 import de.intevation.flys.client.shared.model.CollectionRecord;
15
16 import de.intevation.flys.client.client.FLYSMessages;
17
18
19 /**
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
21 */
22 public class CollectionGrid extends ListGrid {
23
24 /** The message class that provides i18n strings.*/
25 FLYSMessages messages = GWT.create(FLYSMessages.class);
26
27 /**
28 * The default constructor that creates a new ListGrid item.
29 *
30 * @param collection The artifact collection.
31 */
32 public CollectionGrid() {
33 }
34
35 @Override
36 protected Canvas createRecordComponent(
37 final ListGridRecord record, Integer col)
38 {
39 String field = getFieldName(col);
40
41 if (field == null) return null;
42 if (field.equals("date")) return createDateField(record);
43 else if (field.equals("name")) return createNameField(record);
44 else if (field.equals("publish")) return createPublishField(record);
45 else if (field.equals("delete")) return createDeleteField(record);
46
47 return null;
48 }
49
50
51 /**
52 * This method creates the date field for the collection grid.
53 *
54 * @param record The record to be displayed.
55 */
56 protected Canvas createDateField(ListGridRecord record) {
57 CollectionRecord rec = (CollectionRecord) record;
58
59 Date date = rec.getDate();
60 DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format());
61 String formatted = dtf.format(date);
62
63 Label label = new Label(formatted);
64 label.setHeight(15);
65
66 return label;
67 }
68
69
70 /**
71 * This method creates the name field for the collection grid.
72 *
73 * @param record The record to be displayed.
74 */
75 protected Canvas createNameField(ListGridRecord record) {
76 CollectionRecord rec = (CollectionRecord) record;
77
78 Label label = new Label(rec.getName());
79 label.setHeight(15);
80
81 return label;
82 }
83
84
85 /**
86 * This method creates the field for the collection grid that provides a
87 * button to publish the collection.
88 *
89 * @param record The record to be displayed.
90 */
91 protected Canvas createPublishField(ListGridRecord record) {
92 IButton button = new IButton();
93 button.setHeight(15);
94 button.setWidth(30);
95 button.setTitle("PUB");
96 return button;
97 }
98
99
100 /**
101 * This method creates the field for the collection grid that provides a
102 * button to delete the collection.
103 *
104 * @param record The record to be displayed.
105 */
106 protected Canvas createDeleteField(ListGridRecord record) {
107 IButton button = new IButton();
108 button.setHeight(15);
109 button.setWidth(30);
110 button.setTitle("DEL");
111 return button;
112 }
113 }
114 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org