This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 154028
Collapse All | Expand All

(-)apichanges.xml (+13 lines)
Lines 105-110 Link Here
105
105
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
106
<!-- ACTUAL CHANGES BEGIN HERE: -->
107
  <changes>
107
  <changes>
108
    <change id="convertor.recognize.xml">
109
        <api name="settings_spi"/>
110
        <summary>Allow convertors to recognize .xml files in specially attributed folders.</summary>
111
        <version major="1" minor="17"/>
112
        <date day="28" month="11" year="2008"/>
113
        <author login="saubrecht"/>
114
        <compatibility addition="yes"/>
115
        <description>
116
            If a folder in SFS has attribute <code>recognizeXML=true</code> then
117
            Convertors will attempt to process also files with .xml extension.
118
        </description>
119
        <issue number="154028"/>
120
    </change>
108
    <change id="ignore.removed.classes">
121
    <change id="ignore.removed.classes">
109
        <api name="settings_spi"/>
122
        <api name="settings_spi"/>
110
        <summary>Ignore settings for intentionally removed classes.</summary>
123
        <summary>Ignore settings for intentionally removed classes.</summary>
(-)manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.settings/1
2
OpenIDE-Module: org.netbeans.modules.settings/1
3
OpenIDE-Module-Specification-Version: 1.16
3
OpenIDE-Module-Specification-Version: 1.17
4
OpenIDE-Module-Layer: org/netbeans/modules/settings/resources/mf-layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/settings/resources/mf-layer.xml
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/settings/resources/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/settings/resources/Bundle.properties
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
(-)src/org/netbeans/modules/settings/Env.java (-1 / +12 lines)
Lines 48-53 Link Here
48
import org.openide.filesystems.Repository;
48
import org.openide.filesystems.Repository;
49
import org.openide.loaders.DataObject;
49
import org.openide.loaders.DataObject;
50
import org.openide.loaders.Environment;
50
import org.openide.loaders.Environment;
51
import org.openide.loaders.InstanceDataObject;
52
import org.openide.loaders.XMLDataObject;
51
import org.openide.util.Lookup;
53
import org.openide.util.Lookup;
52
54
53
/** A provider for .settings files of a certain DTD.
55
/** A provider for .settings files of a certain DTD.
Lines 108-114 Link Here
108
    }
110
    }
109
    
111
    
110
    public Lookup getEnvironment(DataObject dobj) {
112
    public Lookup getEnvironment(DataObject dobj) {
111
        if (!(dobj instanceof org.openide.loaders.InstanceDataObject)) return Lookup.EMPTY;
113
        boolean recognize = false;
114
        if (dobj instanceof InstanceDataObject) {
115
            recognize = true;
116
        } else if (dobj instanceof XMLDataObject) {
117
            recognize = Boolean.TRUE.equals(dobj.getPrimaryFile().getParent().getAttribute("recognizeXML"));
118
        }
119
120
        if (!recognize) {
121
            return Lookup.EMPTY;
122
        }
112
        InstanceProvider icp = new InstanceProvider(dobj, providerFO);
123
        InstanceProvider icp = new InstanceProvider(dobj, providerFO);
113
        return icp.getLookup();
124
        return icp.getLookup();
114
    }
125
    }
(-)test/unit/src/org/netbeans/spi/settings/DOMConvertorTest.java (-2 / +34 lines)
Lines 91-98 Link Here
91
        
91
        
92
        // test reading
92
        // test reading
93
        FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "settings");
93
        FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "settings");
94
        org.openide.cookies.InstanceCookie ic = (org.openide.cookies.InstanceCookie)
94
        org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class);
95
            DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class);
96
        assertNotNull("missing InstanceCookie", ic);
95
        assertNotNull("missing InstanceCookie", ic);
97
        assertEquals(cs.getClass(), ic.instanceClass());
96
        assertEquals(cs.getClass(), ic.instanceClass());
98
        
97
        
Lines 110-115 Link Here
110
        }
109
        }
111
    }
110
    }
112
    
111
    
112
    public void testCreateSetting_XML() throws Exception {
113
        try {
114
        org.openide.filesystems.FileUtil.createFolder(fs.getRoot(), "testCreateSetting");
115
        DataFolder folder = DataFolder.findFolder(fs.findResource("testCreateSetting"));
116
117
        ComposedSetting cs = new ComposedSetting();
118
        cs.b1 = new java.awt.Button();
119
        cs.b2 = cs.b1;
120
        cs.cs = new ComposedSetting();
121
        cs.cs.b1 = new java.awt.Button();
122
        DataObject dobj = InstanceDataObject.create(folder, "testCreateSetting", cs, null);
123
124
        // test reading
125
        FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "xml");
126
        fo.getParent().setAttribute("recognizeXML", Boolean.TRUE);
127
        org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class);
128
        assertNotNull("missing InstanceCookie", ic);
129
        assertEquals(cs.getClass(), ic.instanceClass());
130
131
        try {
132
            ComposedSetting cs2 = (ComposedSetting) ic.instanceCreate();
133
            assertEquals(cs2.b1, cs2.b2);
134
        } catch (IOException e) {
135
            System.err.println("File contents:\n");
136
            FileUtil.copy(fo.getInputStream(), System.err);
137
            throw e;
138
        }
139
        } catch (Exception ex) {
140
            Logger.global.log(Level.WARNING, null, ex);
141
            throw ex;
142
        }
143
    }
144
113
    public static class ComposedSetting {
145
    public static class ComposedSetting {
114
        java.awt.Button b1;
146
        java.awt.Button b1;
115
        java.awt.Button b2;
147
        java.awt.Button b2;

Return to bug 154028