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

(-)a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java (-21 / +22 lines)
Lines 88-93 Link Here
88
import org.openide.util.Mutex;
88
import org.openide.util.Mutex;
89
import org.openide.util.Utilities;
89
import org.openide.util.Utilities;
90
import org.openide.util.WeakListeners;
90
import org.openide.util.WeakListeners;
91
import org.openide.xml.XMLUtil;
91
import org.w3c.dom.Element;
92
import org.w3c.dom.Element;
92
93
93
/**
94
/**
Lines 192-198 Link Here
192
        if (java == null) {
193
        if (java == null) {
193
            return null;
194
            return null;
194
        }
195
        }
195
        List<Element> compilationUnits = Util.findSubElements(java);
196
        List<Element> compilationUnits = XMLUtil.findSubElements(java);
196
        it = compilationUnits.iterator();
197
        it = compilationUnits.iterator();
197
        while (it.hasNext()) {
198
        while (it.hasNext()) {
198
            Element compilationUnitEl = (Element)it.next();
199
            Element compilationUnitEl = (Element)it.next();
Lines 256-262 Link Here
256
            if (java == null) {
257
            if (java == null) {
257
                return;
258
                return;
258
            }
259
            }
259
            for (Element compilationUnitEl : Util.findSubElements(java)) {
260
            for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
260
                assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
261
                assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
261
                // For each compilation unit, find the package roots first.
262
                // For each compilation unit, find the package roots first.
262
                List<FileObject> packageRoots = findPackageRoots(helper, evaluator, compilationUnitEl);
263
                List<FileObject> packageRoots = findPackageRoots(helper, evaluator, compilationUnitEl);
Lines 335-347 Link Here
335
    
336
    
336
    static List<String> findPackageRootNames(Element compilationUnitEl) {
337
    static List<String> findPackageRootNames(Element compilationUnitEl) {
337
        List<String> names = new ArrayList<String>();
338
        List<String> names = new ArrayList<String>();
338
        Iterator it = Util.findSubElements(compilationUnitEl).iterator();
339
        Iterator it = XMLUtil.findSubElements(compilationUnitEl).iterator();
339
        while (it.hasNext()) {
340
        while (it.hasNext()) {
340
            Element e = (Element) it.next();
341
            Element e = (Element) it.next();
341
            if (!e.getLocalName().equals("package-root")) { // NOI18N
342
            if (!e.getLocalName().equals("package-root")) { // NOI18N
342
                continue;
343
                continue;
343
            }
344
            }
344
            String location = Util.findText(e);
345
            String location = XMLUtil.findText(e);
345
            names.add(location);
346
            names.add(location);
346
        }
347
        }
347
        return names;
348
        return names;
Lines 418-424 Link Here
418
    }
419
    }
419
    
420
    
420
    private List<URL> createCompileClasspath(Element compilationUnitEl) {
421
    private List<URL> createCompileClasspath(Element compilationUnitEl) {
421
        for (Element e : Util.findSubElements(compilationUnitEl)) {
422
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
422
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("compile")) { // NOI18N
423
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("compile")) { // NOI18N
423
                return createClasspath(e);
424
                return createClasspath(e);
424
            }
425
            }
Lines 431-437 Link Here
431
     * Create a classpath from a &lt;classpath&gt; element.
432
     * Create a classpath from a &lt;classpath&gt; element.
432
     */
433
     */
433
    private List<URL> createClasspath(Element classpathEl) {
434
    private List<URL> createClasspath(Element classpathEl) {
434
        String cp = Util.findText(classpathEl);
435
        String cp = XMLUtil.findText(classpathEl);
435
        if (cp == null) {
436
        if (cp == null) {
436
            cp = "";
437
            cp = "";
437
        }
438
        }
Lines 453-459 Link Here
453
    }
454
    }
454
    
455
    
455
    private List<URL> createExecuteClasspath(List<String> packageRoots, Element compilationUnitEl) {
456
    private List<URL> createExecuteClasspath(List<String> packageRoots, Element compilationUnitEl) {
456
        for (Element e : Util.findSubElements(compilationUnitEl)) {
457
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
457
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
458
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
458
                return createClasspath(e);
459
                return createClasspath(e);
459
            }
460
            }
Lines 463-474 Link Here
463
        List<URL> urls = new ArrayList<URL>();
464
        List<URL> urls = new ArrayList<URL>();
464
        urls.addAll(createCompileClasspath(compilationUnitEl));
465
        urls.addAll(createCompileClasspath(compilationUnitEl));
465
        boolean foundBuiltTos = false;
466
        boolean foundBuiltTos = false;
466
        for (Element builtTo : Util.findSubElements(compilationUnitEl)) {
467
        for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
467
            if (!builtTo.getLocalName().equals("built-to")) { // NOI18N
468
            if (!builtTo.getLocalName().equals("built-to")) { // NOI18N
468
                continue;
469
                continue;
469
            }
470
            }
470
            foundBuiltTos = true;
471
            foundBuiltTos = true;
471
            String rawtext = Util.findText(builtTo);
472
            String rawtext = XMLUtil.findText(builtTo);
472
            assert rawtext != null : "Must have nonempty text inside <built-to>";
473
            assert rawtext != null : "Must have nonempty text inside <built-to>";
473
            String text = evaluator.evaluate(rawtext);
474
            String text = evaluator.evaluate(rawtext);
474
            if (text == null) {
475
            if (text == null) {
Lines 483-489 Link Here
483
    }
484
    }
484
    
485
    
485
    private List<URL> createBootClasspath(Element compilationUnitEl) {
486
    private List<URL> createBootClasspath(Element compilationUnitEl) {
486
        for (Element e : Util.findSubElements(compilationUnitEl)) {
487
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
487
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("boot")) { // NOI18N
488
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("boot")) { // NOI18N
488
                return createClasspath(e);
489
                return createClasspath(e);
489
            }
490
            }
Lines 558-564 Link Here
558
            if (java == null) {
559
            if (java == null) {
559
                return null;
560
                return null;
560
            }
561
            }
561
            List<Element> compilationUnits = Util.findSubElements(java);
562
            List<Element> compilationUnits = XMLUtil.findSubElements(java);
562
            Iterator it = compilationUnits.iterator();
563
            Iterator it = compilationUnits.iterator();
563
            while (it.hasNext()) {
564
            while (it.hasNext()) {
564
                Element compilationUnitEl = (Element)it.next();
565
                Element compilationUnitEl = (Element)it.next();
Lines 665-692 Link Here
665
                rootFolder = null;
666
                rootFolder = null;
666
            }
667
            }
667
            Element genldata = Util.getPrimaryConfigurationData(helper);
668
            Element genldata = Util.getPrimaryConfigurationData(helper);
668
            Element foldersE = Util.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
669
            Element foldersE = XMLUtil.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
669
            if (foldersE != null) {
670
            if (foldersE != null) {
670
                for (Element folderE : Util.findSubElements(foldersE)) {
671
                for (Element folderE : XMLUtil.findSubElements(foldersE)) {
671
                    if (folderE.getLocalName().equals("source-folder")) {
672
                    if (folderE.getLocalName().equals("source-folder")) {
672
                        Element typeE = Util.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
673
                        Element typeE = XMLUtil.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
673
                        if (typeE != null) {
674
                        if (typeE != null) {
674
                            String type = Util.findText(typeE);
675
                            String type = XMLUtil.findText(typeE);
675
                            if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
676
                            if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
676
                                Element locationE = Util.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
677
                                Element locationE = XMLUtil.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
677
                                String location = evaluator.evaluate(Util.findText(locationE));
678
                                String location = evaluator.evaluate(XMLUtil.findText(locationE));
678
                                if (location != null && helper.resolveFile(location).equals(rootFolder)) {
679
                                if (location != null && helper.resolveFile(location).equals(rootFolder)) {
679
                                    Element includesE = Util.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
680
                                    Element includesE = XMLUtil.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
680
                                    if (includesE != null) {
681
                                    if (includesE != null) {
681
                                        incl = evaluator.evaluate(Util.findText(includesE));
682
                                        incl = evaluator.evaluate(XMLUtil.findText(includesE));
682
                                        if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
683
                                        if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
683
                                            // Clearly intended to mean "include everything".
684
                                            // Clearly intended to mean "include everything".
684
                                            incl = null;
685
                                            incl = null;
685
                                        }
686
                                        }
686
                                    }
687
                                    }
687
                                    Element excludesE = Util.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
688
                                    Element excludesE = XMLUtil.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
688
                                    if (excludesE != null) {
689
                                    if (excludesE != null) {
689
                                        excl = evaluator.evaluate(Util.findText(excludesE));
690
                                        excl = evaluator.evaluate(XMLUtil.findText(excludesE));
690
                                    }
691
                                    }
691
                                }
692
                                }
692
                            }
693
                            }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaActions.java (-25 / +25 lines)
Lines 506-524 Link Here
506
        antProject.setAttribute("basedir", /* ".." times count('/', FILE_SCRIPT_PATH) */".."); // NOI18N
506
        antProject.setAttribute("basedir", /* ".." times count('/', FILE_SCRIPT_PATH) */".."); // NOI18N
507
        // Look for <properties> in project.xml and make corresponding definitions in the Ant script.
507
        // Look for <properties> in project.xml and make corresponding definitions in the Ant script.
508
        Element data = Util.getPrimaryConfigurationData(helper);
508
        Element data = Util.getPrimaryConfigurationData(helper);
509
        Element properties = Util.findElement(data, "properties", Util.NAMESPACE);
509
        Element properties = XMLUtil.findElement(data, "properties", Util.NAMESPACE);
510
        if (properties != null) {
510
        if (properties != null) {
511
            for (Element el : Util.findSubElements(properties)) {
511
            for (Element el : XMLUtil.findSubElements(properties)) {
512
                Element nue = antProject.getOwnerDocument().createElement("property"); // NOI18N
512
                Element nue = antProject.getOwnerDocument().createElement("property"); // NOI18N
513
                if (el.getLocalName().equals("property")) { // NOI18N
513
                if (el.getLocalName().equals("property")) { // NOI18N
514
                    String name = el.getAttribute("name"); // NOI18N
514
                    String name = el.getAttribute("name"); // NOI18N
515
                    assert name != null;
515
                    assert name != null;
516
                    String text = Util.findText(el);
516
                    String text = XMLUtil.findText(el);
517
                    assert text != null;
517
                    assert text != null;
518
                    nue.setAttribute("name", name);
518
                    nue.setAttribute("name", name);
519
                    nue.setAttribute("value", text);
519
                    nue.setAttribute("value", text);
520
                } else if (el.getLocalName().equals("property-file")) { // NOI18N
520
                } else if (el.getLocalName().equals("property-file")) { // NOI18N
521
                    String text = Util.findText(el);
521
                    String text = XMLUtil.findText(el);
522
                    assert text != null;
522
                    assert text != null;
523
                    nue.setAttribute("file", text);
523
                    nue.setAttribute("file", text);
524
                } else {
524
                } else {
Lines 615-621 Link Here
615
        if (java == null) {
615
        if (java == null) {
616
            return Collections.emptyList();
616
            return Collections.emptyList();
617
        }
617
        }
618
        return Util.findSubElements(java);
618
        return XMLUtil.findSubElements(java);
619
    }
619
    }
620
    
620
    
621
    /**
621
    /**
Lines 684-692 Link Here
684
     */
684
     */
685
    private Element findCompilationUnit(String sources) {
685
    private Element findCompilationUnit(String sources) {
686
        for (Element compilationUnitEl : compilationUnits()) {
686
        for (Element compilationUnitEl : compilationUnits()) {
687
            for (Element packageRoot : Util.findSubElements(compilationUnitEl)) {
687
            for (Element packageRoot : XMLUtil.findSubElements(compilationUnitEl)) {
688
                if (packageRoot.getLocalName().equals("package-root")) { // NOI18N
688
                if (packageRoot.getLocalName().equals("package-root")) { // NOI18N
689
                    if (Util.findText(packageRoot).equals(sources)) {
689
                    if (XMLUtil.findText(packageRoot).equals(sources)) {
690
                        return compilationUnitEl;
690
                        return compilationUnitEl;
691
                    }
691
                    }
692
                }
692
                }
Lines 714-722 Link Here
714
     */
714
     */
715
    private String findClassesOutputDir(Element compilationUnitEl) {
715
    private String findClassesOutputDir(Element compilationUnitEl) {
716
        // Look for an appropriate <built-to>.
716
        // Look for an appropriate <built-to>.
717
        for (Element builtTo : Util.findSubElements(compilationUnitEl)) {
717
        for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
718
            if (builtTo.getLocalName().equals("built-to")) { // NOI18N
718
            if (builtTo.getLocalName().equals("built-to")) { // NOI18N
719
                String rawtext = Util.findText(builtTo);
719
                String rawtext = XMLUtil.findText(builtTo);
720
                // Check that it is not an archive.
720
                // Check that it is not an archive.
721
                String evaltext = evaluator.evaluate(rawtext);
721
                String evaltext = evaluator.evaluate(rawtext);
722
                if (evaltext != null) {
722
                if (evaltext != null) {
Lines 745-753 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 = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_2);
749
            if (sourceLevel != null) {
749
            if (sourceLevel != null) {
750
                return Util.findText(sourceLevel);
750
                return XMLUtil.findText(sourceLevel);
751
            }
751
            }
752
        }
752
        }
753
        return null;
753
        return null;
Lines 761-771 Link Here
761
    String findCUClasspath(String sources, String moud) {
761
    String findCUClasspath(String sources, String moud) {
762
        Element compilationUnitEl = findCompilationUnit(sources);
762
        Element compilationUnitEl = findCompilationUnit(sources);
763
        if (compilationUnitEl != null) {
763
        if (compilationUnitEl != null) {
764
            for (Element classpath : Util.findSubElements(compilationUnitEl)) {
764
            for (Element classpath : XMLUtil.findSubElements(compilationUnitEl)) {
765
                if (classpath.getLocalName().equals("classpath")) { // NOI18N
765
                if (classpath.getLocalName().equals("classpath")) { // NOI18N
766
                    String mode = classpath.getAttribute("mode"); // NOI18N
766
                    String mode = classpath.getAttribute("mode"); // NOI18N
767
                    if (mode.equals(moud)) {
767
                    if (mode.equals(moud)) {
768
                        return Util.findText(classpath);
768
                        return XMLUtil.findText(classpath);
769
                    }
769
                    }
770
                }
770
                }
771
            }
771
            }
Lines 810-820 Link Here
810
        // XXX cannot use FreeformProjectGenerator since that is currently not a public support SPI from ant/freeform
810
        // XXX cannot use FreeformProjectGenerator since that is currently not a public support SPI from ant/freeform
811
        // XXX should this try to find an existing binding? probably not, since it is assumed that if there was one, we would never get here to begin with
811
        // XXX should this try to find an existing binding? probably not, since it is assumed that if there was one, we would never get here to begin with
812
        Element data = Util.getPrimaryConfigurationData(helper);
812
        Element data = Util.getPrimaryConfigurationData(helper);
813
        Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
813
        Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
814
        if (ideActions == null) {
814
        if (ideActions == null) {
815
            //fix for #58442:
815
            //fix for #58442:
816
            ideActions = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "ide-actions"); // NOI18N
816
            ideActions = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "ide-actions"); // NOI18N
817
            Util.appendChildElement(data, ideActions, rootElementsOrder);
817
            XMLUtil.appendChildElement(data, ideActions, rootElementsOrder);
818
        }
818
        }
819
        Document doc = data.getOwnerDocument();
819
        Document doc = data.getOwnerDocument();
820
        Element action = doc.createElementNS(Util.NAMESPACE, "action"); // NOI18N
820
        Element action = doc.createElementNS(Util.NAMESPACE, "action"); // NOI18N
Lines 854-862 Link Here
854
        } else {
854
        } else {
855
            // Add a context menu item, since it applies to the project as a whole.
855
            // Add a context menu item, since it applies to the project as a whole.
856
            // Assume there is already a <context-menu> defined, which is quite likely.
856
            // Assume there is already a <context-menu> defined, which is quite likely.
857
            Element view = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
857
            Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
858
            if (view != null) {
858
            if (view != null) {
859
                Element contextMenu = Util.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
859
                Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
860
                if (contextMenu != null) {
860
                if (contextMenu != null) {
861
                    Element ideAction = doc.createElementNS(Util.NAMESPACE, "ide-action"); // NOI18N
861
                    Element ideAction = doc.createElementNS(Util.NAMESPACE, "ide-action"); // NOI18N
862
                    ideAction.setAttribute("name", command); // NOI18N
862
                    ideAction.setAttribute("name", command); // NOI18N
Lines 994-1000 Link Here
994
                return null;
994
                return null;
995
            }
995
            }
996
        }
996
        }
997
        for (Element target : Util.findSubElements(doc.getDocumentElement())) {
997
        for (Element target : XMLUtil.findSubElements(doc.getDocumentElement())) {
998
            if (target.getLocalName().equals("target") && targetName.equals(target.getAttribute("name"))) { // NOI18N
998
            if (target.getLocalName().equals("target") && targetName.equals(target.getAttribute("name"))) { // NOI18N
999
                return target;
999
                return target;
1000
            }
1000
            }
Lines 1010-1032 Link Here
1010
     */
1010
     */
1011
    String[] findCommandBinding(String command) {
1011
    String[] findCommandBinding(String command) {
1012
        Element data = Util.getPrimaryConfigurationData(helper);
1012
        Element data = Util.getPrimaryConfigurationData(helper);
1013
        Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
1013
        Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
1014
        if (ideActions == null) {
1014
        if (ideActions == null) {
1015
            return null;
1015
            return null;
1016
        }
1016
        }
1017
        String scriptName = "build.xml"; // NOI18N
1017
        String scriptName = "build.xml"; // NOI18N
1018
        for (Element action : Util.findSubElements(ideActions)) {
1018
        for (Element action : XMLUtil.findSubElements(ideActions)) {
1019
            assert action.getLocalName().equals("action");
1019
            assert action.getLocalName().equals("action");
1020
            if (action.getAttribute("name").equals(command)) {
1020
            if (action.getAttribute("name").equals(command)) {
1021
                Element script = Util.findElement(action, "script", Util.NAMESPACE); // NOI18N
1021
                Element script = XMLUtil.findElement(action, "script", Util.NAMESPACE); // NOI18N
1022
                if (script != null) {
1022
                if (script != null) {
1023
                    scriptName = Util.findText(script);
1023
                    scriptName = XMLUtil.findText(script);
1024
                }
1024
                }
1025
                List<String> scriptPlusTargetNames = new ArrayList<String>();
1025
                List<String> scriptPlusTargetNames = new ArrayList<String>();
1026
                scriptPlusTargetNames.add(scriptName);
1026
                scriptPlusTargetNames.add(scriptName);
1027
                for (Element target : Util.findSubElements(action)) {
1027
                for (Element target : XMLUtil.findSubElements(action)) {
1028
                    if (target.getLocalName().equals("target")) { // NOI18N
1028
                    if (target.getLocalName().equals("target")) { // NOI18N
1029
                        scriptPlusTargetNames.add(Util.findText(target));
1029
                        scriptPlusTargetNames.add(XMLUtil.findText(target));
1030
                    }
1030
                    }
1031
                }
1031
                }
1032
                if (scriptName.equals(JdkConfiguration.NBJDK_XML) && scriptPlusTargetNames.size() > 1) {
1032
                if (scriptName.equals(JdkConfiguration.NBJDK_XML) && scriptPlusTargetNames.size() > 1) {
Lines 1069-1075 Link Here
1069
    Element targetUsesTaskExactlyOnce(Element target, String taskName) {
1069
    Element targetUsesTaskExactlyOnce(Element target, String taskName) {
1070
        // XXX should maybe also look for any other usage of the task in the same script in case there is none in the mentioned target
1070
        // XXX should maybe also look for any other usage of the task in the same script in case there is none in the mentioned target
1071
        Element foundTask = null;
1071
        Element foundTask = null;
1072
        for (Element task : Util.findSubElements(target)) {
1072
        for (Element task : XMLUtil.findSubElements(target)) {
1073
            if (task.getLocalName().equals(taskName)) {
1073
            if (task.getLocalName().equals(taskName)) {
1074
                if (foundTask != null) {
1074
                if (foundTask != null) {
1075
                    // Duplicate.
1075
                    // Duplicate.
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaFreeformFileBuiltQuery.java (-4 / +4 lines)
Lines 47-53 Link Here
47
import org.netbeans.api.project.Project;
47
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.ProjectManager;
48
import org.netbeans.api.project.ProjectManager;
49
import org.netbeans.api.queries.FileBuiltQuery.Status;
49
import org.netbeans.api.queries.FileBuiltQuery.Status;
50
import org.netbeans.modules.ant.freeform.spi.support.Util;
51
import org.netbeans.spi.project.AuxiliaryConfiguration;
50
import org.netbeans.spi.project.AuxiliaryConfiguration;
52
import org.netbeans.spi.project.support.ant.AntProjectEvent;
51
import org.netbeans.spi.project.support.ant.AntProjectEvent;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 58-63 Link Here
58
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileUtil;
58
import org.openide.filesystems.FileUtil;
60
import org.openide.util.Mutex;
59
import org.openide.util.Mutex;
60
import org.openide.xml.XMLUtil;
61
import org.w3c.dom.Element;
61
import org.w3c.dom.Element;
62
62
63
/**
63
/**
Lines 99-105 Link Here
99
        List<String> to   = new ArrayList<String>();
99
        List<String> to   = new ArrayList<String>();
100
        
100
        
101
        if (java != null) {
101
        if (java != null) {
102
            List<Element> compilationUnits = Util.findSubElements(java);
102
            List<Element> compilationUnits = XMLUtil.findSubElements(java);
103
            Iterator it = compilationUnits.iterator();
103
            Iterator it = compilationUnits.iterator();
104
            while (it.hasNext()) {
104
            while (it.hasNext()) {
105
                Element compilationUnitEl = (Element)it.next();
105
                Element compilationUnitEl = (Element)it.next();
Lines 188-198 Link Here
188
    
188
    
189
    static List<String> findBuiltToNames(Element compilationUnitEl) {
189
    static List<String> findBuiltToNames(Element compilationUnitEl) {
190
        List<String> names = new ArrayList<String>();
190
        List<String> names = new ArrayList<String>();
191
        for (Element e : Util.findSubElements(compilationUnitEl)) {
191
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
192
            if (!e.getLocalName().equals("built-to")) { // NOI18N
192
            if (!e.getLocalName().equals("built-to")) { // NOI18N
193
                continue;
193
                continue;
194
            }
194
            }
195
            String location = Util.findText(e);
195
            String location = XMLUtil.findText(e);
196
            names.add(location);
196
            names.add(location);
197
        }
197
        }
198
        return names;
198
        return names;
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectGenerator.java (-69 / +70 lines)
Lines 59-64 Link Here
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.util.Exceptions;
61
import org.openide.util.Exceptions;
62
import org.openide.xml.XMLUtil;
62
import org.w3c.dom.Document;
63
import org.w3c.dom.Document;
63
import org.w3c.dom.Element;
64
import org.w3c.dom.Element;
64
65
Lines 112-149 Link Here
112
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
113
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
113
        List<SourceFolder> list = new ArrayList<SourceFolder>();
114
        List<SourceFolder> list = new ArrayList<SourceFolder>();
114
        Element data = Util.getPrimaryConfigurationData(helper);
115
        Element data = Util.getPrimaryConfigurationData(helper);
115
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
116
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
116
        if (foldersEl == null) {
117
        if (foldersEl == null) {
117
            return list;
118
            return list;
118
        }
119
        }
119
        for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
120
        for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
120
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
121
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
121
                continue;
122
                continue;
122
            }
123
            }
123
            SourceFolder sf = new SourceFolder();
124
            SourceFolder sf = new SourceFolder();
124
            Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
125
            Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
125
            if (el != null) {
126
            if (el != null) {
126
                sf.label = Util.findText(el);
127
                sf.label = XMLUtil.findText(el);
127
            }
128
            }
128
            el = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
129
            el = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
129
            if (el != null) {
130
            if (el != null) {
130
                sf.type = Util.findText(el);
131
                sf.type = XMLUtil.findText(el);
131
            }
132
            }
132
            el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
133
            el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
133
            if (el != null) {
134
            if (el != null) {
134
                sf.location = Util.findText(el);
135
                sf.location = XMLUtil.findText(el);
135
            }
136
            }
136
            el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
137
            el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
137
            if (el != null) {
138
            if (el != null) {
138
                sf.includes = Util.findText(el);
139
                sf.includes = XMLUtil.findText(el);
139
            }
140
            }
140
            el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
141
            el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
141
            if (el != null) {
142
            if (el != null) {
142
                sf.excludes = Util.findText(el);
143
                sf.excludes = XMLUtil.findText(el);
143
            }
144
            }
144
            el = Util.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
145
            el = XMLUtil.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
145
            if (el != null) {
146
            if (el != null) {
146
                sf.encoding = Util.findText(el);
147
                sf.encoding = XMLUtil.findText(el);
147
            }
148
            }
148
            if (type == null || type.equals(sf.type)) {
149
            if (type == null || type.equals(sf.type)) {
149
                if (sf.label == null || sf.label.length() == 0) {
150
                if (sf.label == null || sf.label.length() == 0) {
Lines 172-192 Link Here
172
        //assert ProjectManager.mutex().isWriteAccess();
173
        //assert ProjectManager.mutex().isWriteAccess();
173
        Element data = Util.getPrimaryConfigurationData(helper);
174
        Element data = Util.getPrimaryConfigurationData(helper);
174
        Document doc = data.getOwnerDocument();
175
        Document doc = data.getOwnerDocument();
175
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
176
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
176
        if (foldersEl == null) {
177
        if (foldersEl == null) {
177
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
178
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
178
            Util.appendChildElement(data, foldersEl, rootElementsOrder);
179
            XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
179
        } else {
180
        } else {
180
            for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
181
            for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
181
                if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
182
                if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
182
                    continue;
183
                    continue;
183
                }
184
                }
184
                if (type == null) {
185
                if (type == null) {
185
                    foldersEl.removeChild(sourceFolderEl);
186
                    foldersEl.removeChild(sourceFolderEl);
186
                } else {
187
                } else {
187
                    Element typeEl = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
188
                    Element typeEl = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
188
                    if (typeEl != null) {
189
                    if (typeEl != null) {
189
                        String typeElValue = Util.findText(typeEl);
190
                        String typeElValue = XMLUtil.findText(typeEl);
190
                        if (type.equals(typeElValue)) {
191
                        if (type.equals(typeElValue)) {
191
                            foldersEl.removeChild(sourceFolderEl);
192
                            foldersEl.removeChild(sourceFolderEl);
192
                        }
193
                        }
Lines 231-237 Link Here
231
                el.appendChild(doc.createTextNode(sf.encoding)); // NOI18N
232
                el.appendChild(doc.createTextNode(sf.encoding)); // NOI18N
232
                sourceFolderEl.appendChild(el);
233
                sourceFolderEl.appendChild(el);
233
            }
234
            }
234
            Util.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
235
            XMLUtil.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
235
        }
236
        }
236
        Util.putPrimaryConfigurationData(helper, data);
237
        Util.putPrimaryConfigurationData(helper, data);
237
    }
238
    }
Lines 248-283 Link Here
248
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
249
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
249
        List<SourceFolder> list = new ArrayList<SourceFolder>();
250
        List<SourceFolder> list = new ArrayList<SourceFolder>();
250
        Element data = Util.getPrimaryConfigurationData(helper);
251
        Element data = Util.getPrimaryConfigurationData(helper);
251
        Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
252
        Element viewEl =XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
252
        if (viewEl == null) {
253
        if (viewEl == null) {
253
            return list;
254
            return list;
254
        }
255
        }
255
        Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
256
        Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
256
        if (itemsEl == null) {
257
        if (itemsEl == null) {
257
            return list;
258
            return list;
258
        }
259
        }
259
        for (Element sourceFolderEl : Util.findSubElements(itemsEl)) {
260
        for (Element sourceFolderEl : XMLUtil.findSubElements(itemsEl)) {
260
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
261
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
261
                continue;
262
                continue;
262
            }
263
            }
263
            SourceFolder sf = new SourceFolder();
264
            SourceFolder sf = new SourceFolder();
264
            sf.style = sourceFolderEl.getAttribute("style"); // NOI18N
265
            sf.style = sourceFolderEl.getAttribute("style"); // NOI18N
265
            assert sf.style != null && sf.style.length() > 0 : "Bad style attr on <source-folder> in " + helper; // NOI18N
266
            assert sf.style != null && sf.style.length() > 0 : "Bad style attr on <source-folder> in " + helper; // NOI18N
266
            Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
267
            Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
267
            if (el != null) {
268
            if (el != null) {
268
                sf.label = Util.findText(el);
269
                sf.label = XMLUtil.findText(el);
269
            }
270
            }
270
            el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
271
            el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
271
            if (el != null) {
272
            if (el != null) {
272
                sf.location = Util.findText(el);
273
                sf.location = XMLUtil.findText(el);
273
            }
274
            }
274
            el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
275
            el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
275
            if (el != null) {
276
            if (el != null) {
276
                sf.includes = Util.findText(el);
277
                sf.includes = XMLUtil.findText(el);
277
            }
278
            }
278
            el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
279
            el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
279
            if (el != null) {
280
            if (el != null) {
280
                sf.excludes = Util.findText(el);
281
                sf.excludes = XMLUtil.findText(el);
281
            }
282
            }
282
            if (style == null || style.equals(sf.style)) {
283
            if (style == null || style.equals(sf.style)) {
283
                list.add(sf);
284
                list.add(sf);
Lines 299-318 Link Here
299
     */
300
     */
300
    public static void putSourceViews(AntProjectHelper helper, List<SourceFolder> sources, String style) {
301
    public static void putSourceViews(AntProjectHelper helper, List<SourceFolder> sources, String style) {
301
        //assert ProjectManager.mutex().isWriteAccess();
302
        //assert ProjectManager.mutex().isWriteAccess();
302
        ArrayList list = new ArrayList();
303
        //ArrayList list = new ArrayList();
303
        Element data = Util.getPrimaryConfigurationData(helper);
304
        Element data = Util.getPrimaryConfigurationData(helper);
304
        Document doc = data.getOwnerDocument();
305
        Document doc = data.getOwnerDocument();
305
        Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
306
        Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
306
        if (viewEl == null) {
307
        if (viewEl == null) {
307
            viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
308
            viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
308
            Util.appendChildElement(data, viewEl, rootElementsOrder);
309
            XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
309
        }
310
        }
310
        Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
311
        Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
311
        if (itemsEl == null) {
312
        if (itemsEl == null) {
312
            itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
313
            itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
313
            Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
314
            XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
314
        }
315
        }
315
        List<Element> sourceViews = Util.findSubElements(itemsEl);
316
        List<Element> sourceViews = XMLUtil.findSubElements(itemsEl);
316
        Iterator it = sourceViews.iterator();
317
        Iterator it = sourceViews.iterator();
317
        while (it.hasNext()) {
318
        while (it.hasNext()) {
318
            Element sourceViewEl = (Element)it.next();
319
            Element sourceViewEl = (Element)it.next();
Lines 354-360 Link Here
354
                el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
355
                el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
355
                sourceFolderEl.appendChild(el);
356
                sourceFolderEl.appendChild(el);
356
            }
357
            }
357
            Util.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
358
            XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
358
        }
359
        }
359
        Util.putPrimaryConfigurationData(helper, data);
360
        Util.putPrimaryConfigurationData(helper, data);
360
    }
361
    }
Lines 377-396 Link Here
377
        if (data == null) {
378
        if (data == null) {
378
            return list;
379
            return list;
379
        }
380
        }
380
        for (Element cuEl : Util.findSubElements(data)) {
381
        for (Element cuEl : XMLUtil.findSubElements(data)) {
381
            JavaCompilationUnit cu = new JavaCompilationUnit();
382
            JavaCompilationUnit cu = new JavaCompilationUnit();
382
            List<String> outputs = new ArrayList<String>();
383
            List<String> outputs = new ArrayList<String>();
383
            List<String> javadoc = new ArrayList<String>();
384
            List<String> javadoc = new ArrayList<String>();
384
            List<JavaCompilationUnit.CP> cps = new ArrayList<JavaCompilationUnit.CP>();
385
            List<JavaCompilationUnit.CP> cps = new ArrayList<JavaCompilationUnit.CP>();
385
            List<String> packageRoots = new ArrayList<String>();
386
            List<String> packageRoots = new ArrayList<String>();
386
            for (Element el : Util.findSubElements(cuEl)) {
387
            for (Element el : XMLUtil.findSubElements(cuEl)) {
387
                if (el.getLocalName().equals("package-root")) { // NOI18N
388
                if (el.getLocalName().equals("package-root")) { // NOI18N
388
                    packageRoots.add(Util.findText(el));
389
                    packageRoots.add(XMLUtil.findText(el));
389
                    continue;
390
                    continue;
390
                }
391
                }
391
                if (el.getLocalName().equals("classpath")) { // NOI18N
392
                if (el.getLocalName().equals("classpath")) { // NOI18N
392
                    JavaCompilationUnit.CP cp = new JavaCompilationUnit.CP();
393
                    JavaCompilationUnit.CP cp = new JavaCompilationUnit.CP();
393
                    cp.classpath = Util.findText(el);
394
                    cp.classpath = XMLUtil.findText(el);
394
                    cp.mode = el.getAttribute("mode"); // NOI18N
395
                    cp.mode = el.getAttribute("mode"); // NOI18N
395
                    if (cp.mode != null && cp.classpath != null) {
396
                    if (cp.mode != null && cp.classpath != null) {
396
                        cps.add(cp);
397
                        cps.add(cp);
Lines 398-412 Link Here
398
                    continue;
399
                    continue;
399
                }
400
                }
400
                if (el.getLocalName().equals("built-to")) { // NOI18N
401
                if (el.getLocalName().equals("built-to")) { // NOI18N
401
                    outputs.add(Util.findText(el));
402
                    outputs.add(XMLUtil.findText(el));
402
                    continue;
403
                    continue;
403
                }
404
                }
404
                if (el.getLocalName().equals("javadoc-built-to")) { // NOI18N
405
                if (el.getLocalName().equals("javadoc-built-to")) { // NOI18N
405
                    javadoc.add(Util.findText(el));
406
                    javadoc.add(XMLUtil.findText(el));
406
                    continue;
407
                    continue;
407
                }
408
                }
408
                if (el.getLocalName().equals("source-level")) { // NOI18N
409
                if (el.getLocalName().equals("source-level")) { // NOI18N
409
                    cu.sourceLevel = Util.findText(el);
410
                    cu.sourceLevel = XMLUtil.findText(el);
410
                }
411
                }
411
                if (el.getLocalName().equals("unit-tests")) { // NOI18N
412
                if (el.getLocalName().equals("unit-tests")) { // NOI18N
412
                    cu.isTests = true;
413
                    cu.isTests = true;
Lines 463-469 Link Here
463
            }
464
            }
464
        }
465
        }
465
        Document doc = data.getOwnerDocument();
466
        Document doc = data.getOwnerDocument();
466
        for (Element cuEl : Util.findSubElements(data)) {
467
        for (Element cuEl : XMLUtil.findSubElements(data)) {
467
            data.removeChild(cuEl);
468
            data.removeChild(cuEl);
468
        }
469
        }
469
        for (JavaCompilationUnit cu : compUnits) {
470
        for (JavaCompilationUnit cu : compUnits) {
Lines 614-623 Link Here
614
     */
615
     */
615
    public static void putExports(AntProjectHelper helper, List<Export> exports) {
616
    public static void putExports(AntProjectHelper helper, List<Export> exports) {
616
        //assert ProjectManager.mutex().isWriteAccess();
617
        //assert ProjectManager.mutex().isWriteAccess();
617
        ArrayList list = new ArrayList();
618
        //ArrayList list = new ArrayList();
618
        Element data = Util.getPrimaryConfigurationData(helper);
619
        Element data = Util.getPrimaryConfigurationData(helper);
619
        Document doc = data.getOwnerDocument();
620
        Document doc = data.getOwnerDocument();
620
        Iterator it = Util.findSubElements(data).iterator();
621
        Iterator it = XMLUtil.findSubElements(data).iterator();
621
        while (it.hasNext()) {
622
        while (it.hasNext()) {
622
            Element exportEl = (Element)it.next();
623
            Element exportEl = (Element)it.next();
623
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
624
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
Lines 649-655 Link Here
649
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
650
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
650
                exportEl.appendChild(el);
651
                exportEl.appendChild(el);
651
            }
652
            }
652
            Util.appendChildElement(data, exportEl, rootElementsOrder);
653
            XMLUtil.appendChildElement(data, exportEl, rootElementsOrder);
653
        }
654
        }
654
        Util.putPrimaryConfigurationData(helper, data);
655
        Util.putPrimaryConfigurationData(helper, data);
655
    }
656
    }
Lines 694-708 Link Here
694
     */
695
     */
695
    public static void putSubprojects(AntProjectHelper helper, List<String> subprojects) {
696
    public static void putSubprojects(AntProjectHelper helper, List<String> subprojects) {
696
        //assert ProjectManager.mutex().isWriteAccess();
697
        //assert ProjectManager.mutex().isWriteAccess();
697
        ArrayList list = new ArrayList();
698
        //ArrayList list = new ArrayList();
698
        Element data = Util.getPrimaryConfigurationData(helper);
699
        Element data = Util.getPrimaryConfigurationData(helper);
699
        Document doc = data.getOwnerDocument();
700
        Document doc = data.getOwnerDocument();
700
        Element subproject = Util.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
701
        Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
701
        if (subproject != null) {
702
        if (subproject != null) {
702
            data.removeChild(subproject);
703
            data.removeChild(subproject);
703
        }
704
        }
704
        subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
705
        subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
705
        Util.appendChildElement(data, subproject, rootElementsOrder);
706
        XMLUtil.appendChildElement(data, subproject, rootElementsOrder);
706
        
707
        
707
        Iterator it = subprojects.iterator();
708
        Iterator it = subprojects.iterator();
708
        while (it.hasNext()) {
709
        while (it.hasNext()) {
Lines 780-791 Link Here
780
    private static void putBuildElement(AntProjectHelper helper, List<String> buildFolders, String elemName) {
781
    private static void putBuildElement(AntProjectHelper helper, List<String> buildFolders, String elemName) {
781
        Element data = Util.getPrimaryConfigurationData(helper);
782
        Element data = Util.getPrimaryConfigurationData(helper);
782
        Document doc = data.getOwnerDocument();
783
        Document doc = data.getOwnerDocument();
783
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
784
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
784
        if (foldersEl == null) {
785
        if (foldersEl == null) {
785
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
786
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
786
            Util.appendChildElement(data, foldersEl, rootElementsOrder);
787
            XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
787
        } else {
788
        } else {
788
            List<Element> folders = Util.findSubElements(foldersEl);
789
            List<Element> folders = XMLUtil.findSubElements(foldersEl);
789
            Iterator it = folders.iterator();
790
            Iterator it = folders.iterator();
790
            while (it.hasNext()) {
791
            while (it.hasNext()) {
791
                Element buildFolderEl = (Element)it.next();
792
                Element buildFolderEl = (Element)it.next();
Lines 802-808 Link Here
802
            Element locationEl = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
803
            Element locationEl = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
803
            locationEl.appendChild(doc.createTextNode(location));
804
            locationEl.appendChild(doc.createTextNode(location));
804
            buildFolderEl.appendChild(locationEl);
805
            buildFolderEl.appendChild(locationEl);
805
            Util.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
806
            XMLUtil.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
806
        }
807
        }
807
        Util.putPrimaryConfigurationData(helper, data);
808
        Util.putPrimaryConfigurationData(helper, data);
808
    }
809
    }
Lines 861-907 Link Here
861
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
862
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
862
        List<TargetMapping> list = new ArrayList<TargetMapping>();
863
        List<TargetMapping> list = new ArrayList<TargetMapping>();
863
        Element genldata = Util.getPrimaryConfigurationData(helper);
864
        Element genldata = Util.getPrimaryConfigurationData(helper);
864
        Element actionsEl = Util.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
865
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
865
        if (actionsEl == null) {
866
        if (actionsEl == null) {
866
            return list;
867
            return list;
867
        }
868
        }
868
        for (Element actionEl : Util.findSubElements(actionsEl)) {
869
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
869
            TargetMapping tm = new TargetMapping();
870
            TargetMapping tm = new TargetMapping();
870
            tm.name = actionEl.getAttribute("name"); // NOI18N
871
            tm.name = actionEl.getAttribute("name"); // NOI18N
871
            List<String> targetNames = new ArrayList<String>();
872
            List<String> targetNames = new ArrayList<String>();
872
            EditableProperties props = new EditableProperties(false);
873
            EditableProperties props = new EditableProperties(false);
873
            for (Element subEl : Util.findSubElements(actionEl)) {
874
            for (Element subEl : XMLUtil.findSubElements(actionEl)) {
874
                if (subEl.getLocalName().equals("target")) { // NOI18N
875
                if (subEl.getLocalName().equals("target")) { // NOI18N
875
                    targetNames.add(Util.findText(subEl));
876
                    targetNames.add(XMLUtil.findText(subEl));
876
                    continue;
877
                    continue;
877
                }
878
                }
878
                if (subEl.getLocalName().equals("script")) { // NOI18N
879
                if (subEl.getLocalName().equals("script")) { // NOI18N
879
                    tm.script = Util.findText(subEl);
880
                    tm.script = XMLUtil.findText(subEl);
880
                    continue;
881
                    continue;
881
                }
882
                }
882
                if (subEl.getLocalName().equals("context")) { // NOI18N
883
                if (subEl.getLocalName().equals("context")) { // NOI18N
883
                    TargetMapping.Context ctx = new TargetMapping.Context();
884
                    TargetMapping.Context ctx = new TargetMapping.Context();
884
                    for (Element contextSubEl : Util.findSubElements(subEl)) {
885
                    for (Element contextSubEl : XMLUtil.findSubElements(subEl)) {
885
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
886
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
886
                            ctx.property = Util.findText(contextSubEl);
887
                            ctx.property = XMLUtil.findText(contextSubEl);
887
                            continue;
888
                            continue;
888
                        }
889
                        }
889
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
890
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
890
                            ctx.format = Util.findText(contextSubEl);
891
                            ctx.format = XMLUtil.findText(contextSubEl);
891
                            continue;
892
                            continue;
892
                        }
893
                        }
893
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
894
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
894
                            ctx.folder = Util.findText(contextSubEl);
895
                            ctx.folder = XMLUtil.findText(contextSubEl);
895
                            continue;
896
                            continue;
896
                        }
897
                        }
897
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
898
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
898
                            ctx.pattern = Util.findText(contextSubEl);
899
                            ctx.pattern = XMLUtil.findText(contextSubEl);
899
                            continue;
900
                            continue;
900
                        }
901
                        }
901
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
902
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
902
                            Element sepFilesEl = Util.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
903
                            Element sepFilesEl = XMLUtil.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
903
                            if (sepFilesEl != null) {
904
                            if (sepFilesEl != null) {
904
                                ctx.separator = Util.findText(sepFilesEl);
905
                                ctx.separator = XMLUtil.findText(sepFilesEl);
905
                            }
906
                            }
906
                            continue;
907
                            continue;
907
                        }
908
                        }
Lines 955-961 Link Here
955
    
956
    
956
    private static void readProperty(Element propertyElement, EditableProperties props) {
957
    private static void readProperty(Element propertyElement, EditableProperties props) {
957
        String key = propertyElement.getAttribute("name"); // NOI18N
958
        String key = propertyElement.getAttribute("name"); // NOI18N
958
        String value = Util.findText(propertyElement);
959
        String value = XMLUtil.findText(propertyElement);
959
        props.setProperty(key, value);
960
        props.setProperty(key, value);
960
    }
961
    }
961
962
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavadocQuery.java (-6 / +6 lines)
Lines 47-58 Link Here
47
import java.util.List;
47
import java.util.List;
48
import javax.swing.event.ChangeListener;
48
import javax.swing.event.ChangeListener;
49
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
49
import org.netbeans.api.java.queries.JavadocForBinaryQuery;
50
import org.netbeans.modules.ant.freeform.spi.support.Util;
51
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
50
import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation;
52
import org.netbeans.spi.project.AuxiliaryConfiguration;
51
import org.netbeans.spi.project.AuxiliaryConfiguration;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
54
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
53
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
55
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
55
import org.openide.xml.XMLUtil;
56
import org.w3c.dom.Element;
56
import org.w3c.dom.Element;
57
57
58
/**
58
/**
Lines 74-85 Link Here
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_2, true);
76
        if (data != null) {
76
        if (data != null) {
77
            for (Element cu : Util.findSubElements(data)) {
77
            for (Element cu : XMLUtil.findSubElements(data)) {
78
                assert cu.getLocalName().equals("compilation-unit") : cu;
78
                assert cu.getLocalName().equals("compilation-unit") : cu;
79
                boolean rightCU = false;
79
                boolean rightCU = false;
80
                for (Element builtTo : Util.findSubElements(cu)) {
80
                for (Element builtTo : XMLUtil.findSubElements(cu)) {
81
                    if (builtTo.getLocalName().equals("built-to")) { // NOI18N
81
                    if (builtTo.getLocalName().equals("built-to")) { // NOI18N
82
                        String rawtext = Util.findText(builtTo);
82
                        String rawtext = XMLUtil.findText(builtTo);
83
                        assert rawtext != null;
83
                        assert rawtext != null;
84
                        String evaltext = eval.evaluate(rawtext);
84
                        String evaltext = eval.evaluate(rawtext);
85
                        if (evaltext != null) {
85
                        if (evaltext != null) {
Lines 95-103 Link Here
95
                }
95
                }
96
                if (rightCU) {
96
                if (rightCU) {
97
                    List<URL> resultURLs = new ArrayList<URL>();
97
                    List<URL> resultURLs = new ArrayList<URL>();
98
                    for (Element javadocTo : Util.findSubElements(cu)) {
98
                    for (Element javadocTo : XMLUtil.findSubElements(cu)) {
99
                        if (javadocTo.getLocalName().equals("javadoc-built-to")) { // NOI18N
99
                        if (javadocTo.getLocalName().equals("javadoc-built-to")) { // NOI18N
100
                            String rawtext = Util.findText(javadocTo);
100
                            String rawtext = XMLUtil.findText(javadocTo);
101
                            assert rawtext != null;
101
                            assert rawtext != null;
102
                            String evaltext = eval.evaluate(rawtext);
102
                            String evaltext = eval.evaluate(rawtext);
103
                            if (evaltext != null) {
103
                            if (evaltext != null) {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceForBinaryQueryImpl.java (-4 / +4 lines)
Lines 50-56 Link Here
50
import javax.swing.event.ChangeListener;
50
import javax.swing.event.ChangeListener;
51
import org.netbeans.api.java.queries.SourceForBinaryQuery;
51
import org.netbeans.api.java.queries.SourceForBinaryQuery;
52
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.api.project.ProjectManager;
53
import org.netbeans.modules.ant.freeform.spi.support.Util;
54
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
53
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
55
import org.netbeans.spi.project.AuxiliaryConfiguration;
54
import org.netbeans.spi.project.AuxiliaryConfiguration;
56
import org.netbeans.spi.project.support.ant.AntProjectEvent;
55
import org.netbeans.spi.project.support.ant.AntProjectEvent;
Lines 60-65 Link Here
60
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
62
import org.openide.util.Mutex;
61
import org.openide.util.Mutex;
62
import org.openide.xml.XMLUtil;
63
import org.w3c.dom.Element;
63
import org.w3c.dom.Element;
64
64
65
/**
65
/**
Lines 100-106 Link Here
100
            if (java == null) {
100
            if (java == null) {
101
                return null;
101
                return null;
102
            }
102
            }
103
            for (Element compilationUnit : Util.findSubElements(java)) {
103
            for (Element compilationUnit : XMLUtil.findSubElements(java)) {
104
                assert compilationUnit.getLocalName().equals("compilation-unit") : compilationUnit;
104
                assert compilationUnit.getLocalName().equals("compilation-unit") : compilationUnit;
105
                List<URL> binaries = findBinaries(compilationUnit);
105
                List<URL> binaries = findBinaries(compilationUnit);
106
                if (!binaries.isEmpty()) {
106
                if (!binaries.isEmpty()) {
Lines 137-147 Link Here
137
     */
137
     */
138
    private List<URL> findBinaries(Element compilationUnitEl) {
138
    private List<URL> findBinaries(Element compilationUnitEl) {
139
        List<URL> binaries = new ArrayList<URL>();
139
        List<URL> binaries = new ArrayList<URL>();
140
        for (Element builtToEl : Util.findSubElements(compilationUnitEl)) {
140
        for (Element builtToEl : XMLUtil.findSubElements(compilationUnitEl)) {
141
            if (!builtToEl.getLocalName().equals("built-to")) { // NOI18N
141
            if (!builtToEl.getLocalName().equals("built-to")) { // NOI18N
142
                continue;
142
                continue;
143
            }
143
            }
144
            String text = Util.findText(builtToEl);
144
            String text = XMLUtil.findText(builtToEl);
145
            String textEval = evaluator.evaluate(text);
145
            String textEval = evaluator.evaluate(text);
146
            if (textEval == null) {
146
            if (textEval == null) {
147
                continue;
147
                continue;
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/SourceLevelQueryImpl.java (-4 / +4 lines)
Lines 45-51 Link Here
45
import java.util.Map;
45
import java.util.Map;
46
import java.util.WeakHashMap;
46
import java.util.WeakHashMap;
47
import org.netbeans.api.project.ProjectManager;
47
import org.netbeans.api.project.ProjectManager;
48
import org.netbeans.modules.ant.freeform.spi.support.Util;
49
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
48
import org.netbeans.spi.java.queries.SourceLevelQueryImplementation;
50
import org.netbeans.spi.project.AuxiliaryConfiguration;
49
import org.netbeans.spi.project.AuxiliaryConfiguration;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
50
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 54-59 Link Here
54
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
56
import org.openide.util.Mutex;
55
import org.openide.util.Mutex;
56
import org.openide.xml.XMLUtil;
57
import org.w3c.dom.Element;
57
import org.w3c.dom.Element;
58
58
59
/**
59
/**
Lines 102-108 Link Here
102
        if (java == null) {
102
        if (java == null) {
103
            return null;
103
            return null;
104
        }
104
        }
105
        for (Element compilationUnitEl : Util.findSubElements(java)) {
105
        for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
106
            assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
106
            assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
107
            List<FileObject> packageRoots = Classpaths.findPackageRoots(helper, evaluator, compilationUnitEl);
107
            List<FileObject> packageRoots = Classpaths.findPackageRoots(helper, evaluator, compilationUnitEl);
108
            for (FileObject root : packageRoots) {
108
            for (FileObject root : packageRoots) {
Lines 133-141 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 = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_2);
137
        if (sourceLevelEl != null) {
137
        if (sourceLevelEl != null) {
138
            return Util.findText(sourceLevelEl);
138
            return XMLUtil.findText(sourceLevelEl);
139
        } else {
139
        } else {
140
            return null;
140
            return null;
141
        }
141
        }
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/TestQuery.java (-5 / +5 lines)
Lines 46-52 Link Here
46
import java.util.ArrayList;
46
import java.util.ArrayList;
47
import java.util.Arrays;
47
import java.util.Arrays;
48
import java.util.List;
48
import java.util.List;
49
import org.netbeans.modules.ant.freeform.spi.support.Util;
50
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
49
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
51
import org.netbeans.spi.project.AuxiliaryConfiguration;
50
import org.netbeans.spi.project.AuxiliaryConfiguration;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 54-59 Link Here
54
import org.openide.filesystems.FileObject;
53
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileStateInvalidException;
54
import org.openide.filesystems.FileStateInvalidException;
56
import org.openide.filesystems.FileUtil;
55
import org.openide.filesystems.FileUtil;
56
import org.openide.xml.XMLUtil;
57
import org.w3c.dom.Element;
57
import org.w3c.dom.Element;
58
58
59
/**
59
/**
Lines 117-128 Link Here
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_2, true);
119
        if (data != null) {
119
        if (data != null) {
120
            for (Element cu : Util.findSubElements(data)) {
120
            for (Element cu : XMLUtil.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 = XMLUtil.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_2) != null; // NOI18N
123
                for (Element pr : Util.findSubElements(cu)) {
123
                for (Element pr : XMLUtil.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 = XMLUtil.findText(pr);
126
                        assert rawtext != null;
126
                        assert rawtext != null;
127
                        String evaltext = eval.evaluate(rawtext);
127
                        String evaltext = eval.evaluate(rawtext);
128
                        if (evaltext != null) {
128
                        if (evaltext != null) {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/UsageLogger.java (-4 / +4 lines)
Lines 50-56 Link Here
50
import org.netbeans.api.project.ProjectUtils;
50
import org.netbeans.api.project.ProjectUtils;
51
import org.netbeans.modules.ant.freeform.spi.ProjectAccessor;
51
import org.netbeans.modules.ant.freeform.spi.ProjectAccessor;
52
import org.netbeans.modules.ant.freeform.spi.ProjectConstants;
52
import org.netbeans.modules.ant.freeform.spi.ProjectConstants;
53
import org.netbeans.modules.ant.freeform.spi.support.Util;
54
import org.netbeans.spi.project.AuxiliaryConfiguration;
53
import org.netbeans.spi.project.AuxiliaryConfiguration;
55
import org.netbeans.spi.project.support.ant.AntProjectHelper;
54
import org.netbeans.spi.project.support.ant.AntProjectHelper;
56
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
55
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
Lines 60-65 Link Here
60
import org.openide.util.Exceptions;
59
import org.openide.util.Exceptions;
61
import org.openide.util.NbBundle;
60
import org.openide.util.NbBundle;
62
import org.openide.util.RequestProcessor;
61
import org.openide.util.RequestProcessor;
62
import org.openide.xml.XMLUtil;
63
import org.w3c.dom.Element;
63
import org.w3c.dom.Element;
64
64
65
/**
65
/**
Lines 110-127 Link Here
110
            java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
110
            java = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
111
        }
111
        }
112
        if (java != null) {
112
        if (java != null) {
113
            for (Element compilationUnitEl : Util.findSubElements(java)) {
113
            for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
114
                compilationUnits++;
114
                compilationUnits++;
115
                int builtTos = 0;
115
                int builtTos = 0;
116
                int roots = 0;
116
                int roots = 0;
117
                for (Element other : Util.findSubElements(compilationUnitEl)) {
117
                for (Element other : XMLUtil.findSubElements(compilationUnitEl)) {
118
                    String name = other.getLocalName();
118
                    String name = other.getLocalName();
119
                    if (name.equals("package-root")) { // NOI18N
119
                    if (name.equals("package-root")) { // NOI18N
120
                        roots++;
120
                        roots++;
121
                    } else if (name.equals("built-to")) { // NOI18N
121
                    } else if (name.equals("built-to")) { // NOI18N
122
                        builtTos++;
122
                        builtTos++;
123
                    } else if (name.equals("classpath")) { // NOI18N
123
                    } else if (name.equals("classpath")) { // NOI18N
124
                        String text = Util.findText(other);
124
                        String text = XMLUtil.findText(other);
125
                        if (text != null) {
125
                        if (text != null) {
126
                            String textEval = eval.evaluate(text);
126
                            String textEval = eval.evaluate(text);
127
                            if (textEval != null) {
127
                            if (textEval != null) {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/jdkselection/JdkConfiguration.java (-10 / +9 lines)
Lines 53-59 Link Here
53
import org.netbeans.api.project.ProjectManager;
53
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.api.project.ProjectUtils;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.modules.ant.freeform.spi.support.Util;
55
import org.netbeans.modules.ant.freeform.spi.support.Util;
56
import org.netbeans.modules.java.freeform.JavaProjectGenerator;
57
import org.netbeans.spi.project.support.ant.AntProjectHelper;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
58
import org.netbeans.spi.project.support.ant.EditableProperties;
57
import org.netbeans.spi.project.support.ant.EditableProperties;
59
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
58
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
Lines 163-179 Link Here
163
        Element projectE = nbjdkDoc.getDocumentElement();
162
        Element projectE = nbjdkDoc.getDocumentElement();
164
        Set<String> targetsCreated = new HashSet<String>();
163
        Set<String> targetsCreated = new HashSet<String>();
165
        // XXX remove any definition of ${ant.script}, which will by now be obsolete
164
        // XXX remove any definition of ${ant.script}, which will by now be obsolete
166
        Element ideActionsE = Util.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
165
        Element ideActionsE = XMLUtil.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
167
        if (ideActionsE != null) {
166
        if (ideActionsE != null) {
168
            for (Element actionE : Util.findSubElements(ideActionsE)) {
167
            for (Element actionE : XMLUtil.findSubElements(ideActionsE)) {
169
                rebindAction(actionE, projectE, targetsCreated);
168
                rebindAction(actionE, projectE, targetsCreated);
170
            }
169
            }
171
        }
170
        }
172
        Element viewE = Util.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
171
        Element viewE = XMLUtil.findElement(generalDataE, "ide-actions", Util.NAMESPACE);
173
        if (viewE != null) {
172
        if (viewE != null) {
174
            Element contextMenuE = Util.findElement(viewE, "context-menu", Util.NAMESPACE);
173
            Element contextMenuE = XMLUtil.findElement(viewE, "context-menu", Util.NAMESPACE);
175
            if (contextMenuE != null) {
174
            if (contextMenuE != null) {
176
                for (Element actionE : Util.findSubElements(contextMenuE)) {
175
                for (Element actionE : XMLUtil.findSubElements(contextMenuE)) {
177
                    if (!actionE.getLocalName().equals("action")) {
176
                    if (!actionE.getLocalName().equals("action")) {
178
                        continue; // ignore <ide-action> here
177
                        continue; // ignore <ide-action> here
179
                    }
178
                    }
Lines 187-196 Link Here
187
    }
186
    }
188
187
189
    private void rebindAction(Element actionE, Element projectE, Set<String> targetsCreated) {
188
    private void rebindAction(Element actionE, Element projectE, Set<String> targetsCreated) {
190
        Element scriptE = Util.findElement(actionE, "script", Util.NAMESPACE); // NOI18N
189
        Element scriptE = XMLUtil.findElement(actionE, "script", Util.NAMESPACE); // NOI18N
191
        String script;
190
        String script;
192
        if (scriptE != null) {
191
        if (scriptE != null) {
193
            script = Util.findText(scriptE);
192
            script = XMLUtil.findText(scriptE);
194
            actionE.removeChild(scriptE);
193
            actionE.removeChild(scriptE);
195
        } else {
194
        } else {
196
            script = "build.xml"; // NOI18N
195
            script = "build.xml"; // NOI18N
Lines 199-209 Link Here
199
        scriptE.appendChild(actionE.getOwnerDocument().createTextNode(NBJDK_XML));
198
        scriptE.appendChild(actionE.getOwnerDocument().createTextNode(NBJDK_XML));
200
        actionE.insertBefore(scriptE, actionE.getFirstChild());
199
        actionE.insertBefore(scriptE, actionE.getFirstChild());
201
        List<String> targetNames = new ArrayList<String>();
200
        List<String> targetNames = new ArrayList<String>();
202
        for (Element targetE : Util.findSubElements(actionE)) {
201
        for (Element targetE : XMLUtil.findSubElements(actionE)) {
203
            if (!targetE.getLocalName().equals("target")) { // NOI18N
202
            if (!targetE.getLocalName().equals("target")) { // NOI18N
204
                continue;
203
                continue;
205
            }
204
            }
206
            targetNames.add(Util.findText(targetE));
205
            targetNames.add(XMLUtil.findText(targetE));
207
        }
206
        }
208
        if (targetNames.isEmpty()) {
207
        if (targetNames.isEmpty()) {
209
            targetNames.add(null);
208
            targetNames.add(null);
(-)a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/ClasspathsTest.java (-2 / +3 lines)
Lines 77-82 Link Here
77
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileObject;
78
import org.openide.filesystems.FileUtil;
78
import org.openide.filesystems.FileUtil;
79
import org.openide.util.Mutex;
79
import org.openide.util.Mutex;
80
import org.openide.xml.XMLUtil;
80
import org.w3c.dom.Document;
81
import org.w3c.dom.Document;
81
import org.w3c.dom.Element;
82
import org.w3c.dom.Element;
82
83
Lines 456-462 Link Here
456
        FileUtil.createData(new File(d, "s/ignored/file"));
457
        FileUtil.createData(new File(d, "s/ignored/file"));
457
        Element data = Util.getPrimaryConfigurationData(helper);
458
        Element data = Util.getPrimaryConfigurationData(helper);
458
        Document doc = data.getOwnerDocument();
459
        Document doc = data.getOwnerDocument();
459
        Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE)).
460
        Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE)).
460
                appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
461
                appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
461
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
462
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
462
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
463
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
Lines 547-553 Link Here
547
        data.getElementsByTagName("properties").item(0).
548
        data.getElementsByTagName("properties").item(0).
548
                appendChild(doc.createElementNS(Util.NAMESPACE, "property-file")).
549
                appendChild(doc.createElementNS(Util.NAMESPACE, "property-file")).
549
                appendChild(doc.createTextNode("config.properties"));
550
                appendChild(doc.createTextNode("config.properties"));
550
        Element folders = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE));
551
        Element folders = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE));
551
        Element sf = (Element) folders.appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
552
        Element sf = (Element) folders.appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
552
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources #1"));
553
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources #1"));
553
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
554
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode(JavaProjectConstants.SOURCES_TYPE_JAVA));
(-)a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaActionsTest.java (-17 / +16 lines)
Lines 51-57 Link Here
51
import java.util.Locale;
51
import java.util.Locale;
52
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.api.project.ProjectManager;
53
import org.netbeans.modules.ant.freeform.FreeformProject;
53
import org.netbeans.modules.ant.freeform.FreeformProject;
54
import org.netbeans.modules.ant.freeform.FreeformProjectType;
55
import org.netbeans.modules.ant.freeform.TestBase;
54
import org.netbeans.modules.ant.freeform.TestBase;
56
import org.netbeans.modules.ant.freeform.spi.support.Util;
55
import org.netbeans.modules.ant.freeform.spi.support.Util;
57
import org.netbeans.spi.project.ActionProvider;
56
import org.netbeans.spi.project.ActionProvider;
Lines 88-100 Link Here
88
        prj = copyProject(simple);
87
        prj = copyProject(simple);
89
        // Remove existing context-sensitive bindings to make a clean slate.
88
        // Remove existing context-sensitive bindings to make a clean slate.
90
        Element data = prj.getPrimaryConfigurationData();
89
        Element data = prj.getPrimaryConfigurationData();
91
        Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
90
        Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
92
        assertNotNull(ideActions);
91
        assertNotNull(ideActions);
93
        Iterator<Element> actionsIt = Util.findSubElements(ideActions).iterator();
92
        Iterator<Element> actionsIt = XMLUtil.findSubElements(ideActions).iterator();
94
        while (actionsIt.hasNext()) {
93
        while (actionsIt.hasNext()) {
95
            Element action = actionsIt.next();
94
            Element action = actionsIt.next();
96
            assertEquals("action", action.getLocalName());
95
            assertEquals("action", action.getLocalName());
97
            if (Util.findElement(action, "context", Util.NAMESPACE) != null) {
96
            if (XMLUtil.findElement(action, "context", Util.NAMESPACE) != null) {
98
                ideActions.removeChild(action);
97
                ideActions.removeChild(action);
99
            }
98
            }
100
        }
99
        }
Lines 209-217 Link Here
209
        ja.addBinding("some.action", "special.xml", "special-target", "selection", "${some.src.dir}", "\\.java$", "relative-path", ",");
208
        ja.addBinding("some.action", "special.xml", "special-target", "selection", "${some.src.dir}", "\\.java$", "relative-path", ",");
210
        Element data = prj.getPrimaryConfigurationData();
209
        Element data = prj.getPrimaryConfigurationData();
211
        assertNotNull(data);
210
        assertNotNull(data);
212
        Element ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
211
        Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
213
        assertNotNull(ideActions);
212
        assertNotNull(ideActions);
214
        List<Element> actions = Util.findSubElements(ideActions);
213
        List<Element> actions = XMLUtil.findSubElements(ideActions);
215
        Element lastAction = actions.get(actions.size() - 1);
214
        Element lastAction = actions.get(actions.size() - 1);
216
        String expectedXml =
215
        String expectedXml =
217
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
216
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 231-238 Link Here
231
        assertEquals(expectedXml, xmlToString(lastAction));
230
        assertEquals(expectedXml, xmlToString(lastAction));
232
        ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
231
        ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
233
        data = prj.getPrimaryConfigurationData();
232
        data = prj.getPrimaryConfigurationData();
234
        ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
233
        ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
235
        actions = Util.findSubElements(ideActions);
234
        actions = XMLUtil.findSubElements(ideActions);
236
        lastAction = actions.get(actions.size() - 1);
235
        lastAction = actions.get(actions.size() - 1);
237
        expectedXml =
236
        expectedXml =
238
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
237
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 252-259 Link Here
252
        // Non-context-sensitive bindings have no <context> but need to add a view item.
251
        // Non-context-sensitive bindings have no <context> but need to add a view item.
253
        ja.addBinding("general.action", "special.xml", "special-target", null, null, null, null, null);
252
        ja.addBinding("general.action", "special.xml", "special-target", null, null, null, null, null);
254
        data = prj.getPrimaryConfigurationData();
253
        data = prj.getPrimaryConfigurationData();
255
        ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
254
        ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
256
        actions = Util.findSubElements(ideActions);
255
        actions = XMLUtil.findSubElements(ideActions);
257
        lastAction = actions.get(actions.size() - 1);
256
        lastAction = actions.get(actions.size() - 1);
258
        expectedXml =
257
        expectedXml =
259
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
258
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 262-273 Link Here
262
            "    <target>special-target</target>\n" +
261
            "    <target>special-target</target>\n" +
263
            "</action>\n";
262
            "</action>\n";
264
        assertEquals(expectedXml, xmlToString(lastAction));
263
        assertEquals(expectedXml, xmlToString(lastAction));
265
        Element view = Util.findElement(data, "view", Util.NAMESPACE);
264
        Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE);
266
        assertNotNull(view);
265
        assertNotNull(view);
267
        Element contextMenu = Util.findElement(view, "context-menu", Util.NAMESPACE);
266
        Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE);
268
        assertNotNull(contextMenu);
267
        assertNotNull(contextMenu);
269
        // Currently (no FPG to help) it is always added as the last item.
268
        // Currently (no FPG to help) it is always added as the last item.
270
        List<Element> contextMenuActions = Util.findSubElements(contextMenu);
269
        List<Element> contextMenuActions = XMLUtil.findSubElements(contextMenu);
271
        Element lastContextMenuAction = contextMenuActions.get(contextMenuActions.size() - 1);
270
        Element lastContextMenuAction = contextMenuActions.get(contextMenuActions.size() - 1);
272
        expectedXml =
271
        expectedXml =
273
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
272
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 276-288 Link Here
276
        
275
        
277
        //test #58442:
276
        //test #58442:
278
        data = prj.getPrimaryConfigurationData();
277
        data = prj.getPrimaryConfigurationData();
279
        ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
278
        ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
280
        data.removeChild(ideActions);
279
        data.removeChild(ideActions);
281
        
280
        
282
        ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
281
        ja.addBinding("some.other.action", "special.xml", "special-target", "selection", "${some.src.dir}", null, "relative-path", null);
283
        data = prj.getPrimaryConfigurationData();
282
        data = prj.getPrimaryConfigurationData();
284
        ideActions = Util.findElement(data, "ide-actions", Util.NAMESPACE);
283
        ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE);
285
        actions = Util.findSubElements(ideActions);
284
        actions = XMLUtil.findSubElements(ideActions);
286
        lastAction = actions.get(actions.size() - 1);
285
        lastAction = actions.get(actions.size() - 1);
287
        expectedXml =
286
        expectedXml =
288
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
287
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
Lines 460-466 Link Here
460
        assertEquals("Correct code generated for external script", expectedXml, xmlToString(root));
459
        assertEquals("Correct code generated for external script", expectedXml, xmlToString(root));
461
        // And also with locations defined as special properties in various ways...
460
        // And also with locations defined as special properties in various ways...
462
        Element data = prj.getPrimaryConfigurationData();
461
        Element data = prj.getPrimaryConfigurationData();
463
        Element properties = Util.findElement(data, "properties", Util.NAMESPACE);
462
        Element properties = XMLUtil.findElement(data, "properties", Util.NAMESPACE);
464
        assertNotNull(properties);
463
        assertNotNull(properties);
465
        Element property = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "property");
464
        Element property = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "property");
466
        property.setAttribute("name", "external.xml");
465
        property.setAttribute("name", "external.xml");
(-)a/java.freeform/test/unit/src/org/netbeans/modules/java/freeform/JavaProjectGeneratorTest.java (-74 / +75 lines)
Lines 77-82 Link Here
77
import org.netbeans.spi.project.support.ant.PropertyUtils;
77
import org.netbeans.spi.project.support.ant.PropertyUtils;
78
import org.openide.modules.ModuleInfo;
78
import org.openide.modules.ModuleInfo;
79
import org.openide.util.Lookup;
79
import org.openide.util.Lookup;
80
import org.openide.xml.XMLUtil;
80
81
81
/**
82
/**
82
 * Tests for JavaProjectGenerator.
83
 * Tests for JavaProjectGenerator.
Lines 212-236 Link Here
212
        // check that all elements are written in expected order
213
        // check that all elements are written in expected order
213
        
214
        
214
        Element el = Util.getPrimaryConfigurationData(helper);
215
        Element el = Util.getPrimaryConfigurationData(helper);
215
        List subElements = Util.findSubElements(el);
216
        List subElements = XMLUtil.findSubElements(el);
216
        assertEquals(7, subElements.size());
217
        assertEquals(7, subElements.size());
217
        assertElementArray(subElements, 
218
        assertElementArray(subElements, 
218
            new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"}, 
219
            new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"}, 
219
            new String[]{null, null, null, null, null, null, null});
220
            new String[]{null, null, null, null, null, null, null});
220
        Element el2 = (Element)subElements.get(5);
221
        Element el2 = (Element)subElements.get(5);
221
        subElements = Util.findSubElements(el2);
222
        subElements = XMLUtil.findSubElements(el2);
222
        assertEquals(2, subElements.size());
223
        assertEquals(2, subElements.size());
223
        assertElementArray(subElements, 
224
        assertElementArray(subElements, 
224
            new String[]{"items", "context-menu"}, 
225
            new String[]{"items", "context-menu"}, 
225
            new String[]{null, null});
226
            new String[]{null, null});
226
        Element el3 = (Element)subElements.get(0);
227
        Element el3 = (Element)subElements.get(0);
227
        List subEls = Util.findSubElements(el3);
228
        List subEls = XMLUtil.findSubElements(el3);
228
        assertEquals(2, subEls.size());
229
        assertEquals(2, subEls.size());
229
        assertElementArray(subEls, 
230
        assertElementArray(subEls, 
230
            new String[]{"source-folder", "source-file"}, 
231
            new String[]{"source-folder", "source-file"}, 
231
            new String[]{null, null});
232
            new String[]{null, null});
232
        el3 = (Element)subElements.get(1);
233
        el3 = (Element)subElements.get(1);
233
        subEls = Util.findSubElements(el3);
234
        subEls = XMLUtil.findSubElements(el3);
234
        assertEquals(2, subEls.size());
235
        assertEquals(2, subEls.size());
235
        assertElementArray(subEls, 
236
        assertElementArray(subEls, 
236
            new String[]{"ide-action", "action"}, 
237
            new String[]{"ide-action", "action"}, 
Lines 259-283 Link Here
259
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
260
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
260
//        ProjectManager.getDefault().saveAllProjects();
261
//        ProjectManager.getDefault().saveAllProjects();
261
        el = Util.getPrimaryConfigurationData(helper);
262
        el = Util.getPrimaryConfigurationData(helper);
262
        subElements = Util.findSubElements(el);
263
        subElements = XMLUtil.findSubElements(el);
263
        assertEquals(7, subElements.size());
264
        assertEquals(7, subElements.size());
264
        assertElementArray(subElements, 
265
        assertElementArray(subElements, 
265
            new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"}, 
266
            new String[]{"name", "properties", "folders", "ide-actions", "export", "view", "subprojects"}, 
266
            new String[]{null, null, null, null, null, null, null});
267
            new String[]{null, null, null, null, null, null, null});
267
        el2 = (Element)subElements.get(5);
268
        el2 = (Element)subElements.get(5);
268
        subElements = Util.findSubElements(el2);
269
        subElements = XMLUtil.findSubElements(el2);
269
        assertEquals(2, subElements.size());
270
        assertEquals(2, subElements.size());
270
        assertElementArray(subElements, 
271
        assertElementArray(subElements, 
271
            new String[]{"items", "context-menu"}, 
272
            new String[]{"items", "context-menu"}, 
272
            new String[]{null, null});
273
            new String[]{null, null});
273
        el3 = (Element)subElements.get(0);
274
        el3 = (Element)subElements.get(0);
274
        subEls = Util.findSubElements(el3);
275
        subEls = XMLUtil.findSubElements(el3);
275
        assertEquals(2, subEls.size());
276
        assertEquals(2, subEls.size());
276
        assertElementArray(subEls, 
277
        assertElementArray(subEls, 
277
            new String[]{"source-folder", "source-file"}, 
278
            new String[]{"source-folder", "source-file"}, 
278
            new String[]{null, null});
279
            new String[]{null, null});
279
        el3 = (Element)subElements.get(1);
280
        el3 = (Element)subElements.get(1);
280
        subEls = Util.findSubElements(el3);
281
        subEls = XMLUtil.findSubElements(el3);
281
        assertEquals(2, subEls.size());
282
        assertEquals(2, subEls.size());
282
        assertElementArray(subEls, 
283
        assertElementArray(subEls, 
283
            new String[]{"ide-action", "action"}, 
284
            new String[]{"ide-action", "action"}, 
Lines 296-302 Link Here
296
        String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
297
        String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
297
        assertEquals(message, expectedName, element.getLocalName());
298
        assertEquals(message, expectedName, element.getLocalName());
298
        if (expectedValue != null) {
299
        if (expectedValue != null) {
299
            assertEquals(message, expectedValue, Util.findText(element));
300
            assertEquals(message, expectedValue, XMLUtil.findText(element));
300
        }
301
        }
301
    }
302
    }
302
303
Lines 324-330 Link Here
324
            expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
325
            expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
325
        assertEquals(message, expectedName, element.getLocalName());
326
        assertEquals(message, expectedName, element.getLocalName());
326
        if (expectedValue != null) {
327
        if (expectedValue != null) {
327
            assertEquals(message, expectedValue, Util.findText(element));
328
            assertEquals(message, expectedValue, XMLUtil.findText(element));
328
        }
329
        }
329
        String val = element.getAttribute(expectedAttrName);
330
        String val = element.getAttribute(expectedAttrName);
330
        assertEquals(expectedAttrValue, val);
331
        assertEquals(expectedAttrValue, val);
Lines 434-447 Link Here
434
        JavaProjectGenerator.putSourceFolders(helper, folders, null);
435
        JavaProjectGenerator.putSourceFolders(helper, folders, null);
435
//        ProjectManager.getDefault().saveAllProjects();
436
//        ProjectManager.getDefault().saveAllProjects();
436
        Element el = Util.getPrimaryConfigurationData(helper);
437
        Element el = Util.getPrimaryConfigurationData(helper);
437
        el = Util.findElement(el, "folders", Util.NAMESPACE);
438
        el = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
438
        assertNotNull("Source folders were not saved correctly",  el);
439
        assertNotNull("Source folders were not saved correctly",  el);
439
        List subElements = Util.findSubElements(el);
440
        List subElements = XMLUtil.findSubElements(el);
440
        assertEquals(2, subElements.size());
441
        assertEquals(2, subElements.size());
441
        // compare first source folder
442
        // compare first source folder
442
        Element el2 = (Element)subElements.get(0);
443
        Element el2 = (Element)subElements.get(0);
443
        assertElement(el2, "source-folder", null);
444
        assertElement(el2, "source-folder", null);
444
        List l1 = Util.findSubElements(el2);
445
        List l1 = XMLUtil.findSubElements(el2);
445
        assertEquals(3, l1.size());
446
        assertEquals(3, l1.size());
446
        assertElementArray(l1, 
447
        assertElementArray(l1, 
447
            new String[]{"label", "type", "location"}, 
448
            new String[]{"label", "type", "location"}, 
Lines 449-455 Link Here
449
        // compare second source folder
450
        // compare second source folder
450
        el2 = (Element)subElements.get(1);
451
        el2 = (Element)subElements.get(1);
451
        assertElement(el2, "source-folder", null);
452
        assertElement(el2, "source-folder", null);
452
        l1 = Util.findSubElements(el2);
453
        l1 = XMLUtil.findSubElements(el2);
453
        assertEquals(3, l1.size());
454
        assertEquals(3, l1.size());
454
        assertElementArray(l1, 
455
        assertElementArray(l1, 
455
            new String[]{"label", "type", "location"}, 
456
            new String[]{"label", "type", "location"}, 
Lines 467-480 Link Here
467
        JavaProjectGenerator.putSourceFolders(helper, folders, "type2");
468
        JavaProjectGenerator.putSourceFolders(helper, folders, "type2");
468
        ProjectManager.getDefault().saveAllProjects();
469
        ProjectManager.getDefault().saveAllProjects();
469
        el = Util.getPrimaryConfigurationData(helper);
470
        el = Util.getPrimaryConfigurationData(helper);
470
        el = Util.findElement(el, "folders", Util.NAMESPACE);
471
        el = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
471
        assertNotNull("Source folders were not saved correctly",  el);
472
        assertNotNull("Source folders were not saved correctly",  el);
472
        subElements = Util.findSubElements(el);
473
        subElements = XMLUtil.findSubElements(el);
473
        assertEquals(2, subElements.size());
474
        assertEquals(2, subElements.size());
474
        // compare first source folder
475
        // compare first source folder
475
        el2 = (Element)subElements.get(0);
476
        el2 = (Element)subElements.get(0);
476
        assertElement(el2, "source-folder", null);
477
        assertElement(el2, "source-folder", null);
477
        l1 = Util.findSubElements(el2);
478
        l1 = XMLUtil.findSubElements(el2);
478
        assertEquals(3, l1.size());
479
        assertEquals(3, l1.size());
479
        assertElementArray(l1, 
480
        assertElementArray(l1, 
480
            new String[]{"label", "type", "location"}, 
481
            new String[]{"label", "type", "location"}, 
Lines 482-488 Link Here
482
        // compare second source folder
483
        // compare second source folder
483
        el2 = (Element)subElements.get(1);
484
        el2 = (Element)subElements.get(1);
484
        assertElement(el2, "source-folder", null);
485
        assertElement(el2, "source-folder", null);
485
        l1 = Util.findSubElements(el2);
486
        l1 = XMLUtil.findSubElements(el2);
486
        assertEquals(3, l1.size());
487
        assertEquals(3, l1.size());
487
        assertElementArray(l1, 
488
        assertElementArray(l1, 
488
            new String[]{"label", "type", "location"}, 
489
            new String[]{"label", "type", "location"}, 
Lines 582-598 Link Here
582
        JavaProjectGenerator.putSourceViews(helper, folders, null);
583
        JavaProjectGenerator.putSourceViews(helper, folders, null);
583
        ProjectManager.getDefault().saveAllProjects();
584
        ProjectManager.getDefault().saveAllProjects();
584
        Element el = Util.getPrimaryConfigurationData(helper);
585
        Element el = Util.getPrimaryConfigurationData(helper);
585
        el = Util.findElement(el, "view", Util.NAMESPACE);
586
        el = XMLUtil.findElement(el, "view", Util.NAMESPACE);
586
        assertNotNull("View folders were not saved correctly",  el);
587
        assertNotNull("View folders were not saved correctly",  el);
587
        el = Util.findElement(el, "items", Util.NAMESPACE);
588
        el = XMLUtil.findElement(el, "items", Util.NAMESPACE);
588
        assertNotNull("View folders were not saved correctly",  el);
589
        assertNotNull("View folders were not saved correctly",  el);
589
        List subElements = Util.findSubElements(el);
590
        List subElements = XMLUtil.findSubElements(el);
590
        // there will be three sublements: <source-file> is added for build.xml during project.creation
591
        // there will be three sublements: <source-file> is added for build.xml during project.creation
591
        assertEquals(3, subElements.size());
592
        assertEquals(3, subElements.size());
592
        // compare first source view
593
        // compare first source view
593
        Element el2 = (Element)subElements.get(0);
594
        Element el2 = (Element)subElements.get(0);
594
        assertElement(el2, "source-folder", null, "style", "tree");
595
        assertElement(el2, "source-folder", null, "style", "tree");
595
        List l1 = Util.findSubElements(el2);
596
        List l1 = XMLUtil.findSubElements(el2);
596
        assertEquals(2, l1.size());
597
        assertEquals(2, l1.size());
597
        assertElementArray(l1, 
598
        assertElementArray(l1, 
598
            new String[]{"label", "location"}, 
599
            new String[]{"label", "location"}, 
Lines 600-606 Link Here
600
        // compare second source view
601
        // compare second source view
601
        el2 = (Element)subElements.get(1);
602
        el2 = (Element)subElements.get(1);
602
        assertElement(el2, "source-folder", null, "style", "packages");
603
        assertElement(el2, "source-folder", null, "style", "packages");
603
        l1 = Util.findSubElements(el2);
604
        l1 = XMLUtil.findSubElements(el2);
604
        assertEquals(2, l1.size());
605
        assertEquals(2, l1.size());
605
        assertElementArray(l1, 
606
        assertElementArray(l1, 
606
            new String[]{"label", "location"}, 
607
            new String[]{"label", "location"}, 
Lines 618-634 Link Here
618
        JavaProjectGenerator.putSourceViews(helper, folders, "packages");
619
        JavaProjectGenerator.putSourceViews(helper, folders, "packages");
619
        ProjectManager.getDefault().saveAllProjects();
620
        ProjectManager.getDefault().saveAllProjects();
620
        el = Util.getPrimaryConfigurationData(helper);
621
        el = Util.getPrimaryConfigurationData(helper);
621
        el = Util.findElement(el, "view", Util.NAMESPACE);
622
        el = XMLUtil.findElement(el, "view", Util.NAMESPACE);
622
        assertNotNull("Source views were not saved correctly",  el);
623
        assertNotNull("Source views were not saved correctly",  el);
623
        el = Util.findElement(el, "items", Util.NAMESPACE);
624
        el = XMLUtil.findElement(el, "items", Util.NAMESPACE);
624
        assertNotNull("View folders were not saved correctly",  el);
625
        assertNotNull("View folders were not saved correctly",  el);
625
        subElements = Util.findSubElements(el);
626
        subElements = XMLUtil.findSubElements(el);
626
        // there will be three sublements: <source-file> is added for build.xml during project.creation
627
        // there will be three sublements: <source-file> is added for build.xml during project.creation
627
        assertEquals("3 elements in " + subElements, 3, subElements.size());
628
        assertEquals("3 elements in " + subElements, 3, subElements.size());
628
        // compare first source view
629
        // compare first source view
629
        el2 = (Element)subElements.get(0);
630
        el2 = (Element)subElements.get(0);
630
        assertElement(el2, "source-folder", null, "style", "tree");
631
        assertElement(el2, "source-folder", null, "style", "tree");
631
        l1 = Util.findSubElements(el2);
632
        l1 = XMLUtil.findSubElements(el2);
632
        assertEquals(2, l1.size());
633
        assertEquals(2, l1.size());
633
        assertElementArray(l1, 
634
        assertElementArray(l1, 
634
            new String[]{"label", "location"}, 
635
            new String[]{"label", "location"}, 
Lines 636-642 Link Here
636
        // compare second source view
637
        // compare second source view
637
        el2 = (Element)subElements.get(1);
638
        el2 = (Element)subElements.get(1);
638
        assertElement(el2, "source-folder", null, "style", "packages");
639
        assertElement(el2, "source-folder", null, "style", "packages");
639
        l1 = Util.findSubElements(el2);
640
        l1 = XMLUtil.findSubElements(el2);
640
        assertEquals(2, l1.size());
641
        assertEquals(2, l1.size());
641
        assertElementArray(l1, 
642
        assertElementArray(l1, 
642
            new String[]{"label", "location"}, 
643
            new String[]{"label", "location"}, 
Lines 758-769 Link Here
758
//        ProjectManager.getDefault().saveAllProjects();
759
//        ProjectManager.getDefault().saveAllProjects();
759
        Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
760
        Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
760
        assertNotNull("Java compilation units were not saved correctly",  el);
761
        assertNotNull("Java compilation units were not saved correctly",  el);
761
        List subElements = Util.findSubElements(el);
762
        List subElements = XMLUtil.findSubElements(el);
762
        assertEquals(2, subElements.size());
763
        assertEquals(2, subElements.size());
763
        // compare first compilation unit
764
        // compare first compilation unit
764
        Element el2 = (Element)subElements.get(0);
765
        Element el2 = (Element)subElements.get(0);
765
        assertElement(el2, "compilation-unit", null);
766
        assertElement(el2, "compilation-unit", null);
766
        List l1 = Util.findSubElements(el2);
767
        List l1 = XMLUtil.findSubElements(el2);
767
        assertEquals(7, l1.size());
768
        assertEquals(7, l1.size());
768
        assertElementArray(l1, 
769
        assertElementArray(l1, 
769
            new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"}, 
770
            new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"}, 
Lines 775-781 Link Here
775
        // compare second compilation unit
776
        // compare second compilation unit
776
        el2 = (Element)subElements.get(1);
777
        el2 = (Element)subElements.get(1);
777
        assertElement(el2, "compilation-unit", null);
778
        assertElement(el2, "compilation-unit", null);
778
        l1 = Util.findSubElements(el2);
779
        l1 = XMLUtil.findSubElements(el2);
779
        assertEquals(7, l1.size());
780
        assertEquals(7, l1.size());
780
        assertElementArray(l1, 
781
        assertElementArray(l1, 
781
            new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"}, 
782
            new String[]{"package-root", "package-root", "classpath", "classpath", "built-to", "built-to", "source-level"}, 
Lines 797-808 Link Here
797
//        ProjectManager.getDefault().saveAllProjects();
798
//        ProjectManager.getDefault().saveAllProjects();
798
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
799
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
799
        assertNotNull("Java compilation units were not saved correctly",  el);
800
        assertNotNull("Java compilation units were not saved correctly",  el);
800
        subElements = Util.findSubElements(el);
801
        subElements = XMLUtil.findSubElements(el);
801
        assertEquals(1, subElements.size());
802
        assertEquals(1, subElements.size());
802
        // compare first compilation unit
803
        // compare first compilation unit
803
        el2 = (Element)subElements.get(0);
804
        el2 = (Element)subElements.get(0);
804
        assertElement(el2, "compilation-unit", null);
805
        assertElement(el2, "compilation-unit", null);
805
        l1 = Util.findSubElements(el2);
806
        l1 = XMLUtil.findSubElements(el2);
806
        assertEquals(1, l1.size());
807
        assertEquals(1, l1.size());
807
        assertElementArray(l1, 
808
        assertElementArray(l1, 
808
            new String[]{"package-root"}, 
809
            new String[]{"package-root"}, 
Lines 827-838 Link Here
827
        // Check that the correct /1 data was saved.
828
        // Check that the correct /1 data was saved.
828
        Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
829
        Element el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_1, true);
829
        assertNotNull("Java compilation units were saved in /1",  el);
830
        assertNotNull("Java compilation units were saved in /1",  el);
830
        List<Element> subElements = Util.findSubElements(el);
831
        List<Element> subElements = XMLUtil.findSubElements(el);
831
        assertEquals(1, subElements.size());
832
        assertEquals(1, subElements.size());
832
        // compare the compilation unit
833
        // compare the compilation unit
833
        Element el2 = (Element) subElements.get(0);
834
        Element el2 = (Element) subElements.get(0);
834
        assertElement(el2, "compilation-unit", null);
835
        assertElement(el2, "compilation-unit", null);
835
        assertElementArray(Util.findSubElements(el2),
836
        assertElementArray(XMLUtil.findSubElements(el2),
836
            new String[] {"package-root"},
837
            new String[] {"package-root"},
837
            new String[] {"pkgroot1"});
838
            new String[] {"pkgroot1"});
838
        ProjectManager.getDefault().saveAllProjects();
839
        ProjectManager.getDefault().saveAllProjects();
Lines 849-860 Link Here
849
        assertNull("No /1 data", el);
850
        assertNull("No /1 data", el);
850
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
851
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
851
        assertNotNull("Have /2 data", el);
852
        assertNotNull("Have /2 data", el);
852
        subElements = Util.findSubElements(el);
853
        subElements = XMLUtil.findSubElements(el);
853
        assertEquals(1, subElements.size());
854
        assertEquals(1, subElements.size());
854
        // compare the compilation unit
855
        // compare the compilation unit
855
        el2 = (Element) subElements.get(0);
856
        el2 = (Element) subElements.get(0);
856
        assertElement(el2, "compilation-unit", null);
857
        assertElement(el2, "compilation-unit", null);
857
        assertElementArray(Util.findSubElements(el2),
858
        assertElementArray(XMLUtil.findSubElements(el2),
858
            new String[] {"package-root", "unit-tests"},
859
            new String[] {"package-root", "unit-tests"},
859
            new String[] {"pkgroot1", null});
860
            new String[] {"pkgroot1", null});
860
        ProjectManager.getDefault().saveAllProjects();
861
        ProjectManager.getDefault().saveAllProjects();
Lines 874-885 Link Here
874
        assertNull("No /1 data", el);
875
        assertNull("No /1 data", el);
875
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
876
        el = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_2, true);
876
        assertNotNull("Have /2 data", el);
877
        assertNotNull("Have /2 data", el);
877
        subElements = Util.findSubElements(el);
878
        subElements = XMLUtil.findSubElements(el);
878
        assertEquals(1, subElements.size());
879
        assertEquals(1, subElements.size());
879
        // compare the compilation unit
880
        // compare the compilation unit
880
        el2 = (Element) subElements.get(0);
881
        el2 = (Element) subElements.get(0);
881
        assertElement(el2, "compilation-unit", null);
882
        assertElement(el2, "compilation-unit", null);
882
        assertElementArray(Util.findSubElements(el2),
883
        assertElementArray(XMLUtil.findSubElements(el2),
883
            new String[] {"package-root", "javadoc-built-to", "javadoc-built-to"},
884
            new String[] {"package-root", "javadoc-built-to", "javadoc-built-to"},
884
            new String[] {"pkgroot1", "javadoc1", "javadoc2"});
885
            new String[] {"pkgroot1", "javadoc1", "javadoc2"});
885
        ProjectManager.getDefault().saveAllProjects();
886
        ProjectManager.getDefault().saveAllProjects();
Lines 1000-1006 Link Here
1000
        
1001
        
1001
        JavaProjectGenerator.putExports(helper, exports);
1002
        JavaProjectGenerator.putExports(helper, exports);
1002
        Element el = Util.getPrimaryConfigurationData(helper);
1003
        Element el = Util.getPrimaryConfigurationData(helper);
1003
        List subElements = Util.findSubElements(el);
1004
        List subElements = XMLUtil.findSubElements(el);
1004
        // 4, i.e. name, two exports and one view of build.xml file
1005
        // 4, i.e. name, two exports and one view of build.xml file
1005
        assertEquals(5, subElements.size());
1006
        assertEquals(5, subElements.size());
1006
        // compare first compilation unit
1007
        // compare first compilation unit
Lines 1010-1016 Link Here
1010
        assertElement(el2, "properties", null);
1011
        assertElement(el2, "properties", null);
1011
        el2 = (Element)subElements.get(2);
1012
        el2 = (Element)subElements.get(2);
1012
        assertElement(el2, "export", null);
1013
        assertElement(el2, "export", null);
1013
        List l1 = Util.findSubElements(el2);
1014
        List l1 = XMLUtil.findSubElements(el2);
1014
        assertEquals(5, l1.size());
1015
        assertEquals(5, l1.size());
1015
        assertElementArray(l1, 
1016
        assertElementArray(l1, 
1016
            new String[]{"type", "location", "script", "build-target", "clean-target"}, 
1017
            new String[]{"type", "location", "script", "build-target", "clean-target"}, 
Lines 1018-1024 Link Here
1018
        // compare second compilation unit
1019
        // compare second compilation unit
1019
        el2 = (Element)subElements.get(3);
1020
        el2 = (Element)subElements.get(3);
1020
        assertElement(el2, "export", null);
1021
        assertElement(el2, "export", null);
1021
        l1 = Util.findSubElements(el2);
1022
        l1 = XMLUtil.findSubElements(el2);
1022
        assertEquals(3, l1.size());
1023
        assertEquals(3, l1.size());
1023
        assertElementArray(l1, 
1024
        assertElementArray(l1, 
1024
            new String[]{"type", "location", "build-target"}, 
1025
            new String[]{"type", "location", "build-target"}, 
Lines 1038-1044 Link Here
1038
        
1039
        
1039
        JavaProjectGenerator.putExports(helper, exports);
1040
        JavaProjectGenerator.putExports(helper, exports);
1040
        el = Util.getPrimaryConfigurationData(helper);
1041
        el = Util.getPrimaryConfigurationData(helper);
1041
        subElements = Util.findSubElements(el);
1042
        subElements = XMLUtil.findSubElements(el);
1042
        // 3, i.e. name, export and one view of build.xml file
1043
        // 3, i.e. name, export and one view of build.xml file
1043
        assertEquals(4, subElements.size());
1044
        assertEquals(4, subElements.size());
1044
        // compare first compilation unit
1045
        // compare first compilation unit
Lines 1048-1054 Link Here
1048
        assertElement(el2, "properties", null);
1049
        assertElement(el2, "properties", null);
1049
        el2 = (Element)subElements.get(2);
1050
        el2 = (Element)subElements.get(2);
1050
        assertElement(el2, "export", null);
1051
        assertElement(el2, "export", null);
1051
        l1 = Util.findSubElements(el2);
1052
        l1 = XMLUtil.findSubElements(el2);
1052
        assertEquals(3, l1.size());
1053
        assertEquals(3, l1.size());
1053
        assertElementArray(l1, 
1054
        assertElementArray(l1, 
1054
            new String[]{"type", "location", "build-target"}, 
1055
            new String[]{"type", "location", "build-target"}, 
Lines 1123-1131 Link Here
1123
        
1124
        
1124
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1125
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1125
        Element el = Util.getPrimaryConfigurationData(helper);
1126
        Element el = Util.getPrimaryConfigurationData(helper);
1126
        Element subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
1127
        Element subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
1127
        assertNotNull("<subprojects> element exists", subprojectsEl);
1128
        assertNotNull("<subprojects> element exists", subprojectsEl);
1128
        List subElements = Util.findSubElements(subprojectsEl);
1129
        List subElements = XMLUtil.findSubElements(subprojectsEl);
1129
        assertEquals("project depends on two subprojects", 2, subElements.size());
1130
        assertEquals("project depends on two subprojects", 2, subElements.size());
1130
        Element el2 = (Element)subElements.get(0);
1131
        Element el2 = (Element)subElements.get(0);
1131
        assertElement(el2, "project", "/some/path/projA");
1132
        assertElement(el2, "project", "/some/path/projA");
Lines 1140-1155 Link Here
1140
        subprojects.add("/projC");
1141
        subprojects.add("/projC");
1141
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1142
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1142
        el = Util.getPrimaryConfigurationData(helper);
1143
        el = Util.getPrimaryConfigurationData(helper);
1143
        subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
1144
        subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
1144
        subElements = Util.findSubElements(subprojectsEl);
1145
        subElements = XMLUtil.findSubElements(subprojectsEl);
1145
        assertEquals("project depends on one subproject", 1, subElements.size());
1146
        assertEquals("project depends on one subproject", 1, subElements.size());
1146
        el2 = (Element)subElements.get(0);
1147
        el2 = (Element)subElements.get(0);
1147
        assertElement(el2, "project", "/projC");
1148
        assertElement(el2, "project", "/projC");
1148
        subprojects = new ArrayList();
1149
        subprojects = new ArrayList();
1149
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1150
        JavaProjectGenerator.putSubprojects(helper, subprojects);
1150
        el = Util.getPrimaryConfigurationData(helper);
1151
        el = Util.getPrimaryConfigurationData(helper);
1151
        subprojectsEl = Util.findElement(el, "subprojects", Util.NAMESPACE);
1152
        subprojectsEl = XMLUtil.findElement(el, "subprojects", Util.NAMESPACE);
1152
        subElements = Util.findSubElements(subprojectsEl);
1153
        subElements = XMLUtil.findSubElements(subprojectsEl);
1153
        assertEquals("project depends on one subproject", 0, subElements.size());
1154
        assertEquals("project depends on one subproject", 0, subElements.size());
1154
        
1155
        
1155
        ProjectManager.getDefault().saveAllProjects();
1156
        ProjectManager.getDefault().saveAllProjects();
Lines 1212-1229 Link Here
1212
        
1213
        
1213
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1214
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1214
        Element el = Util.getPrimaryConfigurationData(helper);
1215
        Element el = Util.getPrimaryConfigurationData(helper);
1215
        Element foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1216
        Element foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1216
        assertNotNull("<folders> element exists", foldersEl);
1217
        assertNotNull("<folders> element exists", foldersEl);
1217
        List subElements = Util.findSubElements(foldersEl);
1218
        List subElements = XMLUtil.findSubElements(foldersEl);
1218
        assertEquals("project has two build-folders", 2, subElements.size());
1219
        assertEquals("project has two build-folders", 2, subElements.size());
1219
        Element el2 = (Element)subElements.get(0);
1220
        Element el2 = (Element)subElements.get(0);
1220
        assertElement(el2, "build-folder", null);
1221
        assertElement(el2, "build-folder", null);
1221
        assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
1222
        assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
1222
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "/some/path/projA");
1223
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/some/path/projA");
1223
        el2 = (Element)subElements.get(1);
1224
        el2 = (Element)subElements.get(1);
1224
        assertElement(el2, "build-folder", null);
1225
        assertElement(el2, "build-folder", null);
1225
        assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
1226
        assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
1226
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "C:\\dev\\projB");
1227
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "C:\\dev\\projB");
1227
        
1228
        
1228
        ProjectManager.getDefault().saveAllProjects();
1229
        ProjectManager.getDefault().saveAllProjects();
1229
        
1230
        
Lines 1233-1250 Link Here
1233
        buildFolders.add("/projC");
1234
        buildFolders.add("/projC");
1234
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1235
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1235
        el = Util.getPrimaryConfigurationData(helper);
1236
        el = Util.getPrimaryConfigurationData(helper);
1236
        foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1237
        foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1237
        subElements = Util.findSubElements(foldersEl);
1238
        subElements = XMLUtil.findSubElements(foldersEl);
1238
        assertEquals("project has one build-folder", 1, subElements.size());
1239
        assertEquals("project has one build-folder", 1, subElements.size());
1239
        el2 = (Element)subElements.get(0);
1240
        el2 = (Element)subElements.get(0);
1240
        assertElement(el2, "build-folder", null);
1241
        assertElement(el2, "build-folder", null);
1241
        assertEquals("build-folder has one subelement", 1, Util.findSubElements(el2).size());
1242
        assertEquals("build-folder has one subelement", 1, XMLUtil.findSubElements(el2).size());
1242
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "/projC");
1243
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/projC");
1243
        buildFolders = new ArrayList();
1244
        buildFolders = new ArrayList();
1244
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1245
        JavaProjectGenerator.putBuildFolders(helper, buildFolders);
1245
        el = Util.getPrimaryConfigurationData(helper);
1246
        el = Util.getPrimaryConfigurationData(helper);
1246
        foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1247
        foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1247
        subElements = Util.findSubElements(foldersEl);
1248
        subElements = XMLUtil.findSubElements(foldersEl);
1248
        assertEquals("project has no build-folder", 0, subElements.size());
1249
        assertEquals("project has no build-folder", 0, subElements.size());
1249
        
1250
        
1250
        ProjectManager.getDefault().saveAllProjects();
1251
        ProjectManager.getDefault().saveAllProjects();
Lines 1264-1281 Link Here
1264
        
1265
        
1265
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1266
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1266
        Element el = Util.getPrimaryConfigurationData(helper);
1267
        Element el = Util.getPrimaryConfigurationData(helper);
1267
        Element foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1268
        Element foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1268
        assertNotNull("<folders> element exists", foldersEl);
1269
        assertNotNull("<folders> element exists", foldersEl);
1269
        List subElements = Util.findSubElements(foldersEl);
1270
        List subElements = XMLUtil.findSubElements(foldersEl);
1270
        assertEquals("project has two build-files", 2, subElements.size());
1271
        assertEquals("project has two build-files", 2, subElements.size());
1271
        Element el2 = (Element)subElements.get(0);
1272
        Element el2 = (Element)subElements.get(0);
1272
        assertElement(el2, "build-file", null);
1273
        assertElement(el2, "build-file", null);
1273
        assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
1274
        assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
1274
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "/some/path/projA/archive.jar");
1275
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/some/path/projA/archive.jar");
1275
        el2 = (Element)subElements.get(1);
1276
        el2 = (Element)subElements.get(1);
1276
        assertElement(el2, "build-file", null);
1277
        assertElement(el2, "build-file", null);
1277
        assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
1278
        assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
1278
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "C:\\dev\\projB\\library.jar");
1279
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "C:\\dev\\projB\\library.jar");
1279
        
1280
        
1280
        ProjectManager.getDefault().saveAllProjects();
1281
        ProjectManager.getDefault().saveAllProjects();
1281
        
1282
        
Lines 1284-1302 Link Here
1284
        buildFiles.add("/projC/dist/projC.jar");
1285
        buildFiles.add("/projC/dist/projC.jar");
1285
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1286
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1286
        el = Util.getPrimaryConfigurationData(helper);
1287
        el = Util.getPrimaryConfigurationData(helper);
1287
        foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1288
        foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1288
        subElements = Util.findSubElements(foldersEl);
1289
        subElements = XMLUtil.findSubElements(foldersEl);
1289
        assertEquals("project has one build-file", 1, subElements.size());
1290
        assertEquals("project has one build-file", 1, subElements.size());
1290
        el2 = (Element)subElements.get(0);
1291
        el2 = (Element)subElements.get(0);
1291
        assertElement(el2, "build-file", null);
1292
        assertElement(el2, "build-file", null);
1292
        assertEquals("build-file has one subelement", 1, Util.findSubElements(el2).size());
1293
        assertEquals("build-file has one subelement", 1, XMLUtil.findSubElements(el2).size());
1293
        assertElement((Element)Util.findSubElements(el2).get(0), "location", "/projC/dist/projC.jar");
1294
        assertElement((Element)XMLUtil.findSubElements(el2).get(0), "location", "/projC/dist/projC.jar");
1294
        
1295
        
1295
        buildFiles = new ArrayList();
1296
        buildFiles = new ArrayList();
1296
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1297
        JavaProjectGenerator.putBuildFiles(helper, buildFiles);
1297
        el = Util.getPrimaryConfigurationData(helper);
1298
        el = Util.getPrimaryConfigurationData(helper);
1298
        foldersEl = Util.findElement(el, "folders", Util.NAMESPACE);
1299
        foldersEl = XMLUtil.findElement(el, "folders", Util.NAMESPACE);
1299
        subElements = Util.findSubElements(foldersEl);
1300
        subElements = XMLUtil.findSubElements(foldersEl);
1300
        assertEquals("project has no build-file", 0, subElements.size());
1301
        assertEquals("project has no build-file", 0, subElements.size());
1301
        
1302
        
1302
        ProjectManager.getDefault().saveAllProjects();
1303
        ProjectManager.getDefault().saveAllProjects();

Return to bug 136595