public abstract class DocumentHistory extends Object
entries.
Each entry represents a single change made to the document.
Plugins should add entries using addHistoryEntry(entry),
or addHistoryEntry(entry, true)
if they have created an AnnotatedPluginDocument.
Example of adding document history for an edit:
try {
DocumentHistory documentHistory = annotatedPluginDocument.getDocumentHistory();
DocumentHistoryEntry documentHistoryEntry = documentHistory.createDocumentHistoryEntry();
documentHistoryEntry.addField(DocumentHistoryEntryField.DESCRIPTION_CODE, "Edited", "replaced bases");
documentHistoryEntry.addField(this.getClass().getCanonicalName() + ".exampleFieldCode", "Example field name", "example field value");
documentHistory.addHistoryEntry(documentHistoryEntry);
}
catch (IOException e) {
e.printStackTrace();
// there's not much you can do if there's an IO exception while retrieving the history. This probably means the document itself won't save either.
}
Note that save() does not need to be called from within the plugin, Geneious saves entries automatically when the document is saved.
Example of adding document history for creation of an AnnotatedPluginDocument, including referenced documents:
try {
DocumentHistory documentHistory = annotatedPluginDocument.getDocumentHistory();
DocumentHistoryEntry documentHistoryEntry = documentHistory.createDocumentHistoryEntry();
documentHistoryEntry.setReferencedAnnotatedDocuments("Documents used in the creation of this document", annotatedPluginDocuments);
documentHistoryEntry.addField(DocumentHistoryEntryField.DESCRIPTION_CODE, "Created a Document", "using some other documents");
documentHistory.addHistoryEntry(documentHistoryEntry, true);
}
catch (IOException e) {
e.printStackTrace();
// there's not much you can do if there's an IO exception while retrieving the history. This probably means the document itself won't save either.
}
Plugin writers should not extend this class.| Modifier and Type | Method and Description |
|---|---|
abstract void |
addHistoryEntry(DocumentHistoryEntry entry)
|
abstract void |
addHistoryEntry(DocumentHistoryEntry entry,
boolean attemptToSetAsCreationEntry)
Adds a
DocumentHistoryEntry to the history of this document. |
abstract DocumentHistoryEntry |
createDocumentHistoryEntry()
Create a historyEntry which can then have entryFields added to it before it is passed to one of the addHistoryEntry methods in this class.
|
abstract List<DocumentHistoryEntry> |
getHistoryEntries()
Gets the list of entries.
|
abstract void |
save()
Saves the document history.
|
public abstract List<DocumentHistoryEntry> getHistoryEntries()
public abstract void addHistoryEntry(DocumentHistoryEntry entry)
public abstract void addHistoryEntry(DocumentHistoryEntry entry, boolean attemptToSetAsCreationEntry)
DocumentHistoryEntry to the history of this document.
NB If history is turned off (via 'Preferences' -> 'Appearance and Behaviour' -> 'Store history when...' checkbox) this will silently discard the entry.entry - the entry to addattemptToSetAsCreationEntry - if true will attempt to replace the initial entry that Geneious has auto-generated for the document with this entry.
If this cannot occur (eg because another plugin has already set a non-auto-generated entry) this entry will appended to the list of entries.public abstract DocumentHistoryEntry createDocumentHistoryEntry()
DocumentHistoryEntry,public abstract void save()