KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > StructureEvent


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/event/StructureEvent.java,v 1.4 2004/07/28 09:36:20 ib Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/07/28 09:36:20 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

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 JavaDoc;
31 import java.util.EventObject JavaDoc;
32
33 /**
34  * Structure event class
35  *
36  * @version $Revision: 1.4 $
37  */

38 public class StructureEvent extends EventObject JavaDoc {
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 JavaDoc 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 JavaDoc uri = null;
53     private Namespace namespace;
54
55     public StructureEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri) {
56         super(source);
57         this.uri = uri;
58         this.token = token;
59         this.namespace = namespace;
60     }
61
62     public StructureEvent(Object JavaDoc 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 JavaDoc source, SlideToken token, ObjectNode objectNode, String JavaDoc uri) {
70         super(source);
71         this.token = token;
72         this.objectNode = objectNode;
73         this.uri = uri;
74     }
75
76     public String JavaDoc toString() {
77         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(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 JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc event) throws VetoException {
166             if ( listener instanceof StructureListener ) ((StructureListener)listener).retrieve((StructureEvent)event);
167         }
168     }
169 }
Popular Tags