comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/DatacagePairWidget.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java@5e6e89f19a37
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.client.ui;
2
3 import com.google.gwt.core.client.GWT;
4
5 import com.smartgwt.client.util.SC;
6 import com.smartgwt.client.widgets.Button;
7 import com.smartgwt.client.widgets.events.ClickEvent;
8 import com.smartgwt.client.widgets.events.ClickHandler;
9 import com.smartgwt.client.widgets.grid.ListGrid;
10 import com.smartgwt.client.widgets.layout.HLayout;
11 import com.smartgwt.client.widgets.layout.VLayout;
12
13 import de.intevation.flys.client.client.FLYSConstants;
14 import de.intevation.flys.client.shared.model.Artifact;
15 import de.intevation.flys.client.shared.model.ToLoad;
16 import de.intevation.flys.client.shared.model.User;
17
18
19 /**
20 * Widget showing two Datacages and a add-this-button.
21 * Insert a record into a listgrid when add-this-button clicked.
22 */
23 public class DatacagePairWidget
24 extends VLayout
25 {
26 /** i18n resource. */
27 protected FLYSConstants MSG =
28 GWT.create(FLYSConstants.class);
29
30 /** The "remote" ListGrid to insert data to when add-button is clicked. */
31 protected ListGrid grid;
32
33 /** First (upper) DataCage Grid. */
34 protected DatacageWidget firstDatacageWidget;
35
36 /** Second (lower) DataCage Grid. */
37 protected DatacageWidget secondDatacageWidget;
38
39
40 /**
41 *
42 * @param artifact Artifact to query datacage with.
43 * @param user User to query datacage with.
44 * @param outs outs to query datacage with.
45 * @param grid Grid into which to insert selection of pairs.
46 */
47 public DatacagePairWidget(Artifact artifact,
48 User user,
49 String outs,
50 ListGrid grid) {
51 this.grid = grid;
52
53 HLayout hLayout = new HLayout();
54 firstDatacageWidget = new DatacageWidget(
55 artifact,
56 user,
57 outs,
58 "load-system:true",
59 false);
60 secondDatacageWidget = new DatacageWidget(
61 artifact,
62 user,
63 outs,
64 "load-system:true",
65 false);
66 firstDatacageWidget.setIsMutliSelectable(false);
67 secondDatacageWidget.setIsMutliSelectable(false);
68
69 hLayout.addMember(firstDatacageWidget);
70 hLayout.addMember(secondDatacageWidget);
71
72 // TODO: icon
73 Button plusBtn = new Button(MSG.datacage_add_pair());
74 plusBtn.setAutoFit(true);
75 plusBtn.addClickHandler(new ClickHandler() {
76 @Override
77 public void onClick(ClickEvent event) {
78 plusClicked();
79 }
80 });
81
82 addMember(hLayout);
83 addMember(plusBtn);
84 }
85
86
87 /**
88 * Callback for add-button.
89 * Fires to load for every selected element and handler.
90 */
91 public void plusClicked() {
92 ToLoad toLoad1 = firstDatacageWidget.getSelection();
93 ToLoad toLoad2 = secondDatacageWidget.getSelection();
94
95 if (toLoad1 == null || toLoad2 == null ||
96 toLoad1.toRecommendations().isEmpty() ||
97 toLoad2.toRecommendations().isEmpty()) {
98 SC.say(MSG.warning_select_two_values());
99 return;
100 }
101
102 grid.addData(new RecommendationPairRecord(
103 toLoad1.toRecommendations().get(0),
104 toLoad2.toRecommendations().get(0)));
105 }
106 }
107 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org