Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 30042 - [View Mgmt] why save the view state when eclipse workbench and not when view closes
Summary: [View Mgmt] why save the view state when eclipse workbench and not when view ...
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows 2000
: P4 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-23 02:13 EST by Joseph Khalil CLA
Modified: 2019-01-04 05:40 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Khalil CLA 2003-01-23 02:13:56 EST
i think it's a good idea to make a method that enables a view to save its state 
when it's closed , not only when the workbench closes
i tried to put the code that saves in dispose() method in the view , but the 
problems that the swt components of the view is already disposed when dispose() 
method in view is called , so i can't save their states.
i saved them in an IDialogSettings.

i think it's a good idea that you make a method in view
boolean willClose(IMemento memento)which is called before a view is closed
and the user can control whether the view can be closed or not , and can store 
the settings in that memento , and that memento can be just like 
IDialogSettings that it's not saved till the workbench closes , but when the 
view is opened again , that memento comes in its init()method
and that memento will be the same memento that's passed to saveState()
and it's up to the user to see what settings will be saved when the view closes 
and what settings will be saved when the workbench closes
Comment 1 Eduardo Pereira CLA 2003-01-28 17:38:58 EST
What kind of state are you saving?
Just as a workaround if you need, you can add a listener to the view's control.
Comment 2 Joseph Khalil CLA 2003-01-29 02:55:28 EST
My view looks like the resources navigator
i want to save the selection , expantion states , the scrol bar states from the 
tree which can't be retrieved if the tree is disposed 
also i want to save the selected filters and sorters and working set

do you mean by the view control the tree in the view ??
Comment 3 Eduardo Pereira CLA 2003-01-29 09:57:48 EST
The tree.
In case of the Navigator we save the information like selection, expansion etc 
when the workbench is shotdown and some information like sort order we save as 
they change in the dialog settings.

Supose you have 2 windows with your view opened in both; then the user opens a 
couple more windows. Then goes back to the first two and close the views. And 
30 minutes later he opens the view again. Do you expect that the context that 
you saved is still important. If so, are you going to save some info about the 
window as well so you know which one you want to restore?
Comment 4 Joseph Khalil CLA 2003-02-02 03:01:15 EST
But what about my porposal about the
boolean willClose(IMemento memento) method that i described earlier
will you invistigate it , or it's not acceptable
Comment 5 Nick Edgar CLA 2003-02-19 11:15:32 EST
There are no plans for the UI team to work on this defect until higher 
priority items are addressed. 
Comment 6 Omry Yadan CLA 2004-12-22 04:28:18 EST
I believe encountered the same problem.
the scenario is :
my perspective contains a view by default.
when the application is closed, the view saveState(IMemento) is called.
when the view is closed, its saveState is not called, so when the user restore
the view (still in the same session), the state of the view is lost.
I am not sure its a bug, since if the user closed the view, he might no longer
be interested in its content, but I find it annoying.
I think a solution could be to call saveState of the view, maybe with some extra
boolean flag indicating if the view is closed or the entire workspace:
saveState(IMemento m, boolean workspaceCloses);
this will allow a view to choose to save state only when the workspace is closing.

also, the willClose idea is not bad.
about the subject of multiple instances of the same view:
I believe the state should be stored per id + secondary id, so a new instance of
the view will not automatically inherit previous instances state, but perhaps a
mechanism to obtain the state of the last instance of this view should be
provided, something like:
IMemento getStateFor(String viewID);
and
IMemento getStateFor(String viewID, String secondaryID);
Comment 7 Nick Edgar CLA 2004-12-22 10:04:07 EST
How do you think the following case should work:
- view A and A' are different instances of the same view (same primary id and
null secondary id for both)
- it has a setting S which defaults to V0
- in view A in window 1, user changes setting S to value V1
- in view A' in window 2, user changes setting S to value V2
- user closes A'
- user closes A
- user reopens A in window 1
- what should the value for S be in A?  Is it V0, V1 or V2?

V0: corresponds to the current behaviour, where the setting is not saved
V1: corresponds to saving the settings of the last closed instance
V2: corresponds to saving the setting when it was last modified

Then ask:
- user reopens A' in window 2
- what should the value for S be in A'?  Is it V0, V1 or V2?

It gets more interesting when the views have multiple settings that are changed
at different times.
Comment 8 Tod Creasey CLA 2006-06-22 08:35:28 EDT
There are currently no plans to work on this feature
Comment 9 Xavier Loiseau CLA 2007-02-23 05:52:09 EST
Hi,


We have exactly the same problem !

Why is the ViewPart.saveState method not called when the view part is closed ?

Is there any workaround to get this method called when the view part is closed ?

Thank you for your help ...


Xav