Mercurial > dive4elements > river
diff 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 |
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/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 <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +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 :