Add a button from the Core Controls pallete.
The code for the button should be:
context.setDocumentMode("edit");
NB You can also have context.setDocumentMode("readOnly"); and also autoEdit and toggle
The Visible computed formula should be:
!document1.isEditable()
The @formula @IsDocBeingEdited does not work in XPages as there may be several data sources.