org.netbeans.modules.xml.xam/1 1.18.0 1

org.netbeans.modules.xml.xam.dom
Class AbstractDocumentModel<T extends DocumentComponent<T>>

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractModel<T>
      extended by org.netbeans.modules.xml.xam.dom.AbstractDocumentModel<T>
All Implemented Interfaces:
EventListener, UndoableEditListener, DocumentModel<T>, Model<T>, Referenceable

public abstract class AbstractDocumentModel<T extends DocumentComponent<T>>
extends AbstractModel<T>
implements DocumentModel<T>


Nested Class Summary
 
Nested classes/interfaces inherited from class org.netbeans.modules.xml.xam.AbstractModel
AbstractModel.ModelUndoableEdit, AbstractModel.ModelUndoableEditSupport
 
Nested classes/interfaces inherited from interface org.netbeans.modules.xml.xam.Model
Model.State
 
Field Summary
protected  DocumentModelAccess access
           
 
Fields inherited from class org.netbeans.modules.xml.xam.AbstractModel
ues
 
Fields inherited from interface org.netbeans.modules.xml.xam.Model
STATE_PROPERTY
 
Constructor Summary
AbstractDocumentModel(ModelSource source)
           
 
Method Summary
 void addChildComponent(Component target, Component child, int index)
          Adds child component at specified index.
 boolean areSameNodes(Node n1, Node n2)
           
abstract  T createRootComponent(Element root)
           
 AbstractDocumentComponent findComponent(AbstractDocumentComponent base, List<Element> pathFromRoot, int current)
           
 DocumentComponent findComponent(Element e)
           
 DocumentComponent findComponent(int position)
          Find component given a position into the Swing document.
 DocumentComponent findComponent(List<Element> pathFromRoot)
          Find the component given a path to its element node from root.
protected  void firePropertyChangedEvents(SyncUnit unit)
           
protected  void firePropertyChangedEvents(SyncUnit unit, Element oldElement)
           
 DocumentModelAccess getAccess()
           
static DocumentModelAccessProvider getAccessProvider()
           
 Document getBaseDocument()
           
protected abstract  ComponentUpdater<T> getComponentUpdater()
           
 Document getDocument()
           
 Set<String> getElementNames()
           
 Set<QName> getQNames()
          Returns QName of elements used in model.
 Map<QName,List<QName>> getQNameValuedAttributes()
          Returns QName of all attributes with QName value, sorted by containing element QName.
 String getXPathExpression(DocumentComponent component)
          Return XPath expression for the given component.
protected  boolean isDomainElement(Node e)
           
protected  boolean needsSync()
          This method is overridden by subclasses to determine if sync needs to be performed.
 ChangeInfo prepareChangeInfo(List<? extends Node> pathToRoot, List<? extends Node> nsContextPathToRoot)
          Performs intermediate stage of synchronization XDM --> XAM.
 ChangeInfo prepareChangeInfo(List<Node> pathToRoot)
          Deprecated. Use prepareChangeInfo(java.util.List, java.util.List) instead. It is necessary for fixing bug #166177.
 SyncUnit prepareSyncUnit(ChangeInfo change, SyncUnit order)
           
 void processSyncUnit(SyncUnit syncOrder)
           
protected  void refresh()
          Refresh the domain model component trees.
 void removeChildComponent(Component child)
          Removes specified component from model.
protected  void setIdentifyingAttributes()
          Set the identifying attributes for underlying access to merge.
protected  void syncCompleted()
          This method is invoked when sync has completed.
protected  void syncStarted()
          This method is invoked when sync has started.
protected static String toLocalName(String tagName)
           
 
Methods inherited from class org.netbeans.modules.xml.xam.AbstractModel
addComponentListener, addPropertyChangeListener, addUndoableEditListener, addUndoableRefactorListener, createModelUndoableEdit, endTransaction, endTransaction, finishTransaction, fireComponentChangedEvent, firePropertyChangeEvent, getModelSource, getState, inSync, inUndoRedo, isAutoSyncActive, isIntransaction, removeComponentListener, removePropertyChangeListener, removeUndoableEditListener, removeUndoableRefactorListener, rollbackTransaction, setAutoSyncActive, setInSync, setInUndoRedo, setState, startedFiringEvents, startTransaction, sync, transactionCompleted, transactionStarted, undoableEditHappened, validateWrite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.netbeans.modules.xml.xam.dom.DocumentModel
createComponent, getRootComponent
 
Methods inherited from interface org.netbeans.modules.xml.xam.Model
addComponentListener, addPropertyChangeListener, addUndoableEditListener, addUndoableRefactorListener, endTransaction, getModelSource, getState, inSync, isIntransaction, removeComponentListener, removePropertyChangeListener, removeUndoableEditListener, removeUndoableRefactorListener, startTransaction, sync
 

Field Detail

access

protected DocumentModelAccess access
Constructor Detail

AbstractDocumentModel

public AbstractDocumentModel(ModelSource source)
Method Detail

getBaseDocument

public Document getBaseDocument()

createRootComponent

public abstract T createRootComponent(Element root)

areSameNodes

public boolean areSameNodes(Node n1,
                            Node n2)
Specified by:
areSameNodes in interface DocumentModel<T extends DocumentComponent<T>>
Returns:
true if two DOM nodes have same identity.

getQNames

public Set<QName> getQNames()
Returns QName of elements used in model. Domain model implementation needs to override this to be able to embed elements outside of the domain such as child elements of documentation in schema model.

Returns:
full set of element QName's or null if there is no needs for distinction between domain and non-domain elements.

needsSync

protected boolean needsSync()
Description copied from class: AbstractModel
This method is overridden by subclasses to determine if sync needs to be performed. The default implementation simply returns true.

Overrides:
needsSync in class AbstractModel<T extends DocumentComponent<T>>

syncStarted

protected void syncStarted()
Description copied from class: AbstractModel
This method is invoked when sync has started. The default implementation does nothing.

Overrides:
syncStarted in class AbstractModel<T extends DocumentComponent<T>>

syncCompleted

protected void syncCompleted()
Description copied from class: AbstractModel
This method is invoked when sync has completed. The default implementation does nothing.

Overrides:
syncCompleted in class AbstractModel<T extends DocumentComponent<T>>

getComponentUpdater

protected abstract ComponentUpdater<T> getComponentUpdater()

getElementNames

public Set<String> getElementNames()

prepareChangeInfo

public ChangeInfo prepareChangeInfo(List<Node> pathToRoot)
Deprecated. Use prepareChangeInfo(java.util.List, java.util.List) instead. It is necessary for fixing bug #166177.

Parameters:
pathToRoot -
Returns:

prepareChangeInfo

public ChangeInfo prepareChangeInfo(List<? extends Node> pathToRoot,
                                    List<? extends Node> nsContextPathToRoot)
Performs intermediate stage of synchronization XDM --> XAM. A new ChangeInfo object is generated here.

Parameters:
pathToRoot - a path of DOM objects from root to changed one.
nsContextPathToRoot - Usually the same path as previous param, but in case of deletion it contains the same path from old model's tree. It is required in case of prefix declaration deletion, because the deleted declaration is present only in old model's tree. Be aware that the method is designed to be called only from XDM org.netbeans.modules.xml.xdm.xam.XDMListener, but it also can be redifined. An example can be found in org.netbeans.modules.xml.wsdl.model.WSDLModel.
Since:
1.11

prepareSyncUnit

public SyncUnit prepareSyncUnit(ChangeInfo change,
                                SyncUnit order)

firePropertyChangedEvents

protected void firePropertyChangedEvents(SyncUnit unit)

firePropertyChangedEvents

protected void firePropertyChangedEvents(SyncUnit unit,
                                         Element oldElement)

toLocalName

protected static String toLocalName(String tagName)

processSyncUnit

public void processSyncUnit(SyncUnit syncOrder)

addChildComponent

public void addChildComponent(Component target,
                              Component child,
                              int index)
Description copied from interface: Model
Adds child component at specified index.

Specified by:
addChildComponent in interface Model<T extends DocumentComponent<T>>
Parameters:
target - the parent component.
child - the child component to be added.
index - position among same type of child components, or -1 if not relevant.

removeChildComponent

public void removeChildComponent(Component child)
Description copied from interface: Model
Removes specified component from model.

Specified by:
removeChildComponent in interface Model<T extends DocumentComponent<T>>

findComponent

public DocumentComponent findComponent(Element e)

findComponent

public DocumentComponent findComponent(List<Element> pathFromRoot)
Find the component given a path to its element node from root. All elements, except for the target element should be in the latest version of the xdm tree. All components on the path will be updated with latest version elements. Note that returned component could be part of an embedded model, which could be of a different type of model.

Parameters:
pathFromRoot - list of elements from model root to backing element of target component.
Returns:
component backed by the last element on pathFromRoot or null if not found.

findComponent

public AbstractDocumentComponent findComponent(AbstractDocumentComponent base,
                                               List<Element> pathFromRoot,
                                               int current)

findComponent

public DocumentComponent findComponent(int position)
Description copied from interface: DocumentModel
Find component given a position into the Swing document.

Specified by:
findComponent in interface DocumentModel<T extends DocumentComponent<T>>
Returns:
component if found.

getXPathExpression

public String getXPathExpression(DocumentComponent component)
Description copied from interface: DocumentModel
Return XPath expression for the given component.

Specified by:
getXPathExpression in interface DocumentModel<T extends DocumentComponent<T>>

getDocument

public Document getDocument()
Specified by:
getDocument in interface DocumentModel<T extends DocumentComponent<T>>
Returns:
the DOM Document node.

getAccess

public DocumentModelAccess getAccess()
Specified by:
getAccess in class AbstractModel<T extends DocumentComponent<T>>

getAccessProvider

public static DocumentModelAccessProvider getAccessProvider()

setIdentifyingAttributes

protected void setIdentifyingAttributes()
Set the identifying attributes for underlying access to merge.


isDomainElement

protected boolean isDomainElement(Node e)

refresh

protected void refresh()
Description copied from class: AbstractModel
Refresh the domain model component trees. Refresh actually means recreation of root component from XDM root. The old model's content is totally lost after the operation. Because the fresh model is created, the model's state should be VALID as the result of this call. Note: subclasses need to override to provide the actual refresh service. Note: direct links to model's components become invalid after this operation.

Overrides:
refresh in class AbstractModel<T extends DocumentComponent<T>>

getQNameValuedAttributes

public Map<QName,List<QName>> getQNameValuedAttributes()
Returns QName of all attributes with QName value, sorted by containing element QName. Note: if domain model implementation return null, namespace consolidation will not attempt namespace prefix refactoring on each mutation of the underlying XDM DOM tree.


org.netbeans.modules.xml.xam/1 1.18.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.