1 56 57 package org.objectstyle.cayenne.dataview; 58 59 import java.util.EventListener ; 60 61 public class DataObjectChangeEvent extends DispatchableEvent { 62 public static final int DATAOBJECT_ADDED = 1; 63 public static final int DATAOBJECT_REMOVED = 2; 64 public static final int DATAOBJECT_CHANGED = 3; 65 public static final int DATAOBJECTS_CHANGED = 4; 66 67 private int id; 68 private int affectedDataObjectIndex; 69 70 public DataObjectChangeEvent(Object source, int id) { 71 this(source, id, -1); 72 } 73 74 public DataObjectChangeEvent(Object source, int id, int affectedDataObjectIndex) { 75 super(source); 76 this.id = id; 77 this.affectedDataObjectIndex = affectedDataObjectIndex; 78 } 79 80 public void dispatch(EventListener listener) { 81 ((DataObjectChangeListener)listener).dataChanged(this); 82 } 83 84 85 public boolean isMultiObjectChange() { 86 return affectedDataObjectIndex == -1; 87 } 88 89 public int getAffectedDataObjectIndex() { 90 return affectedDataObjectIndex; 91 } 92 93 public final int getId() { 94 return id; 95 } 96 97 public String toString() { 98 return super.toString()+" "+id; 99 } 100 } 101 | Popular Tags |