Showing login window in Eclipse RAP application

If you are looking for a way to show a login window in a Eclipse RAP client, this is one of ways it could be done:

1. create a new perspective (LoginPerspective).
2. add the login view to this perspective, something like:

  @Override
  public void createInitialLayout(IPageLayout layout)
  {
    String editorArea = layout.getEditorArea();
    layout.setEditorAreaVisible(false);

    layout.addStandaloneView(LoginView.ID, false, IPageLayout.RIGHT,0.5f,
      editorArea);
  }

3. in ApplicationWorkbenchWindowAdvisor class, make the perspective first perspective displayed when application starts:

  public void postWindowCreate()
  {
    // close opened perspective
    IPerspectiveDescriptor pers = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective();
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closePerspective(pers, false, false);

    // open login perspective
    pers = PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(LoginPerspectiveFactory.ID);
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(pers);

    Shell shell = getWindowConfigurer().getWindow().getShell();
    //getWindowConfigurer().setInitialSize(new Point(400, 300));
    getWindowConfigurer().setShowCoolBar(false);
    getWindowConfigurer().setShowStatusLine(false);
    getWindowConfigurer().setShowPerspectiveBar(false);
    shell.setMaximized( true );
  }

4. in LoginView, you can load the main perspective after all validation is completed using something like:

  void loadApplicationPerspective()
  {
    IPerspectiveDescriptor pers = PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(Perspective.ID);
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setPerspective(pers);
  }

Happy coding.

Leave a comment

0 Comments.

Leave a Reply

You must be logged in to post a comment.