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

(-)a/java.freeform/src/org/netbeans/modules/java/freeform/AnnotationProcessingQueryImpl.java (-4 / +4 lines)
Lines 147-153 Link Here
147
            final Map<FileObject,R> added = new HashMap<FileObject, R>();
147
            final Map<FileObject,R> added = new HashMap<FileObject, R>();
148
            final Map<FileObject,R> retained = new HashMap<FileObject, R>();
148
            final Map<FileObject,R> retained = new HashMap<FileObject, R>();
149
149
150
            final Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
150
            final Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
151
            if (java != null) {
151
            if (java != null) {
152
                for (Element compilationUnit : XMLUtil.findSubElements(java)) {
152
                for (Element compilationUnit : XMLUtil.findSubElements(java)) {
153
                    assert compilationUnit.getLocalName().equals("compilation-unit") : compilationUnit;
153
                    assert compilationUnit.getLocalName().equals("compilation-unit") : compilationUnit;
Lines 281-288 Link Here
281
            if (ap != null) {
281
            if (ap != null) {
282
                for (Element e : XMLUtil.findSubElements(ap)) {
282
                for (Element e : XMLUtil.findSubElements(ap)) {
283
                    if (e.getLocalName().equals(EL_PROCESSOR_OPTION)) {
283
                    if (e.getLocalName().equals(EL_PROCESSOR_OPTION)) {
284
                        final Element keyElement = XMLUtil.findElement(e, "key", JavaProjectNature.NS_JAVA_3);  //NOI18N
284
                        final Element keyElement = XMLUtil.findElement(e, "key", JavaProjectNature.NS_JAVA_LASTEST);  //NOI18N
285
                        final Element valueElement = XMLUtil.findElement(e, "value", JavaProjectNature.NS_JAVA_3);  //NOI18N
285
                        final Element valueElement = XMLUtil.findElement(e, "value", JavaProjectNature.NS_JAVA_LASTEST);  //NOI18N
286
                        if (keyElement == null || valueElement == null) {
286
                        if (keyElement == null || valueElement == null) {
287
                            continue;
287
                            continue;
288
                        }
288
                        }
Lines 322-328 Link Here
322
        }
322
        }
323
323
324
        private Element findAP(final Element cu) {
324
        private Element findAP(final Element cu) {
325
            return cu == null ? null : XMLUtil.findElement(cu, AnnotationProcessingQueryImpl.EL_ANNOTATION_PROCESSING, JavaProjectNature.NS_JAVA_3);
325
            return cu == null ? null : XMLUtil.findElement(cu, AnnotationProcessingQueryImpl.EL_ANNOTATION_PROCESSING, JavaProjectNature.NS_JAVA_LASTEST);
326
        }
326
        }
327
327
328
    }
328
    }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java (-5 / +5 lines)
Lines 193-199 Link Here
193
            }
193
            }
194
        }
194
        }
195
        // Need to create it.
195
        // Need to create it.
196
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
196
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
197
        if (java == null) {
197
        if (java == null) {
198
            return null;
198
            return null;
199
        }
199
        }
Lines 258-264 Link Here
258
            for (String type : TYPES) {
258
            for (String type : TYPES) {
259
                _registeredClasspaths.put(type, new HashSet<ClassPath>());
259
                _registeredClasspaths.put(type, new HashSet<ClassPath>());
260
            }
260
            }
261
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
261
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
262
            if (java == null) {
262
            if (java == null) {
263
                return;
263
                return;
264
            }
264
            }
Lines 490-498 Link Here
490
    }
490
    }
491
491
492
    private List<URL> createProcessorClasspath(Element compilationUnitEl) {
492
    private List<URL> createProcessorClasspath(Element compilationUnitEl) {
493
        final Element ap = XMLUtil.findElement(compilationUnitEl, AnnotationProcessingQueryImpl.EL_ANNOTATION_PROCESSING, JavaProjectNature.NS_JAVA_3);
493
        final Element ap = XMLUtil.findElement(compilationUnitEl, AnnotationProcessingQueryImpl.EL_ANNOTATION_PROCESSING, JavaProjectNature.NS_JAVA_LASTEST);
494
        if (ap != null) {
494
        if (ap != null) {
495
            final Element path = XMLUtil.findElement(ap, AnnotationProcessingQueryImpl.EL_PROCESSOR_PATH, JavaProjectNature.NS_JAVA_3);
495
            final Element path = XMLUtil.findElement(ap, AnnotationProcessingQueryImpl.EL_PROCESSOR_PATH, JavaProjectNature.NS_JAVA_LASTEST);
496
            if (path != null) {
496
            if (path != null) {
497
                return createClasspath(path);
497
                return createClasspath(path);
498
            }
498
            }
Lines 573-579 Link Here
573
        }
573
        }
574
        
574
        
575
        private Element findCompilationUnit() {
575
        private Element findCompilationUnit() {
576
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
576
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
577
            if (java == null) {
577
            if (java == null) {
578
                return null;
578
                return null;
579
            }
579
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java (-2 / +2 lines)
Lines 775-781 Link Here
775
    }
775
    }
776
    
776
    
777
    private List<Element> compilationUnits() {
777
    private List<Element> compilationUnits() {
778
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
778
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
779
        if (java == null) {
779
        if (java == null) {
780
            return Collections.emptyList();
780
            return Collections.emptyList();
781
        }
781
        }
Lines 909-915 Link Here
909
    String findSourceLevel(String sources) {
909
    String findSourceLevel(String sources) {
910
        Element compilationUnitEl = findCompilationUnit(sources);
910
        Element compilationUnitEl = findCompilationUnit(sources);
911
        if (compilationUnitEl != null) {
911
        if (compilationUnitEl != null) {
912
            Element sourceLevel = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
912
            Element sourceLevel = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_LASTEST);
913
            if (sourceLevel != null) {
913
            if (sourceLevel != null) {
914
                return XMLUtil.findText(sourceLevel);
914
                return XMLUtil.findText(sourceLevel);
915
            }
915
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java (-1 / +1 lines)
Lines 97-103 Link Here
97
            ERR.log(ErrorManager.INFORMATIONAL, "JavaFreeformFileBuiltQuery.createDelegateTo start"); // NOI18N
97
            ERR.log(ErrorManager.INFORMATIONAL, "JavaFreeformFileBuiltQuery.createDelegateTo start"); // NOI18N
98
        }
98
        }
99
        
99
        
100
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
100
        Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
101
        List<String> from = new ArrayList<String>();
101
        List<String> from = new ArrayList<String>();
102
        List<String> to   = new ArrayList<String>();
102
        List<String> to   = new ArrayList<String>();
103
        
103
        
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java (-78 / +49 lines)
Lines 375-388 Link Here
375
     * @return {@link Element} representing JavaCompilationUnit instances or null
375
     * @return {@link Element} representing JavaCompilationUnit instances or null
376
     */
376
     */
377
    public static Element getJavaCompilationUnits (final AuxiliaryConfiguration aux) {
377
    public static Element getJavaCompilationUnits (final AuxiliaryConfiguration aux) {
378
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
378
        for (String ns : JavaProjectNature.JAVA_NAMESPACES) {
379
        if (data == null) {
379
            Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, ns, true);
380
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
380
            if (data != null) return data;
381
        }
381
        }
382
        if (data == null) {
382
        return null;
383
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
384
        }
385
        return data;
386
    }
383
    }
387
384
388
    /**
385
    /**
Lines 436-442 Link Here
436
                    continue;
433
                    continue;
437
                }
434
                }
438
                if ("annotation-processing".equals(el.getLocalName())&&         //NOI18N
435
                if ("annotation-processing".equals(el.getLocalName())&&         //NOI18N
439
                    JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) {
436
                    JavaProjectNature.namespaceAtLeast(el.getNamespaceURI(), JavaProjectNature.NS_JAVA_3)) {
440
                    cu.annotationPorocessing = new JavaCompilationUnit.AnnotationProcessing();
437
                    cu.annotationPorocessing = new JavaCompilationUnit.AnnotationProcessing();
441
                    cu.annotationPorocessing.trigger = EnumSet.<AnnotationProcessingQuery.Trigger>noneOf(AnnotationProcessingQuery.Trigger.class);
438
                    cu.annotationPorocessing.trigger = EnumSet.<AnnotationProcessingQuery.Trigger>noneOf(AnnotationProcessingQuery.Trigger.class);
442
                    cu.annotationPorocessing.processors = new ArrayList<String>();
439
                    cu.annotationPorocessing.processors = new ArrayList<String>();
Lines 445-461 Link Here
445
                        final String localName = apEl.getLocalName();
442
                        final String localName = apEl.getLocalName();
446
                        if ("scan-trigger".equals(localName)) { //NOI18N
443
                        if ("scan-trigger".equals(localName)) { //NOI18N
447
                            cu.annotationPorocessing.trigger.add(AnnotationProcessingQuery.Trigger.ON_SCAN);
444
                            cu.annotationPorocessing.trigger.add(AnnotationProcessingQuery.Trigger.ON_SCAN);
448
                        } else if ("editor-trigger".equals(localName) && JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) {   //NOI18N
445
                        } else if ("editor-trigger".equals(localName)) {   //NOI18N
449
                            cu.annotationPorocessing.trigger.add(AnnotationProcessingQuery.Trigger.IN_EDITOR);
446
                            cu.annotationPorocessing.trigger.add(AnnotationProcessingQuery.Trigger.IN_EDITOR);
450
                        } else if ("source-output".equals(localName) && JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) {
447
                        } else if ("source-output".equals(localName)) {
451
                            cu.annotationPorocessing.sourceOutput = XMLUtil.findText(apEl);
448
                            cu.annotationPorocessing.sourceOutput = XMLUtil.findText(apEl);
452
                        } else if ("processor-path".equals(localName) && JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) {    //NOI18N
449
                        } else if ("processor-path".equals(localName)) {    //NOI18N
453
                            cu.annotationPorocessing.processorPath = XMLUtil.findText(apEl);
450
                            cu.annotationPorocessing.processorPath = XMLUtil.findText(apEl);
454
                        } else if ("processor".equals(localName) && JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) { //NOI18N
451
                        } else if ("processor".equals(localName)) { //NOI18N
455
                            cu.annotationPorocessing.processors.add(XMLUtil.findText(apEl));
452
                            cu.annotationPorocessing.processors.add(XMLUtil.findText(apEl));
456
                        } else if ("processor-option".equals(localName) && JavaProjectNature.NS_JAVA_3.equals(el.getNamespaceURI())) {  //NOI18N
453
                        } else if ("processor-option".equals(localName)) {  //NOI18N
457
                            final Element keyEl = XMLUtil.findElement(apEl, "key", JavaProjectNature.NS_JAVA_3);    //NOI18N
454
                            final Element keyEl = XMLUtil.findElement(apEl, "key", el.getNamespaceURI());    //NOI18N
458
                            final Element valueEl = XMLUtil.findElement(apEl, "value", JavaProjectNature.NS_JAVA_3);     //NOI18N
455
                            final Element valueEl = XMLUtil.findElement(apEl, "value", el.getNamespaceURI());     //NOI18N
459
                            if (keyEl != null && valueEl != null) {
456
                            if (keyEl != null && valueEl != null) {
460
                                final String key = XMLUtil.findText(keyEl);
457
                                final String key = XMLUtil.findText(keyEl);
461
                                final String value = XMLUtil.findText(valueEl);
458
                                final String value = XMLUtil.findText(valueEl);
Lines 486-548 Link Here
486
    public static void putJavaCompilationUnits(AntProjectHelper helper, 
483
    public static void putJavaCompilationUnits(AntProjectHelper helper, 
487
            AuxiliaryConfiguration aux, List<JavaCompilationUnit> compUnits) {
484
            AuxiliaryConfiguration aux, List<JavaCompilationUnit> compUnits) {
488
        //assert ProjectManager.mutex().isWriteAccess();
485
        //assert ProjectManager.mutex().isWriteAccess();
489
        // First check if we need /3 data.
486
        int requiredVersion = 1;
490
        boolean need3 = false;
487
        
488
        // detect minimal required namespace:
491
        for (JavaCompilationUnit unit : compUnits) {
489
        for (JavaCompilationUnit unit : compUnits) {
492
            if (needsNS3(unit)) {
490
            requiredVersion = Math.max(requiredVersion, minimalNS(unit));
493
                need3 = true;
491
        }
494
                break;
492
        
493
        String namespace;
494
        
495
        switch (requiredVersion) {
496
            case 4: namespace = JavaProjectNature.NS_JAVA_4; break;
497
            case 3: namespace = JavaProjectNature.NS_JAVA_3; break;
498
            case 2: namespace = JavaProjectNature.NS_JAVA_2; break;
499
            default: namespace = JavaProjectNature.NS_JAVA_1; break;
500
        }
501
        
502
        Element data = getJavaCompilationUnits(aux);
503
        
504
        if (data == null || !JavaProjectNature.namespaceAtLeast(data.getNamespaceURI(), namespace)) {
505
            if (data != null) {
506
                aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, data.getNamespaceURI(), true);
495
            }
507
            }
496
        }
508
            data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
497
        // Second check whether we need /2 data.
509
                createElementNS(namespace, JavaProjectNature.EL_JAVA);
498
        boolean need2 = false;
499
        for (JavaCompilationUnit unit : compUnits) {
500
            if (unit.isTests || (unit.javadoc != null && !unit.javadoc.isEmpty())) {
501
                need2 = true;
502
                break;
503
            }
504
        }
505
        String namespace;
506
        // Look for existing /3 data.
507
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
508
        if (data != null) {
509
            namespace = JavaProjectNature.NS_JAVA_3;
510
        }
511
        else {
512
            // Look for existing /2 data and possibly update to /3
513
            data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
514
            if (data != null) {
515
                namespace = need3 ? JavaProjectNature.NS_JAVA_3 : JavaProjectNature.NS_JAVA_2;
516
                if (need3) {
517
                    // Have to upgrade to /3
518
                    aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
519
                    data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
520
                        createElementNS(JavaProjectNature.NS_JAVA_3, JavaProjectNature.EL_JAVA);
521
                }
522
            } else {
523
                //Look for existing /1 and possibly update to /2 or /3 as needed
524
                data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
525
                namespace = need3 ? JavaProjectNature.NS_JAVA_3 : need2 ? JavaProjectNature.NS_JAVA_2 : JavaProjectNature.NS_JAVA_1;
526
                if (data != null) {
527
528
                    if (need3) {
529
                        // Have to upgrade to /3
530
                        aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
531
                        data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
532
                            createElementNS(JavaProjectNature.NS_JAVA_3, JavaProjectNature.EL_JAVA);
533
                    }
534
                    else if (need2) {
535
                        // Have to upgrade to /2
536
                        aux.removeConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
537
                        data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
538
                            createElementNS(JavaProjectNature.NS_JAVA_2, JavaProjectNature.EL_JAVA);
539
                    } // else can use it as is
540
                } else {
541
                    // Create a new /1, /2 or /3 data acc. to need.
542
                    data = Util.getPrimaryConfigurationData(helper).getOwnerDocument().
543
                        createElementNS(namespace, JavaProjectNature.EL_JAVA);
544
                }
545
            }
546
        }
510
        }
547
        Document doc = data.getOwnerDocument();
511
        Document doc = data.getOwnerDocument();
548
        for (Element cuEl : XMLUtil.findSubElements(data)) {
512
        for (Element cuEl : XMLUtil.findSubElements(data)) {
Lines 560-566 Link Here
560
                }
524
                }
561
            }
525
            }
562
            if (cu.isTests) {
526
            if (cu.isTests) {
563
                assert namespace.equals(JavaProjectNature.NS_JAVA_2) || namespace.equals(JavaProjectNature.NS_JAVA_3);
527
                assert JavaProjectNature.namespaceAtLeast(namespace, JavaProjectNature.NS_JAVA_2);
564
                cuEl.appendChild(doc.createElementNS(namespace, "unit-tests")); // NOI18N
528
                cuEl.appendChild(doc.createElementNS(namespace, "unit-tests")); // NOI18N
565
            }
529
            }
566
            if (cu.classpath != null) {
530
            if (cu.classpath != null) {
Lines 584-590 Link Here
584
                Iterator it3 = cu.javadoc.iterator();
548
                Iterator it3 = cu.javadoc.iterator();
585
                while (it3.hasNext()) {
549
                while (it3.hasNext()) {
586
                    String javadoc = (String) it3.next();
550
                    String javadoc = (String) it3.next();
587
                    assert namespace.equals(JavaProjectNature.NS_JAVA_2) || namespace.equals(JavaProjectNature.NS_JAVA_3);
551
                    assert JavaProjectNature.namespaceAtLeast(namespace, JavaProjectNature.NS_JAVA_2);
588
                    el = doc.createElementNS(namespace, "javadoc-built-to"); // NOI18N
552
                    el = doc.createElementNS(namespace, "javadoc-built-to"); // NOI18N
589
                    el.appendChild(doc.createTextNode(javadoc));
553
                    el.appendChild(doc.createTextNode(javadoc));
590
                    cuEl.appendChild(el);
554
                    cuEl.appendChild(el);
Lines 1099-1121 Link Here
1099
        props.setProperty(key, value);
1063
        props.setProperty(key, value);
1100
    }
1064
    }
1101
1065
1102
    private static boolean needsNS3(final JavaCompilationUnit unit) {
1066
    private static int minimalNS(final JavaCompilationUnit unit) {
1067
        if (unit.isTests || (unit.javadoc != null && !unit.javadoc.isEmpty())) {
1068
            return 2;
1069
        }
1103
        if (unit.classpath != null) {
1070
        if (unit.classpath != null) {
1104
            for (JavaCompilationUnit.CP cp : unit.classpath) {
1071
            for (JavaCompilationUnit.CP cp : unit.classpath) {
1105
                if ("processor".equals(cp.mode)) {  //NOI18N
1072
                if ("processor".equals(cp.mode)) {  //NOI18N
1106
                    return true;
1073
                    return 3;
1107
                }
1074
                }
1108
            }
1075
            }
1109
        }
1076
        }
1110
        if (unit.sourceLevel != null) {
1077
        if (unit.sourceLevel != null) {
1078
            final SpecificationVersion JAVA_8 = new SpecificationVersion("1.8");  //NOI18N
1079
            final SpecificationVersion current = new SpecificationVersion(unit.sourceLevel);
1080
            if (JAVA_8.compareTo(current) >= 0) {
1081
                return 4;
1082
            }
1111
            final SpecificationVersion JAVA_6 = new SpecificationVersion("1.6");  //NOI18N
1083
            final SpecificationVersion JAVA_6 = new SpecificationVersion("1.6");  //NOI18N
1112
            final SpecificationVersion JAvA_7 = new SpecificationVersion("1.7");  //NOI18N
1084
            final SpecificationVersion JAvA_7 = new SpecificationVersion("1.7");  //NOI18N
1113
            final SpecificationVersion current = new SpecificationVersion(unit.sourceLevel);
1114
            if (JAVA_6.equals(current) || JAvA_7.equals(current)) {
1085
            if (JAVA_6.equals(current) || JAvA_7.equals(current)) {
1115
                return true;
1086
                return 3;
1116
            }
1087
            }
1117
        }
1088
        }
1118
        return false;
1089
        return 1;
1119
    }
1090
    }
1120
1091
    
1121
}
1092
}
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectNature.java (-1 / +15 lines)
Lines 72-77 Link Here
72
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
72
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
73
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
73
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
74
    public static final String NS_JAVA_3 = "http://www.netbeans.org/ns/freeform-project-java/3"; //NOI18N
74
    public static final String NS_JAVA_3 = "http://www.netbeans.org/ns/freeform-project-java/3"; //NOI18N
75
    public static final String NS_JAVA_4 = "http://www.netbeans.org/ns/freeform-project-java/4"; //NOI18N
76
    public static final String NS_JAVA_LASTEST = NS_JAVA_4;
77
    public static final String[] JAVA_NAMESPACES = {
78
        NS_JAVA_4,
79
        NS_JAVA_3,
80
        NS_JAVA_2,
81
        NS_JAVA_1
82
    };
75
    public static final String EL_JAVA = "java-data"; // NOI18N
83
    public static final String EL_JAVA = "java-data"; // NOI18N
76
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
84
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
77
    
85
    
Lines 99-105 Link Here
99
        return PackageView.findPath(root, target);
107
        return PackageView.findPath(root, target);
100
    }
108
    }
101
109
102
    
110
    public static boolean namespaceAtLeast(String nsToTest, String expected) {
111
        for (String ns : JAVA_NAMESPACES) {
112
            if (ns.equals(nsToTest)) return true;
113
            if (ns.equals(expected)) return false;
114
        }
115
        return false;//???
116
    }
103
117
104
    private static class SourceGroupImpl implements  SourceGroup {
118
    private static class SourceGroupImpl implements  SourceGroup {
105
119
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java (-1 / +1 lines)
Lines 75-81 Link Here
75
    }
75
    }
76
76
77
    public JavadocForBinaryQuery.Result findJavadoc(URL binaryRoot) {
77
    public JavadocForBinaryQuery.Result findJavadoc(URL binaryRoot) {
78
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
78
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
79
        if (data != null) {
79
        if (data != null) {
80
            for (Element cu : XMLUtil.findSubElements(data)) {
80
            for (Element cu : XMLUtil.findSubElements(data)) {
81
                assert cu.getLocalName().equals("compilation-unit") : cu;
81
                assert cu.getLocalName().equals("compilation-unit") : cu;
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/LookupProviderImpl.java (-22 / +11 lines)
Lines 147-172 Link Here
147
        public Element getConfigurationFragment(String elementName, String namespace, boolean shared) {
147
        public Element getConfigurationFragment(String elementName, String namespace, boolean shared) {
148
            if (elementName.equals(JavaProjectNature.EL_JAVA) && shared) {
148
            if (elementName.equals(JavaProjectNature.EL_JAVA) && shared) {
149
                Element nue = null;
149
                Element nue = null;
150
                if (namespace.equals(JavaProjectNature.NS_JAVA_3)) {
150
                for (int nsIndex = 0; nsIndex < JavaProjectNature.JAVA_NAMESPACES.length; nsIndex++) {
151
                    nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
151
                    if (namespace.equals(JavaProjectNature.JAVA_NAMESPACES[nsIndex])) {
152
                    if (nue == null) {
152
                        for (int nsLookup = nsIndex; nsLookup < JavaProjectNature.JAVA_NAMESPACES.length; nsLookup++) {
153
                        Element old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
153
                            nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.JAVA_NAMESPACES[nsLookup], true);
154
                        if (old != null) {
154
                            if (nue != null) {
155
                            nue = upgradeSchema(old);
155
                                if (nsLookup != nsIndex) {
156
                        } else {
156
                                    nue = upgradeSchema(nue, JavaProjectNature.JAVA_NAMESPACES[nsIndex]);
157
                            old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
157
                                }
158
                            if (old != null) {
158
                                break;
159
                                nue = upgradeSchema(old);
160
                            }
159
                            }
161
                        }
160
                        }
162
                    }
161
                        
163
                } else if (namespace.equals(JavaProjectNature.NS_JAVA_2)) {
162
                        break;
164
                    nue = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
165
                    if (nue == null) {
166
                        Element old = delegate.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
167
                        if (old != null) {
168
                            nue = upgradeSchema(old, JavaProjectNature.NS_JAVA_2);
169
                        }
170
                    }
163
                    }
171
                }
164
                }
172
                return nue;
165
                return nue;
Lines 185-194 Link Here
185
        
178
        
186
    }
179
    }
187
180
188
    static Element upgradeSchema(Element old) {
189
        return upgradeSchema(old, JavaProjectNature.NS_JAVA_3);
190
    }
191
192
    static Element upgradeSchema(final Element old, final String to) {
181
    static Element upgradeSchema(final Element old, final String to) {
193
        Document doc = old.getOwnerDocument();
182
        Document doc = old.getOwnerDocument();
194
        Element nue = doc.createElementNS(to, JavaProjectNature.EL_JAVA);
183
        Element nue = doc.createElementNS(to, JavaProjectNature.EL_JAVA);
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java (-1 / +1 lines)
Lines 99-105 Link Here
99
        if (roots == null) {
99
        if (roots == null) {
100
            // Need to compute it. Easiest to compute them all at once.
100
            // Need to compute it. Easiest to compute them all at once.
101
            roots = new HashMap<URL,FileObject[]>();
101
            roots = new HashMap<URL,FileObject[]>();
102
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
102
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
103
            if (java == null) {
103
            if (java == null) {
104
                return null;
104
                return null;
105
            }
105
            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java (-2 / +2 lines)
Lines 134-140 Link Here
134
                    return Collections.unmodifiableMap(new HashMap<FileObject,R>(sourceLevels));
134
                    return Collections.unmodifiableMap(new HashMap<FileObject,R>(sourceLevels));
135
                }
135
                }
136
            }
136
            }
137
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
137
            Element java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
138
            if (java != null) {
138
            if (java != null) {
139
                for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
139
                for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
140
                    assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
140
                    assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
Lines 172-178 Link Here
172
     * Get the source level indicated in a compilation unit (or null if none is indicated).
172
     * Get the source level indicated in a compilation unit (or null if none is indicated).
173
     */
173
     */
174
    private String getLevel(Element compilationUnitEl) {
174
    private String getLevel(Element compilationUnitEl) {
175
        Element sourceLevelEl = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
175
        Element sourceLevelEl = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_LASTEST);
176
        if (sourceLevelEl != null) {
176
        if (sourceLevelEl != null) {
177
            return XMLUtil.findText(sourceLevelEl);
177
            return XMLUtil.findText(sourceLevelEl);
178
        } else {
178
        } else {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java (-2 / +2 lines)
Lines 118-128 Link Here
118
    private URL[][] findSourcesAndTests() {
118
    private URL[][] findSourcesAndTests() {
119
        List<URL> sources = new ArrayList<URL>();
119
        List<URL> sources = new ArrayList<URL>();
120
        List<URL> tests = new ArrayList<URL>();
120
        List<URL> tests = new ArrayList<URL>();
121
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
121
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_LASTEST, true);
122
        if (data != null) {
122
        if (data != null) {
123
            for (Element cu : XMLUtil.findSubElements(data)) {
123
            for (Element cu : XMLUtil.findSubElements(data)) {
124
                assert cu.getLocalName().equals("compilation-unit") : cu;
124
                assert cu.getLocalName().equals("compilation-unit") : cu;
125
                boolean isTests = XMLUtil.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_3) != null; // NOI18N
125
                boolean isTests = XMLUtil.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_LASTEST) != null; // NOI18N
126
                for (Element pr : XMLUtil.findSubElements(cu)) {
126
                for (Element pr : XMLUtil.findSubElements(cu)) {
127
                    if (pr.getLocalName().equals("package-root")) { // NOI18N
127
                    if (pr.getLocalName().equals("package-root")) { // NOI18N
128
                        String rawtext = XMLUtil.findText(pr);
128
                        String rawtext = XMLUtil.findText(pr);
(-)197ada535977 (+186 lines)
Added 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-2010 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
47
<!--
48
XML Schema to define the project.xml for a freeform project.
49
Cf. http://projects.netbeans.org/buildsys/design.html#freeform
50
-->
51
52
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
53
            targetNamespace="http://www.netbeans.org/ns/freeform-project-java/4"
54
            xmlns="http://www.netbeans.org/ns/freeform-project-java/4"
55
            elementFormDefault="qualified">
56
57
    <xsd:element name="java-data">
58
        <xsd:complexType>
59
            <xsd:sequence>
60
                <xsd:element name="compilation-unit" minOccurs="0" maxOccurs="unbounded" type="compilation-unit"/>
61
            </xsd:sequence>
62
        </xsd:complexType>
63
    </xsd:element>
64
    
65
    <xsd:complexType name="compilation-unit">
66
        <xsd:sequence>
67
            <xsd:element name="package-root" maxOccurs="unbounded" type="substitutable-text"/>
68
            <xsd:element name="unit-tests" minOccurs="0"><xsd:complexType/></xsd:element>
69
            <xsd:element name="classpath" minOccurs="0" maxOccurs="unbounded">
70
                <!-- XXX use schema to declare that the mode must be unique within this group -->
71
                <xsd:complexType>
72
                    <xsd:simpleContent>
73
                        <xsd:extension base="substitutable-text">
74
                            <xsd:attribute name="mode" use="required">
75
                                <xsd:simpleType>
76
                                    <xsd:restriction base="xsd:NMTOKEN">
77
                                        <xsd:enumeration value="boot"/>
78
                                        <xsd:enumeration value="compile"/>
79
                                        <xsd:enumeration value="execute"/>
80
                                    </xsd:restriction>
81
                                </xsd:simpleType>
82
                            </xsd:attribute>
83
                        </xsd:extension>
84
                    </xsd:simpleContent>
85
                </xsd:complexType>
86
            </xsd:element>
87
            <xsd:element name="built-to" minOccurs="0" maxOccurs="unbounded" type="substitutable-text"/>
88
            <xsd:element name="javadoc-built-to" minOccurs="0" maxOccurs="unbounded" type="substitutable-text"/>
89
            <xsd:element name="source-level" minOccurs="0">
90
                <xsd:simpleType>
91
                    <xsd:restriction base="xsd:NMTOKEN">
92
                        <xsd:pattern value="1\.([3-9]|[1-9][0-9])"/>
93
                    </xsd:restriction>
94
                </xsd:simpleType>
95
            </xsd:element>
96
            <xsd:element name="annotation-processing" minOccurs="0">
97
                <xsd:annotation>
98
                    <xsd:documentation>Annotation processing support</xsd:documentation>   
99
                </xsd:annotation>
100
                <xsd:complexType>
101
                    <xsd:sequence>
102
                        <xsd:element name="scan-trigger" minOccurs="0">
103
                            <xsd:annotation>
104
                                <xsd:documentation>
105
                                    When this element exists the annotation processors are invoked during the scan
106
                                    of the project and when a file is saved
107
                                </xsd:documentation>
108
                             </xsd:annotation>
109
                            <xsd:complexType/>
110
                        </xsd:element>
111
                        <xsd:element name="editor-trigger" minOccurs="0">
112
                            <xsd:annotation>
113
                                <xsd:documentation>
114
                                    When this element exists the annotation processors are also invoked during
115
                                    typing in the editor which may slow down editing. This element requires presence
116
                                    of the scan-trigger element
117
                                </xsd:documentation>
118
                             </xsd:annotation>
119
                            <xsd:complexType/>
120
                        </xsd:element>
121
                        <xsd:element name="source-output" minOccurs="0" type="substitutable-text">
122
                            <xsd:annotation>
123
                                <xsd:documentation>
124
                                    The folder to which annotation processors generate files
125
                                </xsd:documentation>
126
                             </xsd:annotation>
127
                        </xsd:element>
128
                        <xsd:element name="processor-path" minOccurs="0" type="substitutable-text">
129
                            <xsd:annotation>
130
                                <xsd:documentation>
131
                                    Explicit classpath holding the annotation processors. When available
132
                                    this classpath is used to lookup the processors otherwise the compile 
133
                                    classpath is used
134
                                </xsd:documentation>
135
                             </xsd:annotation>
136
                        </xsd:element>
137
                        <xsd:element name="processor" minOccurs="0" maxOccurs="unbounded" type="substitutable-text">
138
                            <xsd:annotation>
139
                                <xsd:documentation>
140
                                    Explicit processor(s) to be invoked. If available these processor(s)
141
                                    are executed otherwise the processors are looked up in META-INF/services
142
                                </xsd:documentation>
143
                             </xsd:annotation>
144
                        </xsd:element>    
145
                        <xsd:element name="processor-option" minOccurs="0" maxOccurs="unbounded" type="processor-option">
146
                            <xsd:annotation>
147
                                <xsd:documentation>
148
                                    Processor specific options
149
                                </xsd:documentation>
150
                             </xsd:annotation>
151
                        </xsd:element>
152
                    </xsd:sequence>
153
                </xsd:complexType>
154
            </xsd:element>
155
        </xsd:sequence>
156
    </xsd:complexType>
157
158
    <!-- XXX: this type was copied from freeform-project-general.xsd -->
159
    <!-- Some text that might be substituted with Ant property references. -->
160
    <xsd:simpleType name="substitutable-text">
161
        <xsd:restriction base="xsd:string">
162
            <!-- XXX limit by regexp, perhaps -->
163
        </xsd:restriction>
164
    </xsd:simpleType>
165
166
    <xsd:complexType name="processor-option">
167
        <xsd:sequence>
168
            <xsd:element name="key" type="xsd:string">
169
                <xsd:annotation>
170
                    <xsd:documentation>
171
                        Name of the option
172
                    </xsd:documentation>
173
                 </xsd:annotation>
174
            </xsd:element><!-- xsd:token???? -->
175
            <xsd:element name="value" type="substitutable-text">
176
                <xsd:annotation>
177
                    <xsd:documentation>
178
                        Option value
179
                    </xsd:documentation>
180
                 </xsd:annotation>
181
            </xsd:element>
182
        </xsd:sequence>
183
    </xsd:complexType>
184
185
186
</xsd:schema>
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/resources/layer.xml (+1 lines)
Lines 65-70 Link Here
65
            <file name="1.xsd" url="freeform-project-java.xsd"/>
65
            <file name="1.xsd" url="freeform-project-java.xsd"/>
66
            <file name="2.xsd" url="freeform-project-java-2.xsd"/>
66
            <file name="2.xsd" url="freeform-project-java-2.xsd"/>
67
            <file name="3.xsd" url="freeform-project-java-3.xsd"/>
67
            <file name="3.xsd" url="freeform-project-java-3.xsd"/>
68
            <file name="4.xsd" url="freeform-project-java-4.xsd"/>
68
        </folder>
69
        </folder>
69
    </folder>
70
    </folder>
70
</filesystem>
71
</filesystem>
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/ui/Bundle.properties (+1 lines)
Lines 80-85 Link Here
80
LBL_SourceFoldersPanel_JDK15=JDK 1.5
80
LBL_SourceFoldersPanel_JDK15=JDK 1.5
81
LBL_SourceFoldersPanel_JDK16=JDK 1.6
81
LBL_SourceFoldersPanel_JDK16=JDK 1.6
82
LBL_SourceFoldersPanel_JDK17=JDK 1.7
82
LBL_SourceFoldersPanel_JDK17=JDK 1.7
83
LBL_SourceFoldersPanel_JDK18=JDK 1.8
83
LBL_SourceFoldersPanel_Package=Package Folder
84
LBL_SourceFoldersPanel_Package=Package Folder
84
LBL_SourceFoldersPanel_Label=Label
85
LBL_SourceFoldersPanel_Label=Label
85
BTN_SourceFoldersPanel_addTestFolder=Add F&older...
86
BTN_SourceFoldersPanel_addTestFolder=Add F&older...
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java (+4 lines)
Lines 151-156 Link Here
151
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK15")); // NOI18N
151
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK15")); // NOI18N
152
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK16")); // NOI18N
152
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK16")); // NOI18N
153
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK17")); // NOI18N
153
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK17")); // NOI18N
154
        sourceLevel.addItem(NbBundle.getMessage(SourceFoldersPanel.class, "LBL_SourceFoldersPanel_JDK18")); // NOI18N
154
    }
155
    }
155
    
156
    
156
    private void updateButtons() {
157
    private void updateButtons() {
Lines 185-190 Link Here
185
            sourceLevel.setSelectedIndex(3);
186
            sourceLevel.setSelectedIndex(3);
186
        } else if (sourceLevelValue.equals("1.7")) { // NOI18N
187
        } else if (sourceLevelValue.equals("1.7")) { // NOI18N
187
            sourceLevel.setSelectedIndex(4);
188
            sourceLevel.setSelectedIndex(4);
189
        } else if (sourceLevelValue.equals("1.8")) { // NOI18N
190
            sourceLevel.setSelectedIndex(5);
188
        }else {
191
        }else {
189
            // user specified some other value in project.xml
192
            // user specified some other value in project.xml
190
            sourceLevel.addItem(sourceLevelValue);
193
            sourceLevel.addItem(sourceLevelValue);
Lines 204-209 Link Here
204
            case 2: return "1.5"; // NOI18N
207
            case 2: return "1.5"; // NOI18N
205
            case 3: return "1.6"; // NOI18N
208
            case 3: return "1.6"; // NOI18N
206
            case 4: return "1.7"; // NOI18N
209
            case 4: return "1.7"; // NOI18N
210
            case 5: return "1.8"; // NOI18N
207
            default: return null;
211
            default: return null;
208
        }
212
        }
209
    }
213
    }
(-)a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectNatureTest.java (+12 lines)
Lines 73-78 Link Here
73
    public void testUpgradeSchema1to3() throws Exception {
73
    public void testUpgradeSchema1to3() throws Exception {
74
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_1, JavaProjectNature.NS_JAVA_3);
74
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_1, JavaProjectNature.NS_JAVA_3);
75
    }
75
    }
76
    
77
    public void testUpgradeSchema1to4() throws Exception {
78
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_1, JavaProjectNature.NS_JAVA_4);
79
    }
80
    
81
    public void testUpgradeSchema2to4() throws Exception {
82
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_2, JavaProjectNature.NS_JAVA_4);
83
    }
84
    
85
    public void testUpgradeSchema3to4() throws Exception {
86
        upgradeSchemaTestImpl(JavaProjectNature.NS_JAVA_3, JavaProjectNature.NS_JAVA_4);
87
    }
76
88
77
    private void upgradeSchemaTestImpl(String from, String to) throws Exception {
89
    private void upgradeSchemaTestImpl(String from, String to) throws Exception {
78
        // Formatting has to be the same as Xerces' formatter produces for this test to pass:
90
        // Formatting has to be the same as Xerces' formatter produces for this test to pass:

Return to bug 226105