Bug 426811 - UserSession should not depend on the UI
Summary: UserSession should not depend on the UI
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 427799
  Show dependency tree
 
Reported: 2014-01-28 11:04 EST by Esteban DUGUEPEROUX CLA
Modified: 2021-03-21 11:25 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Esteban DUGUEPEROUX CLA 2014-01-28 11:04:26 EST
Some Sirius API users use "UserSession.selectViewpoints()" to select some viewpoints at session init. . But in some case it leads to deadlock between UI thread on UI resource and our use of CDO framework with synchronized lock on CDO resources. Then "UserSession.selectViewpoints()" should be deprecated in flavor of an non UI API to select and unselect Viewpoint. Finally this class should be deprecated entirely because all others methods are already available in Sirius API.
Sirius API needs a non UI class to do the Viewpoint selection/unselection and a EMF Command to do that also. For example with :

interface Session {

...
 selectViewpoint(String viewpointName);
 
 unselectViewpoint(String viewpointName);
...

}

and EMF Commands :

class SelectViewpoints extends RecordingCommand {

  SelectViewpoints(Session, Collection<String> viewpointNames);

}

class UnselectViewpoints extends RecordingCommand {


  UnselectViewpoints(Session, Collection<String> viewpointNames);
}

NOTE: with Viewpoints selection in Session interface we could remove Session methods like Session.addSelectedView()/removeSelectedView()/createView() which are Viewpoints selection/unselection specific and are not/must not be used by Sirius API users.
Comment 1 Pierre-Charles David CLA 2014-01-28 11:24:38 EST
I'm not a fan of the whole UserSession API. It was initially created by an external user to work around the complexities of using our standard APIs. The correct way would have been to fix our own APIs instead of trying to paper over it, so +1 to take this opportunity to get a proper (non-UI) API for Viewpoint de/selection.

However, -1 to use viewpoint names as identifiers. It was a bad idea in the original (the name is not globally unique) and we should not reproduce it.

org.eclipse.sirius.business.internal.movida.ViewpointSelection was an attempt at a better solution, with consistency checks and proper identification of Viewpoints, but it was never finished/enabled. Not sure how much of it can be reused (even if just as inspiration).
Comment 2 Esteban DUGUEPEROUX CLA 2014-02-04 08:01:20 EST
A first release of patch has been submitted to Gerrit :  https://git.eclipse.org/r/21509 :

Deprecate some class about Viewpoint selection/unselection in
flavor of Session.selectViewpoint(URI)/unselectViewpoint(URI)

- SelectViewpointCommand/UnselectViewpointCommand replace
ChangeViewpointSelectionCommand which become deprecated
- ViewpointSelection.Callback and all implementations are now deprecated
to have Viewpoint selection independant of UI at compilation and
execution and because a callback here is useless
- deprecate some SiriusResourceHelper methods en flavor of
Session.selectViewpoint()/unselectViewpoint()
- deprecate all Session methods about DView in flavor of
Session.selectViewpoint()/unselectViewpoint()

RAF: 
- have all Sirius code use Session.selectViewpoint()/unselectViewpoint()
instead of deprecated code
- update the release notes/api changes