Community
Participate
Working Groups
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
What kind of state are you saving? Just as a workaround if you need, you can add a listener to the view's control.
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 ??
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?
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
There are no plans for the UI team to work on this defect until higher priority items are addressed.
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);
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.
There are currently no plans to work on this feature
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