2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
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]"
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.
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.
42
package org.netbeans.modules.masterfs.providers;
45
import java.io.IOException;
46
import org.openide.filesystems.FileObject;
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.
58
* @see ProvidedExtensions.IOHandler
59
* @see InterceptionListener
61
* @author Radek Matous
63
public class ProvidedExtensions implements InterceptionListener {
65
* Return instance of {@link ProvidedExtensions.IOHandler}
66
* that is responsible for moving the file or null.
68
* Just the first non null instance of <code>IOHandler</code> is used by
69
* <code>MasterFileSystem</code>
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
76
public ProvidedExtensions.IOHandler getMoveHandler(
82
* Return instance of {@link ProvidedExtensions.IOHandler}
83
* that is responsible for renaming the file or null.
85
* Just the first non null instance of <code>IOHandler</code> is used by
86
* <code>MasterFileSystem</code>
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
93
public ProvidedExtensions.IOHandler getRenameHandler(
94
File from, String newName) {
99
* Return instance of {@link ProvidedExtensions.DeleteHandler}
100
* that is responsible for deleting the file or null.
102
* Just the first non null instance of <code>DeleteHandler</code> is used by
103
* <code>MasterFileSystem</code>
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
109
public ProvidedExtensions.DeleteHandler getDeleteHandler(File f) {
114
public interface IOHandler {
116
* @throws java.io.IOException if handled operation isn't successful
118
void handle() throws IOException;
121
public interface DeleteHandler {
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.
127
* @return <code>true</code> if and only if the file or directory is
128
* successfully deleted; <code>false</code> otherwise
130
boolean delete(File file);
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) {}
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
149
public void beforeChange(FileObject fo) {}
152
* Called by <code>MasterFileSystem</code> after <code>FileObject</code>
154
* @see org.openide.filesystems.FileObject#lock
155
* @param fo file which was locked
158
public void fileLocked(FileObject fo) {}
161
* Called by <code>MasterFileSystem</code> after <code>FileLock</code>
163
* @see org.openide.filesystems.FileLock#releaseLock
164
* @param fo file which <code>FileLock</code> was released
167
public void fileUnlocked(FileObject fo) {}