Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacagePairWidget.java @ 9220:e3c2ae1887e8
Allow to filter contents of datacage on client side.
Allow to override column label of datacage
Some code cleanup
author | gernotbelger |
---|---|
date | Wed, 04 Jul 2018 12:00:51 +0200 |
parents | af73fdd96920 |
children | 84397da33d17 |
comparison
equal
deleted
inserted
replaced
9219:8642a76f22be | 9220:e3c2ae1887e8 |
---|---|
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.client.ui; | 9 package org.dive4elements.river.client.client.ui; |
10 | 10 |
11 import org.dive4elements.river.client.client.FLYSConstants; | 11 import org.dive4elements.river.client.client.FLYSConstants; |
12 import org.dive4elements.river.client.shared.model.Artifact; | |
13 import org.dive4elements.river.client.shared.model.ToLoad; | 12 import org.dive4elements.river.client.shared.model.ToLoad; |
14 import org.dive4elements.river.client.shared.model.User; | |
15 | 13 |
16 import com.google.gwt.core.client.GWT; | 14 import com.google.gwt.core.client.GWT; |
17 import com.smartgwt.client.util.SC; | 15 import com.smartgwt.client.util.SC; |
18 import com.smartgwt.client.widgets.Button; | 16 import com.smartgwt.client.widgets.Button; |
19 import com.smartgwt.client.widgets.events.ClickEvent; | 17 import com.smartgwt.client.widgets.events.ClickEvent; |
26 * Widget showing two Datacages and a add-this-button. | 24 * Widget showing two Datacages and a add-this-button. |
27 * Insert a record into a listgrid when add-this-button clicked. | 25 * Insert a record into a listgrid when add-this-button clicked. |
28 */ | 26 */ |
29 public class DatacagePairWidget extends VLayout { | 27 public class DatacagePairWidget extends VLayout { |
30 /** i18n resource. */ | 28 /** i18n resource. */ |
31 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 29 private final FLYSConstants MSG = GWT.create(FLYSConstants.class); |
32 | 30 |
33 /** The "remote" ListGrid to insert data to when add-button is clicked. */ | 31 /** The "remote" ListGrid to insert data to when add-button is clicked. */ |
34 protected ListGrid grid; | 32 private final ListGrid grid; |
35 | 33 |
36 /** First (upper) DataCage Grid. */ | 34 /** First (upper) DataCage Grid. */ |
37 protected DatacageWidget firstDatacageWidget; | 35 private final DatacageWidget firstDatacageWidget; |
38 | 36 |
39 /** Second (lower) DataCage Grid. */ | 37 /** Second (lower) DataCage Grid. */ |
40 protected DatacageWidget secondDatacageWidget; | 38 private final DatacageWidget secondDatacageWidget; |
41 | 39 |
42 /** Max number of recommendation pairs to be added */ | 40 /** Max number of recommendation pairs to be added */ |
43 private final int maxCount; | 41 private final int maxCount; |
42 | |
44 /** errorMsg maxCount */ | 43 /** errorMsg maxCount */ |
45 private final String msgMaxCount; | 44 private final String msgMaxCount; |
46 | 45 |
47 /** | 46 public DatacagePairWidget(final DatacageWidgetData leftData, final DatacageWidgetData rightData, final ListGrid grid, final int maxCount, |
48 * | |
49 * @param artifact | |
50 * Artifact to query datacage with. | |
51 * @param user | |
52 * User to query datacage with. | |
53 * @param leftOuts | |
54 * outs to query the left datacage with. | |
55 * @param rightOuts | |
56 * outs to query the right datacage with. | |
57 * @param grid | |
58 * Grid into which to insert selection of pairs. | |
59 * @param max | |
60 */ | |
61 public DatacagePairWidget(final Artifact artifact, final User user, final String leftOuts, final String rightOuts, final ListGrid grid, final int maxCount, | |
62 final String msgMaxCount) { | 47 final String msgMaxCount) { |
63 this.msgMaxCount = msgMaxCount; | 48 this.msgMaxCount = msgMaxCount; |
64 this.maxCount = maxCount; | 49 this.maxCount = maxCount; |
65 this.grid = grid; | 50 this.grid = grid; |
66 | 51 |
67 final HLayout hLayout = new HLayout(); | 52 final HLayout hLayout = new HLayout(); |
68 this.firstDatacageWidget = new DatacageWidget(artifact, user, leftOuts, "load-system:true", false); | 53 |
69 this.secondDatacageWidget = new DatacageWidget(artifact, user, rightOuts, "load-system:true", false); | 54 this.firstDatacageWidget = new DatacageWidget(leftData); |
55 this.secondDatacageWidget = new DatacageWidget(rightData); | |
56 | |
70 this.firstDatacageWidget.setIsMutliSelectable(false); | 57 this.firstDatacageWidget.setIsMutliSelectable(false); |
71 this.secondDatacageWidget.setIsMutliSelectable(false); | 58 this.secondDatacageWidget.setIsMutliSelectable(false); |
72 | 59 |
73 hLayout.addMember(this.firstDatacageWidget); | 60 hLayout.addMember(this.firstDatacageWidget); |
74 hLayout.addMember(this.secondDatacageWidget); | 61 hLayout.addMember(this.secondDatacageWidget); |
75 | 62 |
76 // TODO: icon | |
77 final Button plusBtn = new Button(this.MSG.datacage_add_pair()); | 63 final Button plusBtn = new Button(this.MSG.datacage_add_pair()); |
78 plusBtn.setAutoFit(true); | 64 plusBtn.setAutoFit(true); |
79 plusBtn.addClickHandler(new ClickHandler() { | 65 plusBtn.addClickHandler(new ClickHandler() { |
80 @Override | 66 @Override |
81 public void onClick(final ClickEvent event) { | 67 public void onClick(final ClickEvent event) { |
93 */ | 79 */ |
94 public void plusClicked() { | 80 public void plusClicked() { |
95 final ToLoad toLoad1 = this.firstDatacageWidget.getSelection(); | 81 final ToLoad toLoad1 = this.firstDatacageWidget.getSelection(); |
96 final ToLoad toLoad2 = this.secondDatacageWidget.getSelection(); | 82 final ToLoad toLoad2 = this.secondDatacageWidget.getSelection(); |
97 | 83 |
84 // FIXME: allows to select folders... but it should not | |
85 | |
98 if (toLoad1 == null || toLoad2 == null || toLoad1.toRecommendations().isEmpty() || toLoad2.toRecommendations().isEmpty()) { | 86 if (toLoad1 == null || toLoad2 == null || toLoad1.toRecommendations().isEmpty() || toLoad2.toRecommendations().isEmpty()) { |
99 SC.say(this.MSG.warning_select_two_values()); | 87 SC.say(this.MSG.warning_select_two_values()); |
100 return; | 88 return; |
101 } | 89 } |
90 | |
102 if (this.grid.getTotalRows() >= this.maxCount) { | 91 if (this.grid.getTotalRows() >= this.maxCount) { |
103 SC.say(this.msgMaxCount); | 92 SC.say(this.msgMaxCount); |
104 return; | 93 return; |
105 } | 94 } |
106 | 95 |
107 this.grid.addData(new RecommendationPairRecord(toLoad1.toRecommendations().get(0), toLoad2.toRecommendations().get(0))); | 96 this.grid.addData(new RecommendationPairRecord(toLoad1.toRecommendations().get(0), toLoad2.toRecommendations().get(0))); |
108 } | 97 } |
109 } | 98 } |
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |