/**
  * Sets the children of this PaletteContainer to the given list of {@link PaletteEntry} objects.
  *
  * @param list the list of children
  */
 public void setChildren(List list) {
   List oldChildren = children;
   for (int i = 0; i < oldChildren.size(); i++) {
     PaletteEntry entry = (PaletteEntry) oldChildren.get(i);
     entry.setParent(null);
   }
   children = list;
   for (int i = 0; i < children.size(); i++) {
     PaletteEntry entry = (PaletteEntry) children.get(i);
     entry.setParent(this);
   }
   listeners.firePropertyChange(PROPERTY_CHILDREN, oldChildren, getChildren());
 }
 /**
  * Removes the given PaletteEntry from this PaletteContainer
  *
  * @param entry the PaletteEntry to remove
  */
 public void remove(PaletteEntry entry) {
   List oldChildren = new ArrayList(getChildren());
   if (getChildren().remove(entry)) {
     entry.setParent(null);
     listeners.firePropertyChange(PROPERTY_CHILDREN, oldChildren, getChildren());
   }
 }
 /**
  * Adds the list of {@link PaletteEntry} objects to this PaletteContainer.
  *
  * @param list a list of PaletteEntry objects to add to this PaletteContainer
  */
 public void addAll(List list) {
   ArrayList oldChildren = new ArrayList(getChildren());
   for (int i = 0; i < list.size(); i++) {
     PaletteEntry child = (PaletteEntry) list.get(i);
     if (!acceptsType(child.getType()))
       throw new IllegalArgumentException(
           "This container can not contain this type of child: " //$NON-NLS-1$
               + child.getType());
     getChildren().add(child);
     child.setParent(this);
   }
   listeners.firePropertyChange(PROPERTY_CHILDREN, oldChildren, getChildren());
 }
  /**
   * Adds the given PaletteEntry at position <code>index</code>.
   *
   * @param index position to add the PaletteEntry
   * @param entry the PaletteEntry to add
   */
  public void add(int index, PaletteEntry entry) {
    if (!acceptsType(entry.getType()))
      throw new IllegalArgumentException(
          "This container can not contain this type of child: " //$NON-NLS-1$
              + entry.getType());

    List oldChildren = new ArrayList(getChildren());

    int actualIndex = index < 0 ? getChildren().size() : index;
    getChildren().add(actualIndex, entry);
    entry.setParent(this);
    listeners.firePropertyChange(PROPERTY_CHILDREN, oldChildren, getChildren());
  }