Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ContinuePanel.java @ 785:3ae0facd4cab
Added a panel that lets users step to a next state without feeding the current artifact with new data.
flys-client/trunk@2282 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 05 Jul 2011 16:12:34 +0000 |
parents | |
children | 3fa8583434b2 |
comparison
equal
deleted
inserted
replaced
784:3fa64c796ffc | 785:3ae0facd4cab |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import com.google.gwt.core.client.GWT; | |
7 | |
8 import com.smartgwt.client.widgets.Canvas; | |
9 import com.smartgwt.client.widgets.form.DynamicForm; | |
10 import com.smartgwt.client.widgets.form.fields.LinkItem; | |
11 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; | |
12 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; | |
13 | |
14 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
15 import de.intevation.flys.client.shared.model.Data; | |
16 import de.intevation.flys.client.shared.model.DataList; | |
17 | |
18 import de.intevation.flys.client.client.FLYSConstants; | |
19 import de.intevation.flys.client.client.event.AdvanceHandler; | |
20 | |
21 | |
22 /** | |
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
24 */ | |
25 public class ContinuePanel extends AbstractUIProvider { | |
26 | |
27 protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
28 | |
29 protected List<AdvanceHandler> advHandlers; | |
30 | |
31 | |
32 @Override | |
33 public Canvas create(DataList dataList) { | |
34 DynamicForm form = new DynamicForm(); | |
35 form.setWidth(200); | |
36 form.setHeight(35); | |
37 | |
38 LinkItem next = new LinkItem(); | |
39 next.setShowTitle(false); | |
40 next.setLinkTitle(MSG.next()); | |
41 | |
42 final ArtifactDescription desc = artifact.getArtifactDescription(); | |
43 final String[] reachable = desc.getReachableStates(); | |
44 | |
45 next.addClickHandler(new ClickHandler() { | |
46 public void onClick(ClickEvent e) { | |
47 fireOnAdvance(reachable[0]); | |
48 } | |
49 }); | |
50 | |
51 form.setFields(next); | |
52 | |
53 return form; | |
54 } | |
55 | |
56 | |
57 @Override | |
58 public Canvas createOld(DataList dataList) { | |
59 Canvas c = new Canvas(); | |
60 c.setHeight(1); | |
61 c.setWidth(1); | |
62 | |
63 return c; | |
64 } | |
65 | |
66 | |
67 @Override | |
68 protected Data[] getData() { | |
69 return new Data[0]; | |
70 } | |
71 | |
72 | |
73 public void addAdvanceHandler(AdvanceHandler handler) { | |
74 if (advHandlers == null) { | |
75 advHandlers = new ArrayList<AdvanceHandler>(); | |
76 } | |
77 | |
78 if (handler != null) { | |
79 advHandlers.add(handler); | |
80 } | |
81 } | |
82 | |
83 | |
84 public void fireOnAdvance(String target) { | |
85 if (advHandlers == null || advHandlers.isEmpty()) { | |
86 return; | |
87 } | |
88 | |
89 for (AdvanceHandler handler: advHandlers) { | |
90 handler.onAdvance(target); | |
91 } | |
92 } | |
93 } | |
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |