KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
26
27 /** Adapter for listening on changes of fileobjects and refreshing data
28 * shadows/broken links
29 *
30 * @author Ales Kemr
31 */

32 class ShadowChangeAdapter extends Object JavaDoc implements OperationListener {
33
34     /** Creates new ShadowChangeAdapter */
35     ShadowChangeAdapter() {
36
37         /* listen on loader pool to refresh datashadows after
38         * create/delete dataobject
39         */

40         DataLoaderPool.getDefault().addOperationListener(this);
41     }
42
43     /** Checks for BrokenDataShadows */
44     static void checkBrokenDataShadows(EventObject JavaDoc ev) {
45         BrokenDataShadow.checkValidity(ev);
46     }
47     
48     /** Checks for DataShadows */
49     static void checkDataShadows(EventObject JavaDoc ev) {
50         DataShadow.checkValidity(ev);
51     }
52     
53     /** Object has been recognized by
54      * {@link DataLoaderPool#findDataObject}.
55      * This allows listeners
56      * to attach additional cookies, etc.
57      *
58      * @param ev event describing the action
59     */

60     public void operationPostCreate(OperationEvent ev) {
61         checkBrokenDataShadows(ev);
62     }
63     
64     /** Object has been successfully copied.
65      * @param ev event describing the action
66     */

67     public void operationCopy(OperationEvent.Copy ev) {
68     }
69     
70     /** Object has been successfully moved.
71      * @param ev event describing the action
72     */

73     public void operationMove(OperationEvent.Move ev) {
74         checkDataShadows(ev);
75         checkBrokenDataShadows(ev);
76     }
77     
78     /** Object has been successfully deleted.
79      * @param ev event describing the action
80     */

81     public void operationDelete(OperationEvent ev) {
82         checkDataShadows(ev);
83     }
84     
85     /** Object has been successfully renamed.
86      * @param ev event describing the action
87     */

88     public void operationRename(OperationEvent.Rename ev) {
89         checkDataShadows(ev);
90         checkBrokenDataShadows(ev);
91     }
92     
93     /** A shadow of a data object has been created.
94      * @param ev event describing the action
95     */

96     public void operationCreateShadow(OperationEvent.Copy ev) {
97     }
98     
99     /** New instance of an object has been created.
100      * @param ev event describing the action
101     */

102     public void operationCreateFromTemplate(OperationEvent.Copy ev) {
103         checkBrokenDataShadows(ev);
104     }
105     
106 }
107
Popular Tags