Mercurial > hg > STI-GWT
comparison src/econnect/wp3_3/client/core/ApplicationGrid.java @ 32:f635bbdc6a03
local KML display (beta)
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 30 Nov 2012 15:17:25 +0100 |
parents | fef6080e83ad |
children | 18fc3a30e993 |
comparison
equal
deleted
inserted
replaced
31:c7701b00ca5b | 32:f635bbdc6a03 |
---|---|
2 | 2 |
3 import java.util.ArrayList; | 3 import java.util.ArrayList; |
4 import java.util.Date; | 4 import java.util.Date; |
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
7 import com.google.gwt.user.client.ui.FileUpload; | |
7 import com.google.gwt.user.client.ui.Grid; | 8 import com.google.gwt.user.client.ui.Grid; |
8 import com.google.gwt.user.client.ui.HTML; | 9 import com.google.gwt.user.client.ui.HTML; |
9 import com.google.gwt.user.client.ui.HasHorizontalAlignment; | 10 import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
10 import com.google.gwt.user.client.ui.Image; | 11 import com.google.gwt.user.client.ui.Image; |
11 import com.google.gwt.user.client.ui.ListBox; | 12 import com.google.gwt.user.client.ui.ListBox; |
177 final Image openButton = new Image(constants.openImage()); | 178 final Image openButton = new Image(constants.openImage()); |
178 openButton.getElement().addClassName("vCenter"); | 179 openButton.getElement().addClassName("vCenter"); |
179 final ListBox datasource = new ListBox(false); | 180 final ListBox datasource = new ListBox(false); |
180 final List<ListBox> staticListBoxes = new ArrayList<ListBox>(); | 181 final List<ListBox> staticListBoxes = new ArrayList<ListBox>(); |
181 final ArrayList<ArrayList<int[]>> entries = new ArrayList<ArrayList<int[]>>(); | 182 final ArrayList<ArrayList<int[]>> entries = new ArrayList<ArrayList<int[]>>(); |
183 final FileUpload uploadKML = new FileUpload(); | |
184 //skruse: The element will be accessed by its ID in the JS code | |
185 //either don't change this name, or change it also in STICore.js | |
186 uploadKML.getElement().setId("localKMLFileChooser"); | |
182 for( int i=0; i<sources; i++ ){ | 187 for( int i=0; i<sources; i++ ){ |
183 try { | 188 try { |
184 if( core.hasItems(i) ){ | 189 if( core.hasItems(i) ){ |
185 try { | 190 try { |
186 ListBox staticData = new ListBox(); | 191 ListBox staticData = new ListBox(); |
245 headerGrid.setWidget(0, 0, openPanel); | 250 headerGrid.setWidget(0, 0, openPanel); |
246 | 251 |
247 datasource.addChangeHandler(new ChangeHandler() { | 252 datasource.addChangeHandler(new ChangeHandler() { |
248 public void onChange(ChangeEvent event) { | 253 public void onChange(ChangeEvent event) { |
249 int ds = datasource.getSelectedIndex(); | 254 int ds = datasource.getSelectedIndex(); |
255 String label = datasource.getItemText(ds); | |
256 | |
250 if( ds == -1 ){ | 257 if( ds == -1 ){ |
251 return; | 258 return; |
252 } | 259 } |
253 if( staticListBoxes.get(ds) == null ){ | 260 //skruse: test for local KML loading (e.g. useful for the downloaded KMLs) |
261 //TODO: if this remains in the code, the check below has | |
262 //to be improved (some constant somewhere) | |
263 if( label.equals("local KML") ){ | |
264 openPanel.setWidget(0, 1, uploadKML); | |
265 } | |
266 else if( staticListBoxes.get(ds) == null ){ | |
254 openPanel.setWidget(0, 1, searchField); | 267 openPanel.setWidget(0, 1, searchField); |
255 } | 268 } |
256 else { | 269 else { |
257 openPanel.setWidget(0, 1, staticListBoxes.get(ds)); | 270 openPanel.setWidget(0, 1, staticListBoxes.get(ds)); |
258 } | 271 } |
270 loadData(); | 283 loadData(); |
271 } | 284 } |
272 } | 285 } |
273 private void loadData() { | 286 private void loadData() { |
274 int ds = datasource.getSelectedIndex(); | 287 int ds = datasource.getSelectedIndex(); |
288 String label = datasource.getItemText(ds); | |
289 | |
275 if( core.isMaximumReached() ){ | 290 if( core.isMaximumReached() ){ |
276 core.alert(textConstants.maxDatasources()); | 291 core.alert(textConstants.maxDatasources()); |
277 } | 292 } |
278 else if( staticListBoxes.get(ds) != null ){ | 293 else if( staticListBoxes.get(ds) != null ){ |
279 if( staticListBoxes.get(ds).getSelectedIndex() > 0 ){ | 294 if( staticListBoxes.get(ds).getSelectedIndex() > 0 ){ |
280 int[] pair = entries.get(ds).get(staticListBoxes.get(ds).getSelectedIndex() - 1); | 295 int[] pair = entries.get(ds).get(staticListBoxes.get(ds).getSelectedIndex() - 1); |
281 core.openStaticKml(ds,pair[0],pair[1]); | 296 core.openStaticKml(ds,pair[0],pair[1]); |
282 } | 297 } |
298 } | |
299 //skruse: test for local KML loading (e.g. useful for the downloaded KMLs) | |
300 //TODO: if this remains in the code, the check below has | |
301 //to be improved (some constant somewhere) | |
302 else if( (label.equals("local KML")) && (uploadKML.getFilename() != "") ){ | |
303 String fileName = uploadKML.getFilename(); | |
304 core.openLocalKml( ds, fileName ); | |
283 } | 305 } |
284 else if( !searchField.getText().equals("") ){ | 306 else if( !searchField.getText().equals("") ){ |
285 core.openDynamicKml( ds, searchField.getText() ); | 307 core.openDynamicKml( ds, searchField.getText() ); |
286 } | 308 } |
287 openButton.setUrl(constants.openImage()); | 309 openButton.setUrl(constants.openImage()); |