Mercurial > dive4elements > river
view 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 source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.client.ui.minfo; import java.util.List; 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; import org.dive4elements.river.client.shared.model.DataList; import org.dive4elements.river.client.shared.model.ToLoad; import org.dive4elements.river.client.shared.model.User; import com.google.gwt.core.client.GWT; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tree.TreeNode; public class BedHeightsDatacagePanel extends AbstractPairRecommendationPanel { 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()"); final Canvas submit = getNextButton(); final DatacageWidgetData data = new DatacageWidgetData(this.artifact, user, "minfo_diff_panel", "load-system:true", false); 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(final ClickEvent event) { plusClicked(datacage, differencesList); } }); final VLayout layout = new VLayout(); final VLayout helperLayout = new VLayout(); helperLayout.addMember(datacage); helperLayout.addMember(plusBtn); layout.addMember(widget); layout.addMember(submit); layout.setMembersMargin(10); this.helperContainer.addMember(helperLayout); return layout; } /** * Callback for add-button. * Fires to load for every selected element and handler. * * @param differencesList */ 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 (final TreeNode node : selection) { final ToLoad toLoad1 = new ToLoad(); final ToLoad toLoad2 = new ToLoad(); 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))); } } }