Lines 34-40
Link Here
|
34 |
* |
34 |
* |
35 |
* @author Jan Jancura, Ian Formanek, Petr Hamernik |
35 |
* @author Jan Jancura, Ian Formanek, Petr Hamernik |
36 |
*/ |
36 |
*/ |
37 |
public final class SystemFileSystem extends MultiFileSystem implements FileSystem.Status { |
37 |
public final class SystemFileSystem extends MultiFileSystem |
|
|
38 |
implements FileSystem.Status, org.openide.util.LookupListener { |
38 |
// Must be public for BeanInfo to work: #11186. |
39 |
// Must be public for BeanInfo to work: #11186. |
39 |
|
40 |
|
40 |
/** generated Serialized Version UID */ |
41 |
/** generated Serialized Version UID */ |
Lines 55-60
Link Here
|
55 |
/** name of file attribute with URL to 32x32 color icon */ |
56 |
/** name of file attribute with URL to 32x32 color icon */ |
56 |
private static final String ATTR_ICON_32 = "SystemFileSystem.icon32"; // NOI18N |
57 |
private static final String ATTR_ICON_32 = "SystemFileSystem.icon32"; // NOI18N |
57 |
|
58 |
|
|
|
59 |
/** lookup result we listen on */ |
60 |
private static Lookup.Result result = Lookup.getDefault ().lookup (new Lookup.Template (FileSystem.class)); |
61 |
/** the set of layers provided by the system */ |
62 |
private static FileSystem[] layers; |
63 |
|
58 |
/** user fs */ |
64 |
/** user fs */ |
59 |
private ModuleLayeredFileSystem user; |
65 |
private ModuleLayeredFileSystem user; |
60 |
/** home fs */ |
66 |
/** home fs */ |
Lines 67-79
Link Here
|
67 |
|
73 |
|
68 |
/** @param fss list of file systems to delegate to |
74 |
/** @param fss list of file systems to delegate to |
69 |
*/ |
75 |
*/ |
70 |
private SystemFileSystem (FileSystem[] fss) throws PropertyVetoException { |
76 |
private SystemFileSystem () throws PropertyVetoException { |
71 |
super (fss); |
77 |
super (computeLayers ()); |
72 |
user = (ModuleLayeredFileSystem) fss[0]; |
78 |
user = (ModuleLayeredFileSystem) layers[0]; |
73 |
home = fss.length > 2 ? (ModuleLayeredFileSystem) fss[1] : null; |
79 |
home = layers.length > 2 ? (ModuleLayeredFileSystem) layers[1] : null; |
74 |
|
80 |
|
75 |
setSystemName (SYSTEM_NAME); |
81 |
setSystemName (SYSTEM_NAME); |
76 |
setHidden (true); |
82 |
setHidden (true); |
|
|
83 |
|
84 |
result.addLookupListener (this); |
77 |
} |
85 |
} |
78 |
|
86 |
|
79 |
|
87 |
|
Lines 107-114
Link Here
|
107 |
else |
115 |
else |
108 |
s.add (arr[i]); |
116 |
s.add (arr[i]); |
109 |
|
117 |
|
|
|
118 |
layers = (FileSystem []) arr.clone (); |
110 |
// create own internal copy of passed filesystems |
119 |
// create own internal copy of passed filesystems |
111 |
setDelegates ((FileSystem []) arr.clone ()); |
120 |
setDelegates (computeLayers ()); |
112 |
firePropertyChange ("layers", null, null); // NOI18N |
121 |
firePropertyChange ("layers", null, null); // NOI18N |
113 |
} |
122 |
} |
114 |
|
123 |
|
Lines 121-126
Link Here
|
121 |
// don't return reference to internal buffer |
130 |
// don't return reference to internal buffer |
122 |
return (FileSystem []) getDelegates ().clone (); |
131 |
return (FileSystem []) getDelegates ().clone (); |
123 |
} |
132 |
} |
|
|
133 |
|
134 |
private synchronized static FileSystem[] computeLayers () { |
135 |
FileSystem[] fromLookup = (FileSystem[])result.allInstances ().toArray (new FileSystem[0]); |
136 |
|
137 |
if (fromLookup.length > 0) { |
138 |
ArrayList arr = new ArrayList (layers.length + fromLookup.length); |
139 |
arr.addAll (Arrays.asList (layers)); |
140 |
arr.addAll (Arrays.asList (fromLookup)); |
141 |
return (FileSystem[])arr.toArray (new FileSystem[0]); |
142 |
} |
143 |
|
144 |
return layers; |
145 |
} |
124 |
|
146 |
|
125 |
protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { |
147 |
protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { |
126 |
return createWritableOn (oldName); |
148 |
return createWritableOn (oldName); |
Lines 318-324
Link Here
|
318 |
("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N |
340 |
("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N |
319 |
arr[home == null ? 1 : 2] = FixedFileSystem.deflt; |
341 |
arr[home == null ? 1 : 2] = FixedFileSystem.deflt; |
320 |
|
342 |
|
321 |
return new SystemFileSystem (arr); |
343 |
layers = arr; |
|
|
344 |
return new SystemFileSystem (); |
322 |
} |
345 |
} |
323 |
|
346 |
|
324 |
/** Getter for message. |
347 |
/** Getter for message. |
Lines 357-362
Link Here
|
357 |
new NotSerializableException ("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace (); // NOI18N |
380 |
new NotSerializableException ("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace (); // NOI18N |
358 |
return new SingletonSerializer (); |
381 |
return new SingletonSerializer (); |
359 |
} |
382 |
} |
|
|
383 |
|
384 |
/** Refresh layers */ |
385 |
public synchronized void resultChanged (org.openide.util.LookupEvent ev) { |
386 |
setDelegates (computeLayers ()); |
387 |
} |
388 |
|
360 |
private static final class SingletonSerializer extends Object implements Serializable { |
389 |
private static final class SingletonSerializer extends Object implements Serializable { |
361 |
private static final long serialVersionUID = 6436781994611L; |
390 |
private static final long serialVersionUID = 6436781994611L; |
362 |
SingletonSerializer() {} |
391 |
SingletonSerializer() {} |