KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > core > projects > FilterFileSystem


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 Forte for Java, Community Edition. The Initial
16  * Developer of the Original Software is Sun Microsystems, Inc. Portions
17  * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.core.projects;
21
22 import org.openide.filesystems.*;
23 import java.beans.PropertyVetoException JavaDoc;
24 import java.io.IOException JavaDoc;
25 import org.openide.util.Exceptions;
26
27 /**
28  *
29  * @author Petr Jiricka, Vita Stejskal
30  * @version 1.0
31  */

32 public final class FilterFileSystem extends MultiFileSystem {
33     
34     private final FileObject root;
35     private final FileSystem del;
36
37     public FilterFileSystem (FileObject root) throws FileStateInvalidException {
38         super (new FileSystem [] { root.getFileSystem () });
39         this.root = root;
40         this.del = root.getFileSystem ();
41         setSystemName();
42         setPropagateMasks (true);
43     }
44
45     @SuppressWarnings JavaDoc("deprecation")
46     private void setSystemName() {
47         try {
48             setSystemName(del.getSystemName() + " : " + root.getPath()); //NOI18N
49
} catch (PropertyVetoException JavaDoc e) {
50             // ther shouldn't be any listener vetoing setSystemName
51
Exceptions.printStackTrace(e);
52         }
53     }
54
55     public final FileObject getRootFileObject () {
56         return root;
57     }
58
59     protected FileObject findResourceOn (FileSystem fs, String JavaDoc res) {
60         return fs.findResource (root.getPath() + "/" + res); //NOI18N
61
}
62
63     protected java.util.Set JavaDoc createLocksOn (String JavaDoc name) throws IOException JavaDoc {
64         String JavaDoc nn = root.getPath() + "/" + name;
65         org.netbeans.core.startup.layers.LocalFileSystemEx.potentialLock (name, nn);
66         return super.createLocksOn (name);
67     }
68 }
69
Popular Tags