Adding History support
There are two parts to adding History support to your repository:
- Providing implementations for the core history interfaces; see the
Providing History section.
- Creating the UI elements for the History Page which gets displayed in the
History View; see the Showing History section.
Providing History
The core history interfaces allow users to access the history of an item by querying the
IFileHistoryProvider
returned by the RepositoryProvider. To do this, you need to:
Showing History
To display history for items in your repository, you can provide one or more HistoryPages which will be shown
in the History view. To do this, you need to:
- Provide an implementation for IHistoryPage by extending
HistoryPage.
- Provide an implementation for IHistoryPageSource by
extending HistoryPageSource. When a resource is selected to
be shown in the History view it will try to adapt the FileHistoryProvider it gets from your repository provider to a HistoryPageSource. If
it doesn't succeed, it will then try to adapt the repository provider itself. For non-resource objects, the History view will
try to adapt the object to a HistoryPageSource. The FileSystem History view example registers an adapter factory that adapts a FileHistoryProvider
to an IHistoryPageSource.
- Create a Show History Action, provide an object contribution for the Action. See
org.eclipse.ui.popupMenus for more
info.
Showing History for Sub-file Elements
To display the history of a model element that is contained in a file, you can do the following:
- Implement a
StructureCreator
for the file.
- Subclass
ElementLocalHistoryPageSource
and adapt your sub-file element(s) to an instance of the subclass.
- To show the history in the History View, pass your history page source and element to the
showHistoryFor
method of
TeamUI.
- To show the history in a dialog, provide History actions (show, compare, replace) that make use of a
HistoryPageCompareEditorInput
to show the history.
FileSystem History example
The FileSystem example illustrates how you can provide history and a history page for repository items.
Select a resource in a FileSystem managed project and choose Team > Show History. The FileSystem History
page will be displayed in the History view with all of the local revisions as well as the FileSystem revision
displayed. You can right click on any revision and select Open from the context menu to open the revision.
FileRevisionEditorInput
To support the Open functionality, the FileSystem history example had to create its own FileSystemRevisionEditorInput (see
org.eclipse.team.examples.filesystem.ui.FileSystemRevisionEditorInput). This class adapts to IFileRevision and to IFileState, which
can be used to determine whether the editor contains remote contents (IFileRevision) or local history contents (IFileState).
Likewise, the existing FileRevisionEditorInput's that come with the SDK and are used by the CVS History page and Local History page
all adapt to IFileRevision which can be used to determine if the revision contained in the editor is that of a remote revision.