Community
Participate
Working Groups
The current EAP does not allow to persist the state in a way RCP 3.x allowed save the state by implementing IViewPart#saveState(). In EAP we only have @PreDestroy as a lifecycle which is not good because at this moment e.g. SWT-Widgets are already disposed and saving their state in ApplicationElement.persistedState is not possible any more. My suggestion would be to: a) add @PersistState annotation to ui.di b) call it in the ContributedPart renderer in disposeWidget Please not this make it work a bit different than in 3.x where the saveState was called on Workbench shutdown only which always bugged me there already.
Created attachment 210806 [details] Annotation
Created attachment 210807 [details] Modification to PartRenderingEngine
> b) call it in the ContributedPart renderer in disposeWidget > Better position is in the PREngine
Any feedback on the API and functional spec would be appreciated
Is @PersistState really different from @Persist? Perhaps @PreDestroy should be fixed to happen before the widgets a destroyed? I'm wondering if the contribution object should be conceptually considered as part of the rendering, and should be keeping the model up to date anyways.
Yes - it differs a lot from @Persist @Persit == Persit content @PersitState == Persist UI-state e.g. scrolling position, ... I'm not sure we can dispose the context before the widget gets destroyed.
Created attachment 210922 [details] revised patch Patch to execute the save before the dispose happens. @Brian: I don't think we can use @PreDestroy because at the moment the context is destroyed all services have are unjected, widgets destroyed (by going through the renderers), ... . @PreDestroy can guarantee that the widget that got injected is not already disposed at the moment the context is destroyed whereas @PersistState does this. We could though discuss the naming of the annotation my PersistUIState is better?
We decided to go with @PersistState - we also discussed if this could be solved using events but thought @PersistState aligns nicely with @Focus and @Persist so that it makes sense to use it's own annotation. We also discussed if @PreDestroy could would be the correct callback but when creating the Part we do: * Create Context * Create Widget * Create PartObject the opposite should be done on tear down so @PreDestory is not the correct callback. The commit is http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=f2a8ce2a9c2725653391ee3326262a984a9fa896
(In reply to comment #7) > Created attachment 210922 [details] > revised patch > > Patch to execute the save before the dispose happens. > > @Brian: I don't think we can use @PreDestroy because at the moment the context > is destroyed all services have are unjected, I'll just note that during @PreDestroy the context has not been destroyed, and I believe it is called before any of the services are uninjected from the object. PW