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 181439
Collapse All | Expand All

(-)a/java.freeform/apichanges.xml (+11 lines)
Lines 48-53 Link Here
48
    </apidefs>
48
    </apidefs>
49
    <changes>
49
    <changes>
50
50
51
        <change id="source-16">
52
            <summary>Added freeform-project-java/3 schema to support annotation processors and source levels 1.6 and 1.7</summary>
53
            <version major="1" minor="16"/>
54
            <date day="24" month="3" year="2010"/>
55
            <author login="tzezula"/>
56
            <compatibility binary="compatible" source="compatible" semantic="compatible"/>
57
            <description>
58
                Added freeform-project-java/3 schema to support annotation processors and source levels 1.6 and 1.7
59
            </description>
60
            <issue number="181439"/>
61
        </change>
51
        <change id="friend-packages">
62
        <change id="friend-packages">
52
            <summary>Declare SPI packages for friends only</summary>
63
            <summary>Declare SPI packages for friends only</summary>
53
            <version major="1" minor="2"/>
64
            <version major="1" minor="2"/>
(-)a/java.freeform/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.java.freeform/1
2
OpenIDE-Module: org.netbeans.modules.java.freeform/1
3
OpenIDE-Module-Specification-Version: 1.15
3
OpenIDE-Module-Specification-Version: 1.16
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/freeform/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/freeform/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/java/freeform/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/java/freeform/resources/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java (-3 / +3 lines)
Lines 189-195 Link Here
189
            }
189
            }
190
        }
190
        }
191
        // Need to create it.
191
        // Need to create it.
192
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
192
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
193
        if (java == null) {
193
        if (java == null) {
194
            return null;
194
            return null;
195
        }
195
        }
Lines 254-260 Link Here
254
            for (String type : TYPES) {
254
            for (String type : TYPES) {
255
                _registeredClasspaths.put(type, new HashSet<ClassPath>());
255
                _registeredClasspaths.put(type, new HashSet<ClassPath>());
256
            }
256
            }
257
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
257
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
258
            if (java == null) {
258
            if (java == null) {
259
                return;
259
                return;
260
            }
260
            }
Lines 567-573 Link Here
567
        }
567
        }
568
        
568
        
569
        private Element findCompilationUnit() {
569
        private Element findCompilationUnit() {
570
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
570
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
571
            if (java == null) {
571
            if (java == null) {
572
                return null;
572
                return null;
573
            }
573
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java (-2 / +2 lines)
Lines 611-617 Link Here
611
    }
611
    }
612
    
612
    
613
    private List<Element> compilationUnits() {
613
    private List<Element> compilationUnits() {
614
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
614
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
615
        if (java == null) {
615
        if (java == null) {
616
            return Collections.emptyList();
616
            return Collections.emptyList();
617
        }
617
        }
Lines 745-751 Link Here
745
    String findSourceLevel(String sources) {
745
    String findSourceLevel(String sources) {
746
        Element compilationUnitEl = findCompilationUnit(sources);
746
        Element compilationUnitEl = findCompilationUnit(sources);
747
        if (compilationUnitEl != null) {
747
        if (compilationUnitEl != null) {
748
            Element sourceLevel = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_2);
748
            Element sourceLevel = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
749
            if (sourceLevel != null) {
749
            if (sourceLevel != null) {
750
                return Util.findText(sourceLevel);
750
                return Util.findText(sourceLevel);
751
            }
751
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java (-1 / +1 lines)
Lines 94-100 Link Here
94
            ERR.log(ErrorManager.INFORMATIONAL, "JavaFreeformFileBuiltQuery.createDelegateTo start"); // NOI18N
94
            ERR.log(ErrorManager.INFORMATIONAL, "JavaFreeformFileBuiltQuery.createDelegateTo start"); // NOI18N
95
        }
95
        }
96
        
96
        
97
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
97
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
98
        List<String> from = new ArrayList<String>();
98
        List<String> from = new ArrayList<String>();
99
        List<String> to   = new ArrayList<String>();
99
        List<String> to   = new ArrayList<String>();
100
        
100
        
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java (-25 / +83 lines)
Lines 58-63 Link Here
58
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
58
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
59
import org.netbeans.spi.project.support.ant.PropertyUtils;
59
import org.netbeans.spi.project.support.ant.PropertyUtils;
60
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.modules.SpecificationVersion;
61
import org.openide.util.Exceptions;
62
import org.openide.util.Exceptions;
62
import org.w3c.dom.Document;
63
import org.w3c.dom.Document;
63
import org.w3c.dom.Element;
64
import org.w3c.dom.Element;
Lines 358-365 Link Here
358
        }
359
        }
359
        Util.putPrimaryConfigurationData(helper, data);
360
        Util.putPrimaryConfigurationData(helper, data);
360
    }
361
    }
361
    
362
362
    
363
    /**
364
     * Returns {@link Element} for {@link JavaCompilationUnit}.
365
     * @param aux AuxiliaryConfiguration instance
366
     * @return {@link Element} representing JavaCompilationUnit instances or null
367
     */
368
    public static Element getJavaCompilationUnits (final AuxiliaryConfiguration aux) {
369
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
370
        if (data == null) {
371
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
372
        }
373
        if (data == null) {
374
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
375
        }
376
        return data;
377
    }
378
363
    /**
379
    /**
364
     * Read Java compilation units from the project.
380
     * Read Java compilation units from the project.
365
     * @param helper AntProjectHelper instance
381
     * @param helper AntProjectHelper instance
Lines 370-379 Link Here
370
            AntProjectHelper helper, AuxiliaryConfiguration aux) {
386
            AntProjectHelper helper, AuxiliaryConfiguration aux) {
371
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
387
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
372
        List<JavaCompilationUnit> list = new ArrayList<JavaCompilationUnit>();
388
        List<JavaCompilationUnit> list = new ArrayList<JavaCompilationUnit>();
373
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
389
        final Element data = getJavaCompilationUnits(aux);
374
        if (data == null) {
375
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
376
        }
377
        if (data == null) {
390
        if (data == null) {
378
            return list;
391
            return list;
379
        }
392
        }
Lines 432-437 Link Here
432
            AuxiliaryConfiguration aux, List<JavaCompilationUnit> compUnits) {
445
            AuxiliaryConfiguration aux, List<JavaCompilationUnit> compUnits) {
433
        //assert ProjectManager.mutex().isWriteAccess();
446
        //assert ProjectManager.mutex().isWriteAccess();
434
        // First check whether we need /2 data.
447
        // First check whether we need /2 data.
448
        boolean need3 = false;
449
        for (JavaCompilationUnit unit : compUnits) {
450
            if (needsNS3(unit)) {
451
                need3 = true;
452
                break;
453
            }
454
        }
455
        // Second check whether we need /2 data.
435
        boolean need2 = false;
456
        boolean need2 = false;
436
        for (JavaCompilationUnit unit : compUnits) {
457
        for (JavaCompilationUnit unit : compUnits) {
437
            if (unit.isTests || (unit.javadoc != null && !unit.javadoc.isEmpty())) {
458
            if (unit.isTests || (unit.javadoc != null && !unit.javadoc.isEmpty())) {
Lines 440-465 Link Here
440
            }
461
            }
441
        }
462
        }
442
        String namespace;
463
        String namespace;
443
        // Look for existing /2 data.
464
        // Look for existing /3 data.
444
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
465
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
445
        if (data != null) {
466
        if (data != null) {
446
            // Fine, use it as is.
467
            namespace = JavaProjectNature.NS_JAVA_3;
447
            namespace = JavaProjectNature.NS_JAVA_2;
468
        }
448
        } else {
469
        else {
449
            // Or, for existing /1 data.
470
            // Look for existing /2 data and possibly update to /3
450
            namespace = need2 ? JavaProjectNature.NS_JAVA_2 : JavaProjectNature.NS_JAVA_1;
471
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
451
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
452
            if (data != null) {
472
            if (data != null) {
453
                if (need2) {
473
                namespace = need3 ? JavaProjectNature.NS_JAVA_3 : JavaProjectNature.NS_JAVA_2;
454
                    // Have to upgrade.
474
                if (need3) {
455
                    aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
475
                    // Have to upgrade to /3
476
                    aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
456
                    data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
477
                    data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
457
                        createElementNS(JavaProjectNature.NS_JAVA_2, JavaProjectNature.EL_JAVA);
478
                        createElementNS(JavaProjectNature.NS_JAVA_3, JavaProjectNature.EL_JAVA);
458
                } // else can use it as is
479
                }
459
            } else {
480
            } else {
460
                // Create /1 or /2 data acc. to need.
481
                //Look for existing /1 and possibly update to /2 or /3 as needed
461
                data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
482
                data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
462
                    createElementNS(namespace, JavaProjectNature.EL_JAVA);
483
                namespace = need3 ? JavaProjectNature.NS_JAVA_3 : need2 ? JavaProjectNature.NS_JAVA_2 : JavaProjectNature.NS_JAVA_1;
484
                if (data != null) {
485
486
                    if (need3) {
487
                        // Have to upgrade to /3
488
                        aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
489
                        data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
490
                            createElementNS(JavaProjectNature.NS_JAVA_3, JavaProjectNature.EL_JAVA);
491
                    }
492
                    else if (need2) {
493
                        // Have to upgrade to /2
494
                        aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
495
                        data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
496
                            createElementNS(JavaProjectNature.NS_JAVA_2, JavaProjectNature.EL_JAVA);
497
                    } // else can use it as is
498
                } else {
499
                    // Create a new /1, /2 or /3 data acc. to need.
500
                    data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
501
                        createElementNS(namespace, JavaProjectNature.EL_JAVA);
502
                }
463
            }
503
            }
464
        }
504
        }
465
        Document doc = data.getOwnerDocument();
505
        Document doc = data.getOwnerDocument();
Lines 478-484 Link Here
478
                }
518
                }
479
            }
519
            }
480
            if (cu.isTests) {
520
            if (cu.isTests) {
481
                assert namespace.equals(JavaProjectNature.NS_JAVA_2);
521
                assert namespace.equals(JavaProjectNature.NS_JAVA_2) || namespace.equals(JavaProjectNature.NS_JAVA_3);
482
                cuEl.appendChild(doc.createElementNS(namespace, "unit-tests")); // NOI18N
522
                cuEl.appendChild(doc.createElementNS(namespace, "unit-tests")); // NOI18N
483
            }
523
            }
484
            if (cu.classpath != null) {
524
            if (cu.classpath != null) {
Lines 502-508 Link Here
502
                Iterator it3 = cu.javadoc.iterator();
542
                Iterator it3 = cu.javadoc.iterator();
503
                while (it3.hasNext()) {
543
                while (it3.hasNext()) {
504
                    String javadoc = (String) it3.next();
544
                    String javadoc = (String) it3.next();
505
                    assert namespace.equals(JavaProjectNature.NS_JAVA_2);
545
                    assert namespace.equals(JavaProjectNature.NS_JAVA_2) || namespace.equals(JavaProjectNature.NS_JAVA_3);
506
                    el = doc.createElementNS(namespace, "javadoc-built-to"); // NOI18N
546
                    el = doc.createElementNS(namespace, "javadoc-built-to"); // NOI18N
507
                    el.appendChild(doc.createTextNode(javadoc));
547
                    el.appendChild(doc.createTextNode(javadoc));
508
                    cuEl.appendChild(el);
548
                    cuEl.appendChild(el);
Lines 517-523 Link Here
517
        aux.putConfigurationFragment(data, true);
557
        aux.putConfigurationFragment(data, true);
518
    }
558
    }
519
559
520
    
521
    /**
560
    /**
522
     * Structure describing compilation unit.
561
     * Structure describing compilation unit.
523
     * Data in the struct are in the same format as they are stored in XML.
562
     * Data in the struct are in the same format as they are stored in XML.
Lines 959-962 Link Here
959
        props.setProperty(key, value);
998
        props.setProperty(key, value);
960
    }
999
    }
961
1000
1001
    private static boolean needsNS3(final JavaCompilationUnit unit) {
1002
        if (unit.classpath != null) {
1003
            for (JavaCompilationUnit.CP cp : unit.classpath) {
1004
                if ("processor".equals(cp.mode)) {  //NOI18N
1005
                    return true;
1006
                }
1007
            }
1008
        }
1009
        if (unit.sourceLevel != null) {
1010
            final SpecificationVersion JAVA_6 = new SpecificationVersion("1.6");  //NOI18N
1011
            final SpecificationVersion JAvA_7 = new SpecificationVersion("1.7");  //NOI18N
1012
            final SpecificationVersion current = new SpecificationVersion(unit.sourceLevel);
1013
            if (JAVA_6.equals(current) || JAvA_7.equals(current)) {
1014
                return true;
1015
            }
1016
        }
1017
        return false;
1018
    }
1019
962
}
1020
}
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectNature.java (+1 lines)
Lines 68-73 Link Here
68
68
69
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
69
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
70
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
70
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
71
    public static final String NS_JAVA_3 = "http://www.netbeans.org/ns/freeform-project-java/3"; //NOI18N
71
    public static final String EL_JAVA = "java-data"; // NOI18N
72
    public static final String EL_JAVA = "java-data"; // NOI18N
72
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
73
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
73
    
74
    
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java (-1 / +1 lines)
Lines 72-78 Link Here
72
    }
72
    }
73
73
74
    public JavadocForBinaryQuery.Result findJavadoc(URL binaryRoot) {
74
    public JavadocForBinaryQuery.Result findJavadoc(URL binaryRoot) {
75
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
75
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
76
        if (data != null) {
76
        if (data != null) {
77
            for (Element cu : Util.findSubElements(data)) {
77
            for (Element cu : Util.findSubElements(data)) {
78
                assert cu.getLocalName().equals("compilation-unit") : cu;
78
                assert cu.getLocalName().equals("compilation-unit") : cu;
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/LookupProviderImpl.java (-12 / +31 lines)
Lines 100-107 Link Here
100
    }
100
    }
101
    
101
    
102
    public static boolean isMyProject(AuxiliaryConfiguration aux) {
102
    public static boolean isMyProject(AuxiliaryConfiguration aux) {
103
        return aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true) != null ||
103
        return JavaProjectGenerator.getJavaCompilationUnits(aux) != null;
104
               aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true) != null;
105
    }
104
    }
106
    
105
    
107
    private static final class HelpIDFragmentProviderImpl implements HelpIDFragmentProvider {
106
    private static final class HelpIDFragmentProviderImpl implements HelpIDFragmentProvider {
Lines 143-154 Link Here
143
        }
142
        }
144
143
145
        public Element getConfigurationFragment(String elementName, String namespace, boolean shared) {
144
        public Element getConfigurationFragment(String elementName, String namespace, boolean shared) {
146
            if (elementName.equals(JavaProjectNature.EL_JAVA) && namespace.equals(JavaProjectNature.NS_JAVA_2) && shared) {
145
            if (elementName.equals(JavaProjectNature.EL_JAVA) && shared) {
147
                Element nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
146
                Element nue = null;
148
                if (nue == null) {
147
                if (namespace.equals(JavaProjectNature.NS_JAVA_3)) {
149
                    Element old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
148
                    nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
150
                    if (old != null) {
149
                    if (nue == null) {
151
                        nue = upgradeSchema(old);
150
                        Element old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
151
                        if (old != null) {
152
                            nue = upgradeSchema(old);
153
                        } else {
154
                            old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
155
                            if (old != null) {
156
                                nue = upgradeSchema(old);
157
                            }
158
                        }
159
                    }
160
                } else if (namespace.equals(JavaProjectNature.NS_JAVA_2)) {
161
                    nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
162
                    if (nue == null) {
163
                        Element old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
164
                        if (old != null) {
165
                            nue = upgradeSchema(old, JavaProjectNature.NS_JAVA_2);
166
                        }
152
                    }
167
                    }
153
                }
168
                }
154
                return nue;
169
                return nue;
Lines 166-178 Link Here
166
        }
181
        }
167
        
182
        
168
    }
183
    }
169
    
184
170
    static Element upgradeSchema(Element old) {
185
    static Element upgradeSchema(Element old) {
186
        return upgradeSchema(old, JavaProjectNature.NS_JAVA_3);
187
    }
188
189
    static Element upgradeSchema(final Element old, final String to) {
171
        Document doc = old.getOwnerDocument();
190
        Document doc = old.getOwnerDocument();
172
        Element nue = doc.createElementNS(JavaProjectNature.NS_JAVA_2, JavaProjectNature.EL_JAVA);
191
        Element nue = doc.createElementNS(to, JavaProjectNature.EL_JAVA);
173
        copyXMLTree(doc, old, nue, JavaProjectNature.NS_JAVA_2);
192
        copyXMLTree(doc, old, nue, to);
174
        return nue;
193
        return nue;
175
    }  
194
    }
176
    // Copied from org.netbeans.modules.java.j2seproject.UpdateHelper with changes; could be an API eventually:
195
    // Copied from org.netbeans.modules.java.j2seproject.UpdateHelper with changes; could be an API eventually:
177
    private static void copyXMLTree(Document doc, Element from, Element to, String newNamespace) {
196
    private static void copyXMLTree(Document doc, Element from, Element to, String newNamespace) {
178
        NodeList nl = from.getChildNodes();
197
        NodeList nl = from.getChildNodes();
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java (-1 / +1 lines)
Lines 96-102 Link Here
96
        if (roots == null) {
96
        if (roots == null) {
97
            // Need to compute it. Easiest to compute them all at once.
97
            // Need to compute it. Easiest to compute them all at once.
98
            roots = new HashMap<URL,FileObject[]>();
98
            roots = new HashMap<URL,FileObject[]>();
99
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
99
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
100
            if (java == null) {
100
            if (java == null) {
101
                return null;
101
                return null;
102
            }
102
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java (-2 / +2 lines)
Lines 98-104 Link Here
98
            }
98
            }
99
        }
99
        }
100
        // Need to compute it.
100
        // Need to compute it.
101
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
101
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
102
        if (java == null) {
102
        if (java == null) {
103
            return null;
103
            return null;
104
        }
104
        }
Lines 133-139 Link Here
133
     * Get the source level indicated in a compilation unit (or null if none is indicated).
133
     * Get the source level indicated in a compilation unit (or null if none is indicated).
134
     */
134
     */
135
    private String getLevel(Element compilationUnitEl) {
135
    private String getLevel(Element compilationUnitEl) {
136
        Element sourceLevelEl = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_2);
136
        Element sourceLevelEl = Util.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
137
        if (sourceLevelEl != null) {
137
        if (sourceLevelEl != null) {
138
            return Util.findText(sourceLevelEl);
138
            return Util.findText(sourceLevelEl);
139
        } else {
139
        } else {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java (-2 / +2 lines)
Lines 115-125 Link Here
115
    private URL[][] findSourcesAndTests() {
115
    private URL[][] findSourcesAndTests() {
116
        List<URL> sources = new ArrayList<URL>();
116
        List<URL> sources = new ArrayList<URL>();
117
        List<URL> tests = new ArrayList<URL>();
117
        List<URL> tests = new ArrayList<URL>();
118
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
118
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
119
        if (data != null) {
119
        if (data != null) {
120
            for (Element cu : Util.findSubElements(data)) {
120
            for (Element cu : Util.findSubElements(data)) {
121
                assert cu.getLocalName().equals("compilation-unit") : cu;
121
                assert cu.getLocalName().equals("compilation-unit") : cu;
122
                boolean isTests = Util.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_2) != null; // NOI18N
122
                boolean isTests = Util.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_3) != null; // NOI18N
123
                for (Element pr : Util.findSubElements(cu)) {
123
                for (Element pr : Util.findSubElements(cu)) {
124
                    if (pr.getLocalName().equals("package-root")) { // NOI18N
124
                    if (pr.getLocalName().equals("package-root")) { // NOI18N
125
                        String rawtext = Util.findText(pr);
125
                        String rawtext = Util.findText(pr);
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java (-4 / +1 lines)
Lines 105-114 Link Here
105
        int compilationUnitsMissingBuiltTo = 0;
105
        int compilationUnitsMissingBuiltTo = 0;
106
        int compilationUnitsMultipleRoots = 0;
106
        int compilationUnitsMultipleRoots = 0;
107
        Set<String> classpathEntries = new HashSet<String>();
107
        Set<String> classpathEntries = new HashSet<String>();
108
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
108
        Element java = JavaProjectGenerator.getJavaCompilationUnits(aux);
109
        if (java == null) {
110
            java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
111
        }
112
        if (java != null) {
109
        if (java != null) {
113
            for (Element compilationUnitEl : Util.findSubElements(java)) {
110
            for (Element compilationUnitEl : Util.findSubElements(java)) {
114
                compilationUnits++;
111
                compilationUnits++;
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/resources/freeform-project-java-3.xsd (+108 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
7
8
The contents of this file are subject to the terms of either the GNU
9
General Public License Version 2 only ("GPL") or the Common
10
Development and Distribution License("CDDL") (collectively, the
11
"License"). You may not use this file except in compliance with the
12
License. You can obtain a copy of the License at
13
http://www.netbeans.org/cddl-gplv2.html
14
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
specific language governing permissions and limitations under the
16
License.  When distributing the software, include this License Header
17
Notice in each file and include the License file at
18
nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
19
particular file as subject to the "Classpath" exception as provided
20
by Sun in the GPL Version 2 section of the License file that
21
accompanied this code. If applicable, add the following below the
22
License Header, with the fields enclosed by brackets [] replaced by
23
your own identifying information:
24
"Portions Copyrighted [year] [name of copyright owner]"
25
26
Contributor(s):
27
28
The Original Software is NetBeans. The Initial Developer of the Original
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
Microsystems, Inc. All Rights Reserved.
31
32
If you wish your version of this file to be governed by only the CDDL
33
or only the GPL Version 2, indicate your decision by adding
34
"[Contributor] elects to include this software in this distribution
35
under the [CDDL or GPL Version 2] license." If you do not indicate a
36
single choice of license, a recipient has the option to distribute
37
your version of this file under either the CDDL, the GPL Version 2 or
38
to extend the choice of license to its licensees as provided above.
39
However, if you add GPL Version 2 code and therefore, elected the GPL
40
Version 2 license, then the option applies only if the new code is
41
made subject to such option by the copyright holder.
42
-->
43
44
<!--
45
XML Schema to define the project.xml for a freeform project.
46
Cf. http://projects.netbeans.org/buildsys/design.html#freeform
47
-->
48
49
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
50
            targetNamespace="http://www.netbeans.org/ns/freeform-project-java/3"
51
            xmlns="http://www.netbeans.org/ns/freeform-project-java/3"
52
            elementFormDefault="qualified">
53
54
    <xsd:element name="java-data">
55
        <xsd:complexType>
56
            <xsd:sequence>
57
                <xsd:element name="compilation-unit" minOccurs="0" maxOccurs="unbounded" type="compilation-unit"/>
58
            </xsd:sequence>
59
        </xsd:complexType>
60
    </xsd:element>
61
    
62
    <xsd:complexType name="compilation-unit">
63
        <xsd:sequence>
64
            <xsd:element name="package-root" maxOccurs="unbounded" type="substitutable-text"/>
65
            <xsd:element name="unit-tests" minOccurs="0"><xsd:complexType/></xsd:element>
66
            <xsd:element name="classpath" minOccurs="0" maxOccurs="unbounded">
67
                <!-- XXX use schema to declare that the mode must be unique within this group -->
68
                <xsd:complexType>
69
                    <xsd:simpleContent>
70
                        <xsd:extension base="substitutable-text">
71
                            <xsd:attribute name="mode" use="required">
72
                                <xsd:simpleType>
73
                                    <xsd:restriction base="xsd:NMTOKEN">
74
                                        <xsd:enumeration value="boot"/>
75
                                        <xsd:enumeration value="compile"/>
76
                                        <xsd:enumeration value="execute"/>
77
                                        <xsd:enumeration value="processor"/>
78
                                    </xsd:restriction>
79
                                </xsd:simpleType>
80
                            </xsd:attribute>
81
                        </xsd:extension>
82
                    </xsd:simpleContent>
83
                </xsd:complexType>
84
            </xsd:element>
85
            <xsd:element name="built-to" minOccurs="0" maxOccurs="unbounded" type="substitutable-text"/>
86
            <xsd:element name="javadoc-built-to" minOccurs="0" maxOccurs="unbounded" type="substitutable-text"/>
87
            <xsd:element name="source-level" minOccurs="0">
88
                <xsd:simpleType>
89
                    <xsd:restriction base="xsd:NMTOKEN">
90
                        <xsd:enumeration value="1.3"/>
91
                        <xsd:enumeration value="1.4"/>
92
                        <xsd:enumeration value="1.5"/>
93
                        <xsd:enumeration value="1.6"/>
94
                        <xsd:enumeration value="1.7"/>
95
                    </xsd:restriction>
96
                </xsd:simpleType>
97
            </xsd:element>
98
        </xsd:sequence>
99
    </xsd:complexType>
100
101
    <!-- XXX: this type was copied from freeform-project-general.xsd -->
102
    <!-- Some text that might be substituted with Ant property references. -->
103
    <xsd:simpleType name="substitutable-text">
104
        <xsd:restriction base="xsd:string">
105
            <!-- XXX limit by regexp, perhaps -->
106
        </xsd:restriction>
107
    </xsd:simpleType>
108
</xsd:schema>
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/ui/Bundle.properties (+2 lines)
Lines 75-80 Link Here
75
LBL_SourceFoldersPanel_JDK13=JDK 1.3
75
LBL_SourceFoldersPanel_JDK13=JDK 1.3
76
LBL_SourceFoldersPanel_JDK14=JDK 1.4
76
LBL_SourceFoldersPanel_JDK14=JDK 1.4
77
LBL_SourceFoldersPanel_JDK15=JDK 1.5
77
LBL_SourceFoldersPanel_JDK15=JDK 1.5
78
LBL_SourceFoldersPanel_JDK16=JDK 1.6
79
LBL_SourceFoldersPanel_JDK17=JDK 1.7
78
LBL_SourceFoldersPanel_Package=Package Folder
80
LBL_SourceFoldersPanel_Package=Package Folder
79
LBL_SourceFoldersPanel_Label=Label
81
LBL_SourceFoldersPanel_Label=Label
80
BTN_SourceFoldersPanel_addTestFolder=Add F&older...
82
BTN_SourceFoldersPanel_addTestFolder=Add F&older...
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java (-4 / +12 lines)
Lines 143-151 Link Here
143
    }
143
    }
144
    
144
    
145
    private void initSourceLevel() {
145
    private void initSourceLevel() {
146
        sourceLevel.addItem(org.openide.util.NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK13")); // NOI18N
146
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK13")); // NOI18N
147
        sourceLevel.addItem(org.openide.util.NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK14")); // NOI18N
147
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK14")); // NOI18N
148
        sourceLevel.addItem(org.openide.util.NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK15")); // NOI18N
148
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK15")); // NOI18N
149
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK16")); // NOI18N
150
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK17")); // NOI18N
149
    }
151
    }
150
    
152
    
151
    private void updateButtons() {
153
    private void updateButtons() {
Lines 176-182 Link Here
176
            sourceLevel.setSelectedIndex(1);
178
            sourceLevel.setSelectedIndex(1);
177
        } else if (sourceLevelValue.equals("1.5")) { // NOI18N
179
        } else if (sourceLevelValue.equals("1.5")) { // NOI18N
178
            sourceLevel.setSelectedIndex(2);
180
            sourceLevel.setSelectedIndex(2);
179
        } else {
181
        } else if (sourceLevelValue.equals("1.6")) { // NOI18N
182
            sourceLevel.setSelectedIndex(3);
183
        } else if (sourceLevelValue.equals("1.7")) { // NOI18N
184
            sourceLevel.setSelectedIndex(4);
185
        }else {
180
            // user specified some other value in project.xml
186
            // user specified some other value in project.xml
181
            sourceLevel.addItem(sourceLevelValue);
187
            sourceLevel.addItem(sourceLevelValue);
182
            sourceLevel.setSelectedIndex(3);
188
            sourceLevel.setSelectedIndex(3);
Lines 192-197 Link Here
192
            case 0: return "1.3"; // NOI18N
198
            case 0: return "1.3"; // NOI18N
193
            case 1: return "1.4"; // NOI18N
199
            case 1: return "1.4"; // NOI18N
194
            case 2: return "1.5"; // NOI18N
200
            case 2: return "1.5"; // NOI18N
201
            case 3: return "1.6"; // NOI18N
202
            case 4: return "1.7"; // NOI18N
195
            default: return null;
203
            default: return null;
196
        }
204
        }
197
    }
205
    }
(-)a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectNatureTest.java (-6 / +17 lines)
Lines 59-77 Link Here
59
        super(name);
59
        super(name);
60
    }
60
    }
61
61
62
    public void testUpgradeSchema() throws Exception {
62
    public void testUpgradeSchema1to2() throws Exception {
63
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_1, JavaProjectNature.NS_JAVA_2);
64
    }
65
66
    public void testUpgradeSchema2to3() throws Exception {
67
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_2, JavaProjectNature.NS_JAVA_3);
68
    }
69
70
    public void testUpgradeSchema1to3() throws Exception {
71
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_1, JavaProjectNature.NS_JAVA_3);
72
    }
73
74
    private void upgradeSchemaTestImpl(String from, String to) throws Exception {
63
        // Formatting has to be the same as Xerces' formatter produces for this test to pass:
75
        // Formatting has to be the same as Xerces' formatter produces for this test to pass:
64
        String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
76
        String xml1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
65
                      "<java-data xmlns=\"http://www.netbeans.org/ns/freeform-project-java/1\">\n" +
77
                      "<java-data xmlns=\""+from+"\">\n" +
66
                      "    <!-- Hello there. -->\n" +
78
                      "    <!-- Hello there. -->\n" +
67
                      "    <foo bar=\"baz\" quux=\"whatever\">hello</foo>\n" +
79
                      "    <foo bar=\"baz\" quux=\"whatever\">hello</foo>\n" +
68
                      "    <x>OK</x>\n" +
80
                      "    <x>OK</x>\n" +
69
                      "</java-data>\n";
81
                      "</java-data>\n";
70
        String xml2expected = xml1.replaceAll("/1", "/2");
82
        String xml2expected = xml1.replaceAll(from, to);
71
        Document doc1 = XMLUtil.parse(new InputSource(new StringReader(xml1)), false, true, null, null);
83
        Document doc1 = XMLUtil.parse(new InputSource(new StringReader(xml1)), false, true, null, null);
72
        Element el1 = doc1.getDocumentElement();
84
        Element el1 = doc1.getDocumentElement();
73
        Element el2 = LookupProviderImpl.upgradeSchema(el1);
85
        Element el2 = LookupProviderImpl.upgradeSchema(el1,to);
74
        Document doc2 = XMLUtil.createDocument(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, null, null);
86
        Document doc2 = XMLUtil.createDocument(JavaProjectNature.EL_JAVA, to, null, null);
75
        doc2.removeChild(doc2.getDocumentElement());
87
        doc2.removeChild(doc2.getDocumentElement());
76
        doc2.appendChild(doc2.importNode(el2, true));
88
        doc2.appendChild(doc2.importNode(el2, true));
77
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
89
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
Lines 79-83 Link Here
79
        String xml2actual = baos.toString("UTF-8").replaceAll(System.getProperty("line.separator"), "\n");
91
        String xml2actual = baos.toString("UTF-8").replaceAll(System.getProperty("line.separator"), "\n");
80
        assertEquals("Correct upgrade result", xml2expected, xml2actual);
92
        assertEquals("Correct upgrade result", xml2expected, xml2actual);
81
    }
93
    }
82
    
83
}
94
}

Return to bug 181439