comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 785:3ae0facd4cab

Added a panel that lets users step to a next state without feeding the current artifact with new data. flys-client/trunk@2282 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 05 Jul 2011 16:12:34 +0000
parents 84d3c5fde5bb
children dfbc6693247e
comparison
equal deleted inserted replaced
784:3fa64c796ffc 785:3ae0facd4cab
28 import de.intevation.flys.client.shared.model.OutputMode; 28 import de.intevation.flys.client.shared.model.OutputMode;
29 import de.intevation.flys.client.shared.model.River; 29 import de.intevation.flys.client.shared.model.River;
30 import de.intevation.flys.client.client.Config; 30 import de.intevation.flys.client.client.Config;
31 import de.intevation.flys.client.client.FLYS; 31 import de.intevation.flys.client.client.FLYS;
32 import de.intevation.flys.client.client.FLYSConstants; 32 import de.intevation.flys.client.client.FLYSConstants;
33 import de.intevation.flys.client.client.event.AdvanceHandler;
33 import de.intevation.flys.client.client.event.CollectionChangeEvent; 34 import de.intevation.flys.client.client.event.CollectionChangeEvent;
34 import de.intevation.flys.client.client.event.CollectionChangeHandler; 35 import de.intevation.flys.client.client.event.CollectionChangeHandler;
35 import de.intevation.flys.client.client.event.HasParameterChangeHandler; 36 import de.intevation.flys.client.client.event.HasParameterChangeHandler;
36 import de.intevation.flys.client.client.event.HasStepBackHandlers; 37 import de.intevation.flys.client.client.event.HasStepBackHandlers;
37 import de.intevation.flys.client.client.event.HasStepForwardHandlers; 38 import de.intevation.flys.client.client.event.HasStepForwardHandlers;
55 56
56 public class ParameterList 57 public class ParameterList
57 extends Tab 58 extends Tab
58 implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, 59 implements StepBackHandler, StepForwardHandler, ParameterChangeHandler,
59 HasParameterChangeHandler, CollectionChangeHandler, 60 HasParameterChangeHandler, CollectionChangeHandler,
60 OutputModesChangeHandler 61 OutputModesChangeHandler, AdvanceHandler
61 { 62 {
62 /** The message class that provides i18n strings.*/ 63 /** The message class that provides i18n strings.*/
63 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 64 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
64 65
65 /** The ArtifactService used to communicate with the Artifact server. */ 66 /** The ArtifactService used to communicate with the Artifact server. */
327 328
328 329
329 public void addOldDatas(DataList[] old) { 330 public void addOldDatas(DataList[] old) {
330 if (old != null && old.length > 0) { 331 if (old != null && old.length > 0) {
331 for (DataList o: old) { 332 for (DataList o: old) {
333 if (o == null) {
334 continue;
335 }
336
332 if (!exists(o)) { 337 if (!exists(o)) {
333 GWT.log("Data '" + o.getLabel() + "' is new."); 338 GWT.log("Data '" + o.getLabel() + "' is new.");
334 addOldData(o); 339 addOldData(o);
335 } 340 }
336 } 341 }
341 addOldData(null); 346 addOldData(null);
342 } 347 }
343 348
344 349
345 public boolean exists(DataList data) { 350 public boolean exists(DataList data) {
351 if (data == null) {
352 return false;
353 }
354
346 String stateName = data.getState(); 355 String stateName = data.getState();
347 356
348 for (DataList o: old) { 357 for (DataList o: old) {
349 if (stateName.equals(o.getState())) { 358 if (stateName.equals(o.getState())) {
350 return true; 359 return true;
397 public void refreshCurrent() { 406 public void refreshCurrent() {
398 currentItems.removeMembers(currentItems.getMembers()); 407 currentItems.removeMembers(currentItems.getMembers());
399 408
400 if (current != null && uiProvider != null) { 409 if (current != null && uiProvider != null) {
401 Canvas c = uiProvider.create(current); 410 Canvas c = uiProvider.create(current);
411 currentItems.addMember(c);
412 }
413 else if (uiProvider != null) {
414 Canvas c = uiProvider.create(null);
402 c.setLayoutAlign(VerticalAlignment.TOP); 415 c.setLayoutAlign(VerticalAlignment.TOP);
403 416
404 currentItems.addMember(c); 417 currentItems.addMember(c);
405 } 418 }
406 else { 419 else {
468 } 481 }
469 ); 482 );
470 } 483 }
471 484
472 485
486 public void onAdvance(final String target) {
487 Config config = Config.getInstance();
488 final String serverUrl = config.getServerUrl();
489 final String locale = config.getLocale();
490
491 advanceService.advance(serverUrl, locale, artifact, target,
492 new AsyncCallback<Artifact>() {
493 public void onFailure(Throwable caught) {
494 GWT.log("Could not go to '" + target + "'");
495 SC.warn(MSG.getString(caught.getMessage()));
496 }
497
498 public void onSuccess(Artifact artifact) {
499 GWT.log("Successfully advanced to '" + target + "'");
500
501 old.clear();
502 oldItems.removeMembers(oldItems.getMembers());
503
504 setArtifact(artifact);
505 }
506 }
507 );
508 }
509
510
473 /** 511 /**
474 * Implements the onCollectionChange() method to do update the GUI after the 512 * Implements the onCollectionChange() method to do update the GUI after the
475 * parameterization has changed. 513 * parameterization has changed.
476 * 514 *
477 * @param event The ParameterChangeEvent. 515 * @param event The ParameterChangeEvent.
499 ((HasStepBackHandlers) provider).addStepBackHandler(this); 537 ((HasStepBackHandlers) provider).addStepBackHandler(this);
500 538
501 setCurrentData(currentData, provider); 539 setCurrentData(currentData, provider);
502 } 540 }
503 else { 541 else {
504 // we have reached a final state with no more user input 542 String[] reachable = desc.getReachableStates();
505 setCurrentData(null, null); 543 if (reachable != null && reachable.length > 0) {
544 // We have reached a final state with the option to step to
545 // further to a next state. But in the current state, no user
546 // data is required.
547 UIProvider ui = UIProviderFactory.getProvider("continue");
548 ui.setArtifact(art);
549
550 ((ContinuePanel) ui).addAdvanceHandler(this);
551
552 setCurrentData(null, ui);
553 }
554 else {
555 // we have reached a final state with no more user input
556 setCurrentData(null, null);
557 }
506 } 558 }
507 559
508 addOldDatas(desc.getOldData()); 560 addOldDatas(desc.getOldData());
509 } 561 }
510 562

http://dive4elements.wald.intevation.org