Added a Scala preference for Mark Occurrences

Added a toolbar button for quick access.
Fixes #1001466

I also extracted the common code in toggle handlers.

[need back port]