Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 23:dc086030e6a3
The CollectionView is able to create new instances of a WINFO artifact and to display the artifact's state.
flys-client/trunk@1337 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 22 Feb 2011 17:39:23 +0000 |
parents | |
children | 7142386e86c2 |
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/ParameterList.java Tue Feb 22 17:39:23 2011 +0000 @@ -0,0 +1,112 @@ +package de.intevation.flys.client.client.ui; + +import java.util.ArrayList; +import java.util.List; + +import com.smartgwt.client.types.VerticalAlignment; +import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; + + +public class ParameterList extends VLayout { + + protected List<Data> old; + protected Data current; + + protected UIProvider uiProvider; + + protected VLayout oldItems; + protected VLayout currentItems; + + public ParameterList() { + old = new ArrayList<Data>(); + oldItems = new VLayout(); + currentItems = new VLayout(); + + init(); + } + + + protected void init() { + oldItems.setHeight(20); + currentItems.setHeight("*"); + currentItems.setAlign(VerticalAlignment.TOP); + + addMember(oldItems); + addMember(currentItems); + } + + + public void addOldData(Data old) { + if (old != null) { + this.old.add(old); + } + + refreshOld(); + } + + + public void addOldDatas(Data[] old) { + if (old != null && old.length > 0) { + for (Data o: old) { + addOldData(o); + } + + return; + } + + addOldData(null); + } + + + public void setCurrentData(Data current, UIProvider uiProvider) { + this.current = current; + this.uiProvider = uiProvider; + + refreshCurrent(); + } + + + public void refreshOld() { + // XXX maybe we should not remove all items but just add the newest item + // to the list. + oldItems.removeMembers(oldItems.getMembers()); + + for (Data data: old) { + HLayout h = new HLayout(); + h.setAlign(VerticalAlignment.TOP); + h.setHeight(20); + + DataItem[] items = data.getItems(); + Label label = new Label(data.getLabel()); + Label value = new Label(items[0].getLabel()); + + h.addMember(label); + h.addMember(value); + + oldItems.addMember(h); + } + + int minHeight = oldItems.getMinHeight(); + if (minHeight <= 20) { + oldItems.setHeight(20); + } + else { + oldItems.setHeight(minHeight); + } + } + + + /** + * This method refreshes the part displaying the data of the current state. + * The UI is created using the UIProvider stored in the Data object. + */ + public void refreshCurrent() { + currentItems.addMember(uiProvider.create(current)); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :