# HG changeset patch # User Ingo Weinzierl # Date 1297349569 0 # Node ID 89976499e0132f8dda7789c80a02f56bc2605eb2 # Parent 9cf5a40b62c7048f83603abebd64ecf7798e7129 Implemented a ProjectList and added a mockup that displays two collections in that list. flys-client/trunk@1312 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/ChangeLog Thu Feb 10 14:52:49 2011 +0000 @@ -1,3 +1,33 @@ +2011-02-10 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/ProjectList.java: The + ProjectList stores a reference to the current user and provides a list + with his existing projects. + + NOTE: There are created two Collections and two CollectionRecords for the + mockup. This code needs to be removed after a service to fetch the user + collections has been implemented. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionGrid.java: + This grid will show a list of collections with its last modification date, + their uuid and two buttons to publish and delete the collection. + + NOTE: The buttons have no effect yet. + + * src/main/java/de/intevation/flys/client/client/FLYS.java: The FLYS class + has a reference to the ProjectList. If a logged in user was found, the + ProjectList is initialized and added to the FLYSView. + + * src/main/java/de/intevation/flys/client/client/ui/FLYSView.java: There is + a new method to set the ProjectList. Furthermore, all UI components are + put into a HLayout now. On this way, we are able to open/close the + ProjectList. + + * src/main/java/de/intevation/flys/client/client/FLYSMessages.java, + src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties: + Added strings for the project list. + 2011-02-10 Ingo Weinzierl * src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java, diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Thu Feb 10 14:52:49 2011 +0000 @@ -13,6 +13,7 @@ import de.intevation.flys.client.client.services.UserServiceAsync; import de.intevation.flys.client.client.ui.FLYSView; import de.intevation.flys.client.client.ui.MainMenu; +import de.intevation.flys.client.client.ui.ProjectList; /** @@ -25,9 +26,15 @@ /** The UserService used to retrieve information about the current user. */ protected UserServiceAsync userService = GWT.create(UserService.class); + /** The menu bar at the top of the application.*/ protected MainMenu menu; + + /** The content window. It takes the whole space beneath the menu bar.*/ protected FLYSView view; + /** The project list that displays the projects of the user.*/ + protected ProjectList projectList; + /** * This is the entry point method. @@ -57,6 +64,9 @@ public void onSuccess(User user) { GWT.log("Found a user. Set '"+ user.getLastName()+"'"); menu.setCurrentUser(user); + + projectList = new ProjectList(user); + view.setProjectList(projectList); } }); } diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java Thu Feb 10 14:52:49 2011 +0000 @@ -16,5 +16,17 @@ @DefaultMessage("guest") String guest(); + + @DefaultMessage("Projects") + String projects(); + + @DefaultMessage("No existing projects found.") + String no_projects(); + + @DefaultMessage("Loading projects...") + String load_projects(); + + @DefaultMessage("yyyy-MM-dd") + String date_format(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties Thu Feb 10 14:52:49 2011 +0000 @@ -1,3 +1,7 @@ title = FLYS-3.0 user = Benutzer: ''{0}'' guest = Gast +projects = Berechnungen +no_projects = Keine alten Berechnungen gefunden. +load_projects = Lade Berechnungen... +date_format = dd.MM.yyyy diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties Thu Feb 10 14:52:49 2011 +0000 @@ -1,3 +1,7 @@ title = FLYS-3.0 user = User: ''{0}'' guest = guest +projects = Calculations +no_projects = No existing calculations found. +load_projects = Load calculations... +date_format = yyyy-MM-dd diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionGrid.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionGrid.java Thu Feb 10 14:52:49 2011 +0000 @@ -0,0 +1,114 @@ +package de.intevation.flys.client.client.ui; + +import java.util.Date; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.i18n.client.DateTimeFormat; + +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import de.intevation.flys.client.shared.model.CollectionRecord; + +import de.intevation.flys.client.client.FLYSMessages; + + +/** + * @author Ingo Weinzierl + */ +public class CollectionGrid extends ListGrid { + + /** The message class that provides i18n strings.*/ + FLYSMessages messages = GWT.create(FLYSMessages.class); + + /** + * The default constructor that creates a new ListGrid item. + * + * @param collection The artifact collection. + */ + public CollectionGrid() { + } + + @Override + protected Canvas createRecordComponent( + final ListGridRecord record, Integer col) + { + String field = getFieldName(col); + + if (field == null) return null; + if (field.equals("date")) return createDateField(record); + else if (field.equals("name")) return createNameField(record); + else if (field.equals("publish")) return createPublishField(record); + else if (field.equals("delete")) return createDeleteField(record); + + return null; + } + + + /** + * This method creates the date field for the collection grid. + * + * @param record The record to be displayed. + */ + protected Canvas createDateField(ListGridRecord record) { + CollectionRecord rec = (CollectionRecord) record; + + Date date = rec.getDate(); + DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format()); + String formatted = dtf.format(date); + + Label label = new Label(formatted); + label.setHeight(15); + + return label; + } + + + /** + * This method creates the name field for the collection grid. + * + * @param record The record to be displayed. + */ + protected Canvas createNameField(ListGridRecord record) { + CollectionRecord rec = (CollectionRecord) record; + + Label label = new Label(rec.getName()); + label.setHeight(15); + + return label; + } + + + /** + * This method creates the field for the collection grid that provides a + * button to publish the collection. + * + * @param record The record to be displayed. + */ + protected Canvas createPublishField(ListGridRecord record) { + IButton button = new IButton(); + button.setHeight(15); + button.setWidth(30); + button.setTitle("PUB"); + return button; + } + + + /** + * This method creates the field for the collection grid that provides a + * button to delete the collection. + * + * @param record The record to be displayed. + */ + protected Canvas createDeleteField(ListGridRecord record) { + IButton button = new IButton(); + button.setHeight(15); + button.setWidth(30); + button.setTitle("DEL"); + return button; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java Thu Feb 10 14:45:14 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java Thu Feb 10 14:52:49 2011 +0000 @@ -1,7 +1,7 @@ package de.intevation.flys.client.client.ui; import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; /** @@ -9,11 +9,27 @@ */ public class FLYSView extends Canvas { + /** The project list displaying the projects of a user.*/ + protected ProjectList projectList; + + /** The layout provided by this widget.*/ + protected HLayout layout; + + + /** + * The default constructor for creating a new empty FLYSView. After creating + * the components, {@link init()} is called to do the layout work. + */ public FLYSView() { + layout = new HLayout(); + init(); } + /** + * This method is called to do the layout work. + */ protected void init() { setWidth("100%"); setHeight("*"); @@ -21,7 +37,21 @@ setBorder("1px solid #808080"); setBackgroundColor("#C3D9FF"); - addChild(new Label("Hello Content!")); + addChild(layout); + } + + + /** + * Set the current project list. Previous ProjectLists are replaced by the + * new one. + */ + public void setProjectList(ProjectList projectList) { + if (this.projectList != null) { + removeChild(this.projectList); + } + + this.projectList = projectList; + layout.addMember(this.projectList); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 9cf5a40b62c7 -r 89976499e013 flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java --- /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 Ingo Weinzierl + */ +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 :