KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/event/MacroEvent.java,v 1.3 2004/07/28 09:36:22 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:36:22 $
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.Namespace;
27 import org.apache.slide.common.SlideToken;
28
29 import java.util.EventListener JavaDoc;
30 import java.util.EventObject JavaDoc;
31
32 /**
33  * Macro event class
34  *
35  * @version $Revision: 1.3 $
36  */

37 public class MacroEvent extends EventObject JavaDoc implements RemoteInformation {
38     public final static Move MOVE = new Move();
39     public final static Copy COPY = new Copy();
40     public final static Delete DELETE = new Delete();
41
42     public final static String JavaDoc GROUP = "macro";
43     public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { MOVE, COPY, DELETE };
44
45     protected final static String JavaDoc SOURCE_URI_KEY = "source-uri";
46     protected final static String JavaDoc TARGET_URI_KEY = "target-uri";
47     private String JavaDoc sourceURI, targetURI;
48     private SlideToken token;
49     private Namespace namespace;
50
51     public MacroEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc tagetURI) {
52         this(source, token, namespace, null, tagetURI);
53     }
54
55     public MacroEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc sourceURI, String JavaDoc targetURI) {
56         super(source);
57         this.sourceURI = sourceURI;
58         this.targetURI = targetURI;
59         this.token = token;
60         this.namespace = namespace;
61     }
62
63     public SlideToken getToken() {
64         return token;
65     }
66
67     public Namespace getNamespace() {
68         return namespace;
69     }
70
71     public String JavaDoc getSourceURI() {
72         return sourceURI;
73     }
74
75     public String JavaDoc getTargetURI() {
76         return targetURI;
77     }
78
79     public String JavaDoc toString() {
80         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(256);
81         buffer.append(getClass().getName()).append("[source-uri=").append(sourceURI);
82         buffer.append(", target-uri=").append(targetURI);
83         buffer.append("]");
84         return buffer.toString();
85     }
86
87     public String JavaDoc[][] getInformation() {
88         return new String JavaDoc [][] { { SOURCE_URI_KEY, sourceURI },
89                                  { TARGET_URI_KEY, targetURI }};
90     }
91
92     public final static class Copy extends VetoableEventMethod {
93         public Copy() {
94             super(GROUP, "copy");
95         }
96
97         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
98             if ( listener instanceof MacroListener ) ((MacroListener)listener).copy((MacroEvent)event);
99         }
100     }
101
102     public final static class Move extends VetoableEventMethod {
103         public Move() {
104             super(GROUP, "move");
105         }
106
107         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
108             if ( listener instanceof MacroListener ) ((MacroListener)listener).move((MacroEvent)event);
109         }
110     }
111
112     public final static class Delete extends VetoableEventMethod {
113         public Delete() {
114             super(GROUP, "delete");
115         }
116
117         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
118             if ( listener instanceof MacroListener ) ((MacroListener)listener).delete((MacroEvent)event);
119         }
120     }
121 }
Popular Tags