sk.uniba.euromath.document
Class DocumentModifyHelper

java.lang.Object
  extended by sk.uniba.euromath.document.DocumentModifyHelper

public final class DocumentModifyHelper
extends Object

Provides basic editing features, document modification driven by schema.

Author:
Martin Vysny, Tomáš Studva

Constructor Summary
DocumentModifyHelper(XMLAccess xmlAccess)
          Constuctor.
 
Method Summary
 boolean checkInEntity(Shell shell, Node node)
          Checks if given node is in entity.
 void decloseNodes(Shell parent, Element e)
          Manages the process of declosing the nodes - replaces given element with its contents.
 void deleteAttribute(Shell parent, Attr attr)
          Manages the process of deleting the attribute.
 void deleteElements(Shell shell, Set<Element> elements)
          Manages the process of deleting the elements.
 void deleteNode(Shell shell, Node node)
          Tries to delete a single node.
 void deleteTextNode(Shell shell, Node node)
          Deletes given text node.
 void encloseNodes(Shell parent, sk.baka.ikslibs.ptr.DomPointer start, sk.baka.ikslibs.ptr.DomPointer end)
          Manages the process of enclosing the nodes.
 List<QName> getDomQnames(DisplayableNameList dnl)
          Computes QNames of elements from DisplayableNameList.
 DisplayableNameList getInsertableElements(sk.baka.ikslibs.ptr.DomPointer pointer)
          Deprecated. use getInsertableElementsQNames(DomPointer) instead. To display qname use DomTools#printQName(QName).
 List<QName> getInsertableElementsQNames(sk.baka.ikslibs.ptr.DomPointer pointer)
          Computes list of names of elements, insertable at given pointer.
 List<String> getInsertableEntities(Shell parent, sk.baka.ikslibs.ptr.DomPointer ptr)
          Computes insertable entities.
 sk.baka.ikslibs.ptr.DomPointer getPointer(String nodeID, String prevText)
          Returns DomPointer which points to place in node tree to textual node with id nodeID and after text prevText.
 void insertEntity(Shell parent, sk.baka.ikslibs.ptr.DomPointer ptr)
          Manages the process of inserting an entity into selected position by dialog.
 void insertEntity(String entityName, sk.baka.ikslibs.ptr.DomPointer ptr)
          Inserts entity to given position.
 void insertNewAttribute(Shell parent, Element e)
          Manages the process of inserting a new attribute into given element.
 void insertTextNode(Shell shell, Element element)
          Inserts text to end of element by dialog.
 void modifyAttribute(Shell parent, Attr attr)
          Manages the process of modifying the attribute value.
 void modifyTextNode(Shell shell, Node node)
          Modifies text of node by dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentModifyHelper

public DocumentModifyHelper(XMLAccess xmlAccess)
Constuctor.

Parameters:
xmlAccess - the document instance.
Method Detail

insertNewAttribute

public void insertNewAttribute(Shell parent,
                               Element e)
                        throws sk.baka.xml.gene.ExportException
Manages the process of inserting a new attribute into given element.

Parameters:
parent - parent window. Should not be null.
e - the element where to insert new attribute.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

modifyAttribute

public void modifyAttribute(Shell parent,
                            Attr attr)
                     throws sk.baka.xml.gene.ExportException
Manages the process of modifying the attribute value.

Parameters:
parent - parent window. Should not be null.
attr - the attribute whose value has to be modified.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

deleteAttribute

public void deleteAttribute(Shell parent,
                            Attr attr)
                     throws sk.baka.xml.gene.ExportException
Manages the process of deleting the attribute.

Parameters:
parent - parent window. Should not be null.
attr - the attribute which has to be deleted.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

deleteElements

public void deleteElements(Shell shell,
                           Set<Element> elements)
                    throws sk.baka.xml.gene.ExportException
Manages the process of deleting the elements. All elements must have the same parent.

Parameters:
shell - parent window. Should not be null.
elements - set of Element s that must be deleted.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

encloseNodes

public void encloseNodes(Shell parent,
                         sk.baka.ikslibs.ptr.DomPointer start,
                         sk.baka.ikslibs.ptr.DomPointer end)
                  throws sk.baka.xml.gene.ExportException
Manages the process of enclosing the nodes. All nodes must have the same parent. Both pointers may point inside a text.

Parameters:
start - start of the interval. Must point before the end parameter.
end - end of the interval.
parent - parent window. Should not be null.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

decloseNodes

public void decloseNodes(Shell parent,
                         Element e)
                  throws sk.baka.xml.gene.ExportException
Manages the process of declosing the nodes - replaces given element with its contents.

Parameters:
parent - parent window. Should not be null.
e - the element, that shall be replaced by its children if the declosing is allowed.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

insertEntity

public void insertEntity(Shell parent,
                         sk.baka.ikslibs.ptr.DomPointer ptr)
                  throws sk.baka.xml.gene.ExportException
Manages the process of inserting an entity into selected position by dialog.

Parameters:
ptr - the desired place.
parent - parent window. Should not be null.
Throws:
sk.baka.xml.gene.ExportException - when document modification finalization fails.

insertEntity

public void insertEntity(String entityName,
                         sk.baka.ikslibs.ptr.DomPointer ptr)
                  throws sk.baka.xml.gene.ExportException
Inserts entity to given position.

Parameters:
entityName - the entity name.
ptr - the insert point.
Throws:
sk.baka.xml.gene.ExportException - if document modification finalization fails.

getInsertableEntities

public List<String> getInsertableEntities(Shell parent,
                                          sk.baka.ikslibs.ptr.DomPointer ptr)
Computes insertable entities. Shows various warning dialogs if no entities can be found etc.

Parameters:
ptr - the desired place.
parent - parent window. Can be null.
Returns:
entity names that are insertable at given pointer. May return null if no entities are suitable.

getInsertableElements

@Deprecated
public DisplayableNameList getInsertableElements(sk.baka.ikslibs.ptr.DomPointer pointer)
Deprecated. use getInsertableElementsQNames(DomPointer) instead. To display qname use DomTools#printQName(QName).

Computes DisplayableNameList of insertable elements.

Parameters:
pointer - to place where elements should be able to insert.

getInsertableElementsQNames

public List<QName> getInsertableElementsQNames(sk.baka.ikslibs.ptr.DomPointer pointer)
Computes list of names of elements, insertable at given pointer.

Parameters:
pointer -
Returns:
ordered list of qnames.

getDomQnames

public List<QName> getDomQnames(DisplayableNameList dnl)
Computes QNames of elements from DisplayableNameList.


getPointer

public sk.baka.ikslibs.ptr.DomPointer getPointer(String nodeID,
                                                 String prevText)
Returns DomPointer which points to place in node tree to textual node with id nodeID and after text prevText. If nodeID is null or is not valid id of textual node then null is returned.

Parameters:
nodeID - id of textual node in which returned pointer points
prevText - text after which returned pointer points

insertTextNode

public void insertTextNode(Shell shell,
                           Element element)
                    throws DocumentException,
                           sk.baka.xml.gene.ExportException
Inserts text to end of element by dialog.

Parameters:
element - where to insert text node as child
shell - parent window. !!! Cannot be null.
Throws:
DocumentException
sk.baka.xml.gene.ExportException

modifyTextNode

public void modifyTextNode(Shell shell,
                           Node node)
                    throws sk.baka.xml.gene.ExportException
Modifies text of node by dialog.

Parameters:
node - must be text node
shell - parent window. !!!Cannot be null.
Throws:
sk.baka.xml.gene.ExportException - if document fails to transform.

checkInEntity

public boolean checkInEntity(Shell shell,
                             Node node)
Checks if given node is in entity. If yes then error dialog is shown.

Parameters:
shell - parent, should not be null.
node - node to check
Returns:
true if node is in entity, false otherwise.

deleteTextNode

public void deleteTextNode(Shell shell,
                           Node node)
                    throws sk.baka.xml.gene.ExportException
Deletes given text node.

Parameters:
shell - parent window, should not be null.
node - node to delete, must not be null. May be text, cdata or pure-text entity only.
Throws:
sk.baka.xml.gene.ExportException - if shit happens.

deleteNode

public void deleteNode(Shell shell,
                       Node node)
                throws sk.baka.xml.gene.ExportException
Tries to delete a single node.

Parameters:
shell - parent shell, should not be null.
node - node to delete.
Throws:
sk.baka.xml.gene.ExportException - if shit happens.


Copyright © 2003-2006 null. All Rights Reserved.