comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 13:8d9075c07667

Enhanced the CollectionView: there are radio buttons for each module and a button to select one of those. flys-client/trunk@1322 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Feb 2011 09:17:37 +0000
parents a65793e08245
children fe2f4d1dd784
comparison
equal deleted inserted replaced
12:fa0aad20af53 13:8d9075c07667
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2 2
3 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.i18n.client.DateTimeFormat; 4 import com.google.gwt.i18n.client.DateTimeFormat;
5 import com.google.gwt.user.client.ui.RadioButton; 5 import com.google.gwt.user.client.rpc.AsyncCallback;
6 6
7 import com.smartgwt.client.widgets.Canvas; 7 import com.smartgwt.client.widgets.Canvas;
8 import com.smartgwt.client.widgets.IButton;
8 import com.smartgwt.client.widgets.Window; 9 import com.smartgwt.client.widgets.Window;
10 import com.smartgwt.client.widgets.events.ClickEvent;
11 import com.smartgwt.client.widgets.events.ClickHandler;
9 import com.smartgwt.client.widgets.form.DynamicForm; 12 import com.smartgwt.client.widgets.form.DynamicForm;
10 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; 13 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
11 import com.smartgwt.client.widgets.layout.HLayout;
12 import com.smartgwt.client.widgets.layout.VLayout; 14 import com.smartgwt.client.widgets.layout.VLayout;
13 import com.smartgwt.client.widgets.tab.Tab; 15 import com.smartgwt.client.widgets.tab.Tab;
14 import com.smartgwt.client.widgets.tab.TabSet;
15 16
17 import de.intevation.flys.client.shared.model.Artifact;
16 import de.intevation.flys.client.shared.model.Collection; 18 import de.intevation.flys.client.shared.model.Collection;
17 19
20 import de.intevation.flys.client.client.FLYS;
18 import de.intevation.flys.client.client.FLYSMessages; 21 import de.intevation.flys.client.client.FLYSMessages;
22 import de.intevation.flys.client.client.services.ArtifactService;
23 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
19 24
20 25
21 /** 26 /**
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
23 */ 28 */
24 public class CollectionView extends Window { 29 public class CollectionView extends Window {
25 30
31 /** The ArtifactService used to communicate with the Artifact server. */
32 protected ArtifactServiceAsync artifactService =
33 GWT.create(ArtifactService.class);
34
26 /** The message class that provides i18n strings.*/ 35 /** The message class that provides i18n strings.*/
27 FLYSMessages messages = GWT.create(FLYSMessages.class); 36 FLYSMessages messages = GWT.create(FLYSMessages.class);
28 37
38 /** The FLYS instance used to call services.*/
39 protected FLYS flys;
40
29 /** The collection to be displayed.*/ 41 /** The collection to be displayed.*/
30 protected Collection collection; 42 protected Collection collection;
43
44 /** TODO The artifact needs to be removed here after the Collection stuff in
45 * the server has been finished! */
46 protected Artifact artifact;
31 47
32 /** The parameter tab.*/ 48 /** The parameter tab.*/
33 protected Tab parameterTab; 49 protected Tab parameterTab;
34 50
35 /** The output tab.*/ 51 /** The output tab.*/
40 * This constructor creates a new CollectionView that is used to display the 56 * This constructor creates a new CollectionView that is used to display the
41 * <i>collection</i>. 57 * <i>collection</i>.
42 * 58 *
43 * @param collection The collection to be displayed. 59 * @param collection The collection to be displayed.
44 */ 60 */
45 public CollectionView(Collection collection) { 61 public CollectionView(FLYS flys, Collection collection) {
62 this.flys = flys;
46 this.collection = collection; 63 this.collection = collection;
47 64
48 init(); 65 init();
49 } 66 }
50 67
86 * This method creates a Canvas displaying the plugins of FLYS. 103 * This method creates a Canvas displaying the plugins of FLYS.
87 * 104 *
88 * @return a Canvas that displays the plugins of FLYS. 105 * @return a Canvas that displays the plugins of FLYS.
89 */ 106 */
90 protected Canvas renderNew() { 107 protected Canvas renderNew() {
91 HLayout layout = new HLayout(); 108 VLayout layout = new VLayout();
92 layout.setWidth100(); 109 layout.setWidth100();
93 110
94 DynamicForm form = new DynamicForm(); 111 DynamicForm form = new DynamicForm();
95 RadioGroupItem radio = new RadioGroupItem("plugin"); 112 RadioGroupItem radio = new RadioGroupItem("plugin");
96 113
102 messages.map(), 119 messages.map(),
103 messages.fix()); 120 messages.fix());
104 121
105 form.setFields(radio); 122 form.setFields(radio);
106 123
124 IButton go = new IButton(messages.next());
125 go.addClickHandler(new ClickHandler() {
126 public void onClick(ClickEvent event) {
127 artifactService.create("winfo", new AsyncCallback<Artifact>() {
128 public void onFailure(Throwable caught) {
129 GWT.log("Could not create the new artifact.");
130 GWT.log(caught.getMessage());
131 }
132
133 public void onSuccess(Artifact artifact) {
134 GWT.log("Successfully created a new artifact.");
135 setArtifact(artifact);
136 }
137 });
138 }
139 });
140
107 layout.addMember(form); 141 layout.addMember(form);
142 layout.addMember(go);
108 143
109 return layout; 144 return layout;
110 } 145 }
146
147
148 /**
149 * Set the current artifact.
150 *
151 * @param artifact The new artifact.
152 */
153 protected void setArtifact(Artifact artifact) {
154 this.artifact = artifact;
155
156 updateView();
157 }
158
159
160 protected void updateView() {
161 GWT.log("Update the view of the artifact: " + artifact.getUuid());
162 // TODO display the artifact information / data
163 }
111 } 164 }
112 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 165 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org