Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java @ 899:6e678b5d08a4
New widget for future use.
flys-client/trunk@2745 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 14 Sep 2011 14:35:10 +0000 |
parents | |
children | 39a39e9be5af |
comparison
equal
deleted
inserted
replaced
898:a9dd792444a1 | 899:6e678b5d08a4 |
---|---|
1 package de.intevation.flys.client.client.ui; | |
2 | |
3 import de.intevation.flys.client.client.event.DatacageHandler; | |
4 | |
5 import com.google.gwt.core.client.GWT; | |
6 | |
7 import com.google.gwt.user.client.rpc.AsyncCallback; | |
8 | |
9 import com.smartgwt.client.util.SC; | |
10 | |
11 import com.smartgwt.client.widgets.Button; | |
12 | |
13 import com.smartgwt.client.widgets.tree.Tree; | |
14 import com.smartgwt.client.widgets.tree.TreeGrid; | |
15 import com.smartgwt.client.widgets.tree.TreeNode; | |
16 | |
17 import com.smartgwt.client.types.TreeModelType; | |
18 | |
19 import com.smartgwt.client.widgets.layout.VLayout; | |
20 import com.smartgwt.client.widgets.layout.HLayout; | |
21 | |
22 import com.smartgwt.client.widgets.events.ClickHandler; | |
23 import com.smartgwt.client.widgets.events.ClickEvent; | |
24 | |
25 import com.smartgwt.client.widgets.grid.ListGrid; | |
26 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
27 | |
28 import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; | |
29 import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; | |
30 | |
31 import de.intevation.flys.client.shared.model.Artifact; | |
32 import de.intevation.flys.client.shared.model.User; | |
33 import de.intevation.flys.client.shared.model.ToLoad; | |
34 | |
35 import de.intevation.flys.client.client.FLYSConstants; | |
36 import de.intevation.flys.client.client.Config; | |
37 | |
38 import de.intevation.flys.client.client.services.MetaDataService; | |
39 import de.intevation.flys.client.client.services.MetaDataServiceAsync; | |
40 | |
41 import de.intevation.flys.client.shared.model.DataCageTree; | |
42 import de.intevation.flys.client.shared.model.DataCageNode; | |
43 import de.intevation.flys.client.shared.model.AttrList; | |
44 | |
45 import java.util.ArrayList; | |
46 import java.util.List; | |
47 import java.util.Stack; | |
48 | |
49 public class DatacagePairWidget | |
50 extends VLayout | |
51 { | |
52 protected FLYSConstants messages = | |
53 GWT.create(FLYSConstants.class); | |
54 | |
55 /** The "remote" ListGrid to insert data to when add-button is clicked. */ | |
56 protected ListGrid grid; | |
57 | |
58 /** First attribute-name for StringPairRecord. */ | |
59 protected static final String ATTRIBUTE_FIRST = "first"; | |
60 | |
61 /** Second attribute-name for StringPairRecord. */ | |
62 protected static final String ATTRIBUTE_SECOND = "second"; | |
63 | |
64 /** First (upper) DataCage Grid. */ | |
65 protected DatacageWidget firstDatacageWidget; | |
66 | |
67 /** Second (lower) DataCage Grid. */ | |
68 protected DatacageWidget secondDatacageWidget; | |
69 | |
70 | |
71 /** | |
72 * Two strings to be displayed in a GridList. | |
73 */ | |
74 protected class StringPairRecord extends ListGridRecord { | |
75 public StringPairRecord() { | |
76 } | |
77 | |
78 public StringPairRecord(String first, String second) { | |
79 setFirst(first); | |
80 setSecond(second); | |
81 } | |
82 | |
83 | |
84 public void setFirst(String first) { | |
85 setAttribute(ATTRIBUTE_FIRST, first); | |
86 } | |
87 | |
88 | |
89 public void setSecond(String second) { | |
90 setAttribute(ATTRIBUTE_SECOND, second); | |
91 } | |
92 } | |
93 | |
94 | |
95 /** | |
96 * | |
97 * @param artifact Artifact to query datacage with. | |
98 * @param user User to query datacage with. | |
99 * @param outs outs to query datacage with. | |
100 * @param grid Grid into which to insert selection of pairs. | |
101 */ | |
102 public DatacagePairWidget(Artifact artifact, User user, String outs, | |
103 ListGrid grid) { | |
104 this.grid = grid; | |
105 | |
106 HLayout hLayout = new HLayout(); | |
107 | |
108 firstDatacageWidget = new DatacageWidget(artifact, user, outs, false); | |
109 hLayout.addMember(firstDatacageWidget); | |
110 secondDatacageWidget = new DatacageWidget(artifact, user, outs, false); | |
111 hLayout.addMember(secondDatacageWidget); | |
112 | |
113 // TODO: i18n + icon | |
114 Button plusBtn = new Button("+"); | |
115 plusBtn.addClickHandler(new ClickHandler() { | |
116 @Override | |
117 public void onClick(ClickEvent event) { | |
118 plusClicked(); | |
119 } | |
120 }); | |
121 | |
122 addMember(hLayout); | |
123 addMember(plusBtn); | |
124 } | |
125 | |
126 | |
127 /** | |
128 * Callback for add-button. | |
129 * Fires to load for every selected element and handler. | |
130 */ | |
131 public void plusClicked() { | |
132 ToLoad toLoad1 = firstDatacageWidget.getSelection(); | |
133 ToLoad toLoad2 = secondDatacageWidget.getSelection(); | |
134 | |
135 if (toLoad1 == null || toLoad2 == null) { | |
136 return; | |
137 } | |
138 | |
139 //grid.addData(new StringPairRecord((String)toLoad1.getKeys().toArray()[0], (String)toLoad2.getKeys().toArray()[0])); | |
140 } | |
141 } | |
142 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |