1 23 24 package org.apache.slide.event; 25 26 import org.apache.slide.common.SlideToken; 27 import org.apache.slide.common.Namespace; 28 import org.apache.slide.structure.ObjectNode; 29 30 import java.util.EventListener ; 31 import java.util.EventObject ; 32 33 38 public class StructureEvent extends EventObject { 39 public final static Retrieve RETRIEVE = new Retrieve(); 40 public final static Store STORE = new Store(); 41 public final static Create CREATE = new Create(); 42 public final static Remove REMOVE = new Remove(); 43 public final static CreateLink CREATE_LINK = new CreateLink(); 44 public final static AddBinding ADD_BINDING = new AddBinding(); 45 public final static RemoveBinding REMOVE_BINDING = new RemoveBinding(); 46 47 public final static String GROUP = "structure"; 48 public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { RETRIEVE, STORE, CREATE, REMOVE, CREATE_LINK, ADD_BINDING, REMOVE_BINDING }; 49 50 private SlideToken token; 51 private ObjectNode objectNode = null; 52 private String uri = null; 53 private Namespace namespace; 54 55 public StructureEvent(Object source, SlideToken token, Namespace namespace, String uri) { 56 super(source); 57 this.uri = uri; 58 this.token = token; 59 this.namespace = namespace; 60 } 61 62 public StructureEvent(Object source, SlideToken token, Namespace namespace, ObjectNode objectNode) { 63 super(source); 64 this.token = token; 65 this.objectNode = objectNode; 66 this.namespace = namespace; 67 } 68 69 public StructureEvent(Object source, SlideToken token, ObjectNode objectNode, String uri) { 70 super(source); 71 this.token = token; 72 this.objectNode = objectNode; 73 this.uri = uri; 74 } 75 76 public String toString() { 77 StringBuffer buffer = new StringBuffer (256); 78 buffer.append(getClass().getName()).append("[uri=").append(uri); 79 buffer.append(", objectNode=").append(objectNode); 80 buffer.append("]"); 81 return buffer.toString(); 82 } 83 84 public SlideToken getToken() { 85 return token; 86 } 87 88 public ObjectNode getObjectNode() { 89 return objectNode; 90 } 91 92 public String getUri() { 93 return uri; 94 } 95 96 public Namespace getNamespace() { 97 return namespace; 98 } 99 100 public final static class Create extends VetoableEventMethod { 101 public Create() { 102 super(GROUP, "create"); 103 } 104 105 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 106 if ( listener instanceof StructureListener ) ((StructureListener)listener).create((StructureEvent)event); 107 } 108 } 109 110 public final static class CreateLink extends VetoableEventMethod { 111 public CreateLink() { 112 super(GROUP, "create-link"); 113 } 114 115 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 116 if ( listener instanceof StructureListener ) ((StructureListener)listener).createLink((StructureEvent)event); 117 } 118 } 119 120 public final static class Remove extends VetoableEventMethod { 121 public Remove() { 122 super(GROUP, "remove"); 123 } 124 125 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 126 if ( listener instanceof StructureListener ) ((StructureListener)listener).remove((StructureEvent)event); 127 } 128 } 129 130 public final static class AddBinding extends VetoableEventMethod { 131 public AddBinding() { 132 super(GROUP, "add-binding"); 133 } 134 135 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 136 if ( listener instanceof StructureListener ) ((StructureListener)listener).addBinding((StructureEvent)event); 137 } 138 } 139 140 public final static class RemoveBinding extends VetoableEventMethod { 141 public RemoveBinding() { 142 super(GROUP, "remove-binding"); 143 } 144 145 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 146 if ( listener instanceof StructureListener ) ((StructureListener)listener).removeBinding((StructureEvent)event); 147 } 148 } 149 150 public final static class Store extends VetoableEventMethod { 151 public Store() { 152 super(GROUP, "store"); 153 } 154 155 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 156 if ( listener instanceof StructureListener ) ((StructureListener)listener).store((StructureEvent)event); 157 } 158 } 159 160 public final static class Retrieve extends VetoableEventMethod { 161 public Retrieve() { 162 super(GROUP, "retrieve"); 163 } 164 165 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 166 if ( listener instanceof StructureListener ) ((StructureListener)listener).retrieve((StructureEvent)event); 167 } 168 } 169 } | Popular Tags |