public final class DocumentUtilities extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<AnnotatedPluginDocument> |
addAndReturnGeneratedDocuments(List<AnnotatedPluginDocument> documents,
boolean selectDocumentsImmediately,
List<AnnotatedPluginDocument> additionalDocumentsToSelect)
Adds a list of documents that have just been generated to Geneious so that appear in the users local database
and returns the newly added documents.
|
static List<AnnotatedPluginDocument> |
addAndReturnGeneratedDocuments(List<AnnotatedPluginDocument> documents,
boolean selectDocumentsImmediately,
List<AnnotatedPluginDocument> additionalDocumentsToSelect,
WritableDatabaseService destination)
Adds a list of documents that have just been generated to Geneious so that appear in the users local database
and so that they become visible in the document table.
|
static void |
addGeneratedDocument(AnnotatedPluginDocument document,
boolean selectDocumentImmediately)
Adds a newly generated document that will appear in the users local database.
|
static void |
addGeneratedDocuments(List<AnnotatedPluginDocument> documents,
boolean selectDocumentsImmediately)
Adds newly generated documents that will appear in the users local database.
|
static void |
addGeneratedDocuments(List<AnnotatedPluginDocument> documents,
boolean selectDocumentsImmediately,
List<AnnotatedPluginDocument> additionalDocumentsToSelect)
Adds a list of documents that have just been generated to Geneious so that appear in the users local database
and so that they become visible in the document table.
|
static void |
addGeneratedDocuments(List<AnnotatedPluginDocument> documents,
boolean selectDocumentsImmediately,
List<AnnotatedPluginDocument> additionalDocumentsToSelect,
WritableDatabaseService destination)
Adds a list of documents that have just been generated to Geneious so that appear in the users local database
and so that they become visible in the document table.
|
static void |
addGeneratedPluginDocument(PluginDocument document,
boolean selectDocumentImmediately)
Adds a newly generated document that will appear in the users local database.
|
static void |
addGeneratedPluginDocuments(List<PluginDocument> documents,
boolean selectDocumentsImmediately)
Adds newly generated documents that will appear in the users local database.
|
static AnnotatedPluginDocument |
createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement,
ElementProvider pluginDocumentElementProvider,
boolean assignNewURN)
Deprecated.
use
createAnnotatedPluginDocument(org.jdom.Element, ElementProvider, boolean) instead, where the final parameter of null is equivalent to assignNewURN==false or URN.generateUniqueLocalURN() for assignNewURN==true |
static AnnotatedPluginDocument |
createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement,
ElementProvider pluginDocumentElementProvider,
String assignerForUrn)
Deprecated.
|
static AnnotatedPluginDocument |
createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement,
ElementProvider pluginDocumentElementProvider,
URN urnForNewDocument)
Creates an AnnotatedPluginDocument without the internal PluginDocument included.
|
static AnnotatedPluginDocument |
createAnnotatedPluginDocument(PluginDocument document)
|
static AnnotatedPluginDocument |
createAnnotatedPluginDocument(PluginDocument document,
ProgressListener progressListener)
Creates an AnnotatedPluginDocument from a PluginDocument.
|
static List<AnnotatedPluginDocument> |
createAnnotatedPluginDocuments(List<? extends PluginDocument> documents)
Creates a list of AnnotatedPluginDocuments from a list of PluginDocuments.
|
static List<AnnotatedPluginDocument> |
createAnnotatedPluginDocuments(PluginDocument document)
creates a list of AnnotatedPluginDocuments from a single of PluginDocument.
|
static AnnotatedPluginDocument |
duplicateDocument(AnnotatedPluginDocument document,
boolean duplicateReferencedDocuments)
Create a duplicate of document.
|
static AnnotatedPluginDocument |
duplicateDocumentThrowingDocumentOperationExceptionOnFailure(AnnotatedPluginDocument document,
boolean duplicateReferencedDocuments)
Create a duplicate of document.
|
static List<DocumentField> |
getAllDisplayableFields()
Gets a list of all the displayable fields on any document in the user's database
|
static AnnotatedPluginDocument |
getAnnotatedPluginDocumentThatContains(PluginDocument pluginDocument)
Gets the AnnotatedPluginDocument that contains the given PluginDocument.
|
static AnnotatedPluginDocument |
getDocumentByURN(URN urn)
Fetches the specified document from either in memory or from the local or a shared database.
|
static List<AnnotatedPluginDocument> |
getSelectedDocuments()
Gets the currently selected documents in the Geneious document table.
|
static String |
getUniqueNameForDocument(String baseDocumentName)
Deprecated.
use getUniqueNameForDocument(String, WritableDatabaseService, Collection)
|
static String |
getUniqueNameForDocument(String baseDocumentName,
boolean reserveName)
Deprecated.
use getUniqueNameForDocument(String, WritableDatabaseService, Collection)
|
static String |
getUniqueNameForDocument(String baseDocumentName,
WritableDatabaseService mustBeUniqueIn)
Generate a document name that is unique to the given folder, based on the original name passed in.
|
static String |
getUniqueNameForDocument(String baseDocumentName,
WritableDatabaseService mustBeUniqueIn,
Collection<String> mustNotBe)
Generate a document name that is unique to the given folder, based on the original name passed in.
|
static void |
openDocumentsInNewWindow(List<AnnotatedPluginDocument> documents)
Opens a new Geneious window and displays these documents in all available
document viewers that match these documents.
|
static File |
pluginDocumentFileDataFromXml(org.jdom.Element element,
boolean mayReturnNullIfNoFileData,
boolean fileMayBeZeroBytesInSize)
Deserializes the name of a file serialized using
pluginDocumentFileDataToXml(org.jdom.Element, java.io.File, boolean) checking for corruption such
as the file disappearing, changing in size or reducing to 0 bytes in size. |
static void |
pluginDocumentFileDataToXml(org.jdom.Element element,
File file,
boolean fileMayBeZeroBytesInSize)
Provides a system for storing a reference to an arbitrary immutable file from within a PluginDocument.
|
static boolean |
selectDocument(URN urn)
Changes the currently selected document in the Geneious document table.
|
static boolean |
selectDocuments(List<URN> urns)
Changes the currently selected documents in the Geneious document table.
|
static boolean |
selectDocuments(List<URN> urns,
SequenceSelection sequenceSelection)
Changes the currently selected documents in the Geneious document table and selects a region within them.
|
static boolean |
showSaveAsDialog(JComponent viewerComponent)
Shows the "Save As" dialog (i.e.
|
static void |
unselectDocuments()
Unselects any documents currently selected in Geneious.
|
static boolean |
wouldDocumentNameBeUnique(String baseDocumentName)
Deprecated.
|
public static AnnotatedPluginDocument createAnnotatedPluginDocument(PluginDocument document)
document - the underlying PluginDocumentpublic static AnnotatedPluginDocument createAnnotatedPluginDocument(PluginDocument document, ProgressListener progressListener)
AnnotatedPluginDocument.getDocument() is called
on the returned AnnotatedPluginDocument it will not be the same PluginDocument instance as the one passed to this method. See
AnnotatedPluginDocument.getDocument() for further information.document - the underlying PluginDocumentprogressListener - since creating annotated plugin documents wrapping huge plugin documents can take a short but noticeable amount of time, this reports the progress and provides the ability to cancel the creation.public static List<AnnotatedPluginDocument> createAnnotatedPluginDocuments(List<? extends PluginDocument> documents)
createAnnotatedPluginDocument(PluginDocument) for further detailsdocuments - the list of underlying PluginDocumentspublic static List<AnnotatedPluginDocument> createAnnotatedPluginDocuments(PluginDocument document)
createAnnotatedPluginDocument(PluginDocument) for further detailsdocument - the underlying PluginDocumentpublic static void addGeneratedDocuments(List<AnnotatedPluginDocument> documents, boolean selectDocumentsImmediately)
addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List) instead
if you need to reference the newly added document copies.documents - the list of generated AnnotatedPluginDocuments (this list doesn't need to be modifiable)selectDocumentsImmediately - set focus to newly added documents if truepublic static void addGeneratedDocuments(List<AnnotatedPluginDocument> documents, boolean selectDocumentsImmediately, List<AnnotatedPluginDocument> additionalDocumentsToSelect)
addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List) instead
if you need to reference the newly added document copies.documents - List of documents to add; this list doesn't have to be modifiableselectDocumentsImmediately - If true, the generated documents will be immediately selected in the document tableadditionalDocumentsToSelect - Optional list of additional documents to select. May not be null,
but may be empty (e.g. Collections.emptyList()). If this list is nonempty and
selectDocumentImmediately is true, then both these documents and the generated ones will be selected.addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List)public static void addGeneratedDocuments(List<AnnotatedPluginDocument> documents, boolean selectDocumentsImmediately, List<AnnotatedPluginDocument> additionalDocumentsToSelect, WritableDatabaseService destination)
addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List) instead
if you need to reference the newly added document copies.documents - List of documents to add; this list doesn't have to be modifiableselectDocumentsImmediately - If true, the generated documents will be immediately selected in the document tableadditionalDocumentsToSelect - Optional list of additional documents to select. May not be null,
but may be empty (e.g. Collections.emptyList()). If this list is nonempty and
selectDocumentImmediately is true, then both these documents and the generated ones will be selected.destination - destination folder to add the documents to. May be null to use the default location (prompting the user if necessary). An appropriate destination can be obtained using ServiceUtilities.getResultsDestination()addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List)public static List<AnnotatedPluginDocument> addAndReturnGeneratedDocuments(List<AnnotatedPluginDocument> documents, boolean selectDocumentsImmediately, List<AnnotatedPluginDocument> additionalDocumentsToSelect, WritableDatabaseService destination)
addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List) instead
if you need to reference the newly added document copies.documents - List of documents to add; this list doesn't have to be modifiableselectDocumentsImmediately - If true, the generated documents will be immediately selected in the document tableadditionalDocumentsToSelect - Optional list of additional documents to select. May not be null,
but may be empty (e.g. Collections.emptyList()). If this list is nonempty and
selectDocumentImmediately is true, then both these documents and the generated ones will be selected.destination - destination folder to add the documents to. May be null to use the default location (prompting the user if necessary). An appropriate destination can be obtained using ServiceUtilities.getResultsDestination()addAndReturnGeneratedDocuments(java.util.List, boolean, java.util.List)public static List<AnnotatedPluginDocument> addAndReturnGeneratedDocuments(List<AnnotatedPluginDocument> documents, boolean selectDocumentsImmediately, List<AnnotatedPluginDocument> additionalDocumentsToSelect)
documents - List of documents to add; this list doesn't have to be modifiableselectDocumentsImmediately - If true, the generated documents will be immediately selected in the document tableadditionalDocumentsToSelect - Optional list of additional documents to select. May not be null,
but may be empty (e.g. Collections.emptyList()). If this list is nonempty and
selectDocumentImmediately is true, then both these documents and the generated ones will be selected.public static void addGeneratedPluginDocuments(List<PluginDocument> documents, boolean selectDocumentsImmediately)
documents - List of documents to add; this list doesn't have to be modifiableselectDocumentsImmediately - If true, the generated documents will be immediately selected in the document tablepublic static void addGeneratedDocument(AnnotatedPluginDocument document, boolean selectDocumentImmediately)
document - the document to addselectDocumentImmediately - set focus to newly added document if truepublic static void addGeneratedPluginDocument(PluginDocument document, boolean selectDocumentImmediately)
document - the document to addselectDocumentImmediately - set focus to newly added document if truepublic static AnnotatedPluginDocument getDocumentByURN(URN urn)
urn - location of document. If this is null, null will be returned.public static AnnotatedPluginDocument duplicateDocument(AnnotatedPluginDocument document, boolean duplicateReferencedDocuments)
document - sourceduplicateReferencedDocuments - also duplicate any other documents
referenced by this document if trueduplicateDocumentThrowingDocumentOperationExceptionOnFailure(AnnotatedPluginDocument, boolean)public static AnnotatedPluginDocument duplicateDocumentThrowingDocumentOperationExceptionOnFailure(AnnotatedPluginDocument document, boolean duplicateReferencedDocuments) throws DocumentOperationException
document - sourceduplicateReferencedDocuments - also duplicate any other documents
referenced by this document if trueDocumentOperationException - if the document cannot be duplicated, for example because the original document throws an IOException loading the document's internal PluginDocument.duplicateDocument(AnnotatedPluginDocument, boolean)public static boolean wouldDocumentNameBeUnique(String baseDocumentName)
baseDocumentName - the base document namepublic static String getUniqueNameForDocument(String baseDocumentName)
baseDocumentName - the original document namepublic static String getUniqueNameForDocument(String baseDocumentName, boolean reserveName)
baseDocumentName - the original document namereserveName - whether to "reserve" the returned name so that it cannot be returned by future calls to this method with the same baseDocumentName.public static String getUniqueNameForDocument(String baseDocumentName, WritableDatabaseService mustBeUniqueIn) throws DatabaseServiceException
baseDocumentName - the original document namemustBeUniqueIn - the folder in which the name must be unique.DatabaseServiceException - if there is an error checking the folder's documentspublic static String getUniqueNameForDocument(String baseDocumentName, WritableDatabaseService mustBeUniqueIn, Collection<String> mustNotBe) throws DatabaseServiceException
baseDocumentName - the original document namemustBeUniqueIn - the folder in which the name must be unique.mustNotBe - any additional names which must not be usedDatabaseServiceException - if there is an error checking the folder's documentspublic static boolean selectDocument(URN urn)
urn - the URN of the document to be selectedpublic static boolean selectDocuments(List<URN> urns)
urns - the URNs of the documents to be selectedselectDocuments(java.util.List, com.biomatters.geneious.publicapi.plugin.SequenceSelection)public static boolean selectDocuments(List<URN> urns, SequenceSelection sequenceSelection)
urns - the URNs of the documents to be selectedsequenceSelection - the selection to apply within these documents. May be null to leave the selection as it currently is.public static void unselectDocuments()
public static List<AnnotatedPluginDocument> getSelectedDocuments()
@Deprecated public static AnnotatedPluginDocument createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement, ElementProvider pluginDocumentElementProvider, boolean assignNewURN) throws XMLSerializationException
createAnnotatedPluginDocument(org.jdom.Element, ElementProvider, boolean) instead, where the final parameter of null is equivalent to assignNewURN==false or URN.generateUniqueLocalURN() for assignNewURN==trueXMLSerializationException@Deprecated public static AnnotatedPluginDocument createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement, ElementProvider pluginDocumentElementProvider, String assignerForUrn) throws XMLSerializationException
createAnnotatedPluginDocument(org.jdom.Element, ElementProvider, URN) instead.XMLSerializationExceptionpublic static AnnotatedPluginDocument createAnnotatedPluginDocument(org.jdom.Element annotatedDocumentElement, ElementProvider pluginDocumentElementProvider, URN urnForNewDocument) throws XMLSerializationException
WritableDatabaseService implementations.
The database implementation should maintain a SoftReference cache of all documents it creates using this method
and reuse previously created documents that refer to the same document URN.
Furthermore, the database may make calls to AnnotatedPluginDocument.documentChanged(org.jdom.Element)
on any of the documents it stores in this cache.annotatedDocumentElement - some XML returned from a previous call to AnnotatedPluginDocument.toXMLExcludingInternalPluginDocument()pluginDocumentElementProvider - an ElementProvider that will load the PluginDocument when it is requiredurnForNewDocument - the returned document will be assigned this URN, or if this is null the document will use the existing URN defined in its XML. Generally a WritableDatabaseService will use null here when loading documents and a non-null value when creating document copies in WritableDatabaseService.addDocumentCopy(AnnotatedPluginDocument, jebl.util.ProgressListener)XMLSerializationException - if the annotatedDocumentElement is not a valid AnnotatedPluginDocumentpublic static void openDocumentsInNewWindow(List<AnnotatedPluginDocument> documents)
documents - the documents to display.public static AnnotatedPluginDocument getAnnotatedPluginDocumentThatContains(PluginDocument pluginDocument)
AnnotatedPluginDocument.getDocument() or any other getDocument* methods in AnnotatedPluginDocument.
Since PluginDocument passed to createAnnotatedPluginDocument(PluginDocument) is not the same
as the document instance returned from getDocument(), the PluginDocument passed to createAnnotatedPluginDocument is
not considered to be contained in the AnnotatedPluginDocument returned from createAnnotatedPluginDocument.pluginDocument - the plugin document to get the associated AnnotatedPluginDocument for.NullPointerException - if pluginDocument is null.public static boolean showSaveAsDialog(JComponent viewerComponent)
viewerComponent - the component from the currently active document viewer, or null to use the currently focused component.public static List<DocumentField> getAllDisplayableFields()
public static void pluginDocumentFileDataToXml(org.jdom.Element element,
File file,
boolean fileMayBeZeroBytesInSize)
PluginDocument.FILE_DATA_ATTRIBUTE_NAME but has additional safety
checks to fail gracefully on deserialization when the underlying file is corrupted which is prone to
happening on Windows systems where the users data is stored on a network drive. Typically the type of corruption seen
are files being truncated, often to 0 bytes in size, and files just disappearing.
In addition to using PluginDocument.FILE_DATA_ATTRIBUTE_NAME the implementation also adds an attribute called "fileSize" to elementelement - an element to add appropriate attributes to recording the file name and file sizefile - the file to add a reference to in the XMLfileMayBeZeroBytesInSize - true if the size of the file may be zero bytes. If this is false then this method throws an IllegalStateException if the file size is 0 bytes.pluginDocumentFileDataFromXml(org.jdom.Element, boolean, boolean),
PluginDocument.FILE_DATA_ATTRIBUTE_NAMEpublic static File pluginDocumentFileDataFromXml(org.jdom.Element element, boolean mayReturnNullIfNoFileData, boolean fileMayBeZeroBytesInSize) throws XMLSerializationException
pluginDocumentFileDataToXml(org.jdom.Element, java.io.File, boolean) checking for corruption such
as the file disappearing, changing in size or reducing to 0 bytes in size. This may also be used on elements that contain an
attribute called PluginDocument.FILE_DATA_ATTRIBUTE_NAME in which case it will be unable to detect files that have changed in size.element - the element that contains the file attributes. This should be the same element in the XML hierarchy as that passed to pluginDocumentFileDataToXml(org.jdom.Element, java.io.File, boolean)fileMayBeZeroBytesInSize - for serialization performed using pluginDocumentFileDataToXml(org.jdom.Element, java.io.File, boolean) this parameter is ignored since the file size was stored then. This parameter is intended for use with files serialized in earlier versions of GeneiousmayReturnNullIfNoFileData - true if this method may return null if the element does not contain a PluginDocument.FILE_DATA_ATTRIBUTE_NAME attribute. If this is false and the attribute isn't present, then an XMLSerializationException will be thrownPluginDocument.FILE_DATA_ATTRIBUTE_NAME attribute.XMLSerializationException - if the file referred to has become corrupt.pluginDocumentFileDataFromXml(org.jdom.Element, boolean, boolean),
PluginDocument.FILE_DATA_ATTRIBUTE_NAME