Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
22:a85bac235069 | 23:dc086030e6a3 |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import com.smartgwt.client.types.VerticalAlignment; | |
7 import com.smartgwt.client.widgets.Label; | |
8 import com.smartgwt.client.widgets.layout.HLayout; | |
9 import com.smartgwt.client.widgets.layout.VLayout; | |
10 | |
11 import de.intevation.flys.client.shared.model.Data; | |
12 import de.intevation.flys.client.shared.model.DataItem; | |
13 | |
14 | |
15 public class ParameterList extends VLayout { | |
16 | |
17 protected List<Data> old; | |
18 protected Data current; | |
19 | |
20 protected UIProvider uiProvider; | |
21 | |
22 protected VLayout oldItems; | |
23 protected VLayout currentItems; | |
24 | |
25 public ParameterList() { | |
26 old = new ArrayList<Data>(); | |
27 oldItems = new VLayout(); | |
28 currentItems = new VLayout(); | |
29 | |
30 init(); | |
31 } | |
32 | |
33 | |
34 protected void init() { | |
35 oldItems.setHeight(20); | |
36 currentItems.setHeight("*"); | |
37 currentItems.setAlign(VerticalAlignment.TOP); | |
38 | |
39 addMember(oldItems); | |
40 addMember(currentItems); | |
41 } | |
42 | |
43 | |
44 public void addOldData(Data old) { | |
45 if (old != null) { | |
46 this.old.add(old); | |
47 } | |
48 | |
49 refreshOld(); | |
50 } | |
51 | |
52 | |
53 public void addOldDatas(Data[] old) { | |
54 if (old != null && old.length > 0) { | |
55 for (Data o: old) { | |
56 addOldData(o); | |
57 } | |
58 | |
59 return; | |
60 } | |
61 | |
62 addOldData(null); | |
63 } | |
64 | |
65 | |
66 public void setCurrentData(Data current, UIProvider uiProvider) { | |
67 this.current = current; | |
68 this.uiProvider = uiProvider; | |
69 | |
70 refreshCurrent(); | |
71 } | |
72 | |
73 | |
74 public void refreshOld() { | |
75 // XXX maybe we should not remove all items but just add the newest item | |
76 // to the list. | |
77 oldItems.removeMembers(oldItems.getMembers()); | |
78 | |
79 for (Data data: old) { | |
80 HLayout h = new HLayout(); | |
81 h.setAlign(VerticalAlignment.TOP); | |
82 h.setHeight(20); | |
83 | |
84 DataItem[] items = data.getItems(); | |
85 Label label = new Label(data.getLabel()); | |
86 Label value = new Label(items[0].getLabel()); | |
87 | |
88 h.addMember(label); | |
89 h.addMember(value); | |
90 | |
91 oldItems.addMember(h); | |
92 } | |
93 | |
94 int minHeight = oldItems.getMinHeight(); | |
95 if (minHeight <= 20) { | |
96 oldItems.setHeight(20); | |
97 } | |
98 else { | |
99 oldItems.setHeight(minHeight); | |
100 } | |
101 } | |
102 | |
103 | |
104 /** | |
105 * This method refreshes the part displaying the data of the current state. | |
106 * The UI is created using the UIProvider stored in the Data object. | |
107 */ | |
108 public void refreshCurrent() { | |
109 currentItems.addMember(uiProvider.create(current)); | |
110 } | |
111 } | |
112 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |