KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > loaders > OperationEvent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.loaders;
21
22 import java.util.EventObject JavaDoc;
23
24 import org.openide.util.Lookup;
25 import org.openide.filesystems.FileObject;
26
27 /** Event that describes operations taken on
28 * a data object.
29 *
30 * @author Jaroslav Tulach
31 */

32 public class OperationEvent extends EventObject JavaDoc {
33     /** package private numbering of methods */
34     static final int COPY = 1, MOVE = 2, DELETE = 3, RENAME = 4, SHADOW = 5, TEMPL = 6, CREATE = 7;
35
36     /** data object */
37     private DataObject obj;
38     private static final DataLoaderPool pl = DataLoaderPool.getDefault();
39     static final long serialVersionUID =-3884037468317843808L;
40     OperationEvent(DataObject obj) {
41         super (pl);
42         this.obj = obj;
43     }
44
45     /** Get the data object that has been modified.
46     * @return the data object
47     */

48     public DataObject getObject () {
49         return obj;
50     }
51
52     public String JavaDoc toString() {
53         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
54         sb.append(super.toString());
55         sb.append(":");
56         sb.append(" for ");
57         sb.append(obj);
58         writeDebug(sb);
59         return sb.toString();
60     }
61
62     /** For subclasses in this package to write debug info */
63     void writeDebug(StringBuffer JavaDoc sb) {
64     }
65
66     /** Notification of a rename of a data object.
67     */

68     public static final class Rename extends OperationEvent {
69         /** name */
70         private String JavaDoc name;
71
72         static final long serialVersionUID =-1584168503454848519L;
73         /** @param obj renamed object
74         * @param name original name
75         */

76         Rename (DataObject obj, String JavaDoc name) {
77             super (obj);
78             this.name = name;
79         }
80
81         /** Get the old name of the object.
82          * @return the old name
83         */

84         public String JavaDoc getOriginalName () {
85             return name;
86         }
87
88         final void writeDebug(StringBuffer JavaDoc sb) {
89             sb.append(" originalname: ");
90             sb.append(name);
91         }
92     }
93
94     /** Notification of a move of a data object.
95     */

96     public static final class Move extends OperationEvent {
97         /** original file */
98         private FileObject file;
99
100         static final long serialVersionUID =-7753279728025703632L;
101         /** @param obj renamed object
102         * @param file original primary file
103         */

104         Move (DataObject obj, FileObject file) {
105             super (obj);
106             this.file = file;
107         }
108
109         /** Get the original primary file.
110         * @return the file
111         */

112         public FileObject getOriginalPrimaryFile () {
113             return file;
114         }
115         
116         final void writeDebug(StringBuffer JavaDoc sb) {
117             sb.append(" originalfile: ");
118             sb.append(file);
119         }
120     }
121
122     /** Notification of a copy action of a data object, creation of a shadow,
123     * or creation from a template.
124     */

125     public static final class Copy extends OperationEvent {
126         /** original data object */
127         private DataObject orig;
128
129         static final long serialVersionUID =-2768331988864546290L;
130         /** @param obj renamed object
131         * @param orig original object
132         */

133         Copy (DataObject obj, DataObject orig) {
134             super (obj);
135             this.orig = orig;
136         }
137
138
139         /** Get the original data object.
140         * @return the data object
141         */

142         public DataObject getOriginalDataObject () {
143             return orig;
144         }
145         
146         
147         final void writeDebug(StringBuffer JavaDoc sb) {
148             sb.append(" originalobj: ");
149             sb.append(orig);
150         }
151     }
152 }
153
Popular Tags