Lines 29-34
Link Here
|
29 |
import java.io.ObjectStreamException; |
29 |
import java.io.ObjectStreamException; |
30 |
import java.io.Serializable; |
30 |
import java.io.Serializable; |
31 |
import java.net.URL; |
31 |
import java.net.URL; |
|
|
32 |
import java.util.ArrayList; |
33 |
import java.util.Arrays; |
32 |
import java.util.HashSet; |
34 |
import java.util.HashSet; |
33 |
import java.util.Iterator; |
35 |
import java.util.Iterator; |
34 |
import java.util.MissingResourceException; |
36 |
import java.util.MissingResourceException; |
Lines 42-54
Link Here
|
42 |
import org.openide.filesystems.LocalFileSystem; |
44 |
import org.openide.filesystems.LocalFileSystem; |
43 |
import org.openide.filesystems.MultiFileSystem; |
45 |
import org.openide.filesystems.MultiFileSystem; |
44 |
import org.openide.filesystems.Repository; |
46 |
import org.openide.filesystems.Repository; |
|
|
47 |
import org.openide.util.Lookup; |
45 |
import org.openide.util.NbBundle; |
48 |
import org.openide.util.NbBundle; |
46 |
|
49 |
|
47 |
/** The system FileSystem - represents system files under $NETBEANS_HOME/system. |
50 |
/** The system FileSystem - represents system files under $NETBEANS_HOME/system. |
48 |
* |
51 |
* |
49 |
* @author Jan Jancura, Ian Formanek, Petr Hamernik |
52 |
* @author Jan Jancura, Ian Formanek, Petr Hamernik |
50 |
*/ |
53 |
*/ |
51 |
public final class SystemFileSystem extends MultiFileSystem implements FileSystem.Status { |
54 |
public final class SystemFileSystem extends MultiFileSystem |
|
|
55 |
implements FileSystem.Status, org.openide.util.LookupListener { |
52 |
// Must be public for BeanInfo to work: #11186. |
56 |
// Must be public for BeanInfo to work: #11186. |
53 |
|
57 |
|
54 |
/** generated Serialized Version UID */ |
58 |
/** generated Serialized Version UID */ |
Lines 65-70
Link Here
|
65 |
/** name of file attribute with URL to 32x32 color icon */ |
69 |
/** name of file attribute with URL to 32x32 color icon */ |
66 |
private static final String ATTR_ICON_32 = "SystemFileSystem.icon32"; // NOI18N |
70 |
private static final String ATTR_ICON_32 = "SystemFileSystem.icon32"; // NOI18N |
67 |
|
71 |
|
|
|
72 |
/** lookup result we listen on */ |
73 |
private static Lookup.Result<FileSystem> result = Lookup.getDefault().lookupResult(FileSystem.class); |
74 |
/** the set of layers provided by the system */ |
75 |
private static FileSystem[] layers; |
76 |
|
68 |
/** user fs */ |
77 |
/** user fs */ |
69 |
private ModuleLayeredFileSystem user; |
78 |
private ModuleLayeredFileSystem user; |
70 |
/** home fs */ |
79 |
/** home fs */ |
Lines 73-85
Link Here
|
73 |
/** @param fss list of file systems to delegate to |
82 |
/** @param fss list of file systems to delegate to |
74 |
*/ |
83 |
*/ |
75 |
@SuppressWarnings("deprecation") |
84 |
@SuppressWarnings("deprecation") |
76 |
private SystemFileSystem (FileSystem[] fss) throws PropertyVetoException { |
85 |
private SystemFileSystem() throws PropertyVetoException { |
77 |
super (fss); |
86 |
super(computeLayers()); |
78 |
user = (ModuleLayeredFileSystem) fss[0]; |
87 |
user = (ModuleLayeredFileSystem) layers[0]; |
79 |
home = fss.length > 2 ? (ModuleLayeredFileSystem) fss[1] : null; |
88 |
home = layers.length > 2 ? (ModuleLayeredFileSystem) layers[1] : null; |
80 |
|
89 |
|
81 |
setSystemName (SYSTEM_NAME); |
90 |
setSystemName(SYSTEM_NAME); |
82 |
setHidden (true); |
91 |
setHidden(true); |
|
|
92 |
|
93 |
result.addLookupListener(this); |
83 |
} |
94 |
} |
84 |
|
95 |
|
85 |
|
96 |
|
Lines 113-120
Link Here
|
113 |
else |
124 |
else |
114 |
s.add (arr[i]); |
125 |
s.add (arr[i]); |
115 |
|
126 |
|
|
|
127 |
layers = (FileSystem[])arr.clone(); |
116 |
// create own internal copy of passed filesystems |
128 |
// create own internal copy of passed filesystems |
117 |
setDelegates(arr.clone()); |
129 |
setDelegates(computeLayers()); |
118 |
firePropertyChange ("layers", null, null); // NOI18N |
130 |
firePropertyChange ("layers", null, null); // NOI18N |
119 |
} |
131 |
} |
120 |
|
132 |
|
Lines 127-132
Link Here
|
127 |
// don't return reference to internal buffer |
139 |
// don't return reference to internal buffer |
128 |
return getDelegates().clone(); |
140 |
return getDelegates().clone(); |
129 |
} |
141 |
} |
|
|
142 |
|
143 |
private synchronized static FileSystem[] computeLayers () { |
144 |
FileSystem[] fromLookup = (FileSystem[])result.allInstances ().toArray (new FileSystem[0]); |
145 |
|
146 |
if (fromLookup.length > 0) { |
147 |
ArrayList<FileSystem> arr = new ArrayList<FileSystem>(layers.length + fromLookup.length); |
148 |
arr.addAll (Arrays.asList (layers)); |
149 |
arr.addAll (Arrays.asList (fromLookup)); |
150 |
return (FileSystem[])arr.toArray (new FileSystem[0]); |
151 |
} |
152 |
|
153 |
return layers; |
154 |
} |
130 |
|
155 |
|
131 |
protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { |
156 |
protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { |
132 |
return createWritableOn (oldName); |
157 |
return createWritableOn (oldName); |
Lines 280-286
Link Here
|
280 |
("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N |
305 |
("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N |
281 |
arr[home == null ? 1 : 2] = FixedFileSystem.deflt; |
306 |
arr[home == null ? 1 : 2] = FixedFileSystem.deflt; |
282 |
|
307 |
|
283 |
return new SystemFileSystem (arr); |
308 |
layers = arr; |
|
|
309 |
return new SystemFileSystem (); |
284 |
} |
310 |
} |
285 |
|
311 |
|
286 |
/** Notification that a file has migrated from one file system |
312 |
/** Notification that a file has migrated from one file system |
Lines 297-305
Link Here
|
297 |
} |
323 |
} |
298 |
|
324 |
|
299 |
// --- SAFETY --- |
325 |
// --- SAFETY --- |
300 |
private Object writeReplace () throws ObjectStreamException { |
326 |
private Object writeReplace() throws ObjectStreamException { |
301 |
new NotSerializableException ("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace (); // NOI18N |
327 |
new NotSerializableException("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace(); // NOI18N |
302 |
return new SingletonSerializer (); |
328 |
return new SingletonSerializer(); |
|
|
329 |
} |
330 |
|
331 |
/** Refresh layers */ |
332 |
public synchronized void resultChanged(org.openide.util.LookupEvent ev) { |
333 |
setDelegates(computeLayers()); |
303 |
} |
334 |
} |
304 |
|
335 |
|
305 |
private static final class SingletonSerializer extends Object implements Serializable { |
336 |
private static final class SingletonSerializer extends Object implements Serializable { |