Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedHeightsDatacagePanel.java Wed Jul 04 10:46:37 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/BedHeightsDatacagePanel.java Wed Jul 04 12:00:51 2018 +0200 @@ -12,6 +12,7 @@ import org.dive4elements.river.client.client.ui.AbstractPairRecommendationPanel; import org.dive4elements.river.client.client.ui.DatacageWidget; +import org.dive4elements.river.client.client.ui.DatacageWidgetData; import org.dive4elements.river.client.client.ui.DefaultDatacageTwinPanelInfo; import org.dive4elements.river.client.client.ui.RecommendationPairRecord; import org.dive4elements.river.client.client.ui.WaterlevelTwinPanelValidator; @@ -29,35 +30,40 @@ import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tree.TreeNode; -public class BedHeightsDatacagePanel -extends AbstractPairRecommendationPanel { +public class BedHeightsDatacagePanel extends AbstractPairRecommendationPanel { - public BedHeightsDatacagePanel(User user) { - // FIXME: This will lead to a bad error message in English (i.e. contains something about waterlevels), for M-Info/Bed-Differences calculation - // BUT: this is the behavior of 3.2.1 (because of sloppy derivation), so we do not change it now - super(user, new WaterlevelTwinPanelValidator(), new DefaultDatacageTwinPanelInfo("bedheight", null), new DefaultDatacageTwinPanelInfo("bedheight", null) ); + private static final DefaultDatacageTwinPanelInfo INFO = new DefaultDatacageTwinPanelInfo(null, "bedheight", null); + + private static final long serialVersionUID = 1L; + + public BedHeightsDatacagePanel(final User user) { + // FIXME: This will lead to a bad error message in English (i.e. contains something about waterlevels), for + // M-Info/Bed-Differences calculation + // BUT: this is the behavior of 3.2.1 (because of sloppy derivation), so we do not change it now + super(user, new WaterlevelTwinPanelValidator(), INFO, INFO); } @Override protected Canvas createChooserWidgets(final Canvas widget, final DataList dataList, final User user, final ListGrid differencesList) { GWT.log("createData()"); - Canvas submit = getNextButton(); + final Canvas submit = getNextButton(); - final DatacageWidget datacage = new DatacageWidget( - this.artifact, user, "minfo_diff_panel", "load-system:true", false); + final DatacageWidgetData data = new DatacageWidgetData(this.artifact, user, "minfo_diff_panel", "load-system:true", false); - Button plusBtn = new Button(msg().datacage_add_pair()); + final DatacageWidget datacage = new DatacageWidget(data); + + final Button plusBtn = new Button(msg().datacage_add_pair()); plusBtn.setAutoFit(true); plusBtn.addClickHandler(new ClickHandler() { @Override - public void onClick(ClickEvent event) { + public void onClick(final ClickEvent event) { plusClicked(datacage, differencesList); } }); - VLayout layout = new VLayout(); - VLayout helperLayout = new VLayout(); + final VLayout layout = new VLayout(); + final VLayout helperLayout = new VLayout(); helperLayout.addMember(datacage); helperLayout.addMember(plusBtn); @@ -72,50 +78,36 @@ /** * Callback for add-button. * Fires to load for every selected element and handler. - * @param differencesList + * + * @param differencesList */ - protected final static void plusClicked( final DatacageWidget datacage, ListGrid differencesList ) { - List<TreeNode> selection = datacage.getPlainSelection(); + protected final static void plusClicked(final DatacageWidget datacage, final ListGrid differencesList) { + final List<TreeNode> selection = datacage.getPlainSelection(); if (selection == null || selection.isEmpty()) { SC.say(msg().warning()); return; } - for (TreeNode node : selection) { - ToLoad toLoad1 = new ToLoad(); - ToLoad toLoad2 = new ToLoad(); - - String factory = node.getAttribute("factory"); - if (factory != null) { // we need at least a factory - String artifact = node.getAttribute("artifact-id"); - String out = node.getAttribute("out"); - String name = node.getAttribute("facet"); - String ids = node.getAttribute("ids"); - String info = node.getAttribute("info"); - String targetOut = node.getAttribute("target_out"); + for (final TreeNode node : selection) { + final ToLoad toLoad1 = new ToLoad(); + final ToLoad toLoad2 = new ToLoad(); - String[] splitIds = ids.split("#"); - String[] splitInfo = info.split("#"); - toLoad1.add(artifact, - factory, - out, - name, - splitIds[0], - splitInfo[0], - targetOut); - toLoad2.add(artifact, - factory, - out, - name, - splitIds[1], - splitInfo[1], - targetOut); + final String factory = node.getAttribute("factory"); + if (factory != null) { // we need at least a factory + final String artifact = node.getAttribute("artifact-id"); + final String out = node.getAttribute("out"); + final String name = node.getAttribute("facet"); + final String ids = node.getAttribute("ids"); + final String info = node.getAttribute("info"); + final String targetOut = node.getAttribute("target_out"); + + final String[] splitIds = ids.split("#"); + final String[] splitInfo = info.split("#"); + toLoad1.add(artifact, factory, out, name, splitIds[0], splitInfo[0], targetOut); + toLoad2.add(artifact, factory, out, name, splitIds[1], splitInfo[1], targetOut); } - differencesList.addData(new RecommendationPairRecord( - toLoad1.toRecommendations().get(0), - toLoad2.toRecommendations().get(0))); + differencesList.addData(new RecommendationPairRecord(toLoad1.toRecommendations().get(0), toLoad2.toRecommendations().get(0))); } } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +} \ No newline at end of file