1 23 24 package com.sun.enterprise.tools.guiframework.event.descriptors; 25 26 27 import com.iplanet.jato.view.View; 28 29 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 30 import com.sun.enterprise.tools.guiframework.FrameworkDescriptor; 31 32 import java.util.ArrayList ; 33 import java.util.HashMap ; 34 import java.util.List ; 35 import java.util.Map ; 36 37 38 44 public class EventDescriptor implements FrameworkDescriptor { 45 46 52 public EventDescriptor(ViewDescriptor parent, String eventType) { 53 setParent(parent); 54 setType(eventType); 55 } 56 57 58 63 public ViewDescriptor getParent() { 64 return _parent; 65 } 66 67 68 73 protected void setParent(ViewDescriptor parent) { 74 if (parent == null) { 75 throw new RuntimeException ("You must provide a the " + 76 "ViewDescriptor which contains this EventDescriptor!"); 77 } 78 _parent = parent; 79 } 80 81 82 87 public String getType() { 88 return _eventType; 89 } 90 91 92 97 protected void setType(String type) { 98 if (type == null) { 99 throw new IllegalArgumentException ( 100 "You must provide an Event type!"); 101 } 102 103 _eventType = (String )_eventTypesMap.get(type.toLowerCase()); 105 if (_eventType == null) { 106 throw new IllegalArgumentException ( 107 "Illegal event type: "+type); 108 } 109 } 110 111 112 128 public void addEventHandler(UseHandlerDescriptor desc) { 129 _handlers.add(desc); 131 } 132 133 134 143 public List getEventHandlers() { 144 return _handlers; 145 } 146 147 148 155 public void setEventHandlers(List handlers) { 156 _handlers = handlers; 157 } 158 159 160 public interface TYPES { 161 String BEGIN_DISPLAY = "beginDisplay"; 163 String END_DISPLAY = "endDisplay"; 164 String COMMAND = "command"; 165 String BEFORE_CREATE = "beforeCreate"; 166 String AFTER_CREATE = "afterCreate"; 167 String AFTER_REQUEST = "afterRequest"; 168 String ERROR = "error"; 169 String END_WIZARD = "endWizard"; 170 String NEXT_WIZARD_STEP = "nextWizardStep"; 171 String PREV_WIZARD_STEP = "prevWizardStep"; 172 String GOTO_WIZARD_STEP = "gotoWizardStep"; 173 String FINISH_WIZARD_STEP = "finishWizardStep"; 174 String CANCEL_WIZARD_STEP = "cancelWizardStep"; 175 } 176 177 private ViewDescriptor _parent = null; 178 private String _eventType = null; 179 private List _handlers = new ArrayList (); 180 181 private static Map _eventTypesMap = new HashMap (); 182 183 static { 184 _eventTypesMap.put(TYPES.BEGIN_DISPLAY.toLowerCase(), TYPES.BEGIN_DISPLAY); 185 _eventTypesMap.put(TYPES.END_DISPLAY.toLowerCase(), TYPES.END_DISPLAY); 186 _eventTypesMap.put(TYPES.COMMAND.toLowerCase(), TYPES.COMMAND); 187 _eventTypesMap.put(TYPES.BEFORE_CREATE.toLowerCase(), TYPES.BEFORE_CREATE); 188 _eventTypesMap.put(TYPES.AFTER_CREATE.toLowerCase(), TYPES.AFTER_CREATE); 189 _eventTypesMap.put(TYPES.AFTER_REQUEST.toLowerCase(), TYPES.AFTER_REQUEST); 190 _eventTypesMap.put(TYPES.ERROR.toLowerCase(), TYPES.ERROR); 191 _eventTypesMap.put(TYPES.END_WIZARD.toLowerCase(), TYPES.END_WIZARD); 192 _eventTypesMap.put(TYPES.NEXT_WIZARD_STEP.toLowerCase(), TYPES.NEXT_WIZARD_STEP); 193 _eventTypesMap.put(TYPES.PREV_WIZARD_STEP.toLowerCase(), TYPES.PREV_WIZARD_STEP); 194 _eventTypesMap.put(TYPES.GOTO_WIZARD_STEP.toLowerCase(), TYPES.GOTO_WIZARD_STEP); 195 _eventTypesMap.put(TYPES.FINISH_WIZARD_STEP.toLowerCase(), TYPES.FINISH_WIZARD_STEP); 196 _eventTypesMap.put(TYPES.CANCEL_WIZARD_STEP.toLowerCase(), TYPES.CANCEL_WIZARD_STEP); 197 } 198 } 199 | Popular Tags |