Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedHeightsDatacagePanel.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 | 28df64078f27 |
children | 839b2aa84dd0 |
comparison
equal
deleted
inserted
replaced
9219:8642a76f22be | 9220:e3c2ae1887e8 |
---|---|
10 | 10 |
11 import java.util.List; | 11 import java.util.List; |
12 | 12 |
13 import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel; | 13 import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel; |
14 import org.dive4elements.river.client.client.ui.DatacageWidget; | 14 import org.dive4elements.river.client.client.ui.DatacageWidget; |
15 import org.dive4elements.river.client.client.ui.DatacageWidgetData; | |
15 import org.dive4elements.river.client.client.ui.DefaultDatacageTwinPanelInfo; | 16 import org.dive4elements.river.client.client.ui.DefaultDatacageTwinPanelInfo; |
16 import org.dive4elements.river.client.client.ui.RecommendationPairRecord; | 17 import org.dive4elements.river.client.client.ui.RecommendationPairRecord; |
17 import org.dive4elements.river.client.client.ui.WaterlevelTwinPanelValidator; | 18 import org.dive4elements.river.client.client.ui.WaterlevelTwinPanelValidator; |
18 import org.dive4elements.river.client.shared.model.DataList; | 19 import org.dive4elements.river.client.shared.model.DataList; |
19 import org.dive4elements.river.client.shared.model.ToLoad; | 20 import org.dive4elements.river.client.shared.model.ToLoad; |
27 import com.smartgwt.client.widgets.events.ClickHandler; | 28 import com.smartgwt.client.widgets.events.ClickHandler; |
28 import com.smartgwt.client.widgets.grid.ListGrid; | 29 import com.smartgwt.client.widgets.grid.ListGrid; |
29 import com.smartgwt.client.widgets.layout.VLayout; | 30 import com.smartgwt.client.widgets.layout.VLayout; |
30 import com.smartgwt.client.widgets.tree.TreeNode; | 31 import com.smartgwt.client.widgets.tree.TreeNode; |
31 | 32 |
32 public class BedHeightsDatacagePanel | 33 public class BedHeightsDatacagePanel extends AbstractPairRecommendationPanel { |
33 extends AbstractPairRecommendationPanel { | |
34 | 34 |
35 public BedHeightsDatacagePanel(User user) { | 35 private static final DefaultDatacageTwinPanelInfo INFO = new DefaultDatacageTwinPanelInfo(null, "bedheight", null); |
36 // FIXME: This will lead to a bad error message in English (i.e. contains something about waterlevels), for M-Info/Bed-Differences calculation | 36 |
37 // BUT: this is the behavior of 3.2.1 (because of sloppy derivation), so we do not change it now | 37 private static final long serialVersionUID = 1L; |
38 super(user, new WaterlevelTwinPanelValidator(), new DefaultDatacageTwinPanelInfo("bedheight", null), new DefaultDatacageTwinPanelInfo("bedheight", null) ); | 38 |
39 public BedHeightsDatacagePanel(final User user) { | |
40 // FIXME: This will lead to a bad error message in English (i.e. contains something about waterlevels), for | |
41 // M-Info/Bed-Differences calculation | |
42 // BUT: this is the behavior of 3.2.1 (because of sloppy derivation), so we do not change it now | |
43 super(user, new WaterlevelTwinPanelValidator(), INFO, INFO); | |
39 } | 44 } |
40 | 45 |
41 @Override | 46 @Override |
42 protected Canvas createChooserWidgets(final Canvas widget, final DataList dataList, final User user, final ListGrid differencesList) { | 47 protected Canvas createChooserWidgets(final Canvas widget, final DataList dataList, final User user, final ListGrid differencesList) { |
43 GWT.log("createData()"); | 48 GWT.log("createData()"); |
44 | 49 |
45 Canvas submit = getNextButton(); | 50 final Canvas submit = getNextButton(); |
46 | 51 |
47 final DatacageWidget datacage = new DatacageWidget( | 52 final DatacageWidgetData data = new DatacageWidgetData(this.artifact, user, "minfo_diff_panel", "load-system:true", false); |
48 this.artifact, user, "minfo_diff_panel", "load-system:true", false); | |
49 | 53 |
50 Button plusBtn = new Button(msg().datacage_add_pair()); | 54 final DatacageWidget datacage = new DatacageWidget(data); |
55 | |
56 final Button plusBtn = new Button(msg().datacage_add_pair()); | |
51 plusBtn.setAutoFit(true); | 57 plusBtn.setAutoFit(true); |
52 plusBtn.addClickHandler(new ClickHandler() { | 58 plusBtn.addClickHandler(new ClickHandler() { |
53 @Override | 59 @Override |
54 public void onClick(ClickEvent event) { | 60 public void onClick(final ClickEvent event) { |
55 plusClicked(datacage, differencesList); | 61 plusClicked(datacage, differencesList); |
56 } | 62 } |
57 }); | 63 }); |
58 | 64 |
59 VLayout layout = new VLayout(); | 65 final VLayout layout = new VLayout(); |
60 VLayout helperLayout = new VLayout(); | 66 final VLayout helperLayout = new VLayout(); |
61 helperLayout.addMember(datacage); | 67 helperLayout.addMember(datacage); |
62 helperLayout.addMember(plusBtn); | 68 helperLayout.addMember(plusBtn); |
63 | 69 |
64 layout.addMember(widget); | 70 layout.addMember(widget); |
65 layout.addMember(submit); | 71 layout.addMember(submit); |
70 } | 76 } |
71 | 77 |
72 /** | 78 /** |
73 * Callback for add-button. | 79 * Callback for add-button. |
74 * Fires to load for every selected element and handler. | 80 * Fires to load for every selected element and handler. |
75 * @param differencesList | 81 * |
82 * @param differencesList | |
76 */ | 83 */ |
77 protected final static void plusClicked( final DatacageWidget datacage, ListGrid differencesList ) { | 84 protected final static void plusClicked(final DatacageWidget datacage, final ListGrid differencesList) { |
78 List<TreeNode> selection = datacage.getPlainSelection(); | 85 final List<TreeNode> selection = datacage.getPlainSelection(); |
79 | 86 |
80 if (selection == null || selection.isEmpty()) { | 87 if (selection == null || selection.isEmpty()) { |
81 SC.say(msg().warning()); | 88 SC.say(msg().warning()); |
82 return; | 89 return; |
83 } | 90 } |
84 | 91 |
85 for (TreeNode node : selection) { | 92 for (final TreeNode node : selection) { |
86 ToLoad toLoad1 = new ToLoad(); | 93 final ToLoad toLoad1 = new ToLoad(); |
87 ToLoad toLoad2 = new ToLoad(); | 94 final ToLoad toLoad2 = new ToLoad(); |
88 | 95 |
89 String factory = node.getAttribute("factory"); | 96 final String factory = node.getAttribute("factory"); |
90 if (factory != null) { // we need at least a factory | 97 if (factory != null) { // we need at least a factory |
91 String artifact = node.getAttribute("artifact-id"); | 98 final String artifact = node.getAttribute("artifact-id"); |
92 String out = node.getAttribute("out"); | 99 final String out = node.getAttribute("out"); |
93 String name = node.getAttribute("facet"); | 100 final String name = node.getAttribute("facet"); |
94 String ids = node.getAttribute("ids"); | 101 final String ids = node.getAttribute("ids"); |
95 String info = node.getAttribute("info"); | 102 final String info = node.getAttribute("info"); |
96 String targetOut = node.getAttribute("target_out"); | 103 final String targetOut = node.getAttribute("target_out"); |
97 | 104 |
98 String[] splitIds = ids.split("#"); | 105 final String[] splitIds = ids.split("#"); |
99 String[] splitInfo = info.split("#"); | 106 final String[] splitInfo = info.split("#"); |
100 toLoad1.add(artifact, | 107 toLoad1.add(artifact, factory, out, name, splitIds[0], splitInfo[0], targetOut); |
101 factory, | 108 toLoad2.add(artifact, factory, out, name, splitIds[1], splitInfo[1], targetOut); |
102 out, | |
103 name, | |
104 splitIds[0], | |
105 splitInfo[0], | |
106 targetOut); | |
107 toLoad2.add(artifact, | |
108 factory, | |
109 out, | |
110 name, | |
111 splitIds[1], | |
112 splitInfo[1], | |
113 targetOut); | |
114 } | 109 } |
115 differencesList.addData(new RecommendationPairRecord( | 110 differencesList.addData(new RecommendationPairRecord(toLoad1.toRecommendations().get(0), toLoad2.toRecommendations().get(0))); |
116 toLoad1.toRecommendations().get(0), | |
117 toLoad2.toRecommendations().get(0))); | |
118 } | 111 } |
119 } | 112 } |
120 } | 113 } |
121 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |