-
Notifications
You must be signed in to change notification settings - Fork 1k
The Document View Model
MonoDevelop 8.1 implements a new architecture for displaying views in the shell. The main changes of this architecture compared to the old one are:
- Introduction of a Model/View/Controller pattern. By having the data in a Model it will be possible to easily support displaying and editing a file in more than one view, even in different documents.
- Extensibility at document and controller level, so that add-ins can plug into file operations and provide custom commands.
- Proper support of split and tabbed views. Extensions can provide visual designers and previews, and the shell decides the best way to present them.
The following diagram shows the most relevant classes and their relations:

A document represents a tab in the shell, which can show a file in a text editor, a designer or a tool such as the assembly browser.
A document controller is a class that implements the logic for loading, displaying and interacting with the contents of a document. It is roughly equivalent to the old BaseViewContent and ViewContent classes.
A type of controller specialized in showing the content of a file.
An extension object that can be attached to a DocumentController. It can participate in controller operations and provide custom UI.
DocumentView and its derived classes can be used to create complex composite views inside a document. For example, it allows showing two views in tabs, or with splits.
A model is a class that contains the data shown in a view. This concept has no equivalent on the old design, in which data and view were mixed in a single class. By having the data isolated in its own class it will be possible to support simultaneous editing of models in more than one view or even document.
A type of model that represents a file.
Keeps track of the loaded models.
A model is the data being shown in a view. DocumentModel is the base class for models that can be edited in a view. FileModel is a base class for file-based models. TextFileModel is the base class for models stored in text files. TextBufferFileModel is a model that stores data in a TextBuffer. DocumentModelRegistry is a service that can be used to share and get shared models.
The new DocumentController and related classes replace ViewContent and BaseView content. A document controller is a class that implements the logic for loading, displaying and interacting with the contents of a document. The FileDocumentController class is a controller base class specialized in showing the content of files.
DocumentController supports extensions using the DocumentControllerExtension class. Extensions can hook into controller operations and provide custom UI.
Document controllers can provide views using the DocumentView class and derived classes. Unlike the old ViewContent class, which created a Control, the DocumentController class creates a DocumentView. A DocumentView is a component of the shell that can show the content provided by a document controller. The DocumentViewContent subclass can show a Control, and the DocumentViewContainer can show a set of views using tabs or splits.
SdiWorkspaceWindow has changed to support the new DocumentView model. However, all the interaction between DocumentView and the shell implementation is now done through interfaces so that porting to a native toolkit will be easier in the future, and also makes the code easier to unit test.
There are several GtkShellDocumentView* classes that implement the functionality of DocumentView and related classes.
All old ViewContent implementations have been migrated to use DocumentModel and DocumentView.
Document handling logic has been moved from Workbench to a new DocumentManager class.
The Document class is not a subclass of DocumentContext anymore. It has a DocumentContext property instead. All logic in charge of parsing documents has been moved to the new RoslynDocumentExtension class, a document controller extension that is created only when the document is parseable.
Bulding and Running
Writing Add-ins
MonoDevelop API
MonoDevelop Design and Architecure
- The Project Model
- Error and Exception Handling
- The Command System
- The Service Model
- The Document/View Model
MonoDevelop Coding Guides