Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.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 | f48b2cb2e219 |
children | c19985f75118 |
comparison
equal
deleted
inserted
replaced
22:a85bac235069 | 23:dc086030e6a3 |
---|---|
12 import com.smartgwt.client.widgets.Window; | 12 import com.smartgwt.client.widgets.Window; |
13 import com.smartgwt.client.widgets.events.ClickEvent; | 13 import com.smartgwt.client.widgets.events.ClickEvent; |
14 import com.smartgwt.client.widgets.events.ClickHandler; | 14 import com.smartgwt.client.widgets.events.ClickHandler; |
15 import com.smartgwt.client.widgets.form.DynamicForm; | 15 import com.smartgwt.client.widgets.form.DynamicForm; |
16 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; | 16 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; |
17 import com.smartgwt.client.widgets.layout.Layout; | |
17 import com.smartgwt.client.widgets.layout.VLayout; | 18 import com.smartgwt.client.widgets.layout.VLayout; |
18 import com.smartgwt.client.widgets.tab.Tab; | 19 import com.smartgwt.client.widgets.tab.Tab; |
20 import com.smartgwt.client.widgets.tab.TabSet; | |
19 | 21 |
20 import de.intevation.flys.client.shared.model.Artifact; | 22 import de.intevation.flys.client.shared.model.Artifact; |
23 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
21 import de.intevation.flys.client.shared.model.Collection; | 24 import de.intevation.flys.client.shared.model.Collection; |
25 import de.intevation.flys.client.shared.model.Data; | |
22 import de.intevation.flys.client.shared.model.DefaultCollection; | 26 import de.intevation.flys.client.shared.model.DefaultCollection; |
23 | 27 |
24 import de.intevation.flys.client.client.Config; | 28 import de.intevation.flys.client.client.Config; |
25 import de.intevation.flys.client.client.FLYS; | 29 import de.intevation.flys.client.client.FLYS; |
26 import de.intevation.flys.client.client.FLYSMessages; | 30 import de.intevation.flys.client.client.FLYSMessages; |
27 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; | 31 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; |
32 import de.intevation.flys.client.client.event.HasStepForwardHandlers; | |
28 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 33 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
34 import de.intevation.flys.client.client.event.StepForwardEvent; | |
35 import de.intevation.flys.client.client.event.StepForwardHandler; | |
29 import de.intevation.flys.client.client.event.CollectionChangeHandler; | 36 import de.intevation.flys.client.client.event.CollectionChangeHandler; |
30 import de.intevation.flys.client.client.services.ArtifactService; | 37 import de.intevation.flys.client.client.services.ArtifactService; |
31 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 38 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
32 | 39 |
33 | 40 |
34 /** | 41 /** |
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 42 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
36 */ | 43 */ |
37 public class CollectionView | 44 public class CollectionView |
38 extends Window | 45 extends Window |
39 implements CollectionChangeHandler, HasCollectionChangeHandlers { | 46 implements CollectionChangeHandler, HasCollectionChangeHandlers, |
40 | 47 StepForwardHandler |
48 { | |
41 /** The ArtifactService used to communicate with the Artifact server. */ | 49 /** The ArtifactService used to communicate with the Artifact server. */ |
42 protected ArtifactServiceAsync artifactService = | 50 protected ArtifactServiceAsync artifactService = |
43 GWT.create(ArtifactService.class); | 51 GWT.create(ArtifactService.class); |
44 | 52 |
45 /** The message class that provides i18n strings.*/ | 53 /** The message class that provides i18n strings.*/ |
46 FLYSMessages messages = GWT.create(FLYSMessages.class); | 54 FLYSMessages messages = GWT.create(FLYSMessages.class); |
47 | 55 |
48 /** The FLYS instance used to call services.*/ | 56 /** The FLYS instance used to call services.*/ |
49 protected FLYS flys; | 57 protected FLYS flys; |
50 | 58 |
59 /** The ParameterList.*/ | |
60 protected ParameterList parameterList; | |
61 | |
51 /** The list of ValueChangeHandlers.*/ | 62 /** The list of ValueChangeHandlers.*/ |
52 protected List<CollectionChangeHandler> handlers; | 63 protected List<CollectionChangeHandler> handlers; |
53 | 64 |
54 /** The collection to be displayed.*/ | 65 /** The collection to be displayed.*/ |
55 protected Collection collection; | 66 protected Collection collection; |
56 | 67 |
68 protected TabSet tabs; | |
69 | |
57 /** The parameter tab.*/ | 70 /** The parameter tab.*/ |
58 protected Tab parameterTab; | 71 protected Tab parameterTab; |
59 | 72 |
60 /** The output tab.*/ | 73 /** The output tab.*/ |
61 protected Tab outputTab; | 74 protected Tab outputTab; |
75 | |
76 /** The layout.*/ | |
77 protected Layout layout; | |
62 | 78 |
63 | 79 |
64 /** | 80 /** |
65 * This constructor creates a new CollectionView that is used to display the | 81 * This constructor creates a new CollectionView that is used to display the |
66 * <i>collection</i>. | 82 * <i>collection</i>. |
69 */ | 85 */ |
70 public CollectionView(FLYS flys, Collection collection) { | 86 public CollectionView(FLYS flys, Collection collection) { |
71 this.flys = flys; | 87 this.flys = flys; |
72 this.collection = collection; | 88 this.collection = collection; |
73 | 89 |
74 this.handlers = new ArrayList<CollectionChangeHandler>(); | 90 this.tabs = new TabSet(); |
91 this.parameterTab = new Tab(messages.winfo()); | |
92 this.parameterList = new ParameterList(); | |
93 this.handlers = new ArrayList<CollectionChangeHandler>(); | |
94 this.layout = new VLayout(); | |
75 | 95 |
76 addCollectionChangeHandler(this); | 96 addCollectionChangeHandler(this); |
77 | 97 |
78 init(); | 98 init(); |
79 } | 99 } |
84 */ | 104 */ |
85 protected void init() { | 105 protected void init() { |
86 setWidth(600); | 106 setWidth(600); |
87 setHeight(400); | 107 setHeight(400); |
88 | 108 |
109 layout.setWidth100(); | |
110 | |
89 setCanDragResize(true); | 111 setCanDragResize(true); |
90 | 112 |
91 DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format()); | 113 DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format()); |
92 String lastAccess = dtf.format(collection.getLastAccess()); | 114 String lastAccess = dtf.format(collection.getLastAccess()); |
93 setTitle(lastAccess + " - " + collection.getName()); | 115 setTitle(lastAccess + " - " + collection.getName()); |
94 | 116 |
95 VLayout layout = new VLayout(); | |
96 addItem(layout); | 117 addItem(layout); |
97 | 118 |
119 layout.addMember(tabs); | |
120 tabs.addTab(parameterTab); | |
121 | |
98 if (isNew()) { | 122 if (isNew()) { |
99 layout.addMember(renderNew()); | 123 tabs.setTabTitle(0, "MODUL"); |
124 tabs.updateTab(0, renderNew()); | |
100 } | 125 } |
101 } | 126 } |
102 | 127 |
103 | 128 |
104 /** | 129 /** |
141 * This method creates a Canvas displaying the plugins of FLYS. | 166 * This method creates a Canvas displaying the plugins of FLYS. |
142 * | 167 * |
143 * @return a Canvas that displays the plugins of FLYS. | 168 * @return a Canvas that displays the plugins of FLYS. |
144 */ | 169 */ |
145 protected Canvas renderNew() { | 170 protected Canvas renderNew() { |
146 VLayout layout = new VLayout(); | 171 VLayout newLayout = new VLayout(); |
147 layout.setWidth100(); | |
148 | 172 |
149 DynamicForm form = new DynamicForm(); | 173 DynamicForm form = new DynamicForm(); |
150 RadioGroupItem radio = new RadioGroupItem("plugin"); | 174 RadioGroupItem radio = new RadioGroupItem("plugin"); |
151 | 175 |
152 radio.setShowTitle(false); | 176 radio.setShowTitle(false); |
173 } | 197 } |
174 | 198 |
175 public void onSuccess(Artifact artifact) { | 199 public void onSuccess(Artifact artifact) { |
176 GWT.log("Successfully created a new artifact."); | 200 GWT.log("Successfully created a new artifact."); |
177 Collection c = new DefaultCollection("TODO"); | 201 Collection c = new DefaultCollection("TODO"); |
202 | |
178 c.addArtifact(artifact); | 203 c.addArtifact(artifact); |
179 | |
180 setCollection(c); | 204 setCollection(c); |
181 } | 205 } |
182 }); | 206 }); |
183 } | 207 } |
184 }); | 208 }); |
185 | 209 |
186 layout.addMember(form); | 210 newLayout.addMember(form); |
187 layout.addMember(go); | 211 newLayout.addMember(go); |
188 | 212 |
189 return layout; | 213 return newLayout; |
190 } | 214 } |
191 | 215 |
192 | 216 |
193 /** | 217 /** |
194 * Set the current collection. | 218 * Set the current collection. |
206 public void onCollectionChange(CollectionChangeEvent event) { | 230 public void onCollectionChange(CollectionChangeEvent event) { |
207 updateView(); | 231 updateView(); |
208 } | 232 } |
209 | 233 |
210 | 234 |
235 public void onStepForward(StepForwardEvent event) { | |
236 GWT.log("CollectionView - onStepForward()"); | |
237 GWT.log("TODO: IMPLEMENT FEED!"); | |
238 } | |
239 | |
240 | |
241 /** | |
242 * Update the view (refresh the list of old and current data). | |
243 */ | |
211 protected void updateView() { | 244 protected void updateView() { |
212 GWT.log("Update view of the collection: " + collection.identifier()); | 245 GWT.log("Update view of the collection: " + collection.identifier()); |
213 // TODO display the artifact information / data | 246 Artifact artifact = collection.getArtifact(0); |
247 ArtifactDescription desc = artifact.getArtifactDescription(); | |
248 | |
249 Data currentData = desc.getCurrentData(); | |
250 if (currentData != null) { | |
251 String uiProvider = currentData.getUIProvider(); | |
252 UIProvider provider = UIProviderFactory.getProvider(uiProvider); | |
253 | |
254 HasStepForwardHandlers handler = (HasStepForwardHandlers) provider; | |
255 handler.addStepForwardHandler(this); | |
256 | |
257 parameterList.setCurrentData(currentData, provider); | |
258 } | |
259 | |
260 parameterList.addOldDatas(desc.getOldData()); | |
261 | |
262 tabs.setTabTitle(0, messages.winfo()); | |
263 tabs.updateTab(0, parameterList); | |
214 } | 264 } |
215 } | 265 } |
216 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 266 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |