public abstract class AbstractComponent<C extends Component<C>> extends Object implements Component<C>
Constructor and Description |
---|
AbstractComponent(AbstractModel model) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAfter(String propertyName,
C component,
Collection<Class<? extends C>> typeList)
Adds a element after all other children whose types are in the typeList Collection.
|
protected void |
addBefore(String propertyName,
C component,
Collection<Class<? extends C>> typeList)
Adds a element before all other children whose types are in the typeList Collection.
|
void |
addPropertyChangeListener(PropertyChangeListener pcl) |
protected void |
appendChild(String propertyName,
C child) |
protected abstract void |
appendChildQuietly(C component,
List<C> children) |
boolean |
canPaste(Component child)
Default implementation, subclass need to override if needed.
|
void |
checkChildrenPopulated()
This method guarantee that children are populated.
|
protected void |
checkNullOrDuplicateChild(C child) |
protected void |
fireChildAdded() |
protected void |
fireChildRemoved() |
protected void |
firePropertyChange(String propName,
Object oldValue,
Object newValue) |
protected void |
fireValueChanged() |
protected <T extends C> |
getChild(Class<T> type) |
List<C> |
getChildren() |
<T extends C> |
getChildren(Class<T> type) |
List<C> |
getChildren(Collection<Class<? extends C>> typeList) |
int |
getChildrenCount()
Sometimes it's necessary to know amount of children but the children
themselves aren't necessary.
|
AbstractModel |
getModel() |
C |
getParent() |
void |
insertAtIndex(String propertyName,
C component,
int index) |
protected void |
insertAtIndex(String propertyName,
C component,
int index,
Class<? extends C> type)
Inserts a Component child at the specified index relative to
the provided type.
|
protected abstract void |
insertAtIndexQuietly(C newComponent,
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(List<C> children) |
void |
removeChild(String propertyName,
C component) |
protected abstract void |
removeChildQuietly(C component,
List<C> children) |
void |
removeComponentListener(ComponentListener cl) |
void |
removePropertyChangeListener(PropertyChangeListener pcl) |
protected void |
setChild(Class<? extends C> classType,
String propertyName,
C newComponent,
Collection<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(Class<? extends C> classType,
String propertyName,
C newComponent,
Collection<Class<? extends C>> typeList,
boolean before) |
protected void |
setChildAfter(Class<? extends C> classType,
String propertyName,
C newComponent,
Collection<Class<? extends C>> typeList) |
protected void |
setChildBefore(Class<? extends C> classType,
String propertyName,
C newComponent,
Collection<Class<? extends C>> typeList) |
protected void |
setModel(AbstractModel aModel) |
protected void |
setParent(C component) |
protected void |
verifyWrite()
This method ensures that a transaction is currently in progress and
that the current thread is able to write the model.
|
public AbstractComponent(AbstractModel model)
protected abstract void insertAtIndexQuietly(C newComponent, List<C> children, int index)
public final void removePropertyChangeListener(PropertyChangeListener pcl)
public final void addPropertyChangeListener(PropertyChangeListener pcl)
public void removeComponentListener(ComponentListener cl)
public C getParent()
protected void setParent(C component)
protected void setModel(AbstractModel aModel)
public List<C> getChildren()
getChildren
in interface Component<C extends Component<C>>
public void checkChildrenPopulated()
public int getChildrenCount()
protected final boolean isChildrenInitialized()
public <T extends C> List<T> getChildren(Class<T> type)
getChildren
in interface Component<C extends Component<C>>
type
- Interested children type to
return.public List<C> getChildren(Collection<Class<? extends C>> typeList)
getChildren
in interface Component<C extends Component<C>>
typeList
- Collection that accepts the interested types and filters
the return list of Children.public AbstractModel getModel()
protected void verifyWrite()
protected void firePropertyChange(String propName, Object oldValue, Object newValue)
protected void fireValueChanged()
protected void fireChildRemoved()
protected void fireChildAdded()
protected void addBefore(String propertyName, C component, Collection<Class<? extends C>> typeList)
protected void addAfter(String propertyName, C component, Collection<Class<? extends C>> typeList)
protected void checkNullOrDuplicateChild(C child)
protected void insertAtIndex(String propertyName, C component, int index, Class<? extends C> type)
propertyName
- to fire event oncomponent
- to insertindex
- relative to first instance of type, index = firstpostype
- which index should be relative toprotected void setChild(Class<? extends C> classType, String propertyName, C newComponent, Collection<Class<? extends C>> typeList)
classType
- Class of the Component that is being added as a childpropertyName
- Property name used for firing eventsnewComponent
- Component that is being added as a childtypeList
- 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 childprotected void setChildAfter(Class<? extends C> classType, String propertyName, C newComponent, Collection<Class<? extends C>> typeList)
protected void setChildBefore(Class<? extends C> classType, String propertyName, C newComponent, Collection<Class<? extends C>> typeList)
protected void setChild(Class<? extends C> classType, String propertyName, C newComponent, Collection<Class<? extends C>> typeList, boolean before)