comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java @ 1283:e8bb11976c70

Neaten certain GUI aspects with W-Diff waterlevel-pair selection. flys-client/trunk@2867 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 30 Sep 2011 07:44:35 +0000
parents 87b6a93db523
children cdb1505a32f1
comparison
equal deleted inserted replaced
1282:3904519ec161 1283:e8bb11976c70
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2
3 import java.util.List;
4 import java.util.Map;
5 import java.util.Set;
2 6
3 import com.google.gwt.core.client.GWT; 7 import com.google.gwt.core.client.GWT;
4 8
5 import com.smartgwt.client.widgets.Button; 9 import com.smartgwt.client.widgets.Button;
6 10
18 import de.intevation.flys.client.shared.model.ToLoad; 22 import de.intevation.flys.client.shared.model.ToLoad;
19 23
20 import de.intevation.flys.client.client.FLYSConstants; 24 import de.intevation.flys.client.client.FLYSConstants;
21 25
22 import de.intevation.flys.client.shared.model.Recommendation; 26 import de.intevation.flys.client.shared.model.Recommendation;
27 import de.intevation.flys.client.shared.model.Recommendation.Facet;
28 import de.intevation.flys.client.shared.model.Recommendation.Filter;
23 29
24 30
25 /** 31 /**
26 * Widget showing two Datacages and a plus-button. 32 * Widget showing two Datacages and a plus-button.
27 * Insert a record into a listgrid when plus-button clicked. 33 * Insert a record into a listgrid when plus-button clicked.
28 */ 34 */
29 public class DatacagePairWidget 35 public class DatacagePairWidget
30 extends VLayout 36 extends VLayout
31 { 37 {
32 protected FLYSConstants messages = 38 protected FLYSConstants messages =
33 GWT.create(FLYSConstants.class); 39 GWT.create(FLYSConstants.class);
34 40
35 /** The "remote" ListGrid to insert data to when add-button is clicked. */ 41 /** The "remote" ListGrid to insert data to when add-button is clicked. */
36 protected ListGrid grid; 42 protected ListGrid grid;
37 43
38 /** First attribute-name for StringPairRecord. */ 44 /** First attribute-name for StringPairRecord. */
39 protected static final String ATTRIBUTE_FIRST = "first"; 45 protected static final String ATTRIBUTE_FIRST = "first";
40 46
41 /** Second attribute-name for StringPairRecord. */ 47 /** Second attribute-name for StringPairRecord. */
42 protected static final String ATTRIBUTE_SECOND = "second"; 48 protected static final String ATTRIBUTE_SECOND = "second";
43 49
44 /** First (upper) DataCage Grid. */ 50 /** First (upper) DataCage Grid. */
45 protected DatacageWidget firstDatacageWidget; 51 protected DatacageWidget firstDatacageWidget;
46 52
47 /** Second (lower) DataCage Grid. */ 53 /** Second (lower) DataCage Grid. */
48 protected DatacageWidget secondDatacageWidget; 54 protected DatacageWidget secondDatacageWidget;
49 55
50 56
51 /** 57 /**
52 * Two strings to be displayed in a GridList. 58 * Two strings to be displayed in a GridList, derived from two
53 */ 59 * Recommendations.
54 protected class RecommendationPairRecord extends ListGridRecord { 60 */
55 Recommendation first; 61 protected class RecommendationPairRecord extends ListGridRecord {
56 Recommendation second; 62 Recommendation first;
63 Recommendation second;
64 String firstName;
65 String secondName;
57 66
58 public RecommendationPairRecord() { 67 public RecommendationPairRecord() {
59 } 68 }
60 69
61 public RecommendationPairRecord(Recommendation first, Recommendation second) { 70 public RecommendationPairRecord(String firstName,
62 setFirst(first); 71 Recommendation first,
63 setSecond(second); 72 String secondName,
64 } 73 Recommendation second)
65 74 {
66 75 setFirst(first, firstName);
67 public void setFirst(Recommendation first) { 76 setSecond(second, secondName);
68 this.first = first;
69 setAttribute(ATTRIBUTE_FIRST, first.getFactory() + first.getIDs());
70 }
71
72
73 public void setSecond(Recommendation second) {
74 this.second = second;
75 setAttribute(ATTRIBUTE_SECOND, second.getFactory() + second.getIDs());
76 }
77
78 public Recommendation getFirst() {return first;}
79 public Recommendation getSecond() {return second;}
80 } 77 }
81 78
82 79
83 /** 80 public void setFirst(Recommendation first, String name) {
84 * 81 this.first = first;
85 * @param artifact Artifact to query datacage with. 82 this.firstName = name;
86 * @param user User to query datacage with. 83 setAttribute(ATTRIBUTE_FIRST, name);
87 * @param outs outs to query datacage with. 84 }
88 * @param grid Grid into which to insert selection of pairs. 85
89 */ 86
90 public DatacagePairWidget(Artifact artifact, User user, String outs, 87 public void setSecond(Recommendation second, String name) {
91 ListGrid grid) { 88 this.second = second;
89 this.secondName = name;
90 setAttribute(ATTRIBUTE_SECOND, name);
91 }
92
93 public Recommendation getFirst() {return first;}
94 public Recommendation getSecond() {return second;}
95 public String getFirstName() {return firstName;}
96 public String getSecondName() {return secondName;}
97 }
98
99
100 /**
101 *
102 * @param artifact Artifact to query datacage with.
103 * @param user User to query datacage with.
104 * @param outs outs to query datacage with.
105 * @param grid Grid into which to insert selection of pairs.
106 */
107 public DatacagePairWidget(Artifact artifact,
108 User user,
109 String outs,
110 ListGrid grid) {
92 this.grid = grid; 111 this.grid = grid;
93 112
94 HLayout hLayout = new HLayout(); 113 HLayout hLayout = new HLayout();
114 firstDatacageWidget = new DatacageWidget(artifact, user, outs, false);
115 secondDatacageWidget = new DatacageWidget(artifact, user, outs, false);
116 firstDatacageWidget.setIsMutliSelectable(false);
117 secondDatacageWidget.setIsMutliSelectable(false);
95 118
96 firstDatacageWidget = new DatacageWidget(artifact, user, outs, false);
97 hLayout.addMember(firstDatacageWidget); 119 hLayout.addMember(firstDatacageWidget);
98 secondDatacageWidget = new DatacageWidget(artifact, user, outs, false);
99 hLayout.addMember(secondDatacageWidget); 120 hLayout.addMember(secondDatacageWidget);
100 121
101 // TODO: i18n + icon 122 // TODO: i18n + icon
102 Button plusBtn = new Button("+"); 123 Button plusBtn = new Button("+");
103 plusBtn.addClickHandler(new ClickHandler() { 124 plusBtn.addClickHandler(new ClickHandler() {
117 * Fires to load for every selected element and handler. 138 * Fires to load for every selected element and handler.
118 */ 139 */
119 public void plusClicked() { 140 public void plusClicked() {
120 ToLoad toLoad1 = firstDatacageWidget.getSelection(); 141 ToLoad toLoad1 = firstDatacageWidget.getSelection();
121 ToLoad toLoad2 = secondDatacageWidget.getSelection(); 142 ToLoad toLoad2 = secondDatacageWidget.getSelection();
143 String [] sel1 = firstDatacageWidget.getSelectionTitles();
144 String [] sel2 = secondDatacageWidget.getSelectionTitles();
122 145
123 // TODO further sanitize (toRecommendations.length) 146 // TODO further sanitize (toRecommendations.length)
124 if (toLoad1 == null || toLoad2 == null) { 147 if (toLoad1 == null || toLoad2 == null) {
125 return; 148 return;
126 } 149 }
127 150
128 grid.addData(new RecommendationPairRecord( 151 grid.addData(new RecommendationPairRecord(
152 sel1[0],
129 toLoad1.toRecommendations().get(0), 153 toLoad1.toRecommendations().get(0),
154 sel2[0],
130 toLoad2.toRecommendations().get(0))); 155 toLoad2.toRecommendations().get(0)));
131 } 156 }
132 } 157 }
133 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 158 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org