ViewStateManager is a singleton for views to park their global viwe state. The state is saved with project data but the View or View Factory is responsible for restoring the view state when the view is created.
Views should implement getViewState()
so that the view state can be saved and that data is cached
for later use.
Views or View Factories are responsible for restoring the view state when the view of that file is created by recalling the cached state. Views determine what data is store in the view state and how to restore it.
Sets the view state for the specfied file
function _setViewState(file, viewState) {
_viewStateCache[file.fullPath] = viewState;
}
adds an array of view states
function addViewStates(viewStates) {
_viewStateCache = _.extend(_viewStateCache, viewStates);
}
gets the view state for the specified file
function getViewState(file) {
return _viewStateCache[file.fullPath];
}
Updates the view state for the specified view
function updateViewState(view) {
if (view.getViewState) {
_setViewState(view.getFile(), view.getViewState());
}
}