function setViewState(id, value, context, doNotSave) {

        PreferencesImpl.stateManager.set(id, value, context);

        if (!doNotSave) {
            PreferencesImpl.stateManager.save();
        }
    }
Convenience function that sets a view state and then saves the file

@param {string} id preference to set
@param {*} value new value for the preference
@param {?Object} context Optional additional information about the request
@param {boolean=} doNotSave If it is undefined or false, then save the
     view state immediately.