Esempio n. 1
0
 /**
  * Replaces the {@link DataElement} at the specified index. After the element has been
  * successfully replaced all {@link DataListener DataListeners} will be informed.
  *
  * @param index Index of the element which will be replaced by <tt>element</tt>.
  * @param element The new <tt>DataElement</tt>.
  * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be
  *     checked by the method {@link #isValid}.
  */
 public void replaceElementAt(int index, DataElement element) {
   if (isValid(element)) {
     DataElement oldElement = (DataElement) _container.elementAt(index);
     oldElement.setContainer(null);
     _container.setElementAt(element, index);
     element.setContainer(this);
     notifyListeners(DataEvent.createReplaceEvent(this, index, oldElement));
   } else {
     throwException(REPLACE, element);
   }
 }
Esempio n. 2
0
 /**
  * Inserts a {@link DataElement} at the specified index. After the element has been successfully
  * inserted all {@link DataListener DataListeners} will be informed.
  *
  * @param index Index at which <tt>element</tt> will be inserted. All elements with an index &gt;=
  *     <tt>index</tt> will be shifted.
  * @param element DataElement to be added.
  * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be
  *     checked by the method {@link #isValid}.
  */
 public void insertElementAt(int index, DataElement element) {
   if (isValid(element)) {
     _container.insertElementAt(element, index);
     element.setContainer(this);
     notifyListeners(DataEvent.createInsertEvent(this, index));
   } else {
     throwException(INSERT, element);
   }
 }
Esempio n. 3
0
 /**
  * Adds a {@link DataElement}. After the element has been successfully added all {@link
  * DataListener DataListeners} will be informed.
  *
  * @param element DataElement to be added.
  * @throws IllegalArgumentException if <tt>element</tt> is not of the correct type which will be
  *     checked by the method {@link #isValid}.
  */
 public void addElement(DataElement element) {
   if (isValid(element)) {
     _container.addElement(element);
     element.setContainer(this);
     notifyListeners(DataEvent.createAddEvent(this));
   } else {
     throwException(ADD, element);
   }
 }
Esempio n. 4
0
 /**
  * Removes a {@link DataElement} at the specified index. After the element has been successfully
  * removed all {@link DataListener DataListeners} will be informed.
  *
  * @param index Index of the element which will be removed. All elements with an index &gt;
  *     <tt>index</tt> will be shifted.
  */
 public void removeElementAt(int index) {
   DataElement element = (DataElement) _container.elementAt(index);
   element.setContainer(null);
   _container.removeElementAt(index);
   notifyListeners(DataEvent.createRemoveEvent(this, index, element));
 }