Package jaxe

Class JaxeDocument

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.text.Document, javax.swing.text.StyledDocument

    public class JaxeDocument
    extends javax.swing.text.DefaultStyledDocument
    Classe représentant un document XML
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  JaxeDocument.SwingElementSpec  
      • Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument

        javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement
      • Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument

        javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
    • Field Summary

      Fields 
      Modifier and Type Field Description
      Config cfg  
      java.util.HashMap<org.w3c.dom.Node,​JaxeElement> dom2JaxeElement  
      org.w3c.dom.Document DOMdoc  
      java.lang.String encodage  
      java.io.File fsave  
      java.net.URL furl  
      javax.swing.JFrame jframe  
      boolean modif  
      java.lang.String nomFichierCfg  
      JaxeElement rootJE  
      JaxeTextPane textPane  
      • Fields inherited from class javax.swing.text.DefaultStyledDocument

        buffer, BUFFER_SIZE_DEFAULT
      • Fields inherited from class javax.swing.text.AbstractDocument

        BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
      • Fields inherited from interface javax.swing.text.Document

        StreamDescriptionProperty, TitleProperty
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addEditListener​(JaxeEditListenerIf edit)
      Adds a listener for editevents
      void ajouterIndentations​(org.w3c.dom.Document doc, int nbEspaces)
      Ajoute des indentations au document passé en paramètre, avec le nombre d'espaces indiqué pour chaque indentation.
      protected java.lang.String chercherConfig​(org.w3c.dom.Element rootel)  
      boolean coller​(java.lang.Object pp, javax.swing.text.Position pos)
      pour coller du XML
      void coller​(javax.swing.text.JTextComponent target)
      Deprecated.
      boolean coller​(org.w3c.dom.DocumentFragment frag, javax.swing.text.Position pos, boolean event)
      Colle un fragment XML dans le document à la position pos
      org.w3c.dom.DocumentFragment copier​(int debut, int fin)  
      javax.swing.text.EditorKit createEditorKit()  
      static java.lang.String DOMVersXML​(org.w3c.dom.Node xmldoc)  
      void ecrire​(java.io.File f)  
      JaxeElement elementA​(int pos)  
      java.util.ArrayList<JaxeElement> elementsDans​(int dpos, int fpos)
      Renvoit les éléments se trouvant dans la zone du texte indiquée (de dpos à fpos inclu)
      javax.swing.text.Element elementTexteA​(java.lang.String nom, int offset)  
      void enableIgnore()
      Ignorer l'interdiction d'effacer des éléments.
      javax.swing.text.Position fireElementAddedEvent​(JaxeEditEvent event, javax.swing.text.Position pos)
      Fires an event for adding JaxeElements to all listeners an returns a possible new insert position
      void fireElementRemovedEvent​(JaxeEditEvent event)
      Fires an event for removing JaxeElements to all listeners
      javax.swing.text.Position firePrepareElementAddEvent​(javax.swing.text.Position pos)
      Fires an event to prepare the position a JaxeElement will be added and returns a possible new instert position
      void fireTextAddedEvent​(JaxeEditEvent event)
      Fires an event for adding text to all listeners
      void fireTextRemovedEvent​(JaxeEditEvent event)
      Fires an event for removing text to all listeners
      JaxeElement getElementForNode​(org.w3c.dom.Node node)
      Returns the JaxeElement that represents the Node
      InterfaceGestionErreurs getGestionErreurs()
      Renvoit le gestionnaire d'erreurs du document
      boolean getModif()
      Indique si le document a été modifié depuis la dernière sauvegarde ou pas.
      java.lang.String getPathAsString​(int p)  
      java.io.Reader getReader()  
      java.io.Reader getReader​(boolean indenter)  
      org.w3c.dom.Node getRootElement()  
      void imageChanged​(javax.swing.JComponent comp)  
      javax.swing.text.Element insereSpec​(JaxeDocument.SwingElementSpec jspec, int offset)  
      void insertString​(int offset, java.lang.String str, javax.swing.text.AttributeSet a)  
      void insertString​(int offset, java.lang.String str, javax.swing.text.AttributeSet a, boolean event)  
      boolean lire​(java.net.URL url)
      Initialise un document lu à partir d'une URL
      boolean lire​(java.net.URL url, java.lang.String cheminFichierCfg)
      Initialise un document lu à partir d'une URL, en utilisant un fichier de config donné par nom de fichier
      boolean lire​(java.net.URL url, java.net.URL urlFichierCfg)
      Initialise un document lu à partir d'une URL, en utilisant un fichier de config donné par URL
      protected void majIndentAjout​(int offset)
      Mise à jour des indentations après un ajout de \n (appelé par JaxeUndoableEdit)
      protected void majIndentSupp​(int offset)
      Mise à jour des indentations après une suppression de \n (appelé par JaxeUndoableEdit)
      void mettreAJourDOM()  
      void nouveau()
      Initialise un document vide
      java.lang.String pp2string​(java.lang.Object pp)
      Deprecated.
      JaxeDocument.SwingElementSpec prepareSpec​(java.lang.String baliseSpec)  
      JaxeDocument.SwingElementSpec prepareSpec​(java.lang.String baliseSpec, int offset, java.lang.String texte)  
      JaxeDocument.SwingElementSpec prepareSpec​(java.lang.String baliseSpec, javax.swing.text.SimpleAttributeSet att)  
      void remove​(int offs, int len)  
      void remove​(int offs, int len, boolean event)  
      void remove2​(int offs, int len, boolean event)  
      void removeEditListener​(JaxeEditListenerIf edit)
      Removes a listener for editevents
      protected org.w3c.dom.Node removeProcessingInstructions​(org.w3c.dom.Node n)
      Deprecated.
      protected void removeText​(int offs, int len, boolean event)  
      void sendToWriter​(java.io.Writer destination)  
      void sendToWriter​(java.io.Writer destination, boolean indenter)  
      boolean setDOMDoc​(org.w3c.dom.Document ddoc)
      Spécifie le document DOM de ce document Jaxe
      boolean setDOMDoc​(org.w3c.dom.Document ddoc, java.lang.String cheminFichierCfg)
      Spécifie le document DOM de ce document Jaxe, en utilisant un fichier de config donné par nom de fichier.
      boolean setDOMDoc​(org.w3c.dom.Document ddoc, java.net.URL urlFichierCfg)
      Spécifie le document DOM de ce document Jaxe, en utilisant un fichier de config donné par URL
      void setGestionErreurs​(InterfaceGestionErreurs gestionErreurs)
      Définie le gestionnaire d'erreurs pour le document
      void setModif​(boolean modif)
      Spécifie si le document a été modifié depuis la dernière sauvegarde ou pas.
      boolean setRootElement​(org.w3c.dom.Element node)
      Sets the RootNode of the Document
      boolean setRootElement​(org.w3c.dom.Element node, org.w3c.dom.Element configNode)
      Sets the RootNode of the Document with a Node that is used to search the Config-File
      void setTextPane​(JaxeTextPane textPane)  
      void sousSpec​(JaxeDocument.SwingElementSpec parentspec, JaxeDocument.SwingElementSpec enfantspec)  
      void styleChanged()  
      boolean testerInsertionFragment​(org.w3c.dom.DocumentFragment frag, JaxeElement parent, javax.swing.text.Position pos)
      Teste si l'insertion d'un fragment est autorisée sous un certain élément parent à la position pos.
      void virerEspaces​(org.w3c.dom.Element el)  
      • Methods inherited from class javax.swing.text.DefaultStyledDocument

        addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged
      • Methods inherited from class javax.swing.text.AbstractDocument

        addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.text.Document

        addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeUndoableEditListener, render
    • Field Detail

      • DOMdoc

        public org.w3c.dom.Document DOMdoc
      • dom2JaxeElement

        public java.util.HashMap<org.w3c.dom.Node,​JaxeElement> dom2JaxeElement
      • fsave

        public java.io.File fsave
      • furl

        public java.net.URL furl
      • encodage

        public java.lang.String encodage
      • modif

        public boolean modif
      • jframe

        public javax.swing.JFrame jframe
      • nomFichierCfg

        public java.lang.String nomFichierCfg
    • Constructor Detail

      • JaxeDocument

        public JaxeDocument()
      • JaxeDocument

        public JaxeDocument​(java.lang.String nomFichierCfg)
      • JaxeDocument

        public JaxeDocument​(Config newconfig)
      • JaxeDocument

        public JaxeDocument​(JaxeTextPane textPane,
                            java.lang.String nomFichierCfg)
    • Method Detail

      • setGestionErreurs

        public void setGestionErreurs​(InterfaceGestionErreurs gestionErreurs)
        Définie le gestionnaire d'erreurs pour le document
      • getGestionErreurs

        public InterfaceGestionErreurs getGestionErreurs()
        Renvoit le gestionnaire d'erreurs du document
      • setTextPane

        public void setTextPane​(JaxeTextPane textPane)
      • getModif

        public boolean getModif()
        Indique si le document a été modifié depuis la dernière sauvegarde ou pas.
      • setModif

        public void setModif​(boolean modif)
        Spécifie si le document a été modifié depuis la dernière sauvegarde ou pas.
      • nouveau

        public void nouveau()
        Initialise un document vide
      • lire

        public boolean lire​(java.net.URL url)
        Initialise un document lu à partir d'une URL
      • lire

        public boolean lire​(java.net.URL url,
                            java.lang.String cheminFichierCfg)
        Initialise un document lu à partir d'une URL, en utilisant un fichier de config donné par nom de fichier
      • lire

        public boolean lire​(java.net.URL url,
                            java.net.URL urlFichierCfg)
        Initialise un document lu à partir d'une URL, en utilisant un fichier de config donné par URL
      • setDOMDoc

        public boolean setDOMDoc​(org.w3c.dom.Document ddoc)
        Spécifie le document DOM de ce document Jaxe
      • setDOMDoc

        public boolean setDOMDoc​(org.w3c.dom.Document ddoc,
                                 java.lang.String cheminFichierCfg)
        Spécifie le document DOM de ce document Jaxe, en utilisant un fichier de config donné par nom de fichier. Si cheminFichierCfg est null, une config est cherchée en fonction de la racine du document.
      • setDOMDoc

        public boolean setDOMDoc​(org.w3c.dom.Document ddoc,
                                 java.net.URL urlFichierCfg)
        Spécifie le document DOM de ce document Jaxe, en utilisant un fichier de config donné par URL
      • setRootElement

        public boolean setRootElement​(org.w3c.dom.Element node)
        Sets the RootNode of the Document
        Parameters:
        node - the Node
        Returns:
        boolean successfull ?
      • setRootElement

        public boolean setRootElement​(org.w3c.dom.Element node,
                                      org.w3c.dom.Element configNode)
        Sets the RootNode of the Document with a Node that is used to search the Config-File
        Parameters:
        node - the Node
        configNode - the Node wich will be used as Config-File
        Returns:
        boolean successfull ?
      • getRootElement

        public org.w3c.dom.Node getRootElement()
      • chercherConfig

        protected java.lang.String chercherConfig​(org.w3c.dom.Element rootel)
      • virerEspaces

        public void virerEspaces​(org.w3c.dom.Element el)
      • sendToWriter

        public void sendToWriter​(java.io.Writer destination)
      • sendToWriter

        public void sendToWriter​(java.io.Writer destination,
                                 boolean indenter)
      • getReader

        public java.io.Reader getReader()
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getReader

        public java.io.Reader getReader​(boolean indenter)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • ecrire

        public void ecrire​(java.io.File f)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • ajouterIndentations

        public void ajouterIndentations​(org.w3c.dom.Document doc,
                                        int nbEspaces)
        Ajoute des indentations au document passé en paramètre, avec le nombre d'espaces indiqué pour chaque indentation.
      • getPathAsString

        public java.lang.String getPathAsString​(int p)
      • mettreAJourDOM

        public void mettreAJourDOM()
      • elementsDans

        public java.util.ArrayList<JaxeElement> elementsDans​(int dpos,
                                                             int fpos)
        Renvoit les éléments se trouvant dans la zone du texte indiquée (de dpos à fpos inclu)
      • copier

        public org.w3c.dom.DocumentFragment copier​(int debut,
                                                   int fin)
      • removeProcessingInstructions

        @Deprecated
        protected org.w3c.dom.Node removeProcessingInstructions​(org.w3c.dom.Node n)
        Deprecated.
      • testerInsertionFragment

        public boolean testerInsertionFragment​(org.w3c.dom.DocumentFragment frag,
                                               JaxeElement parent,
                                               javax.swing.text.Position pos)
        Teste si l'insertion d'un fragment est autorisée sous un certain élément parent à la position pos. Si elle n'est pas autorisée, affiche un message d'erreur et renvoit false. Sinon renvoit true.
      • coller

        public boolean coller​(java.lang.Object pp,
                              javax.swing.text.Position pos)
        pour coller du XML
      • coller

        public boolean coller​(org.w3c.dom.DocumentFragment frag,
                              javax.swing.text.Position pos,
                              boolean event)
        Colle un fragment XML dans le document à la position pos
        Parameters:
        pos -
        frag -
      • coller

        @Deprecated
        public void coller​(javax.swing.text.JTextComponent target)
        Deprecated.
      • pp2string

        @Deprecated
        public java.lang.String pp2string​(java.lang.Object pp)
        Deprecated.
      • DOMVersXML

        public static java.lang.String DOMVersXML​(org.w3c.dom.Node xmldoc)
      • removeText

        protected void removeText​(int offs,
                                  int len,
                                  boolean event)
                           throws javax.swing.text.BadLocationException
        Throws:
        javax.swing.text.BadLocationException
      • remove

        public void remove​(int offs,
                           int len)
                    throws javax.swing.text.BadLocationException
        Specified by:
        remove in interface javax.swing.text.Document
        Overrides:
        remove in class javax.swing.text.AbstractDocument
        Throws:
        javax.swing.text.BadLocationException
      • remove

        public void remove​(int offs,
                           int len,
                           boolean event)
                    throws javax.swing.text.BadLocationException
        Parameters:
        offs -
        len -
        event -
        Throws:
        javax.swing.text.BadLocationException
      • remove2

        public void remove2​(int offs,
                            int len,
                            boolean event)
      • enableIgnore

        public void enableIgnore()
        Ignorer l'interdiction d'effacer des éléments. Utilisé par ActionInsertionBalise quand l'utilisateur annule une insertion.
      • insertString

        public void insertString​(int offset,
                                 java.lang.String str,
                                 javax.swing.text.AttributeSet a)
                          throws javax.swing.text.BadLocationException
        Specified by:
        insertString in interface javax.swing.text.Document
        Overrides:
        insertString in class javax.swing.text.AbstractDocument
        Throws:
        javax.swing.text.BadLocationException
      • insertString

        public void insertString​(int offset,
                                 java.lang.String str,
                                 javax.swing.text.AttributeSet a,
                                 boolean event)
                          throws javax.swing.text.BadLocationException
        Throws:
        javax.swing.text.BadLocationException
      • majIndentSupp

        protected void majIndentSupp​(int offset)
        Mise à jour des indentations après une suppression de \n (appelé par JaxeUndoableEdit)
      • majIndentAjout

        protected void majIndentAjout​(int offset)
        Mise à jour des indentations après un ajout de \n (appelé par JaxeUndoableEdit)
      • elementTexteA

        public javax.swing.text.Element elementTexteA​(java.lang.String nom,
                                                      int offset)
      • createEditorKit

        public javax.swing.text.EditorKit createEditorKit()
      • styleChanged

        public void styleChanged()
      • imageChanged

        public void imageChanged​(javax.swing.JComponent comp)
      • getElementForNode

        public JaxeElement getElementForNode​(org.w3c.dom.Node node)
        Returns the JaxeElement that represents the Node
        Parameters:
        node - get the JaxeElement for this Node
        Returns:
        The representation for the given Node
      • addEditListener

        public void addEditListener​(JaxeEditListenerIf edit)
        Adds a listener for editevents
        Parameters:
        edit - Listener to add
      • removeEditListener

        public void removeEditListener​(JaxeEditListenerIf edit)
        Removes a listener for editevents
        Parameters:
        edit - Listener to remove
      • fireTextRemovedEvent

        public void fireTextRemovedEvent​(JaxeEditEvent event)
        Fires an event for removing text to all listeners
        Parameters:
        event - Event to send
      • fireElementRemovedEvent

        public void fireElementRemovedEvent​(JaxeEditEvent event)
        Fires an event for removing JaxeElements to all listeners
        Parameters:
        event - Event to send
      • fireTextAddedEvent

        public void fireTextAddedEvent​(JaxeEditEvent event)
        Fires an event for adding text to all listeners
        Parameters:
        event - Event to send
      • fireElementAddedEvent

        public javax.swing.text.Position fireElementAddedEvent​(JaxeEditEvent event,
                                                               javax.swing.text.Position pos)
        Fires an event for adding JaxeElements to all listeners an returns a possible new insert position
        Parameters:
        event - Event to send
        pos - Position element will be added
        Returns:
        New position of insert
      • firePrepareElementAddEvent

        public javax.swing.text.Position firePrepareElementAddEvent​(javax.swing.text.Position pos)
        Fires an event to prepare the position a JaxeElement will be added and returns a possible new instert position
        Parameters:
        pos - Position to prepare
        Returns:
        New position of insert