// 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);
    }
  }
  // Load the persisted state of the Workbench or use the default Perspective definition if no saved
  // state found
  private void loadState() {

    // Call OnStartup before getting the Perspective definition in case any setup is required by
    // @WorkbenchPerspective's
    onStartup(place);

    final PerspectiveDefinition perspective = getPerspective();

    if (perspective.isTransient()) {
      // Transient Perspectives are not saved and hence cannot be loaded
      initialisePerspective(perspective);

    } else {

      wbServices
          .call(
              new RemoteCallback<PerspectiveDefinition>() {
                @Override
                public void callback(PerspectiveDefinition response) {
                  if (response == null) {
                    initialisePerspective(perspective);
                  } else {
                    initialisePerspective(response);
                  }
                }
              })
          .load(perspective.getName());
    }
  }
Ejemplo n.º 3
0
 @Perspective
 public PerspectiveDefinition getPerspective() {
   final PerspectiveDefinition p =
       new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
   p.setName("Jobs");
   p.getRoot().addPart(new PartDefinitionImpl(new DefaultPlaceRequest("Requests List")));
   return p;
 }
 @Perspective
 public PerspectiveDefinition buildPerspective() {
   final PerspectiveDefinition p =
       new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
   p.setName("Simple Perspective No Context");
   p.getRoot().addPart("welcome");
   return p;
 }
  PerspectiveDefinition buildPerspective() {
    PerspectiveDefinition perspective =
        new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
    perspective.setName("Preferences");

    final PanelDefinition actionsBar =
        new PanelDefinitionImpl(StaticWorkbenchPanelPresenter.class.getName());
    actionsBar.setHeight(80);
    actionsBar.addPart(
        new PartDefinitionImpl(
            new DefaultPlaceRequest(PreferencesCentralActionsScreen.IDENTIFIER)));

    perspective.getRoot().insertChild(CompassPosition.SOUTH, actionsBar);

    return perspective;
  }
  @Test
  public void checkPerspectiveDefinition() {
    final ServerManagementPerspective perspective = new ServerManagementPerspective();
    final PerspectiveDefinition definition = perspective.buildPerspective();

    assertNotNull(definition);

    assertEquals("ServerManagementPerspective", definition.getName());
    assertEquals(
        SimpleWorkbenchPanelPresenter.class.getName(), definition.getRoot().getPanelType());

    assertEquals(1, definition.getRoot().getParts().size());

    final PartDefinition partDefinition = definition.getRoot().getParts().iterator().next();

    assertTrue(partDefinition.getPlace() instanceof DefaultPlaceRequest);

    assertEquals("ServerManagementBrowser", partDefinition.getPlace().getIdentifier());
  }
  @Perspective
  public PerspectiveDefinition getPerspective() {
    final PerspectiveDefinition perspective =
        new PerspectiveDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName());
    perspective.setName(constants.Administration());

    perspective
        .getRoot()
        .addPart(new PartDefinitionImpl(new DefaultPlaceRequest("RepositoriesEditor")));

    final PanelDefinition west =
        new PanelDefinitionImpl(SimpleWorkbenchPanelPresenter.class.getName());
    west.setWidth(300);
    west.setMinWidth(200);
    west.addPart(new PartDefinitionImpl(new DefaultPlaceRequest("FileExplorer")));

    perspective.getRoot().insertChild(CompassPosition.WEST, west);

    return perspective;
  }