Index: openide/src/org/openide/ErrorManager.java =================================================================== RCS file: /cvs/openide/src/org/openide/ErrorManager.java,v retrieving revision 1.13 diff -c -r1.13 ErrorManager.java *** openide/src/org/openide/ErrorManager.java 17 Jan 2002 17:54:56 -0000 1.13 --- openide/src/org/openide/ErrorManager.java 5 Feb 2002 15:22:18 -0000 *************** *** 68,74 **** * @since 2.1 */ public static ErrorManager getDefault () { ! ErrorManager em = (ErrorManager)org.openide.util.Lookup.getDefault ().lookup (ErrorManager.class); if (em == null) { em = simple (); } --- 68,74 ---- * @since 2.1 */ public static ErrorManager getDefault () { ! ErrorManager em = null;//(ErrorManager)org.openide.util.Lookup.getDefault ().lookup (ErrorManager.class); if (em == null) { em = simple (); } *************** *** 260,265 **** --- 260,266 ---- t.printStackTrace(); } public void log(int severity, String s) { + if (severity > 1) System.err.println ("Log: " + severity + " msg: " + s); // NOI18N } Index: openide/src/org/openide/filesystems/DefaultAttributes.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/DefaultAttributes.java,v retrieving revision 1.53 diff -c -r1.53 DefaultAttributes.java *** openide/src/org/openide/filesystems/DefaultAttributes.java 10 Jan 2002 15:22:20 -0000 1.53 --- openide/src/org/openide/filesystems/DefaultAttributes.java 5 Feb 2002 15:22:18 -0000 *************** *** 636,643 **** --- 636,650 ---- * @return attribute or null (if not found) */ public Object getAttr (String fileName, String attrName) { + boolean isXML = attrName.equals ("NB-map"); + XMLMapAttr m = (XMLMapAttr)get (fileName); if (m != null) { + if (isXML) { + return m; + } + + Object o = null; try { o = m.getAttribute (attrName); *************** *** 679,684 **** --- 686,700 ---- * @param obj - attribute */ final void setAttr (String fileName, String attrName, Object obj) { + boolean isXML = attrName.equals ("NB-map"); + if (isXML) { + // replaces whole attributes + put (fileName, obj); + version++; + return; + } + + Map m = (Map)get (fileName); if (m == null) { m = new XMLMapAttr();//HashMap (7);//XMLMapAttr(); Index: openide/src/org/openide/filesystems/FileUtil.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/FileUtil.java,v retrieving revision 1.54 diff -c -r1.54 FileUtil.java *** openide/src/org/openide/filesystems/FileUtil.java 13 Nov 2001 09:05:02 -0000 1.54 --- openide/src/org/openide/filesystems/FileUtil.java 5 Feb 2002 15:22:18 -0000 *************** *** 317,327 **** * @exception IOException if the copying failed */ public static void copyAttributes (FileObject source, FileObject dest) throws IOException { Enumeration attrKeys = source.getAttributes(); while (attrKeys.hasMoreElements()) { String key = (String) attrKeys.nextElement(); if (transientAttributes.contains (key)) continue; ! Object value = source.getAttribute(key); if (value != null) { dest.setAttribute(key, value); } --- 317,336 ---- * @exception IOException if the copying failed */ public static void copyAttributes (FileObject source, FileObject dest) throws IOException { + // special handling of complex attributes + Object value = source.getAttribute ("NB-map"); + if (value != null) { + dest.setAttribute ("NB-map", value); + return; + } + Enumeration attrKeys = source.getAttributes(); while (attrKeys.hasMoreElements()) { String key = (String) attrKeys.nextElement(); if (transientAttributes.contains (key)) continue; ! ! ! value = source.getAttribute(key); if (value != null) { dest.setAttribute(key, value); } Index: openide/src/org/openide/filesystems/XMLFileSystem.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/XMLFileSystem.java,v retrieving revision 1.52 diff -c -r1.52 XMLFileSystem.java *** openide/src/org/openide/filesystems/XMLFileSystem.java 28 Jan 2002 14:08:17 -0000 1.52 --- openide/src/org/openide/filesystems/XMLFileSystem.java 5 Feb 2002 15:22:18 -0000 *************** *** 802,807 **** --- 802,812 ---- return getLayers(); } if (foAttrs == null) return null; + + if ("NB-map".equals (attrName)) { + return foAttrs; + } + Object[] objs = new Object[] {fo,attrName}; return foAttrs.get(attrName,objs); } Index: openide/src/org/openide/filesystems/XMLMapAttr.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/XMLMapAttr.java,v retrieving revision 1.29 diff -c -r1.29 XMLMapAttr.java *** openide/src/org/openide/filesystems/XMLMapAttr.java 12 Nov 2001 09:29:05 -0000 1.29 --- openide/src/org/openide/filesystems/XMLMapAttr.java 5 Feb 2002 15:22:18 -0000 *************** *** 483,488 **** --- 483,494 ---- if (keyIndex == isValid ("stringvalue")) { // NOI18N return (value != null)? encode (value) : ""; // NOI18N } + if (keyIndex == isValid ("methodvalue")) { // NOI18N + return (value != null)? encode (value) : ""; // NOI18N + } + if (keyIndex == isValid ("newvalue")) { // NOI18N + return (value != null)? encode (value) : ""; // NOI18N + } return (value != null)?value : ""; // NOI18N } Index: core/src/org/netbeans/core/projects/ModuleLayeredFileSystem.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/projects/ModuleLayeredFileSystem.java,v retrieving revision 1.12 diff -c -r1.12 ModuleLayeredFileSystem.java *** core/src/org/netbeans/core/projects/ModuleLayeredFileSystem.java 17 Jan 2002 15:46:06 -0000 1.12 --- core/src/org/netbeans/core/projects/ModuleLayeredFileSystem.java 5 Feb 2002 15:22:18 -0000 *************** *** 20,29 **** import java.util.*; import org.openide.TopManager; ! import org.openide.filesystems.FileSystem; ! import org.openide.filesystems.MultiFileSystem; ! import org.openide.filesystems.XMLFileSystem; import org.openide.ErrorManager; /** Layered file system serving itself as either the user or installation layer. * Holds one layer of a writable system directory, and some number --- 20,28 ---- import java.util.*; import org.openide.TopManager; ! import org.openide.filesystems.*; import org.openide.ErrorManager; + import org.openide.filesystems.MultiFileSystem; /** Layered file system serving itself as either the user or installation layer. * Holds one layer of a writable system directory, and some number *************** *** 33,44 **** public class ModuleLayeredFileSystem extends MultiFileSystem { /** serial version UID */ private static final long serialVersionUID = 782910986724201983L; /** Create layered filesystem based on a supplied writable layer. * @param writableLayer the writable layer to use, typically a LocalFileSystem */ ! ModuleLayeredFileSystem (FileSystem writableLayer) { ! super (new FileSystem[] { writableLayer, new XMLFileSystem () }); // Wish to permit e.g. a user-installed module to mask files from a // root-installed module, so propagate masks up this high. // SystemFileSystem leaves this off, so that the final file system --- 32,71 ---- public class ModuleLayeredFileSystem extends MultiFileSystem { /** serial version UID */ private static final long serialVersionUID = 782910986724201983L; + + + /** xml */ + private XMLFileSystem xml; + /** cache */ + private LocalFileSystem cache; /** Create layered filesystem based on a supplied writable layer. * @param writableLayer the writable layer to use, typically a LocalFileSystem */ ! ModuleLayeredFileSystem (FileSystem writableLayer, boolean usecache) { ! super (new FileSystem[] { writableLayer, null }); ! ! xml = new XMLFileSystem (); ! ! if (usecache && Boolean.getBoolean ("usecache")) { ! cache = new LocalFileSystem (); ! try { ! File f = new File ("/tmp/NB-CACHE"); ! if (!f.isDirectory ()) { ! f.mkdirs (); ! } ! System.err.println("is dir: " + f.isDirectory()); ! cache.setRootDirectory(f); ! cache.setReadOnly(true); ! } catch (Exception ex) { ! ex.printStackTrace(); ! throw new IllegalStateException (); ! } ! getDelegates()[1] = cache; ! } else { ! getDelegates()[1] = xml; ! } ! // Wish to permit e.g. a user-installed module to mask files from a // root-installed module, so propagate masks up this high. // SystemFileSystem leaves this off, so that the final file system *************** *** 63,70 **** /** Get the XML layer. * @return the XML layer */ ! final XMLFileSystem getXMLLayer () { ! return (XMLFileSystem)getDelegates ()[1]; } /** Creates the system file system. --- 90,103 ---- /** Get the XML layer. * @return the XML layer */ ! private final XMLFileSystem getXMLLayer () { ! return xml; ! } ! ! /** Get cache layer. ! */ ! private final LocalFileSystem getCache () { ! return cache; } /** Creates the system file system. *************** *** 103,108 **** --- 136,153 ---- */ public void setURLs (final List urls) throws Exception { if (urls.contains(null)) throw new NullPointerException("urls=" + urls); // NOI18N + + if (getCache () != null) { + if (getCache ().getRoot ().getChildren ().length > 0) { + System.err.println("Using content of Cache!!!!"); + + return; + } + System.err.println("Recreating the cache"); + } else { + System.err.println("Not using cache for: " + urls); + } + // #17656: don't hold synch lock while firing changes, it could be dangerous... runAtomicAction(new AtomicAction() { *************** *** 115,124 **** --- 160,180 ---- ErrorManager.getDefault().annotate(ioe, pve); throw ioe; } + + if (getCache () != null) { + try { + copyToCache (); + } catch (Exception ex) { + ex.printStackTrace(); + throw new IllegalStateException (); + } + } } + } }); + firePropertyChange ("layers", null, null); // NOI18N } *************** *** 126,133 **** */ public void addURLs (Collection urls) throws Exception { if (urls.contains(null)) throw new NullPointerException("urls=" + urls); // NOI18N ! FileSystem[] delegates = getDelegates (); ! XMLFileSystem fs = delegates.length < 2 ? null : (XMLFileSystem)delegates[1]; ArrayList arr = new ArrayList (); if (fs != null) { arr.addAll (Arrays.asList (fs.getXmlUrls ())); --- 182,188 ---- */ public void addURLs (Collection urls) throws Exception { if (urls.contains(null)) throw new NullPointerException("urls=" + urls); // NOI18N ! XMLFileSystem fs = getXMLLayer (); ArrayList arr = new ArrayList (); if (fs != null) { arr.addAll (Arrays.asList (fs.getXmlUrls ())); *************** *** 140,147 **** * */ public void removeURLs (Collection urls) throws Exception { ! FileSystem[] delegates = getDelegates (); ! XMLFileSystem fs = delegates.length < 2 ? null : (XMLFileSystem)delegates[1]; if (fs == null) { // no filesystem available return; --- 195,201 ---- * */ public void removeURLs (Collection urls) throws Exception { ! XMLFileSystem fs = getXMLLayer (); if (fs == null) { // no filesystem available return; *************** *** 152,155 **** --- 206,248 ---- setURLs (arr); } + /** Copies the XML filesystem to a cache. + */ + private void copyToCache () throws IOException { + FileObject[] arr = getCache ().getRoot().getChildren (); + for (int i = 0; i < arr.length; i++) { + arr[i].delete (); + } + + getCache ().setReadOnly (false); + copyRec (xml.getRoot (), getCache ().getRoot ()); + getCache ().setReadOnly (true); + } + + /** Do the tree copy + */ + private static void copyRec (FileObject from, FileObject to) throws IOException { + FileObject[] arr = from.getChildren (); + + for (int i = 0; i < arr.length; i++) { + FileObject res; + + try { + if (arr[i].isData ()) { + // copy stream and attr + res = FileUtil.copyFile(arr[i], to, arr[i].getName ()); + } else { + // folder copy + res = to.createFolder(arr[i].getNameExt ()); + copyRec (arr[i], res); + } + FileUtil.copyAttributes (arr[i], res); + } catch (IOException ex) { + System.err.println("FAILURE"); + System.err.println("from: " + arr[i]); + ex.printStackTrace(); + } + } + } + } Index: core/src/org/netbeans/core/projects/SystemFileSystem.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/projects/SystemFileSystem.java,v retrieving revision 1.24 diff -c -r1.24 SystemFileSystem.java *** core/src/org/netbeans/core/projects/SystemFileSystem.java 17 Jan 2002 15:46:06 -0000 1.24 --- core/src/org/netbeans/core/projects/SystemFileSystem.java 5 Feb 2002 15:22:18 -0000 *************** *** 393,401 **** } FileSystem[] arr = new FileSystem[home == null ? 2 : 3]; ! arr[0] = new ModuleLayeredFileSystem (user); if (home != null) { ! arr[1] = new ModuleLayeredFileSystem (home); } FixedFileSystem.deflt = new FixedFileSystem ("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N --- 393,401 ---- } FileSystem[] arr = new FileSystem[home == null ? 2 : 3]; ! arr[0] = new ModuleLayeredFileSystem (user, false); if (home != null) { ! arr[1] = new ModuleLayeredFileSystem (home, true); } FixedFileSystem.deflt = new FixedFileSystem ("org.netbeans.core.projects.FixedFileSystem", "Automatic Manifest Installation"); // NOI18N