# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\hg\toolbars\settings # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: apichanges.xml --- apichanges.xml Base (BASE) +++ apichanges.xml Locally Modified (Based On LOCAL) @@ -105,6 +105,19 @@ + + + Allow convertors to recognize .xml files in specially attributed folders. + + + + + + If a folder in SFS has attribute recognizeXML=true then + Convertors will attempt to process also files with .xml extension. + + + Ignore settings for intentionally removed classes. Index: manifest.mf --- manifest.mf Base (BASE) +++ manifest.mf Locally Modified (Based On LOCAL) @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.settings/1 -OpenIDE-Module-Specification-Version: 1.16 +OpenIDE-Module-Specification-Version: 1.17 OpenIDE-Module-Layer: org/netbeans/modules/settings/resources/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/settings/resources/Bundle.properties AutoUpdate-Essential-Module: true Index: src/org/netbeans/modules/settings/Env.java --- src/org/netbeans/modules/settings/Env.java Base (BASE) +++ src/org/netbeans/modules/settings/Env.java Locally Modified (Based On LOCAL) @@ -48,6 +48,8 @@ import org.openide.filesystems.Repository; import org.openide.loaders.DataObject; import org.openide.loaders.Environment; +import org.openide.loaders.InstanceDataObject; +import org.openide.loaders.XMLDataObject; import org.openide.util.Lookup; /** A provider for .settings files of a certain DTD. @@ -108,7 +110,16 @@ } public Lookup getEnvironment(DataObject dobj) { - if (!(dobj instanceof org.openide.loaders.InstanceDataObject)) return Lookup.EMPTY; + boolean recognize = false; + if (dobj instanceof InstanceDataObject) { + recognize = true; + } else if (dobj instanceof XMLDataObject) { + recognize = Boolean.TRUE.equals(dobj.getPrimaryFile().getParent().getAttribute("recognizeXML")); + } + + if (!recognize) { + return Lookup.EMPTY; + } InstanceProvider icp = new InstanceProvider(dobj, providerFO); return icp.getLookup(); } Index: test/unit/src/org/netbeans/spi/settings/DOMConvertorTest.java --- test/unit/src/org/netbeans/spi/settings/DOMConvertorTest.java Base (BASE) +++ test/unit/src/org/netbeans/spi/settings/DOMConvertorTest.java Locally Modified (Based On LOCAL) @@ -91,8 +91,7 @@ // test reading FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "settings"); - org.openide.cookies.InstanceCookie ic = (org.openide.cookies.InstanceCookie) - DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); + org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); assertNotNull("missing InstanceCookie", ic); assertEquals(cs.getClass(), ic.instanceClass()); @@ -110,6 +109,39 @@ } } + public void testCreateSetting_XML() throws Exception { + try { + org.openide.filesystems.FileUtil.createFolder(fs.getRoot(), "testCreateSetting"); + DataFolder folder = DataFolder.findFolder(fs.findResource("testCreateSetting")); + + ComposedSetting cs = new ComposedSetting(); + cs.b1 = new java.awt.Button(); + cs.b2 = cs.b1; + cs.cs = new ComposedSetting(); + cs.cs.b1 = new java.awt.Button(); + DataObject dobj = InstanceDataObject.create(folder, "testCreateSetting", cs, null); + + // test reading + FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "xml"); + fo.getParent().setAttribute("recognizeXML", Boolean.TRUE); + org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); + assertNotNull("missing InstanceCookie", ic); + assertEquals(cs.getClass(), ic.instanceClass()); + + try { + ComposedSetting cs2 = (ComposedSetting) ic.instanceCreate(); + assertEquals(cs2.b1, cs2.b2); + } catch (IOException e) { + System.err.println("File contents:\n"); + FileUtil.copy(fo.getInputStream(), System.err); + throw e; + } + } catch (Exception ex) { + Logger.global.log(Level.WARNING, null, ex); + throw ex; + } + } + public static class ComposedSetting { java.awt.Button b1; java.awt.Button b2;