Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacagePairWidget.java @ 9227:84397da33d17
Allow to control specific behaviour in TwinDatacagePanel
Implemented client logic of 'intelligent datacage filtering' for SINFO
author | gernotbelger |
---|---|
date | Wed, 04 Jul 2018 18:28:08 +0200 |
parents | e3c2ae1887e8 |
children |
comparison
equal
deleted
inserted
replaced
9226:83aee0942eae | 9227:84397da33d17 |
---|---|
23 /** | 23 /** |
24 * Widget showing two Datacages and a add-this-button. | 24 * Widget showing two Datacages and a add-this-button. |
25 * Insert a record into a listgrid when add-this-button clicked. | 25 * Insert a record into a listgrid when add-this-button clicked. |
26 */ | 26 */ |
27 public class DatacagePairWidget extends VLayout { | 27 public class DatacagePairWidget extends VLayout { |
28 | |
29 /** | |
30 * Allows for advanced controlling of the behavior of this pair widget. | |
31 */ | |
32 public static interface IDatacagePairControler { | |
33 void setup(DatacageWidget leftWidget, DatacageWidget rightWidget, HLayout toolbarLayout); | |
34 } | |
35 | |
36 /** | |
37 * {@link IDatacagePairControler} implementation that does nothing. | |
38 */ | |
39 public static final IDatacagePairControler NIL_CONTROLER = new IDatacagePairControler() { | |
40 @Override | |
41 public void setup(final DatacageWidget leftWidget, final DatacageWidget rightWidget, final HLayout toolbarLayout) { | |
42 // does nothing | |
43 } | |
44 }; | |
45 | |
28 /** i18n resource. */ | 46 /** i18n resource. */ |
29 private final FLYSConstants MSG = GWT.create(FLYSConstants.class); | 47 private static final FLYSConstants MSG = GWT.create(FLYSConstants.class); |
30 | 48 |
31 /** The "remote" ListGrid to insert data to when add-button is clicked. */ | 49 /** The "remote" ListGrid to insert data to when add-button is clicked. */ |
32 private final ListGrid grid; | 50 private final ListGrid grid; |
33 | 51 |
34 /** First (upper) DataCage Grid. */ | 52 /** First (upper) DataCage Grid. */ |
41 private final int maxCount; | 59 private final int maxCount; |
42 | 60 |
43 /** errorMsg maxCount */ | 61 /** errorMsg maxCount */ |
44 private final String msgMaxCount; | 62 private final String msgMaxCount; |
45 | 63 |
46 public DatacagePairWidget(final DatacageWidgetData leftData, final DatacageWidgetData rightData, final ListGrid grid, final int maxCount, | 64 public DatacagePairWidget(final IDatacagePairControler controler, final DatacageWidgetData leftData, final DatacageWidgetData rightData, |
47 final String msgMaxCount) { | 65 final ListGrid grid, final int maxCount, final String msgMaxCount) { |
66 | |
48 this.msgMaxCount = msgMaxCount; | 67 this.msgMaxCount = msgMaxCount; |
49 this.maxCount = maxCount; | 68 this.maxCount = maxCount; |
50 this.grid = grid; | 69 this.grid = grid; |
51 | 70 |
52 final HLayout hLayout = new HLayout(); | 71 final HLayout hLayout = new HLayout(); |
58 this.secondDatacageWidget.setIsMutliSelectable(false); | 77 this.secondDatacageWidget.setIsMutliSelectable(false); |
59 | 78 |
60 hLayout.addMember(this.firstDatacageWidget); | 79 hLayout.addMember(this.firstDatacageWidget); |
61 hLayout.addMember(this.secondDatacageWidget); | 80 hLayout.addMember(this.secondDatacageWidget); |
62 | 81 |
63 final Button plusBtn = new Button(this.MSG.datacage_add_pair()); | 82 final HLayout toolbarLayout = new HLayout(); |
83 toolbarLayout.setAutoHeight(); | |
84 | |
85 final Button plusBtn = new Button(MSG.datacage_add_pair()); | |
64 plusBtn.setAutoFit(true); | 86 plusBtn.setAutoFit(true); |
65 plusBtn.addClickHandler(new ClickHandler() { | 87 plusBtn.addClickHandler(new ClickHandler() { |
66 @Override | 88 @Override |
67 public void onClick(final ClickEvent event) { | 89 public void onClick(final ClickEvent event) { |
68 plusClicked(); | 90 plusClicked(); |
69 } | 91 } |
70 }); | 92 }); |
93 toolbarLayout.addMember(plusBtn); | |
71 | 94 |
72 addMember(hLayout); | 95 addMember(hLayout); |
73 addMember(plusBtn); | 96 addMember(toolbarLayout); |
97 | |
98 controler.setup(this.firstDatacageWidget, this.secondDatacageWidget, toolbarLayout); | |
74 } | 99 } |
75 | 100 |
76 /** | 101 /** |
77 * Callback for add-button. | 102 * Callback for add-button. |
78 * Fires to load for every selected element and handler. | 103 * Fires to load for every selected element and handler. |
79 */ | 104 */ |
80 public void plusClicked() { | 105 protected final void plusClicked() { |
81 final ToLoad toLoad1 = this.firstDatacageWidget.getSelection(); | 106 final ToLoad toLoad1 = this.firstDatacageWidget.getSelection(); |
82 final ToLoad toLoad2 = this.secondDatacageWidget.getSelection(); | 107 final ToLoad toLoad2 = this.secondDatacageWidget.getSelection(); |
83 | 108 |
84 // FIXME: allows to select folders... but it should not | 109 // FIXME: allows to select folders... but it should not |
85 | 110 |
86 if (toLoad1 == null || toLoad2 == null || toLoad1.toRecommendations().isEmpty() || toLoad2.toRecommendations().isEmpty()) { | 111 if (toLoad1 == null || toLoad2 == null || toLoad1.toRecommendations().isEmpty() || toLoad2.toRecommendations().isEmpty()) { |
87 SC.say(this.MSG.warning_select_two_values()); | 112 SC.say(MSG.warning_select_two_values()); |
88 return; | 113 return; |
89 } | 114 } |
90 | 115 |
91 if (this.grid.getTotalRows() >= this.maxCount) { | 116 if (this.grid.getTotalRows() >= this.maxCount) { |
92 SC.say(this.msgMaxCount); | 117 SC.say(this.msgMaxCount); |