1 package cz.cuni.amis.pogamut.sposh.elements; 2 3 import java.awt.Desktop; 4 import java.beans.PropertyChangeListener; 5 6 /** 7 * Mainly for widgets. This is the listener that can be registered with the 8 * {@link PoshElement} to listen for various events that happens to the POSH 9 * element (new node, deleted node...) 10 * <p/> 11 * Thanks to generics, listeners can have type check for parent, but not for 12 * child because of multiple possible types of children (e.g. DC has two types 13 * of children, {@link Sense} and {@link DriveElement}, {@link PoshPlan} has {@link ActionPattern} 14 * and {@link Competence}). 15 * 16 * @author HonzaH 17 * @param <PARENT> Type of parent that the listeners will be notified about. 18 */ 19 public interface PoshElementListener<PARENT extends PoshElement> extends PropertyChangeListener { 20 21 /** 22 * Event handler will be notified that parent has added a new child among 23 * its children. 24 * 25 * @param parent parent that has a new child 26 * @param child Child that has been added. 27 */ 28 void childElementAdded(PARENT parent, PoshElement child); 29 30 /** 31 * Evenet handler will be notified that parent has moved a child. 32 * 33 * @param parent Parent element of child. 34 * @param child child that has been moved. 35 * @param oldIndex Index of the child before move. 36 * @param newIndex Absolute position of the moved child with its own 37 * type. E.g. {@link DriveCollection} has two types of children, {@link Sense}s 38 * and {@link DriveElement}. First sense has absolute index 0 and first 39 * drive has absolute index 0. 40 */ 41 void childElementMoved(PARENT parent, PoshElement child, int oldIndex, int newIndex); 42 43 /** 44 * Event handler will be notified when parent has removed child. 45 * 46 * @param parent parent element of child 47 * @param child child element that has been removed 48 * @param removedChildPosition What was position of removed child among 49 * children 50 */ 51 void childElementRemoved(PARENT parent, PoshElement child, int removedChildPosition); 52 }