1 19 20 package org.netbeans.modules.form; 21 22 import java.util.*; 23 import java.beans.EventSetDescriptor ; 24 import java.lang.reflect.Method ; 25 26 31 32 public class Event { 33 34 private static String [] NO_HANDLERS = {}; 35 36 private RADComponent component; 37 private EventSetDescriptor eventSetDescriptor; 38 private Method listenerMethod; 39 private boolean inCEDL; private List eventHandlers; 41 42 Event(RADComponent component, 43 EventSetDescriptor eventSetDescriptor, 44 Method listenerMethod) 45 { 46 this.component = component; 47 this.eventSetDescriptor = eventSetDescriptor; 48 this.listenerMethod = listenerMethod; 49 } 50 51 53 public String getName() { 54 return listenerMethod.getName(); 55 } 56 57 public String getId() { 58 return FormEvents.getEventIdName(listenerMethod); 59 } 60 61 public final RADComponent getComponent() { 62 return component; 63 } 64 65 public final EventSetDescriptor getEventSetDescriptor() { 66 return eventSetDescriptor; 67 } 68 69 public final Method getListenerMethod() { 70 return listenerMethod; 71 } 72 73 public boolean hasEventHandlers() { 74 return eventHandlers != null && eventHandlers.size() > 0; 75 } 76 77 public boolean hasEventHandler(String handler) { 78 return eventHandlers != null ? eventHandlers.contains(handler) : false; 79 } 80 81 public String [] getEventHandlers() { 82 if (eventHandlers == null || eventHandlers.size() == 0) 83 return NO_HANDLERS; 84 85 String [] handlerNames = new String [eventHandlers.size()]; 86 eventHandlers.toArray(handlerNames); 87 return handlerNames; 88 } 89 90 public final boolean isInCEDL() { 92 return inCEDL; 93 } 94 95 97 void setInCEDL(boolean isIn) { 98 inCEDL = isIn; 99 } 100 101 boolean addEventHandler(String handlerName) { 102 if (eventHandlers == null) 103 eventHandlers = new ArrayList(1); 104 else if (eventHandlers.contains(handlerName)) 105 return false; 106 107 eventHandlers.add(handlerName); 108 return true; 109 } 110 111 boolean removeEventHandler(String handlerName) { 112 return eventHandlers != null && eventHandlers.remove(handlerName); 113 } 114 115 boolean renameEventHandler(String oldHandlerName, String newHandlerName) { 116 if (eventHandlers == null) 117 return false; 118 int index = eventHandlers.indexOf(oldHandlerName); 119 if (index < 0 || eventHandlers.contains(newHandlerName)) 120 return false; 121 122 eventHandlers.set(index, newHandlerName); 123 return true; 124 } 125 126 List getEventHandlerList() { 127 return eventHandlers; 128 } 129 } 130 | Popular Tags |