comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.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 2da6be38d8b6
comparison
equal deleted inserted replaced
3:9cf5a40b62c7 4:89976499e013
1 package de.intevation.flys.client.client.ui;
2
3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.widgets.Canvas;
6 import com.smartgwt.client.widgets.Label;
7 import com.smartgwt.client.widgets.grid.ListGrid;
8 import com.smartgwt.client.widgets.grid.ListGridField;
9 import com.smartgwt.client.widgets.layout.VLayout;
10
11 import de.intevation.artifacts.common.model.User;
12
13 import de.intevation.flys.client.shared.model.Collection;
14 import de.intevation.flys.client.shared.model.CollectionRecord;
15 import de.intevation.flys.client.shared.model.DefaultCollection;
16
17 import de.intevation.flys.client.client.FLYSMessages;
18
19
20 /**
21 * The project list shows a list of projects of a specific user.
22 *
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
24 */
25 public class ProjectList extends VLayout {
26
27 /** The interface that provides i18n messages. */
28 private FLYSMessages messages = GWT.create(FLYSMessages.class);
29
30 /** The user whose projects should be displayed.*/
31 protected User user;
32
33 /** The grid that contains the project rows.*/
34 protected ListGrid grid;
35
36 /**
37 * The default constructor that creates a new ProjectList for a specific
38 * user.
39 *
40 * @param user The user.
41 */
42 public ProjectList(User user) {
43 this.user = user;
44
45 grid = new CollectionGrid();
46 initGrid();
47
48 // TODO Remove the following code block after a service to fetch the
49 // user collections has been implemented! Instead of these static lines,
50 // a callback mechanism should be implemented that updates this widget
51 // when the current user changes.
52 Collection c1 = new DefaultCollection("uu-1");
53 Collection c2 = new DefaultCollection("uu-2");
54 CollectionRecord rec1 = new CollectionRecord(c1);
55 CollectionRecord rec2 = new CollectionRecord(c2);
56 grid.addData(rec1);
57 grid.addData(rec2);
58
59 init();
60 }
61
62
63 protected void initGrid() {
64 grid.setEmptyMessage(messages.no_projects());
65 grid.setLoadingDataMessage(messages.load_projects());
66 grid.setShowRecordComponents(true);
67 grid.setShowRecordComponentsByCell(true);
68 grid.setCanRemoveRecords(false);
69 grid.setShowHeader(false);
70 grid.setWidth100();
71
72 ListGridField date = new ListGridField("date", "date");
73 ListGridField name = new ListGridField("name", "name");
74 ListGridField pub = new ListGridField("publish", "publish");
75 ListGridField del = new ListGridField("delete", "delete");
76
77 date.setWidth(70);
78 name.setWidth(155);
79 pub.setWidth(35);
80 del.setWidth(35);
81
82 grid.setFields(date, name, pub, del);
83 }
84
85
86 /**
87 * The init() method handles the layout stuff for this widget.
88 */
89 protected void init() {
90 setWidth(300);
91 setHeight100();
92 setShowResizeBar(true);
93 setShowEdges(false);
94 setLayoutMargin(0);
95
96 Label title = new Label(messages.projects());
97 title.setHeight("20");
98 title.setMargin(5);
99 title.setWidth100();
100
101 Canvas titleWrapper = new Canvas();
102 titleWrapper.setBorder("1px solid #808080");
103 titleWrapper.setBackgroundColor("#C3D9FF");
104 titleWrapper.setWidth100();
105 titleWrapper.addChild(title);
106
107 Canvas gridWrapper = new Canvas();
108 gridWrapper.setBorder("1px solid #808080");
109 gridWrapper.setPadding(0);
110 titleWrapper.setWidth100();
111 gridWrapper.addChild(grid);
112
113 addMember(titleWrapper);
114 addMember(gridWrapper);
115 }
116 }
117 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org