Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Thu Feb 10 14:52:49 2011 +0000 @@ -0,0 +1,117 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.artifacts.common.model.User; + +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.CollectionRecord; +import de.intevation.flys.client.shared.model.DefaultCollection; + +import de.intevation.flys.client.client.FLYSMessages; + + +/** + * The project list shows a list of projects of a specific user. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ProjectList extends VLayout { + + /** The interface that provides i18n messages. */ + private FLYSMessages messages = GWT.create(FLYSMessages.class); + + /** The user whose projects should be displayed.*/ + protected User user; + + /** The grid that contains the project rows.*/ + protected ListGrid grid; + + /** + * The default constructor that creates a new ProjectList for a specific + * user. + * + * @param user The user. + */ + public ProjectList(User user) { + this.user = user; + + grid = new CollectionGrid(); + initGrid(); + + // TODO Remove the following code block after a service to fetch the + // user collections has been implemented! Instead of these static lines, + // a callback mechanism should be implemented that updates this widget + // when the current user changes. + Collection c1 = new DefaultCollection("uu-1"); + Collection c2 = new DefaultCollection("uu-2"); + CollectionRecord rec1 = new CollectionRecord(c1); + CollectionRecord rec2 = new CollectionRecord(c2); + grid.addData(rec1); + grid.addData(rec2); + + init(); + } + + + protected void initGrid() { + grid.setEmptyMessage(messages.no_projects()); + grid.setLoadingDataMessage(messages.load_projects()); + grid.setShowRecordComponents(true); + grid.setShowRecordComponentsByCell(true); + grid.setCanRemoveRecords(false); + grid.setShowHeader(false); + grid.setWidth100(); + + ListGridField date = new ListGridField("date", "date"); + ListGridField name = new ListGridField("name", "name"); + ListGridField pub = new ListGridField("publish", "publish"); + ListGridField del = new ListGridField("delete", "delete"); + + date.setWidth(70); + name.setWidth(155); + pub.setWidth(35); + del.setWidth(35); + + grid.setFields(date, name, pub, del); + } + + + /** + * The init() method handles the layout stuff for this widget. + */ + protected void init() { + setWidth(300); + setHeight100(); + setShowResizeBar(true); + setShowEdges(false); + setLayoutMargin(0); + + Label title = new Label(messages.projects()); + title.setHeight("20"); + title.setMargin(5); + title.setWidth100(); + + Canvas titleWrapper = new Canvas(); + titleWrapper.setBorder("1px solid #808080"); + titleWrapper.setBackgroundColor("#C3D9FF"); + titleWrapper.setWidth100(); + titleWrapper.addChild(title); + + Canvas gridWrapper = new Canvas(); + gridWrapper.setBorder("1px solid #808080"); + gridWrapper.setPadding(0); + titleWrapper.setWidth100(); + gridWrapper.addChild(grid); + + addMember(titleWrapper); + addMember(gridWrapper); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :