コード例 #1
0
  @Test
  public void placeManagerRevealRelativePlaceWithZeroLevelShouldGoToDefaultPlace() {
    // Given
    doAnswer(
            invocation -> {
              Object[] args = invocation.getArguments();
              deferredCommandManager.addCommand(
                  () ->
                      placeManager.updateHistory(
                          new PlaceRequest.Builder().nameToken("defaultPlace").build(), true));
              ((PlaceRequestInternalEvent) args[0]).setHandled();
              return null;
            })
        .when(eventBus)
        .fireEventFromSource(isA(PlaceRequestInternalEvent.class), eq(placeManager));

    // When
    placeManager.revealRelativePlace(0);
    deferredCommandManager.pump();

    // Then
    PlaceRequest placeRequest = placeManager.getCurrentPlaceRequest();
    assertEquals("defaultPlace", placeRequest.getNameToken());
    assertEquals(0, placeRequest.getParameterNames().size());

    verify(gwtWindowMethods).setBrowserHistoryToken(any(String.class), eq(false));
  }
コード例 #2
0
  @Test
  public void placeManagerUserCallUpdateHistoryWhenRevealingPlace() {
    // Given
    doAnswer(
            invocation -> {
              Object[] args = invocation.getArguments();
              deferredCommandManager.addCommand(
                  () ->
                      placeManager.updateHistory(
                          new PlaceRequest.Builder()
                              .nameToken("dummyNameToken")
                              .with("dummyParam", "dummyValue")
                              .build(),
                          true));
              ((PlaceRequestInternalEvent) args[0]).setHandled();
              return null;
            })
        .when(eventBus)
        .fireEventFromSource(isA(PlaceRequestInternalEvent.class), eq(placeManager));

    // When
    placeManager.revealPlace(new PlaceRequest.Builder().nameToken("dummyNameToken").build());
    deferredCommandManager.pump();

    // Then
    PlaceRequest placeRequest = placeManager.getCurrentPlaceRequest();
    assertEquals("dummyNameToken", placeRequest.getNameToken());
    assertEquals(1, placeRequest.getParameterNames().size());
    assertEquals("dummyValue", placeRequest.getParameter("dummyParam", null));

    verify(gwtWindowMethods).setBrowserHistoryToken(any(String.class), eq(false));
  }
コード例 #3
0
 @Override
 public void manualReveal(Presenter<?, ?> presenter) {
   // Reveal only if there are no pending navigation requests
   if (!placeManager.hasPendingNavigation()) {
     if (!presenter.isVisible()) {
       // This will trigger a reset in due time
       presenter.forceReveal();
     } else {
       // We have to do the reset ourselves
       ResetPresentersEvent.fire(this);
     }
   }
   placeManager.unlock();
 }
コード例 #4
0
  // Save the current state of the Workbench
  private void saveState() {

    onClose();

    final PerspectiveDefinition perspective = panelManager.getPerspective();

    if (perspective == null) {
      // On startup the Workbench has not been set to contain a perspective
      loadState();

    } else if (perspective.isTransient()) {
      // Transient Perspectives are not saved
      placeManager.closeAllPlaces();
      loadState();

    } else {
      // Save first, then close all places before loading persisted state
      wbServices
          .call(
              new RemoteCallback<Void>() {
                @Override
                public void callback(Void response) {
                  placeManager.closeAllPlaces();
                  loadState();
                }
              })
          .save(perspective);
    }
  }
コード例 #5
0
 private void addChildren(final PanelDefinition panel) {
   Set<PartDefinition> parts = panel.getParts();
   for (PartDefinition part : parts) {
     final PlaceRequest place = clonePlaceAndMergeParameters(part.getPlace());
     part.setPlace(place);
     placeManager.goTo(part, panel);
   }
   buildPerspective(panel);
 }
コード例 #6
0
 /**
  * Tracks open/closed lifecycle. Subclasses should always call <tt>super.onOpen()</tt> in methods
  * that override this one.
  */
 @Override
 public void onOpen() {
   if (this.place == null) {
     throw new IllegalStateException("Activity " + this + " has not been started");
   }
   if (open) {
     throw new IllegalStateException("Activity " + this + " already open");
   }
   open = true;
   placeManager.executeOnOpenCallback(this.place);
 }
コード例 #7
0
  // Initialise Workbench state to that of the provided perspective
  private void initialisePerspective(final PerspectiveDefinition perspective) {

    panelManager.setPerspective(perspective);

    Set<PartDefinition> parts = panelManager.getRoot().getParts();
    for (PartDefinition part : parts) {
      final PlaceRequest place = clonePlaceAndMergeParameters(part.getPlace());
      part.setPlace(place);
      placeManager.goTo(part, panelManager.getRoot());
    }
    buildPerspective(panelManager.getRoot());

    onOpen();
  }
コード例 #8
0
 @Override
 public void manualRevealFailed() {
   placeManager.unlock();
 }