Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java @ 98:83bf2fb17b7c
Replaced a german string in the ProjectList.
flys-client/trunk@1612 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 30 Mar 2011 07:31:50 +0000 |
parents | 0bec0112c8b3 |
children | b92281182c6b |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; 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.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.types.VerticalAlignment; import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.CollectionRecord; import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSMessages; import de.intevation.flys.client.client.event.CollectionChangeEvent; import de.intevation.flys.client.client.event.CollectionChangeHandler; import de.intevation.flys.client.client.services.UserCollectionsService; import de.intevation.flys.client.client.services.UserCollectionsServiceAsync; /** * 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 implements CollectionChangeHandler { /** The interface that provides i18n messages. */ private FLYSMessages messages = GWT.create(FLYSMessages.class); /** The UserService used to retrieve information about the current user. */ protected UserCollectionsServiceAsync userCollectionsService = GWT.create(UserCollectionsService.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(); init(); updateUserCollections(); } 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(); grid.setHeight100(); ListGridField date = new ListGridField("date", "date"); ListGridField name = new ListGridField("name", "name"); date.setWidth(100); name.setWidth(195); grid.setFields(date, name); } /** * The init() method handles the layout stuff for this widget. */ protected void init() { setWidth(300); setHeight100(); setShowResizeBar(true); setShowEdges(false); setLayoutMargin(0); setLayoutAlign(VerticalAlignment.TOP); Label title = new Label(messages.projects()); title.setHeight("20"); title.setMargin(5); title.setWidth100(); title.setStyleName("fontLightSmall"); Canvas titleWrapper = new Canvas(); titleWrapper.setStyleName("bgBlueDark"); titleWrapper.setWidth100(); titleWrapper.setHeight("20px"); titleWrapper.addChild(title); Canvas gridWrapper = new Canvas(); gridWrapper.setPadding(0); titleWrapper.setWidth100(); gridWrapper.addChild(grid); addMember(titleWrapper); addMember(gridWrapper); } public void onCollectionChange(CollectionChangeEvent event) { GWT.log("ProjectList.onCollectionChange"); updateUserCollections(); } protected void updateUserCollections() { Config config = Config.getInstance(); String url = config.getServerUrl(); userCollectionsService.getUserCollections(url, user.identifier(), new AsyncCallback<Collection[]>() { public void onFailure(Throwable caught) { GWT.log("Could not recieve a list of user collections."); GWT.log(caught.getMessage()); } public void onSuccess(Collection[] collections) { int num = collections != null ? collections.length : 0; GWT.log("Received " + num + " user collections."); if (num == 0) { return; } updateGrid(collections); } } ); } protected void clearGrid() { ListGridRecord[] records = grid.getRecords(); for (ListGridRecord record: records) { grid.removeData(record); } } protected void updateGrid(Collection[] collections) { clearGrid(); for (Collection c: collections) { grid.addData(new CollectionRecord(c)); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :