~ubuntu-branches/ubuntu/trusty/netbeans/trusty

« back to all changes in this revision

Viewing changes to openide/masterfs/src/org/netbeans/modules/masterfs/providers/ProvidedExtensions.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 
3
 *
 
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 
5
 *
 
6
 * The contents of this file are subject to the terms of either the GNU
 
7
 * General Public License Version 2 only ("GPL") or the Common
 
8
 * Development and Distribution License("CDDL") (collectively, the
 
9
 * "License"). You may not use this file except in compliance with the
 
10
 * License. You can obtain a copy of the License at
 
11
 * http://www.netbeans.org/cddl-gplv2.html
 
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 
13
 * specific language governing permissions and limitations under the
 
14
 * License.  When distributing the software, include this License Header
 
15
 * Notice in each file and include the License file at
 
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 
17
 * particular file as subject to the "Classpath" exception as provided
 
18
 * by Sun in the GPL Version 2 section of the License file that
 
19
 * accompanied this code. If applicable, add the following below the
 
20
 * License Header, with the fields enclosed by brackets [] replaced by
 
21
 * your own identifying information:
 
22
 * "Portions Copyrighted [year] [name of copyright owner]"
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * The Original Software is NetBeans. The Initial Developer of the Original
 
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
 
28
 * Microsystems, Inc. All Rights Reserved.
 
29
 *
 
30
 * If you wish your version of this file to be governed by only the CDDL
 
31
 * or only the GPL Version 2, indicate your decision by adding
 
32
 * "[Contributor] elects to include this software in this distribution
 
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 
34
 * single choice of license, a recipient has the option to distribute
 
35
 * your version of this file under either the CDDL, the GPL Version 2 or
 
36
 * to extend the choice of license to its licensees as provided above.
 
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 
38
 * Version 2 license, then the option applies only if the new code is
 
39
 * made subject to such option by the copyright holder.
 
40
 */
 
41
 
 
42
package org.netbeans.modules.masterfs.providers;
 
43
 
 
44
import java.io.File;
 
45
import java.io.IOException;
 
46
import org.openide.filesystems.FileObject;
 
47
 
 
48
/**
 
49
 * Encapsulate a group of individual factory methods that are responsible for creating objects
 
50
 * of specific interfaces. If subclassed and provided by
 
51
 * {@link AnnotationProvider#getInterceptionListener} then
 
52
 * individual instances will be called by <code>MasterFileSystem</code>
 
53
 * There may exist more than one instance of <code>ProvidedExtensions</code>
 
54
 * at a given moment and therefore there is defined for
 
55
 * every method wheter will be called by <code>MasterFileSystem</code>
 
56
 * for every present instance or just for the first one.
 
57
 *
 
58
 * @see ProvidedExtensions.IOHandler
 
59
 * @see InterceptionListener
 
60
 *
 
61
 * @author Radek Matous
 
62
 */
 
63
public class ProvidedExtensions implements InterceptionListener {
 
64
    /**
 
65
     * Return instance of {@link ProvidedExtensions.IOHandler}
 
66
     * that is responsible for moving the file or null.
 
67
     *
 
68
     * Just the first non null instance of <code>IOHandler</code> is used by
 
69
     *  <code>MasterFileSystem</code>
 
70
     *
 
71
     * @param from file to be moved
 
72
     * @param to target to move this file to
 
73
     * @return instance of {@link ProvidedExtensions.IOHandler} 
 
74
     * that is responsible for moving the file or null
 
75
     */
 
76
    public ProvidedExtensions.IOHandler getMoveHandler(
 
77
            File from, File to) {
 
78
        return null;
 
79
    }
 
80
    
 
81
    /*
 
82
     * Return instance of {@link ProvidedExtensions.IOHandler}
 
83
     * that is responsible for renaming the file or null.
 
84
     *
 
85
     * Just the first non null instance of <code>IOHandler</code> is used by
 
86
     *  <code>MasterFileSystem</code>
 
87
     *
 
88
     * @param from file to be renamed
 
89
     * @param newName new name of file
 
90
     * @return instance of {@link ProvidedExtensions.IOHandler} 
 
91
     * that is responsible for renaming the file or null
 
92
     */
 
93
    public ProvidedExtensions.IOHandler getRenameHandler(
 
94
            File from, String newName) {
 
95
        return null;
 
96
    }
 
97
 
 
98
    /*
 
99
     * Return instance of {@link ProvidedExtensions.DeleteHandler}
 
100
     * that is responsible for deleting the file or null.
 
101
     *
 
102
     * Just the first non null instance of <code>DeleteHandler</code> is used by
 
103
     *  <code>MasterFileSystem</code>
 
104
     *
 
105
     * @param f file or folder to be deleted
 
106
     * @return instance of {@link ProvidedExtensions.DeleteHandler} 
 
107
     * that is responsible for deleting the file or null
 
108
     */    
 
109
    public ProvidedExtensions.DeleteHandler getDeleteHandler(File f) {
 
110
        return null;
 
111
    }
 
112
    
 
113
    
 
114
    public interface IOHandler {
 
115
        /**
 
116
         * @throws java.io.IOException if handled operation isn't successful
 
117
         */
 
118
        void handle() throws IOException;
 
119
    }
 
120
    
 
121
    public interface DeleteHandler {
 
122
        /**
 
123
         * Deletes the file or directory denoted by this abstract pathname.  If
 
124
         * this pathname denotes a directory, then the directory must be empty in
 
125
         * order to be deleted.
 
126
         *
 
127
         * @return  <code>true</code> if and only if the file or directory is
 
128
         *          successfully deleted; <code>false</code> otherwise
 
129
         */
 
130
        boolean delete(File file);
 
131
    }
 
132
    
 
133
        
 
134
    public void createSuccess(FileObject fo) {}    
 
135
    public void createFailure(FileObject parent, String name, boolean isFolder) {}   
 
136
    public void beforeCreate(FileObject parent, String name, boolean isFolder) {}    
 
137
    public void deleteSuccess(FileObject fo) {}    
 
138
    public void deleteFailure(FileObject fo) {}
 
139
    public void beforeDelete(FileObject fo) {}
 
140
 
 
141
 
 
142
    /*
 
143
     * Called by <code>MasterFileSystem</code> when <code>FileObject</code>
 
144
     * is going to be modified by asking for <code>OutputStream<code>
 
145
     * @see org.openide.filesystems.FileObject#getOutputStream
 
146
     * @param fo file which is going to be notified
 
147
     * @since 1.10
 
148
     */        
 
149
    public void beforeChange(FileObject fo) {}    
 
150
    
 
151
    /*
 
152
     * Called by <code>MasterFileSystem</code> after <code>FileObject</code>
 
153
     * is locked
 
154
     * @see org.openide.filesystems.FileObject#lock
 
155
     * @param fo file which was locked
 
156
     * @since 1.11
 
157
     */            
 
158
    public void fileLocked(FileObject fo) {}    
 
159
    
 
160
    /*
 
161
     * Called by <code>MasterFileSystem</code> after <code>FileLock</code>
 
162
     * is released
 
163
     * @see org.openide.filesystems.FileLock#releaseLock
 
164
     * @param fo file which <code>FileLock</code> was released
 
165
     * @since 1.11
 
166
     */                
 
167
    public void fileUnlocked(FileObject fo) {}        
 
168
}