Class TextDocument

    • Constructor Detail

      • TextDocument

        public TextDocument​(java.io.File file,
                            java.lang.String name,
                            TextDocument.Format format)
        Create a text document from an existing file
        Parameters:
        file - file containing text, not null, must exist and not be a directory
        name - name of document, not null
        format - format of text, not null
      • TextDocument

        public TextDocument​(java.lang.String text,
                            java.lang.String name,
                            TextDocument.Format format)
                     throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
        Create a text document from a String
        Parameters:
        text - text, not null
        name - name of document, not null
        format - format of text, not null
        Throws:
        com.biomatters.geneious.publicapi.plugin.DocumentOperationException - if text can't be written to disk due to IOException
      • TextDocument

        public TextDocument()
    • Method Detail

      • getDisplayableFields

        public java.util.List<DocumentField> getDisplayableFields()
        Description copied from interface: PluginDocument
        A list of columns for display in the main document panel. This function only defines the columns available to display, not the particular values of these columns, which are returned by PluginDocument.getFieldValue(String).

        Each column is specified by a Field. The fields should be obtained from a call to the appropriate Field.createXXXXField, where XXXX is the appropriate type.

        While it is not required, it is recommended that a PluginDocument handle returning a complete list of its displayable fields before the document has been properly constructed via a call to XMLSerializable.fromXML(org.jdom.Element) The returned list need not and should not be modifiable.

        Specified by:
        getDisplayableFields in interface PluginDocument
        Returns:
        a list of document fields (or null to indicate no displayable fields)
      • getName

        public java.lang.String getName()
        Description copied from interface: PluginDocument
        A short name (preferably one or two words) for the document.

        If this PluginDocument is wrapped inside an AnnotatedPluginDocument then this method will be overridden and delegate back to AnnotatedPluginDocument.getName(). One way to look at it is that when you call PluginDocument.getName() you will get the current name of the document. If you are implementing PluginDocument.getName() then you are returning the default name for the document.

        Specified by:
        getName in interface PluginDocument
        Returns:
        document name. Cannot be null but may be an empty string.
      • getURN

        public URN getURN()
        Description copied from interface: PluginDocument
        A Universal Resource Name.

        Documents from external sources should set this to a unique name inside that service. Documents generated locally (such as from operations) and documents that don't have a unique identifier should return null since Geneious handles URNs for these.

        Specified by:
        getURN in interface PluginDocument
        Returns:
        the urn, or null if this document doesn't have a unique identifier
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: PluginDocument
        A human readable single line of text describing this document, to appear in the description field in the document table.
        Specified by:
        getDescription in interface PluginDocument
        Returns:
        a one line simple text description of the document, or null if no description is available.
      • toHTML

        public java.lang.String toHTML()
        Description copied from interface: PluginDocument
        Provide a textual view of document. The contents should be at most 30K-60K characters. One reason is that this text is rendered using JTextPane, which is horrendously slow when handling large text. The more fundamental reason is that large amounts of text are generally not useful for a user. The whole idea of using a tool such as Geneious is to provide specialized viewers which make the large amount of bioinformatics data perceivable and comprehensible to a human user.

        Return an HTML body fragment (i.e. a fragment which sits inside a <body></body> tag). (Header,stylesheet and annotations are automatically added by GENEious code).

        Can optionally return an entire html tag set, as long as the first six characters are <html>

        Specified by:
        toHTML in interface PluginDocument
        Returns:
        an HTML fragment of tag set, or null to have no text view.
      • getText

        public java.lang.String getText​(int maximumLength)
                                 throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
        Get text including any markup, never null, may have \r\n line endings.
        Parameters:
        maximumLength - return a string up to this length, reading from the start of the file or -1 to return entire file contents
        Throws:
        com.biomatters.geneious.publicapi.plugin.DocumentOperationException - if text can't be read from disk due to IOException
      • setText

        public void setText​(java.lang.String text)
                     throws com.biomatters.geneious.publicapi.plugin.DocumentOperationException
        Set the text content of the document, replacing all current text, doesn't accept null.
        Throws:
        com.biomatters.geneious.publicapi.plugin.DocumentOperationException - if text can't be written to disk due to IOException
      • getFile

        public java.io.File getFile()
        Get the file that this document is backed by in the database. DO NOT MODIFY this file, for read-only purposes.
      • toXML

        public org.jdom.Element toXML()
        Description copied from interface: XMLSerializable
        Convert object to a JDOM element. The representation should be complete so that XMLSerializable.fromXML(org.jdom.Element) can completely restore the object's representation.

        It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored.

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classToXML(String, XMLSerializable) which calls this method internally.

        PluginDocument implementations of this method may choose to throw an XMLSerializationException, enclosed in a RuntimeException.

        Specified by:
        toXML in interface XMLSerializable
        Returns:
        object encoded as a JDOM element
      • fromXML

        public void fromXML​(org.jdom.Element doc)
                     throws XMLSerializationException
        Description copied from interface: XMLSerializable
        Restore the object from the JDOM Element returned by XMLSerializable.toXML().

        This method generally should not be called directly. Instead, you should usually call XMLSerializer.classFromXML(org.jdom.Element) or XMLSerializer.classFromXML(org.jdom.Element, Class) which calls this method internally.

        It is optional to implement this method. Instead of implementing an empty constructor and implementing this method properly, the implementation may instead throw an UnsupportedOperationException and implement a constructor that takes a single Element as a parameter. This allows for cleaner code such as support for final fields in the XMLSerializable class.

        The element parameter should not be modified since it may be reused. If you need a modified version of it, take a copy with Element.clone().

        Specified by:
        fromXML in interface XMLSerializable
        Parameters:
        doc - representation from a previous call to XMLSerializable.toXML()
        Throws:
        XMLSerializationException - if the Element can't be converted into this type of object
      • toXML

        public org.jdom.Element toXML​(Geneious.MajorVersion majorVersion,
                                      jebl.util.ProgressListener progressListener)
        Description copied from interface: XMLSerializable.OldVersionCompatible
        Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious. It is acceptable for the XML to include unnecessary tags that will be ignored by the earlier version. For example if the implementation has only extended the XML since the earlier version, then the XML returned may be identical to the XML returned for the current version.

        See XMLSerializable.toXML() for a more detailed description of what it means to serialize to XML.

        All classes that implement this method must also implement XMLSerializable.toXML() and should delegate back to this method using Geneious.getMajorVersion() and ProgressListener.EMPTY as parameters.

        Specified by:
        toXML in interface XMLSerializable.OldVersionCompatible
        Parameters:
        majorVersion - the major version of Geneious to serialize to XML for. For example "6.0" but not "6.0.0". This must be a version returned greater or equal to a version returned from getVersionSupport(VersionSupportType.OldestVersionSerializableTo) and must never be greater than the current version (Geneious.getMajorVersion())
        progressListener - for reporting progress and cancelling
        Returns:
        object encoded as a JDOM element