1 6 7 package org.netbeans.mdr.test; 8 9 import org.netbeans.api.mdr.events.*; 10 11 import javax.jmi.reflect.*; 12 import javax.jmi.model.*; 13 14 17 18 22 public class MDRAttributeListener implements MDRChangeListener { 23 24 public static final int PLANNED = 0; 26 public static final int CHANGED = 1; 27 public static final int CANCELED = 2; 28 29 private EventsList eventsList; 31 32 33 public MDRAttributeListener() { 34 } 35 36 public void setRef(EventsList el) { 37 eventsList = el; 38 } 39 40 public void change(MDRChangeEvent e) { 41 processEvent(e, CHANGED); 42 } 43 44 private void processEvent(MDRChangeEvent e, int type) { 45 46 if (e.isOfType(AttributeEvent.EVENTMASK_ATTRIBUTE) || e.isOfType(AttributeEvent.EVENTMASK_CLASSATTR)) { 48 49 if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_ADD) && (type == PLANNED)) { 51 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 52 e, System.currentTimeMillis(), EventsList._ADD | EventsList._PLANNED); 53 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_ADD) && (type == CHANGED)) { 54 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 55 e, System.currentTimeMillis(), EventsList._ADD | EventsList._CHANGED); 56 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_ADD) && (type == CANCELED)) { 57 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 58 e, System.currentTimeMillis(), EventsList._ADD | EventsList._CANCELED); 59 } 60 else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_SET) && (type == PLANNED)) { 62 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 63 e, System.currentTimeMillis(), EventsList._SET | EventsList._PLANNED); 64 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_SET) && (type == CHANGED)) { 65 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 66 e, System.currentTimeMillis(), EventsList._SET | EventsList._CHANGED); 67 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_SET) && (type == CANCELED)) { 68 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 69 e, System.currentTimeMillis(), EventsList._SET | EventsList._CANCELED); 70 } 71 else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_REMOVE) && (type == PLANNED)) { 73 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 74 e, System.currentTimeMillis(), EventsList._REMOVE | EventsList._PLANNED); 75 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_REMOVE) && (type == CHANGED)) { 76 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 77 e, System.currentTimeMillis(), EventsList._REMOVE | EventsList._CHANGED); 78 } else if (e.isOfType(AttributeEvent.EVENT_ATTRIBUTE_REMOVE) && (type == CANCELED)) { 79 eventsList.addEvent(((ModelElement) ((RefBaseObject)((AttributeEvent) e).getSource()).refMetaObject()).getName(), 80 e, System.currentTimeMillis(), EventsList._REMOVE | EventsList._CANCELED); 81 } 82 83 } 84 85 } 86 87 } 88 | Popular Tags |