org.netbeans.modules.xml.xam
Class AbstractComponent<C extends Component<C>>

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractComponent<C>
All Implemented Interfaces:
Component<C>
Direct Known Subclasses:
AbstractDocumentComponent

public abstract class AbstractComponent<C extends Component<C>>
extends java.lang.Object
implements Component<C>

Author:
rico, Vidhya Narayanan, Nam Nguyen, Chris Webster

Constructor Summary
AbstractComponent(AbstractModel model)
           
 
Method Summary
protected  void addAfter(java.lang.String propertyName, C component, java.util.Collection<java.lang.Class<? extends C>> typeList)
          Adds a element after all other children whose types are in the typeList Collection.
protected  void addBefore(java.lang.String propertyName, C component, java.util.Collection<java.lang.Class<? extends C>> typeList)
          Adds a element before all other children whose types are in the typeList Collection.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
protected  void appendChild(java.lang.String propertyName, C child)
           
protected abstract  void appendChildQuietly(C component, java.util.List<C> children)
           
 boolean canPaste(Component child)
          Default implementation, subclass need to override if needed.
protected  void checkNullOrDuplicateChild(C child)
           
protected  void fireChildAdded()
           
protected  void fireChildRemoved()
           
protected  void firePropertyChange(java.lang.String propName, java.lang.Object oldValue, java.lang.Object newValue)
           
protected  void fireValueChanged()
           
protected
<T extends C>
T
getChild(java.lang.Class<T> type)
           
 java.util.List<C> getChildren()
           
<T extends C>
java.util.List<T>
getChildren(java.lang.Class<T> type)
           
 java.util.List<C> getChildren(java.util.Collection<java.lang.Class<? extends C>> typeList)
           
 AbstractModel getModel()
           
 C getParent()
           
 void insertAtIndex(java.lang.String propertyName, C component, int index)
           
protected  void insertAtIndex(java.lang.String propertyName, C component, int index, java.lang.Class<? extends C> type)
          Inserts a Component child at the specified index relative to the provided type.
protected abstract  void insertAtIndexQuietly(C newComponent, java.util.List<C> children, int index)
           
protected  boolean isChildrenInitialized()
          This method provides the ability to detect whether calling getChildren() will trigger population of children.
protected abstract  void populateChildren(java.util.List<C> children)
           
 void removeChild(java.lang.String propertyName, C component)
           
protected abstract  void removeChildQuietly(C component, java.util.List<C> children)
           
 void removeComponentListener(ComponentListener cl)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
protected  void setChild(java.lang.Class<? extends C> classType, java.lang.String propertyName, C newComponent, java.util.Collection<java.lang.Class<? extends C>> typeList)
          When a child element is set using this method: (1) All children that are of the same or derived type as classType are removed.
protected  void setChild(java.lang.Class<? extends C> classType, java.lang.String propertyName, C newComponent, java.util.Collection<java.lang.Class<? extends C>> typeList, boolean before)
           
protected  void setChildAfter(java.lang.Class<? extends C> classType, java.lang.String propertyName, C newComponent, java.util.Collection<java.lang.Class<? extends C>> typeList)
           
protected  void setChildBefore(java.lang.Class<? extends C> classType, java.lang.String propertyName, C newComponent, java.util.Collection<java.lang.Class<? extends C>> typeList)
           
protected  void setModel(AbstractModel aModel)
           
protected  void setParent(C component)
           
protected  void verifyWrite()
           
 
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.Component
copy
 

Constructor Detail

AbstractComponent

public AbstractComponent(AbstractModel model)
Method Detail

appendChildQuietly

protected abstract void appendChildQuietly(C component,
                                           java.util.List<C> children)

insertAtIndexQuietly

protected abstract void insertAtIndexQuietly(C newComponent,
                                             java.util.List<C> children,
                                             int index)

removeChildQuietly

protected abstract void removeChildQuietly(C component,
                                           java.util.List<C> children)

populateChildren

protected abstract void populateChildren(java.util.List<C> children)

removePropertyChangeListener

public final void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)

addPropertyChangeListener

public final void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)

removeComponentListener

public void removeComponentListener(ComponentListener cl)

getParent

public C getParent()
Specified by:
getParent in interface Component<C extends Component<C>>
Returns:
parent component.

setParent

protected void setParent(C component)

setModel

protected void setModel(AbstractModel aModel)

getChildren

public java.util.List<C> getChildren()
Specified by:
getChildren in interface Component<C extends Component<C>>
Returns:
the contained elements, this is the model element representations of the DOM children. The returned list is unmodifiable.

isChildrenInitialized

protected final boolean isChildrenInitialized()
This method provides the ability to detect whether calling getChildren() will trigger population of children. This can be used for meta models to determine whether cleanup below a set of children is necessary.


getChildren

public <T extends C> java.util.List<T> getChildren(java.lang.Class<T> type)
Specified by:
getChildren in interface Component<C extends Component<C>>
Parameters:
type - Interested children type to return.
Returns:
the contained elements, this is the model element representations of the DOM children.

getChildren

public java.util.List<C> getChildren(java.util.Collection<java.lang.Class<? extends C>> typeList)
Specified by:
getChildren in interface Component<C extends Component<C>>
Parameters:
typeList - Collection that accepts the interested types and filters the return list of Children.
Returns:
the contained elements, this is the model element representations of the DOM children.

getModel

public AbstractModel getModel()
Specified by:
getModel in interface Component<C extends Component<C>>
Returns:
the model where this element is being used or null if not currently part of a model.

verifyWrite

protected void verifyWrite()

firePropertyChange

protected void firePropertyChange(java.lang.String propName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)

fireValueChanged

protected void fireValueChanged()

fireChildRemoved

protected void fireChildRemoved()

fireChildAdded

protected void fireChildAdded()

getChild

protected <T extends C> T getChild(java.lang.Class<T> type)

addBefore

protected void addBefore(java.lang.String propertyName,
                         C component,
                         java.util.Collection<java.lang.Class<? extends C>> typeList)
Adds a element before all other children whose types are in the typeList Collection.


addAfter

protected void addAfter(java.lang.String propertyName,
                        C component,
                        java.util.Collection<java.lang.Class<? extends C>> typeList)
Adds a element after all other children whose types are in the typeList Collection.


checkNullOrDuplicateChild

protected void checkNullOrDuplicateChild(C child)

appendChild

protected void appendChild(java.lang.String propertyName,
                           C child)

insertAtIndex

protected void insertAtIndex(java.lang.String propertyName,
                             C component,
                             int index,
                             java.lang.Class<? extends C> type)
Inserts a Component child at the specified index relative to the provided type. This method is expected to be used only in sequence.

Parameters:
propertyName - to fire event on
component - to insert
index - relative to first instance of type, index = firstpos
type - which index should be relative to

insertAtIndex

public void insertAtIndex(java.lang.String propertyName,
                          C component,
                          int index)

removeChild

public void removeChild(java.lang.String propertyName,
                        C component)

setChild

protected void setChild(java.lang.Class<? extends C> classType,
                        java.lang.String propertyName,
                        C newComponent,
                        java.util.Collection<java.lang.Class<? extends C>> typeList)
When a child element is set using this method: (1) All children that are of the same or derived type as classType are removed. (2) newEl is added as a child after any children that are of the same type as any of the types listed in typeList

Parameters:
classType - Class of the Component that is being added as a child
propertyName - Property name used for firing events
newComponent - Component that is being added as a child
typeList - Collection of java.lang.Class-es. newEl will be added as a child after any children whose types belong to any listed in this. An empty collection will append the child

setChildAfter

protected void setChildAfter(java.lang.Class<? extends C> classType,
                             java.lang.String propertyName,
                             C newComponent,
                             java.util.Collection<java.lang.Class<? extends C>> typeList)

setChildBefore

protected void setChildBefore(java.lang.Class<? extends C> classType,
                              java.lang.String propertyName,
                              C newComponent,
                              java.util.Collection<java.lang.Class<? extends C>> typeList)

setChild

protected void setChild(java.lang.Class<? extends C> classType,
                        java.lang.String propertyName,
                        C newComponent,
                        java.util.Collection<java.lang.Class<? extends C>> typeList,
                        boolean before)

canPaste

public boolean canPaste(Component child)
Default implementation, subclass need to override if needed.

Specified by:
canPaste in interface Component<C extends Component<C>>