# HG changeset patch # User Felix Wolfsteller # Date 1316010910 0 # Node ID 6e678b5d08a4406326c85aac4fa39ddc3b13d3ea # Parent a9dd792444a1a7017d966f146853e96c7f4d8118 New widget for future use. flys-client/trunk@2745 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r a9dd792444a1 -r 6e678b5d08a4 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Sep 14 14:27:07 2011 +0000 +++ b/flys-client/ChangeLog Wed Sep 14 14:35:10 2011 +0000 @@ -8,6 +8,15 @@ 2011-09-14 Felix Wolfsteller + New DatacageTwinWidget to be used in W-Differences GUI. + + * src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java: + New, display two datacages and a "+" button. On selection and + plus-button press will in future add names of selections into a + given ListGrid. + +2011-09-14 Felix Wolfsteller + Ease access to selected elements of a DatacageWidget. Make button-less DatacageWidget possible. diff -r a9dd792444a1 -r 6e678b5d08a4 flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java Wed Sep 14 14:35:10 2011 +0000 @@ -0,0 +1,142 @@ +package de.intevation.flys.client.client.ui; + +import de.intevation.flys.client.client.event.DatacageHandler; + +import com.google.gwt.core.client.GWT; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import com.smartgwt.client.util.SC; + +import com.smartgwt.client.widgets.Button; + +import com.smartgwt.client.widgets.tree.Tree; +import com.smartgwt.client.widgets.tree.TreeGrid; +import com.smartgwt.client.widgets.tree.TreeNode; + +import com.smartgwt.client.types.TreeModelType; + +import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.layout.HLayout; + +import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.events.ClickEvent; + +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; +import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; + +import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.User; +import de.intevation.flys.client.shared.model.ToLoad; + +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.Config; + +import de.intevation.flys.client.client.services.MetaDataService; +import de.intevation.flys.client.client.services.MetaDataServiceAsync; + +import de.intevation.flys.client.shared.model.DataCageTree; +import de.intevation.flys.client.shared.model.DataCageNode; +import de.intevation.flys.client.shared.model.AttrList; + +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +public class DatacagePairWidget +extends VLayout +{ + protected FLYSConstants messages = + GWT.create(FLYSConstants.class); + + /** The "remote" ListGrid to insert data to when add-button is clicked. */ + protected ListGrid grid; + + /** First attribute-name for StringPairRecord. */ + protected static final String ATTRIBUTE_FIRST = "first"; + + /** Second attribute-name for StringPairRecord. */ + protected static final String ATTRIBUTE_SECOND = "second"; + + /** First (upper) DataCage Grid. */ + protected DatacageWidget firstDatacageWidget; + + /** Second (lower) DataCage Grid. */ + protected DatacageWidget secondDatacageWidget; + + + /** + * Two strings to be displayed in a GridList. + */ + protected class StringPairRecord extends ListGridRecord { + public StringPairRecord() { + } + + public StringPairRecord(String first, String second) { + setFirst(first); + setSecond(second); + } + + + public void setFirst(String first) { + setAttribute(ATTRIBUTE_FIRST, first); + } + + + public void setSecond(String second) { + setAttribute(ATTRIBUTE_SECOND, second); + } + } + + + /** + * + * @param artifact Artifact to query datacage with. + * @param user User to query datacage with. + * @param outs outs to query datacage with. + * @param grid Grid into which to insert selection of pairs. + */ + public DatacagePairWidget(Artifact artifact, User user, String outs, + ListGrid grid) { + this.grid = grid; + + HLayout hLayout = new HLayout(); + + firstDatacageWidget = new DatacageWidget(artifact, user, outs, false); + hLayout.addMember(firstDatacageWidget); + secondDatacageWidget = new DatacageWidget(artifact, user, outs, false); + hLayout.addMember(secondDatacageWidget); + + // TODO: i18n + icon + Button plusBtn = new Button("+"); + plusBtn.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + plusClicked(); + } + }); + + addMember(hLayout); + addMember(plusBtn); + } + + + /** + * Callback for add-button. + * Fires to load for every selected element and handler. + */ + public void plusClicked() { + ToLoad toLoad1 = firstDatacageWidget.getSelection(); + ToLoad toLoad2 = secondDatacageWidget.getSelection(); + + if (toLoad1 == null || toLoad2 == null) { + return; + } + + //grid.addData(new StringPairRecord((String)toLoad1.getKeys().toArray()[0], (String)toLoad2.getKeys().toArray()[0])); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :