Where to store global data in an Eclipse RCP application?

I start with Eclipse RCP, and I'm trying to create an application for myself to let it go. I am confused about how the processing of model objects actually happens. None of the examples I can find cope with the problem I am facing, so I suspect that I am wrong.

Let's say I need to initialize the application with a class that contains authenticated user information. I used WorkbenchWindowAdvisor(the wrong place?) To do some initialization (e.g. authentication) to determine which view should be displayed. After that, the view will be shown. Now this view also needs access to the user information that I previously received / prepared.

The question is, how is this representation supposed to get this data? View connected to plugin.xml. I see no way to provide data for presentation. Therefore, I suggest that the view should somehow get it. But what is the place to extract it? I was thinking of including static variables in the implementation IApplication, but that was wrong. Any tips or pointers are greatly appreciated. Thanks.

+3
source share
1 answer

The problem you are facing is not, in my opinion, related to RCP. Its a more architectural problem. Your opinion is connected with business logic and! The decision can be made using two (common) design patterns:

  • Model-View-Controler (MVC)
  • Model-View-Presenter (MVP)

. MVP.

. , , RCP-, rcp.view. , ( org.eclipse.core.runtime ) rcp.presenter. , .

:

  • rcp.presenter rcp.view( , )
  • , rcp.presenter .
  • rcp.presenter IPerspective, (showLogiDialog(), showAdministratorViews ( ), showStandardViews ( ))
  • PerspectivePresenter, IPerspective
  • rcp.view , IPerspective, presenter = new PerspectivePresenter (this)
  • presenter.load() implenent , ,

:

public void load()
{
  User user = view.showLoginDialog(); // returns a user with the provided name/pw
  user.login(); // login to system/database
  if(user.isAdministrator())
    view.showAdministratorViews(user);
  else
    view.showStandardViews(user);
}

, , -, , . , , -.

, , ( ), . . JFace-Databindings ( ). , WorkbenchWindowAdisor , . , , / .. (, isAdministrator adminMenu).

, , Eclipse RCP ( ) . . RCP , ... , . MVP ( ). , , .

, , , .

+5

Source: https://habr.com/ru/post/1714633/


All Articles