1. In the present implementation the document is locked when double-click, that is, before the commencement of Querymodechange! This is wrong - on Querymodechange there are some conditions for which are not permitted to translate the document into edit mode.
I propose to block the document between Querymodechange and Postmodechange, while in edit mode, the document should be translated only if the document was blocked!
If suddenly you need to block the document before, it can be done elementarily programmatically by calling notesDocument.Lock() on Querymodechange.
2. If the document has been blocked by the current user and will re-lock (an attempt to translate the document into edit mode), then the document should not explicitly blocked and translated into edit mode, rather, it is not true, because document at the same time could be changed by another process from the same user, such as background agent. If you give to save the document, the data entered by another process will be replaced by the current instance.
Ideally, there should be a link with this idea, or should warn you that "the document is changed by another process..."
3. Lock indicators:
This is all seen in the debugger and flies in the runtime...