comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java @ 1349:46a4b74d87bf

Allow (yet limited) usage of zus and flood-protection data in wdiffs. flys-client/trunk@3020 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 18 Oct 2011 15:43:33 +0000
parents 1627a28c4504
children 01b18db3b288
comparison
equal deleted inserted replaced
1348:fb224f54c643 1349:46a4b74d87bf
71 de.intevation.flys.client.client.services.LoadArtifactService.class); 71 de.intevation.flys.client.client.services.LoadArtifactService.class);
72 72
73 /** Service to remove artifacts from collection. */ 73 /** Service to remove artifacts from collection. */
74 RemoveArtifactServiceAsync removeArtifactService = GWT.create( 74 RemoveArtifactServiceAsync removeArtifactService = GWT.create(
75 de.intevation.flys.client.client.services.RemoveArtifactService.class); 75 de.intevation.flys.client.client.services.RemoveArtifactService.class);
76
76 77
77 public DatacageTwinPanel(User user) { 78 public DatacageTwinPanel(User user) {
78 super(); 79 super();
79 this.user = user; 80 this.user = user;
80 } 81 }
219 VLayout layout = new VLayout(); 220 VLayout layout = new VLayout();
220 differencesList = new ListGrid(); 221 differencesList = new ListGrid();
221 222
222 differencesList.setCanEdit(false); 223 differencesList.setCanEdit(false);
223 differencesList.setCanSort(false); 224 differencesList.setCanSort(false);
225 differencesList.setShowHeaderContextMenu(false);
224 differencesList.setHeight(150); 226 differencesList.setHeight(150);
225 differencesList.setShowAllRecords(true); 227 differencesList.setShowAllRecords(true);
226 228
227 ListGridField nameField = new ListGridField("first", "Minuend"); 229 ListGridField nameField = new ListGridField("first", "Minuend");
228 ListGridField capitalField = new ListGridField("second", "Subtrahend"); 230 ListGridField capitalField = new ListGridField("second", "Subtrahend");
229 // Track removed rows, therefore more or less reimplement 231 // Track removed rows, therefore more or less reimplement
230 // setCanRecomeRecords. 232 // setCanRecomeRecords.
231 final ListGridField removeField = 233 final ListGridField removeField =
232 new ListGridField("_removeRecord", "Remove Record"){{ 234 new ListGridField("_removeRecord", "Remove Record"){{
233 setType(ListGridFieldType.ICON); 235 setType(ListGridFieldType.ICON);
236 // TODO evaluate which icon to use (and how).
237 //setIcon("images/removeFeature.png");
234 setIcon("[SKIN]/actions/remove.png"); 238 setIcon("[SKIN]/actions/remove.png");
235 setCanEdit(false); 239 setCanEdit(false);
236 setCanFilter(false); 240 setCanFilter(false);
237 setCanSort(false); 241 setCanSort(false);
238 setCanGroupBy(false); 242 setCanGroupBy(false);
281 showErrors(errors); 285 showErrors(errors);
282 return; 286 return;
283 } 287 }
284 288
285 Config config = Config.getInstance(); 289 Config config = Config.getInstance();
290 String url = config.getServerUrl();
291 String locale = config.getLocale();
292
286 ListGridRecord[] records = differencesList.getRecords(); 293 ListGridRecord[] records = differencesList.getRecords();
287 294
288 List<Recommendation> ar = new ArrayList<Recommendation>(); 295 List<Recommendation> ar = new ArrayList<Recommendation>();
289 List<Recommendation> all = new ArrayList<Recommendation>(); 296 List<Recommendation> all = new ArrayList<Recommendation>();
290 List<Recommendation> statics = new ArrayList<Recommendation>(); 297
291 for (ListGridRecord record : records) { 298 for (ListGridRecord record : records) {
292 RecommendationPairRecord r = 299 RecommendationPairRecord r =
293 (RecommendationPairRecord) record; 300 (RecommendationPairRecord) record;
294 // Do not add "old" recommendations. 301 // Do not add "old" recommendations.
295 if (!r.isAlreadyLoaded()) { 302 if (!r.isAlreadyLoaded()) {
296 // Check whether one of those is a dike or similar. 303 // Check whether one of those is a dike or similar.
297 // TODO differentiate and merge: new clones, new, old. 304 // TODO differentiate and merge: new clones, new, old.
298 if(r.getFirst().getIDs() != null 305 Recommendation firstR = r.getFirst();
299 && r.getFirst().getIDs().startsWith("flood_protection")) 306 if(firstR.getIDs() != null) {
307 GWT.log("First IDs: " + firstR.getIDs());
308 }
309 // TODO resolve this hack, fix datacage/recommendation for this case.
310 if(firstR.getIDs() != null &&
311 firstR.getIDs().startsWith("flood_protection"))
300 { 312 {
301 // These do not get cloned but loaded ("spawned"). 313 // These do not get cloned but loaded ("spawned").
302 } 314 firstR.setFactory("staticwkms");
303 ar.add(r.getFirst()); 315 }
304 ar.add(r.getSecond()); 316 else {
317 firstR.setFactory("waterlevel");
318 }
319 Recommendation secondR = r.getSecond();
320 if(secondR.getIDs() != null) {
321 GWT.log("Second IDs: " + secondR.getIDs());
322 }
323 if(secondR.getIDs() != null
324 && secondR.getIDs().startsWith("flood_protection"))
325 {
326 // These do not get cloned but loaded ("spawned").
327 secondR.setFactory("staticwkms");
328 }
329 else {
330 secondR.setFactory("waterlevel");
331 }
332
333 ar.add(firstR);
334 ar.add(secondR);
305 } 335 }
306 else { 336 else {
307 all.add(r.getFirst()); 337 all.add(r.getFirst());
308 all.add(r.getSecond()); 338 all.add(r.getSecond());
309 } 339 }
341 // Remove old artifacts, if any. Do this asychronously without much 371 // Remove old artifacts, if any. Do this asychronously without much
342 // feedback. 372 // feedback.
343 for(final String uuid: artifactIdsToRemove) { 373 for(final String uuid: artifactIdsToRemove) {
344 removeArtifactService.remove(this.collection, 374 removeArtifactService.remove(this.collection,
345 uuid, 375 uuid,
346 config.getServerUrl(), 376 url,
347 config.getLocale(), 377 locale,
348 new AsyncCallback<Collection>() { 378 new AsyncCallback<Collection>() {
349 public void onFailure(Throwable caught) { 379 public void onFailure(Throwable caught) {
350 GWT.log("RemoveArtifact (" + uuid + ") failed."); 380 GWT.log("RemoveArtifact (" + uuid + ") failed.");
351 } 381 }
352 public void onSuccess(Collection collection) { 382 public void onSuccess(Collection collection) {
353 GWT.log("RemoveArtifact succeeded"); 383 GWT.log("RemoveArtifact succeeded");
354 } 384 }
355 }); 385 });
356 } 386 }
357 387
358 // Clone new ones, go forward. 388 // Clone new ones (and spawn statics), go forward.
359 loadArtifactService.loadMany( 389 loadArtifactService.loadMany(
360 this.collection, 390 this.collection,
361 toClone, 391 toClone,
362 "waterlevel", 392 //"staticwkms",
363 config.getServerUrl(), 393 null,
364 config.getLocale(), 394 url,
365 new AsyncCallback<Artifact[]>() { 395 locale,
396 new AsyncCallback<Artifact[]>() {
366 public void onFailure(Throwable caught) { 397 public void onFailure(Throwable caught) {
367 GWT.log("Failure of cloning with waterlevelfactory!"); 398 GWT.log("Failure of cloning with factories!");
368 } 399 }
369 public void onSuccess(Artifact[] artifacts) { 400 public void onSuccess(Artifact[] artifacts) {
370 GWT.log("Successfully cloned " + toClone.length + 401 GWT.log("Successfully cloned " + toClone.length +
371 " with watelevelfactory."); 402 " with factories.");
372 403
373 fireStepForwardEvent(new StepForwardEvent( 404 fireStepForwardEvent(new StepForwardEvent(
374 getData(toClone, artifacts, toUse))); 405 getData(toClone, artifacts, toUse)));
375 } 406 }
376 } ); 407 });
377 } 408 }
378 409
379 410
380 /** 411 /**
381 * Create Data and DataItem from selection (a long string with identifiers 412 * Create Data and DataItem from selection (a long string with identifiers
424 * Creates part of the String that encodes minuend or subtrahend. 455 * Creates part of the String that encodes minuend or subtrahend.
425 */ 456 */
426 protected String createDataString(String artifact, Filter filter) { 457 protected String createDataString(String artifact, Filter filter) {
427 Facet f = null; 458 Facet f = null;
428 459
429 Map<String, List<Facet>> outs = filter.getOuts(); 460 if(filter != null) {
430 Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet(); 461 Map<String, List<Facet>> outs = filter.getOuts();
431 462 Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet();
432 for (Map.Entry<String, List<Facet>> entry: entries) { 463
433 List<Facet> fs = entry.getValue(); 464 for (Map.Entry<String, List<Facet>> entry: entries) {
434 465 List<Facet> fs = entry.getValue();
435 f = fs.get(0); 466
436 if (f != null) { 467 f = fs.get(0);
437 break; 468 if (f != null) {
438 } 469 break;
439 } 470 }
440 471 }
441 return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; 472
473 return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]";
474 }
475 else {
476 return "[" + artifact + ";staticwkms;0]";
477 }
478
479
442 } 480 }
443 } 481 }
444 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 482 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org