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/ant.freeform/nbproject/project.xml (-1 / +1 lines)
Lines 160-166 Link Here
160
                    <build-prerequisite/>
160
                    <build-prerequisite/>
161
                    <compile-dependency/>
161
                    <compile-dependency/>
162
                    <run-dependency>
162
                    <run-dependency>
163
                        <specification-version>8.0</specification-version>
163
                        <specification-version>8.3</specification-version>
164
                    </run-dependency>
164
                    </run-dependency>
165
                </dependency>
165
                </dependency>
166
                <dependency>
166
                <dependency>
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/Actions.java (-38 / +34 lines)
Lines 67-84 Link Here
67
import javax.swing.JMenuItem;
67
import javax.swing.JMenuItem;
68
import javax.swing.JSeparator;
68
import javax.swing.JSeparator;
69
import org.apache.tools.ant.module.api.support.ActionUtils;
69
import org.apache.tools.ant.module.api.support.ActionUtils;
70
import org.netbeans.modules.ant.freeform.spi.support.Util;
71
import org.netbeans.modules.ant.freeform.ui.TargetMappingPanel;
70
import org.netbeans.modules.ant.freeform.ui.TargetMappingPanel;
72
import org.netbeans.modules.ant.freeform.ui.UnboundTargetAlert;
71
import org.netbeans.modules.ant.freeform.ui.UnboundTargetAlert;
73
import org.netbeans.spi.project.ActionProvider;
72
import org.netbeans.spi.project.ActionProvider;
74
import org.netbeans.spi.project.support.ant.AntProjectHelper;
73
import org.netbeans.spi.project.support.ant.AntProjectHelper;
75
import org.netbeans.spi.project.ui.support.CommonProjectActions;
76
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
74
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
77
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
75
import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
78
import org.openide.DialogDisplayer;
76
import org.openide.DialogDisplayer;
79
import org.openide.ErrorManager;
77
import org.openide.ErrorManager;
80
import org.openide.NotifyDescriptor;
78
import org.openide.NotifyDescriptor;
81
import org.openide.actions.FindAction;
82
import org.openide.awt.DynamicMenuContent;
79
import org.openide.awt.DynamicMenuContent;
83
import org.openide.filesystems.FileObject;
80
import org.openide.filesystems.FileObject;
84
import org.openide.filesystems.FileUtil;
81
import org.openide.filesystems.FileUtil;
Lines 86-94 Link Here
86
import org.openide.util.ContextAwareAction;
83
import org.openide.util.ContextAwareAction;
87
import org.openide.util.Lookup;
84
import org.openide.util.Lookup;
88
import org.openide.util.NbBundle;
85
import org.openide.util.NbBundle;
89
import org.openide.util.Utilities;
90
import org.openide.util.actions.Presenter;
86
import org.openide.util.actions.Presenter;
91
import org.openide.util.actions.SystemAction;
87
import org.openide.xml.XMLUtil;
92
import org.w3c.dom.Element;
88
import org.w3c.dom.Element;
93
89
94
/**
90
/**
Lines 141-153 Link Here
141
    
137
    
142
    public String[] getSupportedActions() {
138
    public String[] getSupportedActions() {
143
        Element genldata = project.getPrimaryConfigurationData();
139
        Element genldata = project.getPrimaryConfigurationData();
144
        Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
140
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
145
        if (actionsEl == null) {
141
        if (actionsEl == null) {
146
            return new String[0];
142
            return new String[0];
147
        }
143
        }
148
        // Use a set, not a list, since when using context you can define one action several times:
144
        // Use a set, not a list, since when using context you can define one action several times:
149
        Set<String> names = new LinkedHashSet<String>();
145
        Set<String> names = new LinkedHashSet<String>();
150
        for (Element actionEl : Util.findSubElements(actionsEl)) {
146
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
151
            names.add(actionEl.getAttribute("name")); // NOI18N
147
            names.add(actionEl.getAttribute("name")); // NOI18N
152
        }
148
        }
153
        // #46886: also always enable all common global actions, in case they should be selected:
149
        // #46886: also always enable all common global actions, in case they should be selected:
Lines 174-189 Link Here
174
        }
170
        }
175
        
171
        
176
        Element genldata = project.getPrimaryConfigurationData();
172
        Element genldata = project.getPrimaryConfigurationData();
177
        Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
173
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
178
        if (actionsEl == null) {
174
        if (actionsEl == null) {
179
            throw new IllegalArgumentException("No commands supported"); // NOI18N
175
            throw new IllegalArgumentException("No commands supported"); // NOI18N
180
        }
176
        }
181
        boolean foundAction = false;
177
        boolean foundAction = false;
182
        for (Element actionEl : Util.findSubElements(actionsEl)) {
178
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
183
            if (actionEl.getAttribute("name").equals(command)) { // NOI18N
179
            if (actionEl.getAttribute("name").equals(command)) { // NOI18N
184
                foundAction = true;
180
                foundAction = true;
185
                // XXX perhaps check also existence of script
181
                // XXX perhaps check also existence of script
186
                Element contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
182
                Element contextEl = XMLUtil.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
187
                if (contextEl != null) {
183
                if (contextEl != null) {
188
                    // Check whether the context contains files all in this folder,
184
                    // Check whether the context contains files all in this folder,
189
                    // matching the pattern if any, and matching the arity (single/multiple).
185
                    // matching the pattern if any, and matching the arity (single/multiple).
Lines 194-202 Link Here
194
                        return true;
190
                        return true;
195
                    } else if (!selection.isEmpty()) {
191
                    } else if (!selection.isEmpty()) {
196
                        // Multiple selection; check arity.
192
                        // Multiple selection; check arity.
197
                        Element arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
193
                        Element arityEl = XMLUtil.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
198
                        assert arityEl != null : "No <arity> in <context> for " + command;
194
                        assert arityEl != null : "No <arity> in <context> for " + command;
199
                        if (Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL) != null) { // NOI18N
195
                        if (XMLUtil.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL) != null) { // NOI18N
200
                            // Supports multiple selection, take it.
196
                            // Supports multiple selection, take it.
201
                            return true;
197
                            return true;
202
                        }
198
                        }
Lines 238-249 Link Here
238
        }
234
        }
239
        
235
        
240
        Element genldata = project.getPrimaryConfigurationData();
236
        Element genldata = project.getPrimaryConfigurationData();
241
        Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
237
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
242
        if (actionsEl == null) {
238
        if (actionsEl == null) {
243
            throw new IllegalArgumentException("No commands supported"); // NOI18N
239
            throw new IllegalArgumentException("No commands supported"); // NOI18N
244
        }
240
        }
245
        boolean foundAction = false;
241
        boolean foundAction = false;
246
        for (Element actionEl : Util.findSubElements(actionsEl)) {
242
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
247
            if (actionEl.getAttribute("name").equals(command)) { // NOI18N
243
            if (actionEl.getAttribute("name").equals(command)) { // NOI18N
248
                foundAction = true;
244
                foundAction = true;
249
                runConfiguredAction(project, actionEl, context);
245
                runConfiguredAction(project, actionEl, context);
Lines 278-286 Link Here
278
            _files.add(d.getPrimaryFile());
274
            _files.add(d.getPrimaryFile());
279
        }
275
        }
280
        Collection<? extends FileObject> files = _files;
276
        Collection<? extends FileObject> files = _files;
281
        Element folderEl = Util.findElement(contextEl, "folder", FreeformProjectType.NS_GENERAL); // NOI18N
277
        Element folderEl = XMLUtil.findElement(contextEl, "folder", FreeformProjectType.NS_GENERAL); // NOI18N
282
        assert folderEl != null : "Must have <folder> in <context>";
278
        assert folderEl != null : "Must have <folder> in <context>";
283
        String rawtext = Util.findText(folderEl);
279
        String rawtext = XMLUtil.findText(folderEl);
284
        assert rawtext != null : "Must have text contents in <folder>";
280
        assert rawtext != null : "Must have text contents in <folder>";
285
        String evaltext = project.evaluator().evaluate(rawtext);
281
        String evaltext = project.evaluator().evaluate(rawtext);
286
        if (evaltext == null) {
282
        if (evaltext == null) {
Lines 291-299 Link Here
291
            return Collections.emptyMap();
287
            return Collections.emptyMap();
292
        }
288
        }
293
        Pattern pattern = null;
289
        Pattern pattern = null;
294
        Element patternEl = Util.findElement(contextEl, "pattern", FreeformProjectType.NS_GENERAL); // NOI18N
290
        Element patternEl = XMLUtil.findElement(contextEl, "pattern", FreeformProjectType.NS_GENERAL); // NOI18N
295
        if (patternEl != null) {
291
        if (patternEl != null) {
296
            String text = Util.findText(patternEl);
292
            String text = XMLUtil.findText(patternEl);
297
            assert text != null : "Must have text contents in <pattern>";
293
            assert text != null : "Must have text contents in <pattern>";
298
            try {
294
            try {
299
                pattern = Pattern.compile(text);
295
                pattern = Pattern.compile(text);
Lines 322-330 Link Here
322
     */
318
     */
323
    private static void runConfiguredAction(FreeformProject project, Element actionEl, Lookup context) {
319
    private static void runConfiguredAction(FreeformProject project, Element actionEl, Lookup context) {
324
        String script;
320
        String script;
325
        Element scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
321
        Element scriptEl = XMLUtil.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
326
        if (scriptEl != null) {
322
        if (scriptEl != null) {
327
            script = Util.findText(scriptEl);
323
            script = XMLUtil.findText(scriptEl);
328
        } else {
324
        } else {
329
            script = "build.xml"; // NOI18N
325
            script = "build.xml"; // NOI18N
330
        }
326
        }
Lines 340-352 Link Here
340
            DialogDisplayer.getDefault().notify(nd);
336
            DialogDisplayer.getDefault().notify(nd);
341
            return;
337
            return;
342
        }
338
        }
343
        List<Element> targets = Util.findSubElements(actionEl);
339
        List<Element> targets = XMLUtil.findSubElements(actionEl);
344
        List<String> targetNames = new ArrayList<String>(targets.size());
340
        List<String> targetNames = new ArrayList<String>(targets.size());
345
        for (Element targetEl : targets) {
341
        for (Element targetEl : targets) {
346
            if (!targetEl.getLocalName().equals("target")) { // NOI18N
342
            if (!targetEl.getLocalName().equals("target")) { // NOI18N
347
                continue;
343
                continue;
348
            }
344
            }
349
            targetNames.add(Util.findText(targetEl));
345
            targetNames.add(XMLUtil.findText(targetEl));
350
        }
346
        }
351
        String[] targetNameArray;
347
        String[] targetNameArray;
352
        if (!targetNames.isEmpty()) {
348
        if (!targetNames.isEmpty()) {
Lines 356-362 Link Here
356
            targetNameArray = null;
352
            targetNameArray = null;
357
        }
353
        }
358
        Properties props = new Properties();
354
        Properties props = new Properties();
359
        Element contextEl = Util.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
355
        Element contextEl = XMLUtil.findElement(actionEl, "context", FreeformProjectType.NS_GENERAL); // NOI18N
360
        if (contextEl != null) {
356
        if (contextEl != null) {
361
            Map<String,FileObject> selection = findSelection(contextEl, context, project);
357
            Map<String,FileObject> selection = findSelection(contextEl, context, project);
362
            if (selection.isEmpty()) {
358
            if (selection.isEmpty()) {
Lines 365-382 Link Here
365
            String separator = null;
361
            String separator = null;
366
            if (selection.size() > 1) {
362
            if (selection.size() > 1) {
367
                // Find the right separator.
363
                // Find the right separator.
368
                Element arityEl = Util.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
364
                Element arityEl = XMLUtil.findElement(contextEl, "arity", FreeformProjectType.NS_GENERAL); // NOI18N
369
                assert arityEl != null : "No <arity> in <context> for " + actionEl.getAttribute("name");
365
                assert arityEl != null : "No <arity> in <context> for " + actionEl.getAttribute("name");
370
                Element sepFilesEl = Util.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
366
                Element sepFilesEl = XMLUtil.findElement(arityEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
371
                if (sepFilesEl == null) {
367
                if (sepFilesEl == null) {
372
                    // Only handles single files -> skip it.
368
                    // Only handles single files -> skip it.
373
                    return;
369
                    return;
374
                }
370
                }
375
                separator = Util.findText(sepFilesEl);
371
                separator = XMLUtil.findText(sepFilesEl);
376
            }
372
            }
377
            Element formatEl = Util.findElement(contextEl, "format", FreeformProjectType.NS_GENERAL); // NOI18N
373
            Element formatEl = XMLUtil.findElement(contextEl, "format", FreeformProjectType.NS_GENERAL); // NOI18N
378
            assert formatEl != null : "No <format> in <context> for " + actionEl.getAttribute("name");
374
            assert formatEl != null : "No <format> in <context> for " + actionEl.getAttribute("name");
379
            String format = Util.findText(formatEl);
375
            String format = XMLUtil.findText(formatEl);
380
            StringBuffer buf = new StringBuffer();
376
            StringBuffer buf = new StringBuffer();
381
            Iterator<Map.Entry<String,FileObject>> it = selection.entrySet().iterator();
377
            Iterator<Map.Entry<String,FileObject>> it = selection.entrySet().iterator();
382
            while (it.hasNext()) {
378
            while (it.hasNext()) {
Lines 427-435 Link Here
427
                    buf.append(separator);
423
                    buf.append(separator);
428
                }
424
                }
429
            }
425
            }
430
            Element propEl = Util.findElement(contextEl, "property", FreeformProjectType.NS_GENERAL); // NOI18N
426
            Element propEl = XMLUtil.findElement(contextEl, "property", FreeformProjectType.NS_GENERAL); // NOI18N
431
            assert propEl != null : "No <property> in <context> for " + actionEl.getAttribute("name");
427
            assert propEl != null : "No <property> in <context> for " + actionEl.getAttribute("name");
432
            String prop = Util.findText(propEl);
428
            String prop = XMLUtil.findText(propEl);
433
            assert prop != null : "Must have text contents in <property>";
429
            assert prop != null : "Must have text contents in <property>";
434
            props.setProperty(prop, buf.toString());
430
            props.setProperty(prop, buf.toString());
435
        }
431
        }
Lines 437-443 Link Here
437
            if (!propEl.getLocalName().equals("property")) { // NOI18N
433
            if (!propEl.getLocalName().equals("property")) { // NOI18N
438
                continue;
434
                continue;
439
            }
435
            }
440
            String rawtext = Util.findText(propEl);
436
            String rawtext = XMLUtil.findText(propEl);
441
            if (rawtext == null) {
437
            if (rawtext == null) {
442
                // Legal to have e.g. <property name="intentionally-left-blank"/>
438
                // Legal to have e.g. <property name="intentionally-left-blank"/>
443
                rawtext = ""; // NOI18N
439
                rawtext = ""; // NOI18N
Lines 503-514 Link Here
503
    static Action[] contextMenuCustomActions(FreeformProject p) {
499
    static Action[] contextMenuCustomActions(FreeformProject p) {
504
        List<Action> actions = new ArrayList<Action>();
500
        List<Action> actions = new ArrayList<Action>();
505
        Element genldata = p.getPrimaryConfigurationData();
501
        Element genldata = p.getPrimaryConfigurationData();
506
        Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
502
        Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
507
        if (viewEl != null) {
503
        if (viewEl != null) {
508
            Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
504
            Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
509
            if (contextMenuEl != null) {
505
            if (contextMenuEl != null) {
510
                actions.add(null);
506
                actions.add(null);
511
                for (Element actionEl : Util.findSubElements(contextMenuEl)) {
507
                for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
512
                    if (actionEl.getLocalName().equals("ide-action")) { // NOI18N
508
                    if (actionEl.getLocalName().equals("ide-action")) { // NOI18N
513
                        String cmd = actionEl.getAttribute("name");
509
                        String cmd = actionEl.getAttribute("name");
514
                        String displayName;
510
                        String displayName;
Lines 547-555 Link Here
547
        
543
        
548
        public boolean isEnabled() {
544
        public boolean isEnabled() {
549
            String script;
545
            String script;
550
            Element scriptEl = Util.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
546
            Element scriptEl = XMLUtil.findElement(actionEl, "script", FreeformProjectType.NS_GENERAL); // NOI18N
551
            if (scriptEl != null) {
547
            if (scriptEl != null) {
552
                script = Util.findText(scriptEl);
548
                script = XMLUtil.findText(scriptEl);
553
            } else {
549
            } else {
554
                script = "build.xml"; // NOI18N
550
                script = "build.xml"; // NOI18N
555
            }
551
            }
Lines 559-566 Link Here
559
        
555
        
560
        public Object getValue(String key) {
556
        public Object getValue(String key) {
561
            if (key.equals(Action.NAME)) {
557
            if (key.equals(Action.NAME)) {
562
                Element labelEl = Util.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
558
                Element labelEl = XMLUtil.findElement(actionEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
563
                return Util.findText(labelEl);
559
                return XMLUtil.findText(labelEl);
564
            } else {
560
            } else {
565
                return super.getValue(key);
561
                return super.getValue(key);
566
            }
562
            }
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/ArtifactProvider.java (-17 / +16 lines)
Lines 47-62 Link Here
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.HashMap;
48
import java.util.HashMap;
49
import java.util.HashSet;
49
import java.util.HashSet;
50
import java.util.Iterator;
51
import java.util.LinkedHashSet;
50
import java.util.LinkedHashSet;
52
import java.util.List;
51
import java.util.List;
53
import java.util.Set;
52
import java.util.Set;
54
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.ant.AntArtifact;
54
import org.netbeans.api.project.ant.AntArtifact;
56
import org.netbeans.modules.ant.freeform.spi.support.Util;
57
import org.netbeans.spi.project.ant.AntArtifactProvider;
55
import org.netbeans.spi.project.ant.AntArtifactProvider;
58
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
56
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
59
import org.openide.ErrorManager;
57
import org.openide.ErrorManager;
58
import org.openide.xml.XMLUtil;
60
import org.w3c.dom.Element;
59
import org.w3c.dom.Element;
61
60
62
/**
61
/**
Lines 76-82 Link Here
76
        List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
75
        List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
77
        Set<String> ids = new HashSet<String>();
76
        Set<String> ids = new HashSet<String>();
78
        HashMap<String,FreeformArtifact> uniqueArtifacts = new HashMap<String,FreeformArtifact>();
77
        HashMap<String,FreeformArtifact> uniqueArtifacts = new HashMap<String,FreeformArtifact>();
79
        for (Element export : Util.findSubElements(data)) {
78
        for (Element export : XMLUtil.findSubElements(data)) {
80
            if (!export.getLocalName().equals("export")) { // NOI18N
79
            if (!export.getLocalName().equals("export")) { // NOI18N
81
                continue;
80
                continue;
82
            }
81
            }
Lines 112-120 Link Here
112
    }
111
    }
113
    
112
    
114
    public static URI readArtifactLocation(Element export, PropertyEvaluator eval) {
113
    public static URI readArtifactLocation(Element export, PropertyEvaluator eval) {
115
        Element locEl = Util.findElement(export, "location", FreeformProjectType.NS_GENERAL); // NOI18N
114
        Element locEl = XMLUtil.findElement(export, "location", FreeformProjectType.NS_GENERAL); // NOI18N
116
        assert locEl != null;
115
        assert locEl != null;
117
        String loc = Util.findText(locEl);
116
        String loc = XMLUtil.findText(locEl);
118
        assert loc != null;
117
        assert loc != null;
119
        String locationResolved = eval.evaluate(loc);
118
        String locationResolved = eval.evaluate(loc);
120
        if (locationResolved == null) {
119
        if (locationResolved == null) {
Lines 154-193 Link Here
154
        }
153
        }
155
154
156
        public String getType() {
155
        public String getType() {
157
            Element typeEl = Util.findElement(export, "type", FreeformProjectType.NS_GENERAL); // NOI18N
156
            Element typeEl = XMLUtil.findElement(export, "type", FreeformProjectType.NS_GENERAL); // NOI18N
158
            assert typeEl != null;
157
            assert typeEl != null;
159
            String type = Util.findText(typeEl);
158
            String type = XMLUtil.findText(typeEl);
160
            assert type != null;
159
            assert type != null;
161
            return type;
160
            return type;
162
        }
161
        }
163
162
164
        public String getTargetName() {
163
        public String getTargetName() {
165
            Element targetEl = Util.findElement(export, "build-target", FreeformProjectType.NS_GENERAL); // NOI18N
164
            Element targetEl = XMLUtil.findElement(export, "build-target", FreeformProjectType.NS_GENERAL); // NOI18N
166
            assert targetEl != null;
165
            assert targetEl != null;
167
            String target = Util.findText(targetEl);
166
            String target = XMLUtil.findText(targetEl);
168
            assert target != null;
167
            assert target != null;
169
            return target;
168
            return target;
170
        }
169
        }
171
170
172
        public String getCleanTargetName() {
171
        public String getCleanTargetName() {
173
            Element targetEl = Util.findElement(export, "clean-target", FreeformProjectType.NS_GENERAL); // NOI18N
172
            Element targetEl = XMLUtil.findElement(export, "clean-target", FreeformProjectType.NS_GENERAL); // NOI18N
174
            if (targetEl != null) {
173
            if (targetEl != null) {
175
                String target = Util.findText(targetEl);
174
                String target = XMLUtil.findText(targetEl);
176
                assert target != null;
175
                assert target != null;
177
                return target;
176
                return target;
178
            } else {
177
            } else {
179
                // Guess based on configured target for 'clean' command, if any.
178
                // Guess based on configured target for 'clean' command, if any.
180
                String target = null;
179
                String target = null;
181
                Element genldata = project.getPrimaryConfigurationData();
180
                Element genldata = project.getPrimaryConfigurationData();
182
                Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
181
                Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
183
                if (actionsEl != null) {
182
                if (actionsEl != null) {
184
                    for (Element actionEl : Util.findSubElements(actionsEl)) {
183
                    for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
185
                        if (actionEl.getAttribute("name").equals("clean")) { // NOI18N
184
                        if (actionEl.getAttribute("name").equals("clean")) { // NOI18N
186
                            for (Element actionTargetEl : Util.findSubElements(actionEl)) {
185
                            for (Element actionTargetEl : XMLUtil.findSubElements(actionEl)) {
187
                                if (!actionTargetEl.getLocalName().equals("target")) { // NOI18N
186
                                if (!actionTargetEl.getLocalName().equals("target")) { // NOI18N
188
                                    continue;
187
                                    continue;
189
                                }
188
                                }
190
                                String possibleTarget = Util.findText(actionTargetEl);
189
                                String possibleTarget = XMLUtil.findText(actionTargetEl);
191
                                assert possibleTarget != null;
190
                                assert possibleTarget != null;
192
                                if (target == null) {
191
                                if (target == null) {
193
                                    // OK, probably use it (unless there is another target for this command).
192
                                    // OK, probably use it (unless there is another target for this command).
Lines 213-221 Link Here
213
212
214
        public File getScriptLocation() {
213
        public File getScriptLocation() {
215
            String loc = null;
214
            String loc = null;
216
            Element scriptEl = Util.findElement(export, "script", FreeformProjectType.NS_GENERAL); // NOI18N
215
            Element scriptEl = XMLUtil.findElement(export, "script", FreeformProjectType.NS_GENERAL); // NOI18N
217
            if (scriptEl != null) {
216
            if (scriptEl != null) {
218
                String script = Util.findText(scriptEl);
217
                String script = XMLUtil.findText(scriptEl);
219
                assert script != null;
218
                assert script != null;
220
                loc = project.evaluator().evaluate(script);
219
                loc = project.evaluator().evaluate(script);
221
            }
220
            }
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformEvaluator.java (-5 / +5 lines)
Lines 52-58 Link Here
52
import java.util.List;
52
import java.util.List;
53
import java.util.Map;
53
import java.util.Map;
54
import java.util.Set;
54
import java.util.Set;
55
import org.netbeans.modules.ant.freeform.spi.support.Util;
56
import org.netbeans.spi.project.support.ant.AntProjectEvent;
55
import org.netbeans.spi.project.support.ant.AntProjectEvent;
57
import org.netbeans.spi.project.support.ant.AntProjectListener;
56
import org.netbeans.spi.project.support.ant.AntProjectListener;
58
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
57
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
Lines 60-65 Link Here
60
import org.netbeans.spi.project.support.ant.PropertyUtils;
59
import org.netbeans.spi.project.support.ant.PropertyUtils;
61
import org.openide.ErrorManager;
60
import org.openide.ErrorManager;
62
import org.openide.util.Parameters;
61
import org.openide.util.Parameters;
62
import org.openide.xml.XMLUtil;
63
import org.w3c.dom.Element;
63
import org.w3c.dom.Element;
64
64
65
/**
65
/**
Lines 105-122 Link Here
105
        PropertyProvider preprovider = project.helper().getStockPropertyPreprovider();
105
        PropertyProvider preprovider = project.helper().getStockPropertyPreprovider();
106
        List<PropertyProvider> defs = new ArrayList<PropertyProvider>();
106
        List<PropertyProvider> defs = new ArrayList<PropertyProvider>();
107
        Element genldata = project.getPrimaryConfigurationData();
107
        Element genldata = project.getPrimaryConfigurationData();
108
        Element properties = Util.findElement(genldata, "properties", FreeformProjectType.NS_GENERAL); // NOI18N
108
        Element properties = XMLUtil.findElement(genldata, "properties", FreeformProjectType.NS_GENERAL); // NOI18N
109
        if (properties != null) {
109
        if (properties != null) {
110
            for (Element e : Util.findSubElements(properties)) {
110
            for (Element e : XMLUtil.findSubElements(properties)) {
111
                if (e.getLocalName().equals("property")) { // NOI18N
111
                if (e.getLocalName().equals("property")) { // NOI18N
112
                    String val = Util.findText(e);
112
                    String val = XMLUtil.findText(e);
113
                    if (val == null) {
113
                    if (val == null) {
114
                        val = "";
114
                        val = "";
115
                    }
115
                    }
116
                    defs.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap(e.getAttribute("name"), val))); // NOI18N
116
                    defs.add(PropertyUtils.fixedPropertyProvider(Collections.singletonMap(e.getAttribute("name"), val))); // NOI18N
117
                } else {
117
                } else {
118
                    assert e.getLocalName().equals("property-file") : e;
118
                    assert e.getLocalName().equals("property-file") : e;
119
                    String fname = Util.findText(e);
119
                    String fname = XMLUtil.findText(e);
120
                    if (fname.contains("${")) { // NOI18N
120
                    if (fname.contains("${")) { // NOI18N
121
                        // Tricky (#48230): need to listen to changes in the location of the file as well as its contents.
121
                        // Tricky (#48230): need to listen to changes in the location of the file as well as its contents.
122
                        PropertyEvaluator intermediate = PropertyUtils.sequentialPropertyEvaluator(preprovider, defs.toArray(new PropertyProvider[defs.size()]));
122
                        PropertyEvaluator intermediate = PropertyUtils.sequentialPropertyEvaluator(preprovider, defs.toArray(new PropertyProvider[defs.size()]));
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformFileEncodingQueryImpl.java (-6 / +7 lines)
Lines 60-65 Link Here
60
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
60
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
61
import org.openide.util.Exceptions;
61
import org.openide.util.Exceptions;
62
import org.openide.util.Mutex;
62
import org.openide.util.Mutex;
63
import org.openide.xml.XMLUtil;
63
64
64
/**
65
/**
65
 * Implementation of FileEncodingQuery for Freeform project, its instance can be 
66
 * Implementation of FileEncodingQuery for Freeform project, its instance can be 
Lines 114-136 Link Here
114
    private void computeEncodingsCache() {
115
    private void computeEncodingsCache() {
115
        Map<FileObject,Charset> cache = new HashMap<FileObject,Charset>(3);
116
        Map<FileObject,Charset> cache = new HashMap<FileObject,Charset>(3);
116
        Element data = Util.getPrimaryConfigurationData(helper);
117
        Element data = Util.getPrimaryConfigurationData(helper);
117
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
118
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
118
        if (foldersEl != null) {
119
        if (foldersEl != null) {
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
                FileObject srcRoot = null;
124
                FileObject srcRoot = null;
124
                Element locationEl = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
125
                Element locationEl = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
125
                if (locationEl != null) {
126
                if (locationEl != null) {
126
                    String location = evaluator.evaluate(Util.findText(locationEl));
127
                    String location = evaluator.evaluate(XMLUtil.findText(locationEl));
127
                    if (location != null) {
128
                    if (location != null) {
128
                        srcRoot = helper.resolveFileObject(location);
129
                        srcRoot = helper.resolveFileObject(location);
129
                    }
130
                    }
130
                }
131
                }
131
                Element encodingEl = Util.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
132
                Element encodingEl = XMLUtil.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
132
                if (encodingEl != null && srcRoot != null) {
133
                if (encodingEl != null && srcRoot != null) {
133
                    String encoding = evaluator.evaluate(Util.findText(encodingEl));
134
                    String encoding = evaluator.evaluate(XMLUtil.findText(encodingEl));
134
                    Charset charset = null;
135
                    Charset charset = null;
135
                    if (encoding != null) {
136
                    if (encoding != null) {
136
                        try {
137
                        try {
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java (-3 / +3 lines)
Lines 46-52 Link Here
46
import java.util.logging.Level;
46
import java.util.logging.Level;
47
import java.util.logging.Logger;
47
import java.util.logging.Logger;
48
import javax.swing.Icon;
48
import javax.swing.Icon;
49
import javax.swing.ImageIcon;
50
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.ProjectInformation;
50
import org.netbeans.api.project.ProjectInformation;
52
import org.netbeans.api.project.ProjectManager;
51
import org.netbeans.api.project.ProjectManager;
Lines 66-71 Link Here
66
import org.openide.util.Lookup;
65
import org.openide.util.Lookup;
67
import org.openide.util.Mutex;
66
import org.openide.util.Mutex;
68
import org.openide.util.lookup.Lookups;
67
import org.openide.util.lookup.Lookups;
68
import org.openide.xml.XMLUtil;
69
import org.w3c.dom.Element;
69
import org.w3c.dom.Element;
70
import org.w3c.dom.NodeList;
70
import org.w3c.dom.NodeList;
71
71
Lines 196-207 Link Here
196
            return ProjectManager.mutex().readAccess(new Mutex.Action<String>() {
196
            return ProjectManager.mutex().readAccess(new Mutex.Action<String>() {
197
                public String run() {
197
                public String run() {
198
                    Element genldata = getPrimaryConfigurationData();
198
                    Element genldata = getPrimaryConfigurationData();
199
                    Element nameEl = Util.findElement(genldata, "name", FreeformProjectType.NS_GENERAL); // NOI18N
199
                    Element nameEl = XMLUtil.findElement(genldata, "name", FreeformProjectType.NS_GENERAL); // NOI18N
200
                    if (nameEl == null) {
200
                    if (nameEl == null) {
201
                        // Corrupt. Cf. #48267 (cause unknown).
201
                        // Corrupt. Cf. #48267 (cause unknown).
202
                        return "???"; // NOI18N
202
                        return "???"; // NOI18N
203
                    }
203
                    }
204
                    return Util.findText(nameEl);
204
                    return XMLUtil.findText(nameEl);
205
                }
205
                }
206
            });
206
            });
207
        }
207
        }
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectGenerator.java (-39 / +40 lines)
Lines 63-68 Link Here
63
import org.openide.filesystems.FileStateInvalidException;
63
import org.openide.filesystems.FileStateInvalidException;
64
import org.openide.filesystems.FileUtil;
64
import org.openide.filesystems.FileUtil;
65
import org.openide.util.NbBundle;
65
import org.openide.util.NbBundle;
66
import org.openide.xml.XMLUtil;
66
import org.w3c.dom.Document;
67
import org.w3c.dom.Document;
67
import org.w3c.dom.Element;
68
import org.w3c.dom.Element;
68
import org.w3c.dom.Node;
69
import org.w3c.dom.Node;
Lines 196-242 Link Here
196
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
197
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
197
        List<TargetMapping> list = new ArrayList<TargetMapping>();
198
        List<TargetMapping> list = new ArrayList<TargetMapping>();
198
        Element genldata = Util.getPrimaryConfigurationData(helper);
199
        Element genldata = Util.getPrimaryConfigurationData(helper);
199
        Element actionsEl = Util.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
200
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
200
        if (actionsEl == null) {
201
        if (actionsEl == null) {
201
            return list;
202
            return list;
202
        }
203
        }
203
        for (Element actionEl : Util.findSubElements(actionsEl)) {
204
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
204
            TargetMapping tm = new TargetMapping();
205
            TargetMapping tm = new TargetMapping();
205
            tm.name = actionEl.getAttribute("name"); // NOI18N
206
            tm.name = actionEl.getAttribute("name"); // NOI18N
206
            List<String> targetNames = new ArrayList<String>();
207
            List<String> targetNames = new ArrayList<String>();
207
            EditableProperties props = new EditableProperties(false);
208
            EditableProperties props = new EditableProperties(false);
208
            for (Element subEl : Util.findSubElements(actionEl)) {
209
            for (Element subEl : XMLUtil.findSubElements(actionEl)) {
209
                if (subEl.getLocalName().equals("target")) { // NOI18N
210
                if (subEl.getLocalName().equals("target")) { // NOI18N
210
                    targetNames.add(Util.findText(subEl));
211
                    targetNames.add(XMLUtil.findText(subEl));
211
                    continue;
212
                    continue;
212
                }
213
                }
213
                if (subEl.getLocalName().equals("script")) { // NOI18N
214
                if (subEl.getLocalName().equals("script")) { // NOI18N
214
                    tm.script = Util.findText(subEl);
215
                    tm.script = XMLUtil.findText(subEl);
215
                    continue;
216
                    continue;
216
                }
217
                }
217
                if (subEl.getLocalName().equals("context")) { // NOI18N
218
                if (subEl.getLocalName().equals("context")) { // NOI18N
218
                    TargetMapping.Context ctx = new TargetMapping.Context();
219
                    TargetMapping.Context ctx = new TargetMapping.Context();
219
                    for (Element contextSubEl : Util.findSubElements(subEl)) {
220
                    for (Element contextSubEl : XMLUtil.findSubElements(subEl)) {
220
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
221
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
221
                            ctx.property = Util.findText(contextSubEl);
222
                            ctx.property = XMLUtil.findText(contextSubEl);
222
                            continue;
223
                            continue;
223
                        }
224
                        }
224
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
225
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
225
                            ctx.format = Util.findText(contextSubEl);
226
                            ctx.format = XMLUtil.findText(contextSubEl);
226
                            continue;
227
                            continue;
227
                        }
228
                        }
228
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
229
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
229
                            ctx.folder = Util.findText(contextSubEl);
230
                            ctx.folder = XMLUtil.findText(contextSubEl);
230
                            continue;
231
                            continue;
231
                        }
232
                        }
232
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
233
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
233
                            ctx.pattern = Util.findText(contextSubEl);
234
                            ctx.pattern = XMLUtil.findText(contextSubEl);
234
                            continue;
235
                            continue;
235
                        }
236
                        }
236
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
237
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
237
                            Element sepFilesEl = Util.findElement(contextSubEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
238
                            Element sepFilesEl = XMLUtil.findElement(contextSubEl, "separated-files", FreeformProjectType.NS_GENERAL); // NOI18N
238
                            if (sepFilesEl != null) {
239
                            if (sepFilesEl != null) {
239
                                ctx.separator = Util.findText(sepFilesEl);
240
                                ctx.separator = XMLUtil.findText(sepFilesEl);
240
                            }
241
                            }
241
                            continue;
242
                            continue;
242
                        }
243
                        }
Lines 259-265 Link Here
259
    
260
    
260
    private static void readProperty(Element propertyElement, EditableProperties props) {
261
    private static void readProperty(Element propertyElement, EditableProperties props) {
261
        String key = propertyElement.getAttribute("name"); // NOI18N
262
        String key = propertyElement.getAttribute("name"); // NOI18N
262
        String value = Util.findText(propertyElement);
263
        String value = XMLUtil.findText(propertyElement);
263
        props.setProperty(key, value);
264
        props.setProperty(key, value);
264
    }
265
    }
265
266
Lines 273-279 Link Here
273
        //assert ProjectManager.mutex().isWriteAccess();
274
        //assert ProjectManager.mutex().isWriteAccess();
274
        Element data = Util.getPrimaryConfigurationData(helper);
275
        Element data = Util.getPrimaryConfigurationData(helper);
275
        Document doc = data.getOwnerDocument();
276
        Document doc = data.getOwnerDocument();
276
        Element actions = Util.findElement(data, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
277
        Element actions = XMLUtil.findElement(data, "ide-actions", FreeformProjectType.NS_GENERAL); // NOI18N
277
        if (actions != null) {
278
        if (actions != null) {
278
            data.removeChild(actions);
279
            data.removeChild(actions);
279
        }
280
        }
Lines 331-337 Link Here
331
            }
332
            }
332
            actions.appendChild(action);
333
            actions.appendChild(action);
333
        }
334
        }
334
        Util.appendChildElement(data, actions, rootElementsOrder);
335
        XMLUtil.appendChildElement(data, actions, rootElementsOrder);
335
        Util.putPrimaryConfigurationData(helper, data);
336
        Util.putPrimaryConfigurationData(helper, data);
336
    }
337
    }
337
    
338
    
Lines 357-373 Link Here
357
        //assert ProjectManager.mutex().isWriteAccess();
358
        //assert ProjectManager.mutex().isWriteAccess();
358
        Element data = Util.getPrimaryConfigurationData(helper);
359
        Element data = Util.getPrimaryConfigurationData(helper);
359
        Document doc = data.getOwnerDocument();
360
        Document doc = data.getOwnerDocument();
360
        Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
361
        Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
361
        if (viewEl == null) {
362
        if (viewEl == null) {
362
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
363
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
363
            Util.appendChildElement(data, viewEl, rootElementsOrder);
364
            XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
364
        }
365
        }
365
        Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
366
        Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
366
        if (contextMenuEl == null) {
367
        if (contextMenuEl == null) {
367
            contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
368
            contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
368
            Util.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
369
            XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
369
        }
370
        }
370
        for (Element ideActionEl : Util.findSubElements(contextMenuEl)) {
371
        for (Element ideActionEl : XMLUtil.findSubElements(contextMenuEl)) {
371
            if (!ideActionEl.getLocalName().equals("ide-action")) { // NOI18N
372
            if (!ideActionEl.getLocalName().equals("ide-action")) { // NOI18N
372
                continue;
373
                continue;
373
            }
374
            }
Lines 380-386 Link Here
380
            }
381
            }
381
            Element ideAction = doc.createElementNS(FreeformProjectType.NS_GENERAL, "ide-action"); //NOI18N
382
            Element ideAction = doc.createElementNS(FreeformProjectType.NS_GENERAL, "ide-action"); //NOI18N
382
            ideAction.setAttribute("name", tm.name); // NOI18N
383
            ideAction.setAttribute("name", tm.name); // NOI18N
383
            Util.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
384
            XMLUtil.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
384
        }
385
        }
385
        Util.putPrimaryConfigurationData(helper, data);
386
        Util.putPrimaryConfigurationData(helper, data);
386
    }
387
    }
Lines 394-425 Link Here
394
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
395
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
395
        List<CustomTarget> list = new ArrayList<CustomTarget>();
396
        List<CustomTarget> list = new ArrayList<CustomTarget>();
396
        Element genldata = Util.getPrimaryConfigurationData(helper);
397
        Element genldata = Util.getPrimaryConfigurationData(helper);
397
        Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
398
        Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
398
        if (viewEl == null) {
399
        if (viewEl == null) {
399
            return list;
400
            return list;
400
        }
401
        }
401
        Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
402
        Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
402
        if (contextMenuEl == null) {
403
        if (contextMenuEl == null) {
403
            return list;
404
            return list;
404
        }
405
        }
405
        for (Element actionEl : Util.findSubElements(contextMenuEl)) {
406
        for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
406
            if (!actionEl.getLocalName().equals("action")) { // NOI18N
407
            if (!actionEl.getLocalName().equals("action")) { // NOI18N
407
                continue;
408
                continue;
408
            }
409
            }
409
            CustomTarget ct = new CustomTarget();
410
            CustomTarget ct = new CustomTarget();
410
            List<String> targetNames = new ArrayList<String>();
411
            List<String> targetNames = new ArrayList<String>();
411
            EditableProperties props = new EditableProperties(false);
412
            EditableProperties props = new EditableProperties(false);
412
            for (Element subEl : Util.findSubElements(actionEl)) {
413
            for (Element subEl : XMLUtil.findSubElements(actionEl)) {
413
                if (subEl.getLocalName().equals("target")) { // NOI18N
414
                if (subEl.getLocalName().equals("target")) { // NOI18N
414
                    targetNames.add(Util.findText(subEl));
415
                    targetNames.add(XMLUtil.findText(subEl));
415
                    continue;
416
                    continue;
416
                }
417
                }
417
                if (subEl.getLocalName().equals("script")) { // NOI18N
418
                if (subEl.getLocalName().equals("script")) { // NOI18N
418
                    ct.script = Util.findText(subEl);
419
                    ct.script = XMLUtil.findText(subEl);
419
                    continue;
420
                    continue;
420
                }
421
                }
421
                if (subEl.getLocalName().equals("label")) { // NOI18N
422
                if (subEl.getLocalName().equals("label")) { // NOI18N
422
                    ct.label = Util.findText(subEl);
423
                    ct.label = XMLUtil.findText(subEl);
423
                    continue;
424
                    continue;
424
                }
425
                }
425
                if (subEl.getLocalName().equals("property")) { // NOI18N
426
                if (subEl.getLocalName().equals("property")) { // NOI18N
Lines 448-464 Link Here
448
        //assert ProjectManager.mutex().isWriteAccess();
449
        //assert ProjectManager.mutex().isWriteAccess();
449
        Element data = Util.getPrimaryConfigurationData(helper);
450
        Element data = Util.getPrimaryConfigurationData(helper);
450
        Document doc = data.getOwnerDocument();
451
        Document doc = data.getOwnerDocument();
451
        Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
452
        Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
452
        if (viewEl == null) {
453
        if (viewEl == null) {
453
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
454
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
454
            Util.appendChildElement(data, viewEl, rootElementsOrder);
455
            XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
455
        }
456
        }
456
        Element contextMenuEl = Util.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
457
        Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
457
        if (contextMenuEl == null) {
458
        if (contextMenuEl == null) {
458
            contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
459
            contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
459
            Util.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
460
            XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
460
        }
461
        }
461
        for (Element actionEl : Util.findSubElements(contextMenuEl)) {
462
        for (Element actionEl : XMLUtil.findSubElements(contextMenuEl)) {
462
            if (!actionEl.getLocalName().equals("action")) { // NOI18N
463
            if (!actionEl.getLocalName().equals("action")) { // NOI18N
463
                continue;
464
                continue;
464
            }
465
            }
Lines 484-490 Link Here
484
            if (ct.properties != null) {
485
            if (ct.properties != null) {
485
                writeProperties(ct.properties, doc, action);
486
                writeProperties(ct.properties, doc, action);
486
            }
487
            }
487
            Util.appendChildElement(contextMenuEl, action, contextMenuElementsOrder);
488
            XMLUtil.appendChildElement(contextMenuEl, action, contextMenuElementsOrder);
488
        }
489
        }
489
        Util.putPrimaryConfigurationData(helper, data);
490
        Util.putPrimaryConfigurationData(helper, data);
490
    }
491
    }
Lines 523-543 Link Here
523
    private static void putBuildXMLSourceFile(AntProjectHelper helper, String antPath) {
524
    private static void putBuildXMLSourceFile(AntProjectHelper helper, String antPath) {
524
        Element data = Util.getPrimaryConfigurationData(helper);
525
        Element data = Util.getPrimaryConfigurationData(helper);
525
        Document doc = data.getOwnerDocument();
526
        Document doc = data.getOwnerDocument();
526
        Element viewEl = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
527
        Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
527
        if (viewEl == null) {
528
        if (viewEl == null) {
528
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
529
            viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
529
            Util.appendChildElement(data, viewEl, rootElementsOrder);
530
            XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
530
        }
531
        }
531
        Element itemsEl = Util.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
532
        Element itemsEl = XMLUtil.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
532
        if (itemsEl == null) {
533
        if (itemsEl == null) {
533
            itemsEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "items"); // NOI18N
534
            itemsEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "items"); // NOI18N
534
            Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
535
            XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
535
        }
536
        }
536
        Element fileEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "source-file"); // NOI18N
537
        Element fileEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "source-file"); // NOI18N
537
        Element el = doc.createElementNS(FreeformProjectType.NS_GENERAL, "location"); // NOI18N
538
        Element el = doc.createElementNS(FreeformProjectType.NS_GENERAL, "location"); // NOI18N
538
        el.appendChild(doc.createTextNode(antPath)); // NOI18N
539
        el.appendChild(doc.createTextNode(antPath)); // NOI18N
539
        fileEl.appendChild(el);
540
        fileEl.appendChild(el);
540
        Util.appendChildElement(itemsEl, fileEl, viewItemElementsOrder);
541
        XMLUtil.appendChildElement(itemsEl, fileEl, viewItemElementsOrder);
541
        Util.putPrimaryConfigurationData(helper, data);
542
        Util.putPrimaryConfigurationData(helper, data);
542
    }
543
    }
543
544
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProjectOperations.java (-8 / +5 lines)
Lines 45-62 Link Here
45
import java.io.IOException;
45
import java.io.IOException;
46
import java.util.ArrayList;
46
import java.util.ArrayList;
47
import java.util.Collections;
47
import java.util.Collections;
48
import java.util.Iterator;
49
import java.util.List;
48
import java.util.List;
50
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.modules.ant.freeform.spi.support.Util;
53
import org.netbeans.spi.project.CopyOperationImplementation;
50
import org.netbeans.spi.project.CopyOperationImplementation;
54
import org.netbeans.spi.project.DeleteOperationImplementation;
51
import org.netbeans.spi.project.DeleteOperationImplementation;
55
import org.netbeans.spi.project.MoveOperationImplementation;
52
import org.netbeans.spi.project.MoveOperationImplementation;
56
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
53
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
57
import org.openide.ErrorManager;
58
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileUtil;
55
import org.openide.filesystems.FileUtil;
56
import org.openide.xml.XMLUtil;
60
import org.w3c.dom.Element;
57
import org.w3c.dom.Element;
61
58
62
/**
59
/**
Lines 90-97 Link Here
90
    
87
    
91
    public List<FileObject> getDataFiles() {
88
    public List<FileObject> getDataFiles() {
92
        Element genldata = project.getPrimaryConfigurationData();
89
        Element genldata = project.getPrimaryConfigurationData();
93
        Element foldersEl = Util.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
90
        Element foldersEl = XMLUtil.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
94
        List<Element> folders = foldersEl != null ? Util.findSubElements(foldersEl) : Collections.<Element>emptyList();
91
        List<Element> folders = foldersEl != null ? XMLUtil.findSubElements(foldersEl) : Collections.<Element>emptyList();
95
        List<FileObject> result = new ArrayList<FileObject>();
92
        List<FileObject> result = new ArrayList<FileObject>();
96
93
97
        for (Element el : folders) {
94
        for (Element el : folders) {
Lines 106-119 Link Here
106
    }
103
    }
107
    
104
    
108
    private void addFile(Element folder, List<FileObject> result) {
105
    private void addFile(Element folder, List<FileObject> result) {
109
        Element location = Util.findElement(folder, "location", FreeformProjectType.NS_GENERAL); // NOI18N
106
        Element location = XMLUtil.findElement(folder, "location", FreeformProjectType.NS_GENERAL); // NOI18N
110
        
107
        
111
        if (location == null) {
108
        if (location == null) {
112
            return ;
109
            return ;
113
        }
110
        }
114
        
111
        
115
        PropertyEvaluator evaluator = project.evaluator();
112
        PropertyEvaluator evaluator = project.evaluator();
116
        String val = evaluator.evaluate(Util.findText(location));
113
        String val = evaluator.evaluate(XMLUtil.findText(location));
117
        
114
        
118
        if (val == null) {
115
        if (val == null) {
119
            return ;
116
            return ;
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSharabilityQuery.java (-4 / +2 lines)
Lines 54-62 Link Here
54
import org.openide.filesystems.FileUtil;
54
import org.openide.filesystems.FileUtil;
55
import org.openide.xml.XMLUtil;
55
import org.openide.xml.XMLUtil;
56
import org.w3c.dom.Element;
56
import org.w3c.dom.Element;
57
import org.w3c.dom.Node;
58
import org.w3c.dom.NodeList;
57
import org.w3c.dom.NodeList;
59
import org.w3c.dom.Text;
60
58
61
/**
59
/**
62
 *
60
 *
Lines 117-125 Link Here
117
                    final NodeList exports = root.getElementsByTagNameNS(FreeformProjectType.NS_GENERAL, "export"); //NOI18N
115
                    final NodeList exports = root.getElementsByTagNameNS(FreeformProjectType.NS_GENERAL, "export"); //NOI18N
118
                    for (int i=0; i< exports.getLength(); i++) {
116
                    for (int i=0; i< exports.getLength(); i++) {
119
                        final Element export = (Element) exports.item(i);
117
                        final Element export = (Element) exports.item(i);
120
                        final Element location = Util.findElement(export, "location", FreeformProjectType.NS_GENERAL);   //NOI18N
118
                        final Element location = XMLUtil.findElement(export, "location", FreeformProjectType.NS_GENERAL);   //NOI18N
121
                        if (location != null) {
119
                        if (location != null) {
122
                            final String path = Util.findText(location);
120
                            final String path = XMLUtil.findText(location);
123
                            if (path != null) {
121
                            if (path != null) {
124
                                final File exportedFile = Util.resolveFile(project.evaluator(), FileUtil.toFile(project.getProjectDirectory()), path);
122
                                final File exportedFile = Util.resolveFile(project.evaluator(), FileUtil.toFile(project.getProjectDirectory()), path);
125
                                if (exportedFile != null) {
123
                                if (exportedFile != null) {
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformSources.java (-13 / +13 lines)
Lines 46-57 Link Here
46
import org.netbeans.api.project.ProjectManager;
46
import org.netbeans.api.project.ProjectManager;
47
import org.netbeans.api.project.SourceGroup;
47
import org.netbeans.api.project.SourceGroup;
48
import org.netbeans.api.project.Sources;
48
import org.netbeans.api.project.Sources;
49
import org.netbeans.modules.ant.freeform.spi.support.Util;
50
import org.netbeans.spi.project.support.ant.AntProjectEvent;
49
import org.netbeans.spi.project.support.ant.AntProjectEvent;
51
import org.netbeans.spi.project.support.ant.AntProjectListener;
50
import org.netbeans.spi.project.support.ant.AntProjectListener;
52
import org.netbeans.spi.project.support.ant.SourcesHelper;
51
import org.netbeans.spi.project.support.ant.SourcesHelper;
53
import org.openide.util.ChangeSupport;
52
import org.openide.util.ChangeSupport;
54
import org.openide.util.Mutex;
53
import org.openide.util.Mutex;
54
import org.openide.xml.XMLUtil;
55
import org.w3c.dom.Element;
55
import org.w3c.dom.Element;
56
56
57
/**
57
/**
Lines 86-117 Link Here
86
    private Sources initSources() {
86
    private Sources initSources() {
87
        SourcesHelper h = new SourcesHelper(project, project.helper(), project.evaluator());
87
        SourcesHelper h = new SourcesHelper(project, project.helper(), project.evaluator());
88
        Element genldata = project.getPrimaryConfigurationData();
88
        Element genldata = project.getPrimaryConfigurationData();
89
        Element foldersE = Util.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
89
        Element foldersE = XMLUtil.findElement(genldata, "folders", FreeformProjectType.NS_GENERAL); // NOI18N
90
        if (foldersE != null) {
90
        if (foldersE != null) {
91
            for (Element folderE : Util.findSubElements(foldersE)) {
91
            for (Element folderE : XMLUtil.findSubElements(foldersE)) {
92
                Element locationE = Util.findElement(folderE, "location", FreeformProjectType.NS_GENERAL); // NOI18N
92
                Element locationE = XMLUtil.findElement(folderE, "location", FreeformProjectType.NS_GENERAL); // NOI18N
93
                String location = Util.findText(locationE);
93
                String location = XMLUtil.findText(locationE);
94
                if (folderE.getLocalName().equals("build-folder")) { // NOI18N
94
                if (folderE.getLocalName().equals("build-folder")) { // NOI18N
95
                    h.addNonSourceRoot(location);
95
                    h.addNonSourceRoot(location);
96
                } else if (folderE.getLocalName().equals("build-file")) { // NOI18N
96
                } else if (folderE.getLocalName().equals("build-file")) { // NOI18N
97
                    h.addOwnedFile(location);
97
                    h.addOwnedFile(location);
98
                } else {
98
                } else {
99
                    assert folderE.getLocalName().equals("source-folder") : folderE;
99
                    assert folderE.getLocalName().equals("source-folder") : folderE;
100
                    Element nameE = Util.findElement(folderE, "label", FreeformProjectType.NS_GENERAL); // NOI18N
100
                    Element nameE = XMLUtil.findElement(folderE, "label", FreeformProjectType.NS_GENERAL); // NOI18N
101
                    String name = Util.findText(nameE);
101
                    String name = XMLUtil.findText(nameE);
102
                    Element typeE = Util.findElement(folderE, "type", FreeformProjectType.NS_GENERAL); // NOI18N
102
                    Element typeE = XMLUtil.findElement(folderE, "type", FreeformProjectType.NS_GENERAL); // NOI18N
103
                    String includes = null;
103
                    String includes = null;
104
                    Element includesE = Util.findElement(folderE, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
104
                    Element includesE = XMLUtil.findElement(folderE, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
105
                    if (includesE != null) {
105
                    if (includesE != null) {
106
                        includes = Util.findText(includesE);
106
                        includes = XMLUtil.findText(includesE);
107
                    }
107
                    }
108
                    String excludes = null;
108
                    String excludes = null;
109
                    Element excludesE = Util.findElement(folderE, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
109
                    Element excludesE = XMLUtil.findElement(folderE, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
110
                    if (excludesE != null) {
110
                    if (excludesE != null) {
111
                        excludes = Util.findText(excludesE);
111
                        excludes = XMLUtil.findText(excludesE);
112
                    }
112
                    }
113
                    if (typeE != null) {
113
                    if (typeE != null) {
114
                        String type = Util.findText(typeE);
114
                        String type = XMLUtil.findText(typeE);
115
                        h.addTypedSourceRoot(location, includes, excludes, type, name, null, null);
115
                        h.addTypedSourceRoot(location, includes, excludes, type, name, null, null);
116
                    } else {
116
                    } else {
117
                        h.addPrincipalSourceRoot(location, includes, excludes, name, null, null);
117
                        h.addPrincipalSourceRoot(location, includes, excludes, name, null, null);
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformTemplateAttributesProvider.java (-2 / +3 lines)
Lines 51-56 Link Here
51
import org.openide.loaders.CreateFromTemplateAttributesProvider;
51
import org.openide.loaders.CreateFromTemplateAttributesProvider;
52
import org.openide.loaders.DataFolder;
52
import org.openide.loaders.DataFolder;
53
import org.openide.loaders.DataObject;
53
import org.openide.loaders.DataObject;
54
import org.openide.xml.XMLUtil;
54
import org.w3c.dom.Element;
55
import org.w3c.dom.Element;
55
56
56
/**
57
/**
Lines 77-90 Link Here
77
    
78
    
78
    public Map<String, ?> attributesFor(DataObject template, DataFolder target, String name) {
79
    public Map<String, ?> attributesFor(DataObject template, DataFolder target, String name) {
79
        Element primData = Util.getPrimaryConfigurationData(helper);
80
        Element primData = Util.getPrimaryConfigurationData(helper);
80
        Element licenseEl = Util.findElement(primData, "project-license", Util.NAMESPACE); // NOI18N
81
        Element licenseEl = XMLUtil.findElement(primData, "project-license", Util.NAMESPACE); // NOI18N
81
        Charset charset = encodingQuery.getEncoding(target.getPrimaryFile());
82
        Charset charset = encodingQuery.getEncoding(target.getPrimaryFile());
82
        if (licenseEl == null && charset == null) {
83
        if (licenseEl == null && charset == null) {
83
            return null;
84
            return null;
84
        } else {
85
        } else {
85
            Map<String, String> values = new HashMap<String, String>();
86
            Map<String, String> values = new HashMap<String, String>();
86
            if (licenseEl != null) {
87
            if (licenseEl != null) {
87
                values.put("license", evaluator.evaluate(Util.findText(licenseEl))); // NOI18N
88
                values.put("license", evaluator.evaluate(XMLUtil.findText(licenseEl))); // NOI18N
88
            }
89
            }
89
            if (charset != null) {
90
            if (charset != null) {
90
                values.put("encoding", charset.name()); // NOI18N
91
                values.put("encoding", charset.name()); // NOI18N
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/Subprojects.java (-5 / +4 lines)
Lines 46-60 Link Here
46
import java.util.Collections;
46
import java.util.Collections;
47
import java.util.HashSet;
47
import java.util.HashSet;
48
import java.util.Iterator;
48
import java.util.Iterator;
49
import java.util.List;
50
import java.util.Set;
49
import java.util.Set;
51
import javax.swing.event.ChangeListener;
50
import javax.swing.event.ChangeListener;
52
import org.netbeans.api.project.Project;
51
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.modules.ant.freeform.spi.support.Util;
55
import org.netbeans.spi.project.SubprojectProvider;
53
import org.netbeans.spi.project.SubprojectProvider;
56
import org.openide.ErrorManager;
54
import org.openide.ErrorManager;
57
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
56
import org.openide.xml.XMLUtil;
58
import org.w3c.dom.Element;
57
import org.w3c.dom.Element;
59
58
60
/**
59
/**
Lines 88-98 Link Here
88
     */
87
     */
89
    private Set<Project> createSubprojects(Set<Project> subprojects) {
88
    private Set<Project> createSubprojects(Set<Project> subprojects) {
90
        Element config = project.getPrimaryConfigurationData();
89
        Element config = project.getPrimaryConfigurationData();
91
        Element subprjsEl = Util.findElement(config, "subprojects", FreeformProjectType.NS_GENERAL); // NOI18N
90
        Element subprjsEl = XMLUtil.findElement(config, "subprojects", FreeformProjectType.NS_GENERAL); // NOI18N
92
        if (subprjsEl != null) {
91
        if (subprjsEl != null) {
93
            for (Element prjEl : Util.findSubElements(subprjsEl)) {
92
            for (Element prjEl : XMLUtil.findSubElements(subprjsEl)) {
94
                assert prjEl.getLocalName().equals("project") : "Bad element " + prjEl + " in <subprojects> for " + project;
93
                assert prjEl.getLocalName().equals("project") : "Bad element " + prjEl + " in <subprojects> for " + project;
95
                String rawtext = Util.findText(prjEl);
94
                String rawtext = XMLUtil.findText(prjEl);
96
                assert rawtext != null : "Need text content for <project> in " + project;
95
                assert rawtext != null : "Need text content for <project> in " + project;
97
                String evaltext = project.evaluator().evaluate(rawtext);
96
                String evaltext = project.evaluator().evaluate(rawtext);
98
                if (evaltext == null) {
97
                if (evaltext == null) {
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java (-139 / +3 lines)
Lines 43-52 Link Here
43
43
44
import java.io.File;
44
import java.io.File;
45
import java.io.IOException;
45
import java.io.IOException;
46
import java.util.ArrayList;
47
import java.util.Arrays;
48
import java.util.Iterator;
49
import java.util.List;
50
import javax.xml.XMLConstants;
46
import javax.xml.XMLConstants;
51
import javax.xml.validation.Schema;
47
import javax.xml.validation.Schema;
52
import javax.xml.validation.SchemaFactory;
48
import javax.xml.validation.SchemaFactory;
Lines 71-80 Link Here
71
import org.w3c.dom.DOMException;
67
import org.w3c.dom.DOMException;
72
import org.w3c.dom.Document;
68
import org.w3c.dom.Document;
73
import org.w3c.dom.Element;
69
import org.w3c.dom.Element;
74
import org.w3c.dom.NamedNodeMap;
75
import org.w3c.dom.Node;
76
import org.w3c.dom.NodeList;
77
import org.w3c.dom.Text;
78
import org.w3c.dom.ls.DOMImplementationLS;
70
import org.w3c.dom.ls.DOMImplementationLS;
79
import org.w3c.dom.ls.LSSerializer;
71
import org.w3c.dom.ls.LSSerializer;
80
import org.xml.sax.SAXException;
72
import org.xml.sax.SAXException;
Lines 87-170 Link Here
87
    
79
    
88
    private Util() {}
80
    private Util() {}
89
    
81
    
90
    // XXX XML methods copied from ant/project... make a general API of these instead?
91
    
92
    /**
93
     * Search for an XML element in the direct children of a parent.
94
     * DOM provides a similar method but it does a recursive search
95
     * which we do not want. It also gives a node list and we want
96
     * only one result.
97
     * @param parent a parent element
98
     * @param name the intended local name
99
     * @param namespace the intended namespace
100
     * @return the one child element with that name, or null if none or more than one
101
     */
102
    public static Element findElement(Element parent, String name, String namespace) {
103
        Element result = null;
104
        NodeList l = parent.getChildNodes();
105
        for (int i = 0; i < l.getLength(); i++) {
106
            if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
107
                Element el = (Element)l.item(i);
108
                if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
109
                    if (result == null) {
110
                        result = el;
111
                    } else {
112
                        return null;
113
                    }
114
                }
115
            }
116
        }
117
        return result;
118
    }
119
    
120
    /**
121
     * Extract nested text from an element.
122
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
123
     * @param parent a parent element
124
     * @return the nested text, or null if none was found
125
     */
126
    public static String findText(Element parent) {
127
        NodeList l = parent.getChildNodes();
128
        for (int i = 0; i < l.getLength(); i++) {
129
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
130
                Text text = (Text)l.item(i);
131
                return text.getNodeValue();
132
            }
133
        }
134
        return null;
135
    }
136
    
137
    /**
138
     * Find all direct child elements of an element.
139
     * More useful than {@link Element#getElementsByTagNameNS} because it does
140
     * not recurse into recursive child elements.
141
     * Children which are all-whitespace text nodes are ignored; others cause
142
     * an exception to be thrown.
143
     * @param parent a parent element in a DOM tree
144
     * @return a list of direct child elements (may be empty)
145
     * @throws IllegalArgumentException if there are non-element children besides whitespace
146
     */
147
    public static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
148
        NodeList l = parent.getChildNodes();
149
        List<Element> elements = new ArrayList<Element>(l.getLength());
150
        for (int i = 0; i < l.getLength(); i++) {
151
            Node n = l.item(i);
152
            if (n.getNodeType() == Node.ELEMENT_NODE) {
153
                elements.add((Element)n);
154
            } else if (n.getNodeType() == Node.TEXT_NODE) {
155
                String text = ((Text)n).getNodeValue();
156
                if (text.trim().length() > 0) {
157
                    throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
158
                }
159
            } else if (n.getNodeType() == Node.COMMENT_NODE) {
160
                // skip
161
            } else {
162
                throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
163
            }
164
        }
165
        return elements;
166
    }
167
168
    /**
82
    /**
169
     * Finds AuxiliaryConfiguration for the given project helper. The method
83
     * Finds AuxiliaryConfiguration for the given project helper. The method
170
     * finds project associated with the helper and searches 
84
     * finds project associated with the helper and searches 
Lines 241-271 Link Here
241
        }
155
        }
242
    }
156
    }
243
157
244
    /**
245
     * Append child element to the correct position according to given
246
     * order.
247
     * @param parent parent to which the child will be added
248
     * @param el element to be added
249
     * @param order order of the elements which must be followed
250
     */
251
    public static void appendChildElement(Element parent, Element el, String[] order) {
252
        Element insertBefore = null;
253
        List l = Arrays.asList(order);
254
        int index = l.indexOf(el.getLocalName());
255
        assert index != -1 : el.getLocalName()+" was not found in "+l; // NOI18N
256
        Iterator it = Util.findSubElements(parent).iterator();
257
        while (it.hasNext()) {
258
            Element e = (Element)it.next();
259
            int index2 = l.indexOf(e.getLocalName());
260
            assert index2 != -1 : e.getLocalName()+" was not found in "+l; // NOI18N
261
            if (index2 > index) {
262
                insertBefore = e;
263
                break;
264
            }
265
        }
266
        parent.insertBefore(el, insertBefore);
267
    }
268
    
269
    /**Get the "default" (user-specified) ant script for the given freeform project.
158
    /**Get the "default" (user-specified) ant script for the given freeform project.
270
     * Please note that this method may return <code>null</code> if there is no such script.
159
     * Please note that this method may return <code>null</code> if there is no such script.
271
     *
160
     *
Lines 287-317 Link Here
287
    }
176
    }
288
    
177
    
289
    /**
178
    /**
290
     * Convert an XML fragment from one namespace to another.
291
     */
292
    private static Element translateXML(Element from, String namespace) {
293
        Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
294
        NodeList nl = from.getChildNodes();
295
        int length = nl.getLength();
296
        for (int i = 0; i < length; i++) {
297
            Node node = nl.item(i);
298
            Node newNode;
299
            if (node.getNodeType() == Node.ELEMENT_NODE) {
300
                newNode = translateXML((Element) node, namespace);
301
            } else {
302
                newNode = node.cloneNode(true);
303
            }
304
            to.appendChild(newNode);
305
        }
306
        NamedNodeMap m = from.getAttributes();
307
        for (int i = 0; i < m.getLength(); i++) {
308
            Node attr = m.item(i);
309
            to.setAttribute(attr.getNodeName(), attr.getNodeValue());
310
        }
311
        return to;
312
    }
313
314
    /**
315
     * Namespace of data used in {@link #getPrimaryConfigurationData} and {@link #putPrimaryConfigurationData}.
179
     * Namespace of data used in {@link #getPrimaryConfigurationData} and {@link #putPrimaryConfigurationData}.
316
     * @since org.netbeans.modules.ant.freeform/1 1.15
180
     * @since org.netbeans.modules.ant.freeform/1 1.15
317
     */
181
     */
Lines 332-338 Link Here
332
                if (data != null) {
196
                if (data != null) {
333
                    return data;
197
                    return data;
334
                } else {
198
                } else {
335
                    return translateXML(helper.getPrimaryConfigurationData(true), NAMESPACE);
199
                    return XMLUtil.translateXML(helper.getPrimaryConfigurationData(true), NAMESPACE);
336
                }
200
                }
337
            }
201
            }
338
        });
202
        });
Lines 353-359 Link Here
353
        }
217
        }
354
        ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
218
        ProjectManager.mutex().writeAccess(new Mutex.Action<Void>() {
355
            public Void run() {
219
            public Void run() {
356
                Element dataAs1 = translateXML(data, FreeformProjectType.NS_GENERAL_1);
220
                Element dataAs1 = XMLUtil.translateXML(data, FreeformProjectType.NS_GENERAL_1);
357
                if (SCHEMA_1 == null) {
221
                if (SCHEMA_1 == null) {
358
                    try {
222
                    try {
359
                        SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
223
                        SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Lines 390-396 Link Here
390
        Element dummy1 = doc.createElementNS(FreeformProjectType.NS_GENERAL_1, FreeformProjectType.NAME_SHARED);
254
        Element dummy1 = doc.createElementNS(FreeformProjectType.NS_GENERAL_1, FreeformProjectType.NAME_SHARED);
391
        // Make sure it is not invalid.
255
        // Make sure it is not invalid.
392
        dummy1.appendChild(doc.createElementNS(FreeformProjectType.NS_GENERAL_1, "name")). // NOI18N
256
        dummy1.appendChild(doc.createElementNS(FreeformProjectType.NS_GENERAL_1, "name")). // NOI18N
393
                appendChild(doc.createTextNode(findText(findElement(data, "name", NAMESPACE)))); // NOI18N
257
                appendChild(doc.createTextNode(XMLUtil.findText(XMLUtil.findElement(data, "name", NAMESPACE)))); // NOI18N
394
        helper.putPrimaryConfigurationData(dummy1, true);
258
        helper.putPrimaryConfigurationData(dummy1, true);
395
        helper.createAuxiliaryConfiguration().putConfigurationFragment(data, true);
259
        helper.createAuxiliaryConfiguration().putConfigurationFragment(data, true);
396
    }
260
    }
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/ui/FolderNodeFactory.java (-12 / +12 lines)
Lines 64-70 Link Here
64
import org.netbeans.api.queries.VisibilityQuery;
64
import org.netbeans.api.queries.VisibilityQuery;
65
import org.netbeans.modules.ant.freeform.FreeformProject;
65
import org.netbeans.modules.ant.freeform.FreeformProject;
66
import org.netbeans.modules.ant.freeform.FreeformProjectType;
66
import org.netbeans.modules.ant.freeform.FreeformProjectType;
67
import org.netbeans.modules.ant.freeform.spi.support.Util;
68
import org.netbeans.modules.ant.freeform.spi.ProjectNature;
67
import org.netbeans.modules.ant.freeform.spi.ProjectNature;
69
import org.netbeans.spi.project.support.ant.AntProjectEvent;
68
import org.netbeans.spi.project.support.ant.AntProjectEvent;
70
import org.netbeans.spi.project.support.ant.AntProjectListener;
69
import org.netbeans.spi.project.support.ant.AntProjectListener;
Lines 91-96 Link Here
91
import org.openide.util.RequestProcessor;
90
import org.openide.util.RequestProcessor;
92
import org.openide.util.actions.SystemAction;
91
import org.openide.util.actions.SystemAction;
93
import org.openide.util.lookup.Lookups;
92
import org.openide.util.lookup.Lookups;
93
import org.openide.xml.XMLUtil;
94
import org.w3c.dom.Element;
94
import org.w3c.dom.Element;
95
95
96
/**
96
/**
Lines 136-145 Link Here
136
        
136
        
137
        private void updateKeys(boolean fromListener) {
137
        private void updateKeys(boolean fromListener) {
138
            Element genldata = p.getPrimaryConfigurationData();
138
            Element genldata = p.getPrimaryConfigurationData();
139
            Element viewEl = Util.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
139
            Element viewEl = XMLUtil.findElement(genldata, "view", FreeformProjectType.NS_GENERAL); // NOI18N
140
            if (viewEl != null) {
140
            if (viewEl != null) {
141
                Element itemsEl = Util.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
141
                Element itemsEl = XMLUtil.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
142
                keys = Util.findSubElements(itemsEl);
142
                keys = XMLUtil.findSubElements(itemsEl);
143
            } else {
143
            } else {
144
                keys = Collections.<Element>emptyList();
144
                keys = Collections.<Element>emptyList();
145
            }
145
            }
Lines 182-189 Link Here
182
        
182
        
183
        public Node node(Element itemEl) {
183
        public Node node(Element itemEl) {
184
            
184
            
185
            Element locationEl = Util.findElement(itemEl, "location", FreeformProjectType.NS_GENERAL); // NOI18N
185
            Element locationEl = XMLUtil.findElement(itemEl, "location", FreeformProjectType.NS_GENERAL); // NOI18N
186
            String location = Util.findText(locationEl);
186
            String location = XMLUtil.findText(locationEl);
187
            String locationEval = p.evaluator().evaluate(location);
187
            String locationEval = p.evaluator().evaluate(location);
188
            if (locationEval == null) {
188
            if (locationEval == null) {
189
                return null;
189
                return null;
Lines 194-202 Link Here
194
                return null;
194
                return null;
195
            }
195
            }
196
            String label;
196
            String label;
197
            Element labelEl = Util.findElement(itemEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
197
            Element labelEl = XMLUtil.findElement(itemEl, "label", FreeformProjectType.NS_GENERAL); // NOI18N
198
            if (labelEl != null) {
198
            if (labelEl != null) {
199
                label = Util.findText(labelEl);
199
                label = XMLUtil.findText(labelEl);
200
            } else {
200
            } else {
201
                label = null;
201
                label = null;
202
            }
202
            }
Lines 206-223 Link Here
206
                    return null;
206
                    return null;
207
                }
207
                }
208
                String includes = null;
208
                String includes = null;
209
                Element includesEl = Util.findElement(itemEl, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
209
                Element includesEl = XMLUtil.findElement(itemEl, "includes", FreeformProjectType.NS_GENERAL); // NOI18N
210
                if (includesEl != null) {
210
                if (includesEl != null) {
211
                    includes = p.evaluator().evaluate(Util.findText(includesEl));
211
                    includes = p.evaluator().evaluate(XMLUtil.findText(includesEl));
212
                    if (includes.matches("\\$\\{[^}]+\\}")) { // NOI18N
212
                    if (includes.matches("\\$\\{[^}]+\\}")) { // NOI18N
213
                        // Clearly intended to mean "include everything".
213
                        // Clearly intended to mean "include everything".
214
                        includes = null;
214
                        includes = null;
215
                    }
215
                    }
216
                }
216
                }
217
                String excludes = null;
217
                String excludes = null;
218
                Element excludesEl = Util.findElement(itemEl, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
218
                Element excludesEl = XMLUtil.findElement(itemEl, "excludes", FreeformProjectType.NS_GENERAL); // NOI18N
219
                if (excludesEl != null) {
219
                if (excludesEl != null) {
220
                    excludes = p.evaluator().evaluate(Util.findText(excludesEl));
220
                    excludes = p.evaluator().evaluate(XMLUtil.findText(excludesEl));
221
                }
221
                }
222
                String style = itemEl.getAttribute("style"); // NOI18N
222
                String style = itemEl.getAttribute("style"); // NOI18N
223
                for (ProjectNature nature : Lookup.getDefault().lookupAll(ProjectNature.class)) {
223
                for (ProjectNature nature : Lookup.getDefault().lookupAll(ProjectNature.class)) {
(-)a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ArtifactProviderTest.java (-3 / +4 lines)
Lines 49-54 Link Here
49
import org.netbeans.api.project.ant.AntArtifactQuery;
49
import org.netbeans.api.project.ant.AntArtifactQuery;
50
import org.netbeans.modules.ant.freeform.spi.support.Util;
50
import org.netbeans.modules.ant.freeform.spi.support.Util;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
52
import org.openide.xml.XMLUtil;
52
import org.w3c.dom.Document;
53
import org.w3c.dom.Document;
53
import org.w3c.dom.Element;
54
import org.w3c.dom.Element;
54
55
Lines 137-143 Link Here
137
        //assert ProjectManager.mutex().isWriteAccess();
138
        //assert ProjectManager.mutex().isWriteAccess();
138
        Element data = Util.getPrimaryConfigurationData(helper);
139
        Element data = Util.getPrimaryConfigurationData(helper);
139
        Document doc = data.getOwnerDocument();
140
        Document doc = data.getOwnerDocument();
140
        for (Element exportEl : Util.findSubElements(data)) {
141
        for (Element exportEl : XMLUtil.findSubElements(data)) {
141
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
142
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
142
                continue;
143
                continue;
143
            }
144
            }
Lines 165-173 Link Here
165
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
166
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
166
                exportEl.appendChild(el);
167
                exportEl.appendChild(el);
167
            }
168
            }
168
            Element later = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
169
            Element later = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
169
            if (later == null) {
170
            if (later == null) {
170
                later = Util.findElement(data, "subprojects", FreeformProjectType.NS_GENERAL);
171
                later = XMLUtil.findElement(data, "subprojects", FreeformProjectType.NS_GENERAL);
171
            }
172
            }
172
            data.insertBefore(exportEl, later);
173
            data.insertBefore(exportEl, later);
173
        }
174
        }
(-)a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformProjectGeneratorTest.java (-33 / +34 lines)
Lines 62-67 Link Here
62
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
63
import org.openide.modules.ModuleInfo;
63
import org.openide.modules.ModuleInfo;
64
import org.openide.util.Lookup;
64
import org.openide.util.Lookup;
65
import org.openide.xml.XMLUtil;
65
import org.w3c.dom.Element;
66
import org.w3c.dom.Element;
66
67
67
/**
68
/**
Lines 227-240 Link Here
227
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
228
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
228
//        ProjectManager.getDefault().saveAllProjects();
229
//        ProjectManager.getDefault().saveAllProjects();
229
        Element el = Util.getPrimaryConfigurationData(helper);
230
        Element el = Util.getPrimaryConfigurationData(helper);
230
        el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
231
        el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
231
        assertNotNull("Target mapping were not saved correctly",  el);
232
        assertNotNull("Target mapping were not saved correctly",  el);
232
        List<Element> subElements = Util.findSubElements(el);
233
        List<Element> subElements = XMLUtil.findSubElements(el);
233
        assertEquals(2, subElements.size());
234
        assertEquals(2, subElements.size());
234
        // compare first target mapping
235
        // compare first target mapping
235
        Element el2 = subElements.get(0);
236
        Element el2 = subElements.get(0);
236
        assertElement(el2, "action", null, "name", "first-targetName");
237
        assertElement(el2, "action", null, "name", "first-targetName");
237
        List<Element> l1 = Util.findSubElements(el2);
238
        List<Element> l1 = XMLUtil.findSubElements(el2);
238
        assertEquals(7, l1.size());
239
        assertEquals(7, l1.size());
239
        assertElementArray(l1, 
240
        assertElementArray(l1, 
240
            new String[]{"script", "target", "target", "target", "property", "property", "context"}, 
241
            new String[]{"script", "target", "target", "target", "property", "property", "context"}, 
Lines 244-259 Link Here
244
        el2 = l1.get(5);
245
        el2 = l1.get(5);
245
        assertElement(el2, "property", "v2", "name", "k2");
246
        assertElement(el2, "property", "v2", "name", "k2");
246
        el2 = l1.get(6);
247
        el2 = l1.get(6);
247
        List<Element> l2 = Util.findSubElements(el2);
248
        List<Element> l2 = XMLUtil.findSubElements(el2);
248
        assertEquals(5, l2.size());
249
        assertEquals(5, l2.size());
249
        assertElementArray(l2, 
250
        assertElementArray(l2, 
250
            new String[]{"property", "folder", "pattern", "format", "arity"}, 
251
            new String[]{"property", "folder", "pattern", "format", "arity"}, 
251
            new String[]{"someProperty1", "someFolder1", "somePattern1", "relative-path", null});
252
            new String[]{"someProperty1", "someFolder1", "somePattern1", "relative-path", null});
252
        assertNotNull("have <one-file-only>", Util.findElement(l2.get(4), "one-file-only", FreeformProjectType.NS_GENERAL));
253
        assertNotNull("have <one-file-only>", XMLUtil.findElement(l2.get(4), "one-file-only", FreeformProjectType.NS_GENERAL));
253
        // compare second target mapping
254
        // compare second target mapping
254
        el2 = subElements.get(1);
255
        el2 = subElements.get(1);
255
        assertElement(el2, "action", null, "name", "second-targetName");
256
        assertElement(el2, "action", null, "name", "second-targetName");
256
        l1 = Util.findSubElements(el2);
257
        l1 = XMLUtil.findSubElements(el2);
257
        assertEquals(7, l1.size());
258
        assertEquals(7, l1.size());
258
        assertElementArray(l1, 
259
        assertElementArray(l1, 
259
            new String[]{"script", "target", "target", "target", "property", "property", "context"},
260
            new String[]{"script", "target", "target", "target", "property", "property", "context"},
Lines 263-276 Link Here
263
        el2 = l1.get(5);
264
        el2 = l1.get(5);
264
        assertElement(el2, "property", "second-v2", "name", "second-k2");
265
        assertElement(el2, "property", "second-v2", "name", "second-k2");
265
        el2 = l1.get(6);
266
        el2 = l1.get(6);
266
        l2 = Util.findSubElements(el2);
267
        l2 = XMLUtil.findSubElements(el2);
267
        assertEquals(4, l2.size());
268
        assertEquals(4, l2.size());
268
        assertElementArray(l2, 
269
        assertElementArray(l2, 
269
            new String[]{"property", "folder", "format", "arity"}, 
270
            new String[]{"property", "folder", "format", "arity"}, 
270
            new String[]{"second-someProperty1", "second-someFolder1", "java-name", null});
271
            new String[]{"second-someProperty1", "second-someFolder1", "java-name", null});
271
        Element sepFilesEl = Util.findElement(l2.get(3), "separated-files", FreeformProjectType.NS_GENERAL);
272
        Element sepFilesEl = XMLUtil.findElement(l2.get(3), "separated-files", FreeformProjectType.NS_GENERAL);
272
        assertNotNull("have <separated-files>", sepFilesEl);
273
        assertNotNull("have <separated-files>", sepFilesEl);
273
        assertEquals("right separator", "someSeparator1", Util.findText(sepFilesEl));
274
        assertEquals("right separator", "someSeparator1", XMLUtil.findText(sepFilesEl));
274
        ProjectManager.getDefault().saveAllProjects();
275
        ProjectManager.getDefault().saveAllProjects();
275
            
276
            
276
        // test updating
277
        // test updating
Lines 289-302 Link Here
289
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
290
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
290
//        ProjectManager.getDefault().saveAllProjects();
291
//        ProjectManager.getDefault().saveAllProjects();
291
        el = Util.getPrimaryConfigurationData(helper);
292
        el = Util.getPrimaryConfigurationData(helper);
292
        el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
293
        el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
293
        assertNotNull("Target mapping were not saved correctly",  el);
294
        assertNotNull("Target mapping were not saved correctly",  el);
294
        subElements = Util.findSubElements(el);
295
        subElements = XMLUtil.findSubElements(el);
295
        assertEquals(1, subElements.size());
296
        assertEquals(1, subElements.size());
296
        // compare first target mapping
297
        // compare first target mapping
297
        el2 = subElements.get(0);
298
        el2 = subElements.get(0);
298
        assertElement(el2, "action", null, "name", "foo");
299
        assertElement(el2, "action", null, "name", "foo");
299
        l1 = Util.findSubElements(el2);
300
        l1 = XMLUtil.findSubElements(el2);
300
        assertEquals(5, l1.size());
301
        assertEquals(5, l1.size());
301
        assertElementArray(l1, 
302
        assertElementArray(l1, 
302
            new String[]{"script", "target", "target", "property", "property"}, 
303
            new String[]{"script", "target", "target", "property", "property"}, 
Lines 319-332 Link Here
319
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
320
        FreeformProjectGenerator.putTargetMappings(helper, mappings);
320
//        ProjectManager.getDefault().saveAllProjects();
321
//        ProjectManager.getDefault().saveAllProjects();
321
        el = Util.getPrimaryConfigurationData(helper);
322
        el = Util.getPrimaryConfigurationData(helper);
322
        el = Util.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
323
        el = XMLUtil.findElement(el, "ide-actions", FreeformProjectType.NS_GENERAL);
323
        assertNotNull("Target mapping were not saved correctly",  el);
324
        assertNotNull("Target mapping were not saved correctly",  el);
324
        subElements = Util.findSubElements(el);
325
        subElements = XMLUtil.findSubElements(el);
325
        assertEquals(1, subElements.size());
326
        assertEquals(1, subElements.size());
326
        // compare first target mapping
327
        // compare first target mapping
327
        el2 = subElements.get(0);
328
        el2 = subElements.get(0);
328
        assertElement(el2, "action", null, "name", "foo");
329
        assertElement(el2, "action", null, "name", "foo");
329
        l1 = Util.findSubElements(el2);
330
        l1 = XMLUtil.findSubElements(el2);
330
        assertEquals(5, l1.size());
331
        assertEquals(5, l1.size());
331
        assertElementArray(l1, 
332
        assertElementArray(l1, 
332
            new String[]{"script", "target", "target", "property", "property"}, 
333
            new String[]{"script", "target", "target", "property", "property"}, 
Lines 361-371 Link Here
361
        FreeformProjectGenerator.putContextMenuAction(helper, mappings);
362
        FreeformProjectGenerator.putContextMenuAction(helper, mappings);
362
//        ProjectManager.getDefault().saveAllProjects();
363
//        ProjectManager.getDefault().saveAllProjects();
363
        Element el = Util.getPrimaryConfigurationData(helper);
364
        Element el = Util.getPrimaryConfigurationData(helper);
364
        el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
365
        el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
365
        assertNotNull("Target mapping were not saved correctly",  el);
366
        assertNotNull("Target mapping were not saved correctly",  el);
366
        el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
367
        el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
367
        assertNotNull("Target mapping were not saved correctly",  el);
368
        assertNotNull("Target mapping were not saved correctly",  el);
368
        List<Element> subElements = Util.findSubElements(el);
369
        List<Element> subElements = XMLUtil.findSubElements(el);
369
        assertEquals(2, subElements.size());
370
        assertEquals(2, subElements.size());
370
        assertElementArray(subElements, 
371
        assertElementArray(subElements, 
371
            new String[]{"ide-action", "ide-action"}, 
372
            new String[]{"ide-action", "ide-action"}, 
Lines 386-396 Link Here
386
        FreeformProjectGenerator.putContextMenuAction(helper, mappings);
387
        FreeformProjectGenerator.putContextMenuAction(helper, mappings);
387
//        ProjectManager.getDefault().saveAllProjects();
388
//        ProjectManager.getDefault().saveAllProjects();
388
        el = Util.getPrimaryConfigurationData(helper);
389
        el = Util.getPrimaryConfigurationData(helper);
389
        el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
390
        el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
390
        assertNotNull("Target mapping were not saved correctly",  el);
391
        assertNotNull("Target mapping were not saved correctly",  el);
391
        el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
392
        el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
392
        assertNotNull("Target mapping were not saved correctly",  el);
393
        assertNotNull("Target mapping were not saved correctly",  el);
393
        subElements = Util.findSubElements(el);
394
        subElements = XMLUtil.findSubElements(el);
394
        assertEquals(4, subElements.size());
395
        assertEquals(4, subElements.size());
395
        assertElementArray(subElements, 
396
        assertElementArray(subElements, 
396
            new String[]{"ide-action", "ide-action", "ide-action", "ide-action"},
397
            new String[]{"ide-action", "ide-action", "ide-action", "ide-action"},
Lines 437-454 Link Here
437
        FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
438
        FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
438
//        ProjectManager.getDefault().saveAllProjects();
439
//        ProjectManager.getDefault().saveAllProjects();
439
        Element el = Util.getPrimaryConfigurationData(helper);
440
        Element el = Util.getPrimaryConfigurationData(helper);
440
        el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
441
        el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
441
        assertNotNull("Target mapping were not saved correctly",  el);
442
        assertNotNull("Target mapping were not saved correctly",  el);
442
        el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
443
        el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
443
        assertNotNull("Target mapping were not saved correctly",  el);
444
        assertNotNull("Target mapping were not saved correctly",  el);
444
        List<Element> subElements = Util.findSubElements(el);
445
        List<Element> subElements = XMLUtil.findSubElements(el);
445
        assertEquals(2, subElements.size());
446
        assertEquals(2, subElements.size());
446
        assertElementArray(subElements, 
447
        assertElementArray(subElements, 
447
            new String[]{"action", "action"}, 
448
            new String[]{"action", "action"}, 
448
            new String[]{null, null});
449
            new String[]{null, null});
449
        // compare first custom action
450
        // compare first custom action
450
        Element el2 = subElements.get(0);
451
        Element el2 = subElements.get(0);
451
        List<Element> l1 = Util.findSubElements(el2);
452
        List<Element> l1 = XMLUtil.findSubElements(el2);
452
        assertEquals(6, l1.size());
453
        assertEquals(6, l1.size());
453
        assertElementArray(l1, 
454
        assertElementArray(l1, 
454
            new String[]{"script", "label", "target", "target", "property", "property"}, 
455
            new String[]{"script", "label", "target", "target", "property", "property"}, 
Lines 459-465 Link Here
459
        assertElement(el2, "property", "v2", "name", "k2");
460
        assertElement(el2, "property", "v2", "name", "k2");
460
        // compare second custom action
461
        // compare second custom action
461
        el2 = subElements.get(1);
462
        el2 = subElements.get(1);
462
        l1 = Util.findSubElements(el2);
463
        l1 = XMLUtil.findSubElements(el2);
463
        assertEquals(6, l1.size());
464
        assertEquals(6, l1.size());
464
        assertElementArray(l1, 
465
        assertElementArray(l1, 
465
            new String[]{"script", "label", "target", "target", "property", "property"}, 
466
            new String[]{"script", "label", "target", "target", "property", "property"}, 
Lines 482-506 Link Here
482
        FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
483
        FreeformProjectGenerator.putCustomContextMenuActions(helper, customActions);
483
//        ProjectManager.getDefault().saveAllProjects();
484
//        ProjectManager.getDefault().saveAllProjects();
484
        el = Util.getPrimaryConfigurationData(helper);
485
        el = Util.getPrimaryConfigurationData(helper);
485
        el = Util.findElement(el, "view", FreeformProjectType.NS_GENERAL);
486
        el = XMLUtil.findElement(el, "view", FreeformProjectType.NS_GENERAL);
486
        assertNotNull("Target mapping were not saved correctly",  el);
487
        assertNotNull("Target mapping were not saved correctly",  el);
487
        el = Util.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
488
        el = XMLUtil.findElement(el, "context-menu", FreeformProjectType.NS_GENERAL);
488
        assertNotNull("Target mapping were not saved correctly",  el);
489
        assertNotNull("Target mapping were not saved correctly",  el);
489
        subElements = Util.findSubElements(el);
490
        subElements = XMLUtil.findSubElements(el);
490
        assertEquals(2, subElements.size());
491
        assertEquals(2, subElements.size());
491
        assertElementArray(subElements, 
492
        assertElementArray(subElements, 
492
            new String[]{"action", "action"}, 
493
            new String[]{"action", "action"}, 
493
            new String[]{null, null});
494
            new String[]{null, null});
494
        // compare first custom action
495
        // compare first custom action
495
        el2 = subElements.get(0);
496
        el2 = subElements.get(0);
496
        l1 = Util.findSubElements(el2);
497
        l1 = XMLUtil.findSubElements(el2);
497
        assertEquals(1, l1.size());
498
        assertEquals(1, l1.size());
498
        assertElementArray(l1, 
499
        assertElementArray(l1, 
499
            new String[]{"label"}, 
500
            new String[]{"label"}, 
500
            new String[]{"fooLabel"});
501
            new String[]{"fooLabel"});
501
        // compare second custom action
502
        // compare second custom action
502
        el2 = subElements.get(1);
503
        el2 = subElements.get(1);
503
        l1 = Util.findSubElements(el2);
504
        l1 = XMLUtil.findSubElements(el2);
504
        assertEquals(1, l1.size());
505
        assertEquals(1, l1.size());
505
        assertElementArray(l1, 
506
        assertElementArray(l1, 
506
            new String[]{"label"}, 
507
            new String[]{"label"}, 
Lines 518-524 Link Here
518
        String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
519
        String message = "Element "+element+" does not match [name="+expectedName+",value="+expectedValue+"]"; // NOI18N
519
        assertEquals(message, expectedName, element.getLocalName());
520
        assertEquals(message, expectedName, element.getLocalName());
520
        if (expectedValue != null) {
521
        if (expectedValue != null) {
521
            assertEquals(message, expectedValue, Util.findText(element));
522
            assertEquals(message, expectedValue, XMLUtil.findText(element));
522
        }
523
        }
523
    }
524
    }
524
525
Lines 546-552 Link Here
546
            expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
547
            expectedValue+", attr="+expectedAttrName+", attrvalue="+expectedAttrValue+"]"; // NOI18N
547
        assertEquals(message, expectedName, element.getLocalName());
548
        assertEquals(message, expectedName, element.getLocalName());
548
        if (expectedValue != null) {
549
        if (expectedValue != null) {
549
            assertEquals(message, expectedValue, Util.findText(element));
550
            assertEquals(message, expectedValue, XMLUtil.findText(element));
550
        }
551
        }
551
        String val = element.getAttribute(expectedAttrName);
552
        String val = element.getAttribute(expectedAttrName);
552
        assertEquals(expectedAttrValue, val);
553
        assertEquals(expectedAttrValue, val);
(-)a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/FreeformSourcesTest.java (-4 / +5 lines)
Lines 58-63 Link Here
58
import org.netbeans.spi.project.support.ant.EditableProperties;
58
import org.netbeans.spi.project.support.ant.EditableProperties;
59
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.xml.XMLUtil;
61
import org.w3c.dom.Document;
62
import org.w3c.dom.Document;
62
import org.w3c.dom.Element;
63
import org.w3c.dom.Element;
63
import org.w3c.dom.NodeList;
64
import org.w3c.dom.NodeList;
Lines 110-121 Link Here
110
        TestCL l = new TestCL();
111
        TestCL l = new TestCL();
111
        s.addChangeListener(l);
112
        s.addChangeListener(l);
112
        Element data = extsrcroot.getPrimaryConfigurationData();
113
        Element data = extsrcroot.getPrimaryConfigurationData();
113
        Element folders = Util.findElement(data, "folders", FreeformProjectType.NS_GENERAL);
114
        Element folders = XMLUtil.findElement(data, "folders", FreeformProjectType.NS_GENERAL);
114
        assertNotNull("have <folders>", folders);
115
        assertNotNull("have <folders>", folders);
115
        List/*<Element>*/ sourceFolders = Util.findSubElements(folders);
116
        List<Element> sourceFolders = XMLUtil.findSubElements(folders);
116
        assertEquals("have 2 <source-folder>s", 2, sourceFolders.size());
117
        assertEquals("have 2 <source-folder>s", 2, sourceFolders.size());
117
        Element sourceFolder = (Element) sourceFolders.get(1);
118
        Element sourceFolder = (Element) sourceFolders.get(1);
118
        Element location = Util.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
119
        Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
119
        assertNotNull("have <location>", location);
120
        assertNotNull("have <location>", location);
120
        NodeList nl = location.getChildNodes();
121
        NodeList nl = location.getChildNodes();
121
        assertEquals("one child (text)", 1, nl.getLength());
122
        assertEquals("one child (text)", 1, nl.getLength());
Lines 146-152 Link Here
146
        FileUtil.createData(new File(d, "s/ignored/file"));
147
        FileUtil.createData(new File(d, "s/ignored/file"));
147
        Element data = Util.getPrimaryConfigurationData(helper);
148
        Element data = Util.getPrimaryConfigurationData(helper);
148
        Document doc = data.getOwnerDocument();
149
        Document doc = data.getOwnerDocument();
149
        Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), Util.findElement(data, "view", Util.NAMESPACE)).
150
        Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE)).
150
                appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
151
                appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
151
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
152
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
152
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode("stuff"));
153
        sf.appendChild(doc.createElementNS(Util.NAMESPACE, "type")).appendChild(doc.createTextNode("stuff"));
(-)a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/UnboundTargetAlertTest.java (-3 / +4 lines)
Lines 52-57 Link Here
52
import org.netbeans.modules.ant.freeform.FreeformProjectType;
52
import org.netbeans.modules.ant.freeform.FreeformProjectType;
53
import org.netbeans.modules.ant.freeform.TestBase;
53
import org.netbeans.modules.ant.freeform.TestBase;
54
import org.netbeans.modules.ant.freeform.spi.support.Util;
54
import org.netbeans.modules.ant.freeform.spi.support.Util;
55
import org.openide.xml.XMLUtil;
55
import org.w3c.dom.Element;
56
import org.w3c.dom.Element;
56
57
57
/**
58
/**
Lines 98-109 Link Here
98
        assertEquals(null, lastMapping.context);
99
        assertEquals(null, lastMapping.context);
99
        // Also check the context menu.
100
        // Also check the context menu.
100
        Element data = prj.getPrimaryConfigurationData();
101
        Element data = prj.getPrimaryConfigurationData();
101
        Element view = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
102
        Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
102
        assertNotNull(view);
103
        assertNotNull(view);
103
        Element contextMenu = Util.findElement(view, "context-menu", FreeformProjectType.NS_GENERAL);
104
        Element contextMenu = XMLUtil.findElement(view, "context-menu", FreeformProjectType.NS_GENERAL);
104
        assertNotNull(contextMenu);
105
        assertNotNull(contextMenu);
105
        Set<String> actionNames = new TreeSet<String>();
106
        Set<String> actionNames = new TreeSet<String>();
106
        for (Element action : Util.findSubElements(contextMenu)) {
107
        for (Element action : XMLUtil.findSubElements(contextMenu)) {
107
            if (action.getLocalName().equals("ide-action")) {
108
            if (action.getLocalName().equals("ide-action")) {
108
                actionNames.add(action.getAttribute("name"));
109
                actionNames.add(action.getAttribute("name"));
109
            }
110
            }
(-)a/ant.freeform/test/unit/src/org/netbeans/modules/ant/freeform/ui/ViewTest.java (-5 / +6 lines)
Lines 70-75 Link Here
70
import org.openide.nodes.NodeReorderEvent;
70
import org.openide.nodes.NodeReorderEvent;
71
import org.w3c.dom.Document;
71
import org.w3c.dom.Document;
72
import org.openide.util.Lookup;
72
import org.openide.util.Lookup;
73
import org.openide.xml.XMLUtil;
73
import org.w3c.dom.Element;
74
import org.w3c.dom.Element;
74
import org.w3c.dom.NodeList;
75
import org.w3c.dom.NodeList;
75
76
Lines 120-138 Link Here
120
        TestNL l = new TestNL();
121
        TestNL l = new TestNL();
121
        root.addNodeListener(l);
122
        root.addNodeListener(l);
122
        Element data = extsrcroot.getPrimaryConfigurationData();
123
        Element data = extsrcroot.getPrimaryConfigurationData();
123
        Element view = Util.findElement(data, "view", FreeformProjectType.NS_GENERAL);
124
        Element view = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL);
124
        assertNotNull("have <view>", view);
125
        assertNotNull("have <view>", view);
125
        Element items = Util.findElement(view, "items", FreeformProjectType.NS_GENERAL);
126
        Element items = XMLUtil.findElement(view, "items", FreeformProjectType.NS_GENERAL);
126
        assertNotNull("have <items>", items);
127
        assertNotNull("have <items>", items);
127
        Element sourceFolder = Util.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
128
        Element sourceFolder = XMLUtil.findElement(items, "source-folder", FreeformProjectType.NS_GENERAL);
128
        assertNotNull("have <source-folder>", sourceFolder);
129
        assertNotNull("have <source-folder>", sourceFolder);
129
        Element location = Util.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
130
        Element location = XMLUtil.findElement(sourceFolder, "location", FreeformProjectType.NS_GENERAL);
130
        assertNotNull("have <location>", location);
131
        assertNotNull("have <location>", location);
131
        NodeList nl = location.getChildNodes();
132
        NodeList nl = location.getChildNodes();
132
        assertEquals("one child", 1, nl.getLength());
133
        assertEquals("one child", 1, nl.getLength());
133
        location.removeChild(nl.item(0));
134
        location.removeChild(nl.item(0));
134
        location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
135
        location.appendChild(location.getOwnerDocument().createTextNode("../src2"));
135
        Element sourceFile =  Util.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
136
        Element sourceFile =  XMLUtil.findElement(items, "source-file", FreeformProjectType.NS_GENERAL);
136
        assertNotNull("have <source-file>", sourceFile);
137
        assertNotNull("have <source-file>", sourceFile);
137
        items.removeChild(sourceFile);
138
        items.removeChild(sourceFile);
138
        extsrcroot.putPrimaryConfigurationData(data);
139
        extsrcroot.putPrimaryConfigurationData(data);
(-)a/apisupport.project/nbproject/project.xml (-1 / +1 lines)
Lines 370-376 Link Here
370
                    <build-prerequisite/>
370
                    <build-prerequisite/>
371
                    <compile-dependency/>
371
                    <compile-dependency/>
372
                    <run-dependency>
372
                    <run-dependency>
373
                        <specification-version>8.0</specification-version>
373
                        <specification-version>8.3</specification-version>
374
                    </run-dependency>
374
                    </run-dependency>
375
                </dependency>
375
                </dependency>
376
                <dependency>
376
                <dependency>
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java (-5 / +6 lines)
Lines 87-92 Link Here
87
import org.openide.util.RequestProcessor;
87
import org.openide.util.RequestProcessor;
88
import org.openide.util.Utilities;
88
import org.openide.util.Utilities;
89
import org.openide.util.WeakListeners;
89
import org.openide.util.WeakListeners;
90
import org.openide.xml.XMLUtil;
90
import org.w3c.dom.Element;
91
import org.w3c.dom.Element;
91
92
92
/**
93
/**
Lines 603-620 Link Here
603
     */
604
     */
604
    private String computeModuleClasspath(ModuleList ml) {
605
    private String computeModuleClasspath(ModuleList ml) {
605
        Element data = project.getPrimaryConfigurationData();
606
        Element data = project.getPrimaryConfigurationData();
606
        Element moduleDependencies = Util.findElement(data,
607
        Element moduleDependencies = XMLUtil.findElement(data,
607
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
608
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
608
        assert moduleDependencies != null : "Malformed metadata in " + project;
609
        assert moduleDependencies != null : "Malformed metadata in " + project;
609
        StringBuffer cp = new StringBuffer();
610
        StringBuffer cp = new StringBuffer();
610
        for (Element dep : Util.findSubElements(moduleDependencies)) {
611
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
611
            if (Util.findElement(dep, "compile-dependency", // NOI18N
612
            if (XMLUtil.findElement(dep, "compile-dependency", // NOI18N
612
                    NbModuleProject.NAMESPACE_SHARED) == null) {
613
                    NbModuleProject.NAMESPACE_SHARED) == null) {
613
                continue;
614
                continue;
614
            }
615
            }
615
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
616
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
616
                NbModuleProject.NAMESPACE_SHARED);
617
                NbModuleProject.NAMESPACE_SHARED);
617
            String cnb = Util.findText(cnbEl);
618
            String cnb = XMLUtil.findText(cnbEl);
618
            ModuleEntry module = ml.getEntry(cnb);
619
            ModuleEntry module = ml.getEntry(cnb);
619
            if (module == null) {
620
            if (module == null) {
620
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
621
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + FileUtil.getFileDisplayName(project.getProjectDirectory()));
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java (-14 / +15 lines)
Lines 131-136 Link Here
131
import org.openide.util.Exceptions;
131
import org.openide.util.Exceptions;
132
import org.openide.util.lookup.AbstractLookup;
132
import org.openide.util.lookup.AbstractLookup;
133
import org.openide.util.lookup.InstanceContent;
133
import org.openide.util.lookup.InstanceContent;
134
import org.openide.xml.XMLUtil;
134
135
135
/**
136
/**
136
 * A NetBeans module project.
137
 * A NetBeans module project.
Lines 221-228 Link Here
221
                    .displayName(NbBundle.getMessage(NbModuleProject.class, "LBL_javahelp_packages")).add();
222
                    .displayName(NbBundle.getMessage(NbModuleProject.class, "LBL_javahelp_packages")).add();
222
        }
223
        }
223
        for (Map.Entry<FileObject,Element> entry : getExtraCompilationUnits().entrySet()) {
224
        for (Map.Entry<FileObject,Element> entry : getExtraCompilationUnits().entrySet()) {
224
            Element pkgrootEl = Util.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
225
            Element pkgrootEl = XMLUtil.findElement(entry.getValue(), "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
225
            String pkgrootS = Util.findText(pkgrootEl);
226
            String pkgrootS = XMLUtil.findText(pkgrootEl);
226
            sourcesHelper.sourceRoot(pkgrootS).type(JavaProjectConstants.SOURCES_TYPE_JAVA)
227
            sourcesHelper.sourceRoot(pkgrootS).type(JavaProjectConstants.SOURCES_TYPE_JAVA)
227
                    .displayName(/* XXX should schema incl. display name? */entry.getKey().getNameExt()).add();
228
                    .displayName(/* XXX should schema incl. display name? */entry.getKey().getNameExt()).add();
228
        }
229
        }
Lines 340-346 Link Here
340
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
341
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
341
                Element data = ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true);
342
                Element data = ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true);
342
                if (data != null) {
343
                if (data != null) {
343
                    return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
344
                    return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
344
                } else {
345
                } else {
345
                    return helper.getPrimaryConfigurationData(true);
346
                    return helper.getPrimaryConfigurationData(true);
346
                }
347
                }
Lines 357-363 Link Here
357
            public Void run() {
358
            public Void run() {
358
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
359
                AuxiliaryConfiguration ac = helper.createAuxiliaryConfiguration();
359
                if (ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true) != null) {
360
                if (ac.getConfigurationFragment(NbModuleProject.NAME_SHARED, NbModuleProject.NAMESPACE_SHARED_2, true) != null) {
360
                    ac.putConfigurationFragment(Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
361
                    ac.putConfigurationFragment(XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED_2), true);
361
                } else {
362
                } else {
362
                    helper.putPrimaryConfigurationData(data, true);
363
                    helper.putPrimaryConfigurationData(data, true);
363
                }
364
                }
Lines 373-381 Link Here
373
374
374
    private NbModuleProvider.NbModuleType getModuleType() {
375
    private NbModuleProvider.NbModuleType getModuleType() {
375
        Element data = getPrimaryConfigurationData();
376
        Element data = getPrimaryConfigurationData();
376
        if (Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
377
        if (XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
377
            return NbModuleProvider.SUITE_COMPONENT;
378
            return NbModuleProvider.SUITE_COMPONENT;
378
        } else if (Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
379
        } else if (XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null) { // NOI18N
379
            return NbModuleProvider.STANDALONE;
380
            return NbModuleProvider.STANDALONE;
380
        } else {
381
        } else {
381
            return NbModuleProvider.NETBEANS_ORG;
382
            return NbModuleProvider.NETBEANS_ORG;
Lines 471-479 Link Here
471
472
472
    public String getCodeNameBase() {
473
    public String getCodeNameBase() {
473
        Element config = getPrimaryConfigurationData();
474
        Element config = getPrimaryConfigurationData();
474
        Element cnb = Util.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
475
        Element cnb = XMLUtil.findElement(config, "code-name-base", NbModuleProject.NAMESPACE_SHARED); // NOI18N
475
        if (cnb != null) {
476
        if (cnb != null) {
476
            return Util.findText(cnb);
477
            return XMLUtil.findText(cnb);
477
        } else {
478
        } else {
478
            return null;
479
            return null;
479
        }
480
        }
Lines 623-634 Link Here
623
            return true;
624
            return true;
624
        }
625
        }
625
        Element config = getPrimaryConfigurationData();
626
        Element config = getPrimaryConfigurationData();
626
        Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
627
        Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
627
        if (pubPkgs == null) {
628
        if (pubPkgs == null) {
628
            // Try <friend-packages> too.
629
            // Try <friend-packages> too.
629
            pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
630
            pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
630
        }
631
        }
631
        return pubPkgs != null && !Util.findSubElements(pubPkgs).isEmpty();
632
        return pubPkgs != null && !XMLUtil.findSubElements(pubPkgs).isEmpty();
632
    }
633
    }
633
    
634
    
634
    public List<String> supportedTestTypes() {
635
    public List<String> supportedTestTypes() {
Lines 655-664 Link Here
655
    public Map<FileObject,Element> getExtraCompilationUnits() {
656
    public Map<FileObject,Element> getExtraCompilationUnits() {
656
        if (extraCompilationUnits == null) {
657
        if (extraCompilationUnits == null) {
657
            extraCompilationUnits = new HashMap<FileObject,Element>();
658
            extraCompilationUnits = new HashMap<FileObject,Element>();
658
            for (Element ecu : Util.findSubElements(getPrimaryConfigurationData())) {
659
            for (Element ecu : XMLUtil.findSubElements(getPrimaryConfigurationData())) {
659
                if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
660
                if (ecu.getLocalName().equals("extra-compilation-unit")) { // NOI18N
660
                    Element pkgrootEl = Util.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
661
                    Element pkgrootEl = XMLUtil.findElement(ecu, "package-root", NbModuleProject.NAMESPACE_SHARED); // NOI18N
661
                    String pkgrootS = Util.findText(pkgrootEl);
662
                    String pkgrootS = XMLUtil.findText(pkgrootEl);
662
                    String pkgrootEval = evaluator().evaluate(pkgrootS);
663
                    String pkgrootEval = evaluator().evaluate(pkgrootS);
663
                    FileObject pkgroot = getHelper().resolveFileObject(pkgrootEval);
664
                    FileObject pkgroot = getHelper().resolveFileObject(pkgrootEval);
664
                    if (pkgroot == null) {
665
                    if (pkgroot == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ProjectXMLManager.java (-30 / +30 lines)
Lines 218-226 Link Here
218
        } else {
218
        } else {
219
            ml = ModuleList.getModuleList(prjDirF);
219
            ml = ModuleList.getModuleList(prjDirF);
220
        }
220
        }
221
        for (Element depEl : Util.findSubElements(moduleDependencies)) {
221
        for (Element depEl : XMLUtil.findSubElements(moduleDependencies)) {
222
            Element cnbEl = findElement(depEl, ProjectXMLManager.CODE_NAME_BASE);
222
            Element cnbEl = findElement(depEl, ProjectXMLManager.CODE_NAME_BASE);
223
            String _cnb = Util.findText(cnbEl);
223
            String _cnb = XMLUtil.findText(cnbEl);
224
            ModuleDependency depToAdd = getModuleDependency(_cnb, ml, depEl);
224
            ModuleDependency depToAdd = getModuleDependency(_cnb, ml, depEl);
225
            if (depToAdd == null) {
225
            if (depToAdd == null) {
226
                continue;
226
                continue;
Lines 255-267 Link Here
255
        Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
255
        Element relVerEl = findElement(runDepEl, ProjectXMLManager.RELEASE_VERSION);
256
        String relVer = null;
256
        String relVer = null;
257
        if (relVerEl != null) {
257
        if (relVerEl != null) {
258
            relVer = Util.findText(relVerEl);
258
            relVer = XMLUtil.findText(relVerEl);
259
        }
259
        }
260
260
261
        Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
261
        Element specVerEl = findElement(runDepEl, ProjectXMLManager.SPECIFICATION_VERSION);
262
        String specVer = null;
262
        String specVer = null;
263
        if (specVerEl != null) {
263
        if (specVerEl != null) {
264
            specVer = Util.findText(specVerEl);
264
            specVer = XMLUtil.findText(specVerEl);
265
        }
265
        }
266
266
267
        Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
267
        Element compDepEl = findElement(depEl, ProjectXMLManager.COMPILE_DEPENDENCY);
Lines 287-295 Link Here
287
        } else {
287
        } else {
288
            ml = ModuleList.getModuleList(prjDirF);
288
            ml = ModuleList.getModuleList(prjDirF);
289
        }
289
        }
290
        for (Element dep : Util.findSubElements(moduleDependencies)) {
290
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
291
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
291
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
292
            String depCnb = Util.findText(cnbEl);
292
            String depCnb = XMLUtil.findText(cnbEl);
293
            if (depCnb.equals(cnb)) {
293
            if (depCnb.equals(cnb)) {
294
                return getModuleDependency(cnb, ml, dep);
294
                return getModuleDependency(cnb, ml, dep);
295
            }
295
            }
Lines 301-309 Link Here
301
    public void removeDependency(String cnbToRemove) {
301
    public void removeDependency(String cnbToRemove) {
302
        Element _confData = getConfData();
302
        Element _confData = getConfData();
303
        Element moduleDependencies = findModuleDependencies(_confData);
303
        Element moduleDependencies = findModuleDependencies(_confData);
304
        for (Element dep : Util.findSubElements(moduleDependencies)) {
304
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
305
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
305
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
306
            String _cnb = Util.findText(cnbEl);
306
            String _cnb = XMLUtil.findText(cnbEl);
307
            if (cnbToRemove.equals(_cnb)) {
307
            if (cnbToRemove.equals(_cnb)) {
308
                moduleDependencies.removeChild(dep);
308
                moduleDependencies.removeChild(dep);
309
            }
309
            }
Lines 330-338 Link Here
330
    public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
330
    public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
331
        Element _confData = getConfData();
331
        Element _confData = getConfData();
332
        Element moduleDependencies = findModuleDependencies(_confData);
332
        Element moduleDependencies = findModuleDependencies(_confData);
333
        for (Element dep : Util.findSubElements(moduleDependencies)) {
333
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
334
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
334
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
335
            String _cnb = Util.findText(cnbEl);
335
            String _cnb = XMLUtil.findText(cnbEl);
336
            if (cnbsToDelete.remove(_cnb)) {
336
            if (cnbsToDelete.remove(_cnb)) {
337
                moduleDependencies.removeChild(dep);
337
                moduleDependencies.removeChild(dep);
338
            }
338
            }
Lines 350-360 Link Here
350
    public void editDependency(ModuleDependency origDep, ModuleDependency newDep) {
350
    public void editDependency(ModuleDependency origDep, ModuleDependency newDep) {
351
        Element _confData = getConfData();
351
        Element _confData = getConfData();
352
        Element moduleDependencies = findModuleDependencies(_confData);
352
        Element moduleDependencies = findModuleDependencies(_confData);
353
        List<Element> currentDeps = Util.findSubElements(moduleDependencies);
353
        List<Element> currentDeps = XMLUtil.findSubElements(moduleDependencies);
354
        for (Iterator<Element> it = currentDeps.iterator(); it.hasNext();) {
354
        for (Iterator<Element> it = currentDeps.iterator(); it.hasNext();) {
355
            Element dep = it.next();
355
            Element dep = it.next();
356
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
356
            Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
357
            String _cnb = Util.findText(cnbEl);
357
            String _cnb = XMLUtil.findText(cnbEl);
358
            if (_cnb.equals(origDep.getModuleEntry().getCodeNameBase())) {
358
            if (_cnb.equals(origDep.getModuleEntry().getCodeNameBase())) {
359
                moduleDependencies.removeChild(dep);
359
                moduleDependencies.removeChild(dep);
360
                Element nextDep = it.hasNext() ? it.next() : null;
360
                Element nextDep = it.hasNext() ? it.next() : null;
Lines 474-494 Link Here
474
        Element _confData = getConfData();
474
        Element _confData = getConfData();
475
        Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
475
        Element testModuleDependenciesEl = findTestDependenciesElement(_confData);
476
        Element testTypeRemoveEl = null;
476
        Element testTypeRemoveEl = null;
477
        for (Element type : Util.findSubElements(testModuleDependenciesEl)) {
477
        for (Element type : XMLUtil.findSubElements(testModuleDependenciesEl)) {
478
            Element nameEl = findElement(type, TEST_TYPE_NAME);
478
            Element nameEl = findElement(type, TEST_TYPE_NAME);
479
            String nameOfType = Util.findText(nameEl);
479
            String nameOfType = XMLUtil.findText(nameEl);
480
            if (testType.equals(nameOfType)) {
480
            if (testType.equals(nameOfType)) {
481
                testTypeRemoveEl = type;
481
                testTypeRemoveEl = type;
482
            }
482
            }
483
        }
483
        }
484
        //found such a test type
484
        //found such a test type
485
        if (testTypeRemoveEl != null) {
485
        if (testTypeRemoveEl != null) {
486
            for (Element el : Util.findSubElements(testTypeRemoveEl)) {
486
            for (Element el : XMLUtil.findSubElements(testTypeRemoveEl)) {
487
                Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
487
                Element cnbEl = findElement(el, TEST_DEPENDENCY_CNB);
488
                if (cnbEl == null) {
488
                if (cnbEl == null) {
489
                    continue;   //name node, continue
489
                    continue;   //name node, continue
490
                }
490
                }
491
                String _cnb = Util.findText(cnbEl);
491
                String _cnb = XMLUtil.findText(cnbEl);
492
                if (cnbToRemove.equals(_cnb)) {
492
                if (cnbToRemove.equals(_cnb)) {
493
                    // found test dependency with desired CNB
493
                    // found test dependency with desired CNB
494
                    testTypeRemoveEl.removeChild(el);
494
                    testTypeRemoveEl.removeChild(el);
Lines 542-548 Link Here
542
                }
542
                }
543
                Element testTypeEl = null;
543
                Element testTypeEl = null;
544
                //iterate through test types to determine if testType exist
544
                //iterate through test types to determine if testType exist
545
                for (Element tt : Util.findSubElements(testModuleDependenciesEl)) {
545
                for (Element tt : XMLUtil.findSubElements(testModuleDependenciesEl)) {
546
                    Node nameNode = findElement(tt, "name"); // NOI18N
546
                    Node nameNode = findElement(tt, "name"); // NOI18N
547
                    assert nameNode != null : "should be some child with name";
547
                    assert nameNode != null : "should be some child with name";
548
                    //Node nameNode = tt.getFirstChild();
548
                    //Node nameNode = tt.getFirstChild();
Lines 638-661 Link Here
638
        Map<String, Set<TestModuleDependency>> testDeps = new HashMap<String, Set<TestModuleDependency>>();
638
        Map<String, Set<TestModuleDependency>> testDeps = new HashMap<String, Set<TestModuleDependency>>();
639
639
640
        if (testDepsEl != null) {
640
        if (testDepsEl != null) {
641
            for (Element typeEl : Util.findSubElements(testDepsEl)) {
641
            for (Element typeEl : XMLUtil.findSubElements(testDepsEl)) {
642
                Element testTypeEl = findElement(typeEl, TEST_TYPE_NAME);
642
                Element testTypeEl = findElement(typeEl, TEST_TYPE_NAME);
643
                String testType = null;
643
                String testType = null;
644
                if (testTypeEl != null) {
644
                if (testTypeEl != null) {
645
                    testType = Util.findText(testTypeEl);
645
                    testType = XMLUtil.findText(testTypeEl);
646
                }
646
                }
647
                if (testType == null) {
647
                if (testType == null) {
648
                    testType = TestModuleDependency.UNIT; // default variant
648
                    testType = TestModuleDependency.UNIT; // default variant
649
                }
649
                }
650
                Set<TestModuleDependency> directTestDeps = new TreeSet<TestModuleDependency>();
650
                Set<TestModuleDependency> directTestDeps = new TreeSet<TestModuleDependency>();
651
                for (Element depEl : Util.findSubElements(typeEl)) {
651
                for (Element depEl : XMLUtil.findSubElements(typeEl)) {
652
                    if (depEl.getTagName().equals(TEST_DEPENDENCY)) {
652
                    if (depEl.getTagName().equals(TEST_DEPENDENCY)) {
653
                        // parse test dep
653
                        // parse test dep
654
                        Element cnbEl = findElement(depEl, TEST_DEPENDENCY_CNB);
654
                        Element cnbEl = findElement(depEl, TEST_DEPENDENCY_CNB);
655
                        boolean test = findElement(depEl, TEST_DEPENDENCY_TEST) != null;
655
                        boolean test = findElement(depEl, TEST_DEPENDENCY_TEST) != null;
656
                        String _cnb = null;
656
                        String _cnb = null;
657
                        if (cnbEl != null) {
657
                        if (cnbEl != null) {
658
                            _cnb = Util.findText(cnbEl);
658
                            _cnb = XMLUtil.findText(cnbEl);
659
                        }
659
                        }
660
                        boolean recursive = findElement(depEl, TEST_DEPENDENCY_RECURSIVE) != null;
660
                        boolean recursive = findElement(depEl, TEST_DEPENDENCY_RECURSIVE) != null;
661
                        boolean compile = findElement(depEl, TEST_DEPENDENCY_COMPILE) != null;
661
                        boolean compile = findElement(depEl, TEST_DEPENDENCY_COMPILE) != null;
Lines 806-817 Link Here
806
            return Collections.unmodifiableMap(cpExtensions);
806
            return Collections.unmodifiableMap(cpExtensions);
807
        }
807
        }
808
        Map<String, String> cps = new HashMap<String, String>();
808
        Map<String, String> cps = new HashMap<String, String>();
809
        for (Element cpExtEl : Util.findSubElements(getConfData())) {
809
        for (Element cpExtEl : XMLUtil.findSubElements(getConfData())) {
810
            if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
810
            if (CLASS_PATH_EXTENSION.equals(cpExtEl.getTagName())) {
811
                Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
811
                Element binOrigEl = findElement(cpExtEl, BINARY_ORIGIN);
812
                Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
812
                Element runtimePathEl = findElement(cpExtEl, CLASS_PATH_RUNTIME_PATH);
813
                if (binOrigEl != null && runtimePathEl != null) {
813
                if (binOrigEl != null && runtimePathEl != null) {
814
                    cps.put(Util.findText(runtimePathEl), Util.findText(binOrigEl));
814
                    cps.put(XMLUtil.findText(runtimePathEl), XMLUtil.findText(binOrigEl));
815
                }
815
                }
816
            }
816
            }
817
        }
817
        }
Lines 822-828 Link Here
822
    public String getCodeNameBase() {
822
    public String getCodeNameBase() {
823
        if (cnb == null) {
823
        if (cnb == null) {
824
            Element cnbEl = findElement(getConfData(), ProjectXMLManager.CODE_NAME_BASE);
824
            Element cnbEl = findElement(getConfData(), ProjectXMLManager.CODE_NAME_BASE);
825
            cnb = Util.findText(cnbEl);
825
            cnb = XMLUtil.findText(cnbEl);
826
        }
826
        }
827
        return cnb;
827
        return cnb;
828
    }
828
    }
Lines 875-881 Link Here
875
    }
875
    }
876
876
877
    private static Element findElement(Element parentEl, String elementName) {
877
    private static Element findElement(Element parentEl, String elementName) {
878
        return Util.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
878
        return XMLUtil.findElement(parentEl, elementName, NbModuleProject.NAMESPACE_SHARED);
879
    }
879
    }
880
880
881
    /** Package-private for unit tests only. */
881
    /** Package-private for unit tests only. */
Lines 922-932 Link Here
922
     */
922
     */
923
    private static Set<ManifestManager.PackageExport> findAllPackages(Element parent) {
923
    private static Set<ManifestManager.PackageExport> findAllPackages(Element parent) {
924
        Set<ManifestManager.PackageExport> packages = new HashSet<ManifestManager.PackageExport>();
924
        Set<ManifestManager.PackageExport> packages = new HashSet<ManifestManager.PackageExport>();
925
        for (Element pkgEl : Util.findSubElements(parent)) {
925
        for (Element pkgEl : XMLUtil.findSubElements(parent)) {
926
            if (PACKAGE.equals(pkgEl.getTagName())) {
926
            if (PACKAGE.equals(pkgEl.getTagName())) {
927
                packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), false));
927
                packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), false));
928
            } else if (SUBPACKAGES.equals(pkgEl.getTagName())) {
928
            } else if (SUBPACKAGES.equals(pkgEl.getTagName())) {
929
                packages.add(new ManifestManager.PackageExport(Util.findText(pkgEl), true));
929
                packages.add(new ManifestManager.PackageExport(XMLUtil.findText(pkgEl), true));
930
            }
930
            }
931
        }
931
        }
932
        return packages;
932
        return packages;
Lines 958-966 Link Here
958
        Element friendsEl = findFriendsElement(confData);
958
        Element friendsEl = findFriendsElement(confData);
959
        if (friendsEl != null) {
959
        if (friendsEl != null) {
960
            Set<String> friends = new TreeSet<String>();
960
            Set<String> friends = new TreeSet<String>();
961
            for (Element friendEl : Util.findSubElements(friendsEl)) {
961
            for (Element friendEl : XMLUtil.findSubElements(friendsEl)) {
962
                if (FRIEND.equals(friendEl.getTagName())) {
962
                if (FRIEND.equals(friendEl.getTagName())) {
963
                    friends.add(Util.findText(friendEl));
963
                    friends.add(XMLUtil.findText(friendEl));
964
                }
964
                }
965
            }
965
            }
966
            return friends.toArray(new String[friends.size()]);
966
            return friends.toArray(new String[friends.size()]);
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/Util.java (-98 / +1 lines)
Lines 125-230 Link Here
125
    private static final String SFS_VALID_PATH_RE = "(\\p{Alnum}|\\/|_)+"; // NOI18N
125
    private static final String SFS_VALID_PATH_RE = "(\\p{Alnum}|\\/|_)+"; // NOI18N
126
    
126
    
127
    // COPIED FROM org.netbeans.modules.project.ant:
127
    // COPIED FROM org.netbeans.modules.project.ant:
128
    // (except for namespace == null support in findElement)
128
    // (**EXCEPT** except for namespace == null support in findElement)
129
    // (and support for comments in findSubElements)
129
    // (and support for comments in findSubElements)
130
    
130
    
131
    /**
132
     * Search for an XML element in the direct children of a parent.
133
     * DOM provides a similar method but it does a recursive search
134
     * which we do not want. It also gives a node list and we want
135
     * only one result.
136
     * @param parent a parent element
137
     * @param name the intended local name
138
     * @param namespace the intended namespace (or null)
139
     * @return the first child element with that name, or null if none
140
     */
141
    public static Element findElement(Element parent, String name, String namespace) {
142
        NodeList l = parent.getChildNodes();
143
        for (int i = 0; i < l.getLength(); i++) {
144
            if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
145
                Element el = (Element)l.item(i);
146
                if ((namespace == null && name.equals(el.getTagName())) ||
147
                        (namespace != null && name.equals(el.getLocalName()) &&
148
                        namespace.equals(el.getNamespaceURI()))) {
149
                    return el;
150
                }
151
            }
152
        }
153
        return null;
154
    }
155
    
156
    /**
157
     * Extract nested text from an element.
158
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
159
     * @param parent a parent element
160
     * @return the nested text, or null if none was found
161
     */
162
    public static String findText(Element parent) {
163
        NodeList l = parent.getChildNodes();
164
        for (int i = 0; i < l.getLength(); i++) {
165
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
166
                Text text = (Text)l.item(i);
167
                return text.getNodeValue();
168
            }
169
        }
170
        return null;
171
    }
172
    
173
    /**
174
     * Find all direct child elements of an element.
175
     * More useful than {@link Element#getElementsByTagNameNS} because it does
176
     * not recurse into recursive child elements.
177
     * Children which are all-whitespace text nodes or comments are ignored; others cause
178
     * an exception to be thrown.
179
     * @param parent a parent element in a DOM tree
180
     * @return a list of direct child elements (may be empty)
181
     * @throws IllegalArgumentException if there are non-element children besides whitespace
182
     */
183
    public static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
184
        NodeList l = parent.getChildNodes();
185
        List<Element> elements = new ArrayList<Element>(l.getLength());
186
        for (int i = 0; i < l.getLength(); i++) {
187
            Node n = l.item(i);
188
            if (n.getNodeType() == Node.ELEMENT_NODE) {
189
                elements.add((Element)n);
190
            } else if (n.getNodeType() == Node.TEXT_NODE) {
191
                String text = ((Text)n).getNodeValue();
192
                if (text.trim().length() > 0) {
193
                    throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
194
                }
195
            } else if (n.getNodeType() == Node.COMMENT_NODE) {
196
                // OK, ignore
197
            } else {
198
                throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
199
            }
200
        }
201
        return elements;
202
    }
203
204
    /**
205
     * Convert an XML fragment from one namespace to another.
206
     */
207
    public static Element translateXML(Element from, String namespace) {
208
        Element to = from.getOwnerDocument().createElementNS(namespace, from.getLocalName());
209
        NodeList nl = from.getChildNodes();
210
        int length = nl.getLength();
211
        for (int i = 0; i < length; i++) {
212
            Node node = nl.item(i);
213
            Node newNode;
214
            if (node.getNodeType() == Node.ELEMENT_NODE) {
215
                newNode = translateXML((Element) node, namespace);
216
            } else {
217
                newNode = node.cloneNode(true);
218
            }
219
            to.appendChild(newNode);
220
        }
221
        NamedNodeMap m = from.getAttributes();
222
        for (int i = 0; i < m.getLength(); i++) {
223
            Node attr = m.item(i);
224
            to.setAttribute(attr.getNodeName(), attr.getNodeValue());
225
        }
226
        return to;
227
    }
228
131
229
    /**
132
    /**
230
     * Pass to {@link XPath#setNamespaceContext} to bind {@code nbm:} to the /3 namespace.
133
     * Pass to {@link XPath#setNamespaceContext} to bind {@code nbm:} to the /3 namespace.
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/AccessibilityQueryImpl.java (-4 / +5 lines)
Lines 48-53 Link Here
48
import org.openide.ErrorManager;
48
import org.openide.ErrorManager;
49
import org.openide.filesystems.FileObject;
49
import org.openide.filesystems.FileObject;
50
import org.openide.filesystems.FileUtil;
50
import org.openide.filesystems.FileUtil;
51
import org.openide.xml.XMLUtil;
51
import org.w3c.dom.Element;
52
import org.w3c.dom.Element;
52
53
53
/**
54
/**
Lines 69-85 Link Here
69
            if (path != null) {
70
            if (path != null) {
70
                String name = path.replace('/', '.');
71
                String name = path.replace('/', '.');
71
                Element config = project.getPrimaryConfigurationData();
72
                Element config = project.getPrimaryConfigurationData();
72
                Element pubPkgs = Util.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
73
                Element pubPkgs = XMLUtil.findElement(config, "public-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
73
                if (pubPkgs == null) {
74
                if (pubPkgs == null) {
74
                    // Try <friend-packages> too.
75
                    // Try <friend-packages> too.
75
                    pubPkgs = Util.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
76
                    pubPkgs = XMLUtil.findElement(config, "friend-packages", NbModuleProject.NAMESPACE_SHARED); // NOI18N
76
                }
77
                }
77
                if (pubPkgs != null) {
78
                if (pubPkgs != null) {
78
                    Iterator it = Util.findSubElements(pubPkgs).iterator();
79
                    Iterator it = XMLUtil.findSubElements(pubPkgs).iterator();
79
                    while (it.hasNext()) {
80
                    while (it.hasNext()) {
80
                        Element pubPkg = (Element) it.next();
81
                        Element pubPkg = (Element) it.next();
81
                        boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
82
                        boolean sub = "subpackages".equals(pubPkg.getLocalName()); // NOI18N
82
                        String pubPkgS = Util.findText(pubPkg);
83
                        String pubPkgS = XMLUtil.findText(pubPkg);
83
                        if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
84
                        if (name.equals(pubPkgS) || (sub && name.startsWith(pubPkgS + '.'))) {
84
                            return true;
85
                            return true;
85
                        }
86
                        }
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/ClassPathProviderImpl.java (-7 / +7 lines)
Lines 63-69 Link Here
63
import org.netbeans.spi.java.classpath.ClassPathProvider;
63
import org.netbeans.spi.java.classpath.ClassPathProvider;
64
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
64
import org.netbeans.spi.java.classpath.support.ClassPathSupport;
65
import org.netbeans.modules.apisupport.project.NbModuleProject;
65
import org.netbeans.modules.apisupport.project.NbModuleProject;
66
import org.netbeans.modules.apisupport.project.Util;
67
import org.netbeans.spi.java.classpath.PathResourceImplementation;
66
import org.netbeans.spi.java.classpath.PathResourceImplementation;
68
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
67
import org.netbeans.spi.java.project.classpath.support.ProjectClassPathSupport;
69
import org.netbeans.spi.project.support.ant.AntProjectEvent;
68
import org.netbeans.spi.project.support.ant.AntProjectEvent;
Lines 74-79 Link Here
74
import org.openide.filesystems.FileStateInvalidException;
73
import org.openide.filesystems.FileStateInvalidException;
75
import org.openide.filesystems.FileUtil;
74
import org.openide.filesystems.FileUtil;
76
import org.openide.util.WeakListeners;
75
import org.openide.util.WeakListeners;
76
import org.openide.xml.XMLUtil;
77
import org.w3c.dom.Element;
77
import org.w3c.dom.Element;
78
78
79
public final class ClassPathProviderImpl implements ClassPathProvider {
79
public final class ClassPathProviderImpl implements ClassPathProvider {
Lines 296-304 Link Here
296
        for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
296
        for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
297
            final FileObject pkgroot = entry.getKey();
297
            final FileObject pkgroot = entry.getKey();
298
            Element pkgrootEl = entry.getValue();
298
            Element pkgrootEl = entry.getValue();
299
            Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
299
            Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
300
            assert classpathEl != null : "no <classpath> in " + pkgrootEl;
300
            assert classpathEl != null : "no <classpath> in " + pkgrootEl;
301
            final String classpathS = Util.findText(classpathEl);
301
            final String classpathS = XMLUtil.findText(classpathEl);
302
            if (classpathS == null) {
302
            if (classpathS == null) {
303
                extraCompilationUnitsCompile.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
303
                extraCompilationUnitsCompile.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
304
                extraCompilationUnitsExecute.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
304
                extraCompilationUnitsExecute.put(pkgroot, ClassPathSupport.createClassPath(new URL[0]));
Lines 333-341 Link Here
333
                    }
333
                    }
334
                    public void configurationXmlChanged(AntProjectEvent ev) {
334
                    public void configurationXmlChanged(AntProjectEvent ev) {
335
                        Element pkgrootEl = project.getExtraCompilationUnits().get(pkgroot);
335
                        Element pkgrootEl = project.getExtraCompilationUnits().get(pkgroot);
336
                        Element classpathEl = Util.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
336
                        Element classpathEl = XMLUtil.findElement(pkgrootEl, "classpath", NbModuleProject.NAMESPACE_SHARED); // NOI18N
337
                        assert classpathEl != null : "no <classpath> in " + pkgrootEl;
337
                        assert classpathEl != null : "no <classpath> in " + pkgrootEl;
338
                        cpS = Util.findText(classpathEl);
338
                        cpS = XMLUtil.findText(classpathEl);
339
                        pcs.firePropertyChange(PROP_RESOURCES, null, null);
339
                        pcs.firePropertyChange(PROP_RESOURCES, null, null);
340
                    }
340
                    }
341
                    public void propertiesChanged(AntProjectEvent ev) {}
341
                    public void propertiesChanged(AntProjectEvent ev) {}
Lines 344-354 Link Here
344
                extraCompilationUnitsCompile.put(pkgroot, ClassPathFactory.createClassPath(ecuCompile));
344
                extraCompilationUnitsCompile.put(pkgroot, ClassPathFactory.createClassPath(ecuCompile));
345
                // Add <built-to> dirs and JARs for ClassPath.EXECUTE.
345
                // Add <built-to> dirs and JARs for ClassPath.EXECUTE.
346
                List<PathResourceImplementation> extraEntries = new ArrayList<PathResourceImplementation>();
346
                List<PathResourceImplementation> extraEntries = new ArrayList<PathResourceImplementation>();
347
                for (Element kid : Util.findSubElements(pkgrootEl)) {
347
                for (Element kid : XMLUtil.findSubElements(pkgrootEl)) {
348
                    if (!kid.getLocalName().equals("built-to")) { // NOI18N
348
                    if (!kid.getLocalName().equals("built-to")) { // NOI18N
349
                        continue;
349
                        continue;
350
                    }
350
                    }
351
                    String rawtext = Util.findText(kid);
351
                    String rawtext = XMLUtil.findText(kid);
352
                    assert rawtext != null : "Null content for <built-to> in " + project;
352
                    assert rawtext != null : "Null content for <built-to> in " + project;
353
                    String text = project.evaluator().evaluate(rawtext);
353
                    String text = project.evaluator().evaluate(rawtext);
354
                    if (text == null) {
354
                    if (text == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/GlobalSourceForBinaryImpl.java (-5 / +5 lines)
Lines 409-421 Link Here
409
                is.close();
409
                is.close();
410
            }
410
            }
411
            Element docel = doc.getDocumentElement();
411
            Element docel = doc.getDocumentElement();
412
            Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
412
            Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
413
            String cnb = null;
413
            String cnb = null;
414
            if (Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
414
            if (XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
415
                Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
415
                Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
416
                Element data = Util.findElement(cfg, "data", null); // NOI18N
416
                Element data = XMLUtil.findElement(cfg, "data", null); // NOI18N
417
                if (data != null) {
417
                if (data != null) {
418
                    cnb = Util.findText(Util.findElement(data, "code-name-base", null)); // NOI18N
418
                    cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", null)); // NOI18N
419
                }
419
                }
420
            }
420
            }
421
            return cnb;
421
            return cnb;
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SourceForBinaryImpl.java (-3 / +3 lines)
Lines 50-60 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.modules.apisupport.project.NbModuleProject;
52
import org.netbeans.modules.apisupport.project.NbModuleProject;
53
import org.netbeans.modules.apisupport.project.Util;
54
import org.netbeans.modules.apisupport.project.universe.TestEntry;
53
import org.netbeans.modules.apisupport.project.universe.TestEntry;
55
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
54
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
56
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.xml.XMLUtil;
58
import org.w3c.dom.Element;
58
import org.w3c.dom.Element;
59
59
60
/**
60
/**
Lines 136-146 Link Here
136
                if (res == null) {
136
                if (res == null) {
137
                // Check extra compilation units.
137
                // Check extra compilation units.
138
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
138
                ECUS: for (Map.Entry<FileObject,Element> entry : project.getExtraCompilationUnits().entrySet()) {
139
                    for (Element kid : Util.findSubElements(entry.getValue())) {
139
                    for (Element kid : XMLUtil.findSubElements(entry.getValue())) {
140
                        if (!kid.getLocalName().equals("built-to")) { // NOI18N
140
                        if (!kid.getLocalName().equals("built-to")) { // NOI18N
141
                            continue;
141
                            continue;
142
                        }
142
                        }
143
                        String rawtext = Util.findText(kid);
143
                        String rawtext = XMLUtil.findText(kid);
144
                        assert rawtext != null : "Null content for <built-to> in " + project;
144
                        assert rawtext != null : "Null content for <built-to> in " + project;
145
                        String text = project.evaluator().evaluate(rawtext);
145
                        String text = project.evaluator().evaluate(rawtext);
146
                        if (text == null) {
146
                        if (text == null) {
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java (-8 / +9 lines)
Lines 63-68 Link Here
63
import org.openide.ErrorManager;
63
import org.openide.ErrorManager;
64
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
66
import org.openide.xml.XMLUtil;
66
import org.w3c.dom.Element;
67
import org.w3c.dom.Element;
67
68
68
/**
69
/**
Lines 89-107 Link Here
89
            return Collections.emptySet();
90
            return Collections.emptySet();
90
        }
91
        }
91
        Element data = project.getPrimaryConfigurationData();
92
        Element data = project.getPrimaryConfigurationData();
92
        Element moduleDependencies = Util.findElement(data,
93
        Element moduleDependencies = XMLUtil.findElement(data,
93
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
94
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
94
        assert moduleDependencies != null : "Malformed metadata in " + project;
95
        assert moduleDependencies != null : "Malformed metadata in " + project;
95
        for (Element dep : Util.findSubElements(moduleDependencies)) {
96
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
96
            /* Probably better to open runtime deps too. TBD.
97
            /* Probably better to open runtime deps too. TBD.
97
            if (Util.findElement(dep, "build-prerequisite", // NOI18N
98
            if (XMLUtil.findElement(dep, "build-prerequisite", // NOI18N
98
                    NbModuleProject.NAMESPACE_SHARED) == null) {
99
                    NbModuleProject.NAMESPACE_SHARED) == null) {
99
                continue;
100
                continue;
100
            }
101
            }
101
             */
102
             */
102
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
103
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
103
                NbModuleProject.NAMESPACE_SHARED);
104
                NbModuleProject.NAMESPACE_SHARED);
104
            String cnb = Util.findText(cnbEl);
105
            String cnb = XMLUtil.findText(cnbEl);
105
            ModuleEntry module = ml.getEntry(cnb);
106
            ModuleEntry module = ml.getEntry(cnb);
106
            if (module == null) {
107
            if (module == null) {
107
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + project);
108
                Util.err.log(ErrorManager.WARNING, "Warning - could not find dependent module " + cnb + " for " + project);
Lines 129-143 Link Here
129
            }
130
            }
130
        }
131
        }
131
        // #63824: consider also artifacts found in ${cp.extra} and/or <class-path-extension>s
132
        // #63824: consider also artifacts found in ${cp.extra} and/or <class-path-extension>s
132
        for (Element cpext : Util.findSubElements(data)) {
133
        for (Element cpext : XMLUtil.findSubElements(data)) {
133
            if (!cpext.getTagName().equals("class-path-extension")) { // NOI18N
134
            if (!cpext.getTagName().equals("class-path-extension")) { // NOI18N
134
                continue;
135
                continue;
135
            }
136
            }
136
            Element binorig = Util.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
137
            Element binorig = XMLUtil.findElement(cpext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
137
            if (binorig == null) {
138
            if (binorig == null) {
138
                continue;
139
                continue;
139
            }
140
            }
140
            String text = Util.findText(binorig);
141
            String text = XMLUtil.findText(binorig);
141
            String eval = project.evaluator().evaluate(text);
142
            String eval = project.evaluator().evaluate(text);
142
            if (eval == null) {
143
            if (eval == null) {
143
                continue;
144
                continue;
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/suite/SuiteProject.java (-2 / +3 lines)
Lines 89-94 Link Here
89
import org.openide.util.Lookup;
89
import org.openide.util.Lookup;
90
import org.openide.util.Mutex;
90
import org.openide.util.Mutex;
91
import org.openide.util.lookup.Lookups;
91
import org.openide.util.lookup.Lookups;
92
import org.openide.xml.XMLUtil;
92
import org.w3c.dom.Element;
93
import org.w3c.dom.Element;
93
94
94
/**
95
/**
Lines 242-249 Link Here
242
        }
243
        }
243
        
244
        
244
        private String getSimpleName() {
245
        private String getSimpleName() {
245
            Element nameEl = Util.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
246
            Element nameEl = XMLUtil.findElement(helper.getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
246
            String text = (nameEl != null) ? Util.findText(nameEl) : null;
247
            String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
247
            return (text != null) ? text : "???"; // NOI18N
248
            return (text != null) ? text : "???"; // NOI18N
248
        }
249
        }
249
        
250
        
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/BasicBrandingModel.java (-3 / +3 lines)
Lines 56-62 Link Here
56
import org.netbeans.api.annotations.common.CheckForNull;
56
import org.netbeans.api.annotations.common.CheckForNull;
57
import org.netbeans.api.annotations.common.NullAllowed;
57
import org.netbeans.api.annotations.common.NullAllowed;
58
import org.netbeans.api.project.Project;
58
import org.netbeans.api.project.Project;
59
import org.netbeans.modules.apisupport.project.Util;
60
import org.netbeans.modules.apisupport.project.suite.BrandingSupport;
59
import org.netbeans.modules.apisupport.project.suite.BrandingSupport;
61
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BrandedFile;
60
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BrandedFile;
62
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BundleKey;
61
import org.netbeans.modules.apisupport.project.suite.BrandingSupport.BundleKey;
Lines 67-72 Link Here
67
import org.openide.filesystems.FileUtil;
66
import org.openide.filesystems.FileUtil;
68
import org.openide.util.ChangeSupport;
67
import org.openide.util.ChangeSupport;
69
import org.openide.util.NbBundle;
68
import org.openide.util.NbBundle;
69
import org.openide.xml.XMLUtil;
70
import org.w3c.dom.Element;
70
import org.w3c.dom.Element;
71
71
72
/**
72
/**
Lines 406-413 Link Here
406
                res = getProjectDirectoryFile().getName();
406
                res = getProjectDirectoryFile().getName();
407
            return res;
407
            return res;
408
        }
408
        }
409
        Element nameEl = Util.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
409
        Element nameEl = XMLUtil.findElement(suiteProps.getProject().getHelper().getPrimaryConfigurationData(true), "name", SuiteProjectType.NAMESPACE_SHARED); // NOI18N
410
        String text = (nameEl != null) ? Util.findText(nameEl) : null;
410
        String text = (nameEl != null) ? XMLUtil.findText(nameEl) : null;
411
        return (text != null) ? text : "???"; // NOI18N
411
        return (text != null) ? text : "???"; // NOI18N
412
    }
412
    }
413
413
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/customizer/SuiteCustomizerLibraries.java (-9 / +9 lines)
Lines 1467-1489 Link Here
1467
            dependencies = new HashSet<Dependency>();
1467
            dependencies = new HashSet<Dependency>();
1468
            // Cannot use ProjectXMLManager since we need to report also deps on nonexistent modules.
1468
            // Cannot use ProjectXMLManager since we need to report also deps on nonexistent modules.
1469
            Element dataE = project.getPrimaryConfigurationData();
1469
            Element dataE = project.getPrimaryConfigurationData();
1470
            Element depsE = Util.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1470
            Element depsE = XMLUtil.findElement(dataE, "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1471
            assert depsE != null : "Malformed metadata in " + project;
1471
            assert depsE != null : "Malformed metadata in " + project;
1472
            for (Element dep : Util.findSubElements(depsE)) {
1472
            for (Element dep : XMLUtil.findSubElements(depsE)) {
1473
                Element run = Util.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1473
                Element run = XMLUtil.findElement(dep, "run-dependency", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1474
                if (run == null) {
1474
                if (run == null) {
1475
                    continue;
1475
                    continue;
1476
                }
1476
                }
1477
                String text = Util.findText(Util.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
1477
                String text = XMLUtil.findText(XMLUtil.findElement(dep, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
1478
                Element relverE = Util.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1478
                Element relverE = XMLUtil.findElement(run, "release-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1479
                if (relverE != null) {
1479
                if (relverE != null) {
1480
                    text += '/' + Util.findText(relverE);
1480
                    text += '/' + XMLUtil.findText(relverE);
1481
                }
1481
                }
1482
                Element specverE = Util.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1482
                Element specverE = XMLUtil.findElement(run, "specification-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1483
                if (specverE != null) {
1483
                if (specverE != null) {
1484
                    text += " > " + Util.findText(specverE);
1484
                    text += " > " + XMLUtil.findText(specverE);
1485
                } else {
1485
                } else {
1486
                    Element implver = Util.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1486
                    Element implver = XMLUtil.findElement(run, "implementation-version", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1487
                    if (implver != null) {
1487
                    if (implver != null) {
1488
                        // Will special-case '*' as an impl version to mean "match anything".
1488
                        // Will special-case '*' as an impl version to mean "match anything".
1489
                        text += " = *"; // NOI18N
1489
                        text += " = *"; // NOI18N
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/AbstractEntryWithSources.java (-5 / +6 lines)
Lines 54-59 Link Here
54
import org.openide.ErrorManager;
54
import org.openide.ErrorManager;
55
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.xml.XMLUtil;
57
import org.w3c.dom.Element;
58
import org.w3c.dom.Element;
58
59
59
abstract class AbstractEntryWithSources extends AbstractEntry {
60
abstract class AbstractEntryWithSources extends AbstractEntry {
Lines 136-152 Link Here
136
            return new String[0];
137
            return new String[0];
137
        }
138
        }
138
        Element data = project.getPrimaryConfigurationData();
139
        Element data = project.getPrimaryConfigurationData();
139
        Element moduleDependencies = Util.findElement(data,
140
        Element moduleDependencies = XMLUtil.findElement(data,
140
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
141
            "module-dependencies", NbModuleProject.NAMESPACE_SHARED); // NOI18N
141
        assert moduleDependencies != null : "Malformed metadata in " + project;
142
        assert moduleDependencies != null : "Malformed metadata in " + project;
142
        for (Element dep : Util.findSubElements(moduleDependencies)) {
143
        for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
143
            if (Util.findElement(dep, "run-dependency", // NOI18N
144
            if (XMLUtil.findElement(dep, "run-dependency", // NOI18N
144
                    NbModuleProject.NAMESPACE_SHARED) == null) {
145
                    NbModuleProject.NAMESPACE_SHARED) == null) {
145
                continue;
146
                continue;
146
            }
147
            }
147
            Element cnbEl = Util.findElement(dep, "code-name-base", // NOI18N
148
            Element cnbEl = XMLUtil.findElement(dep, "code-name-base", // NOI18N
148
                NbModuleProject.NAMESPACE_SHARED);
149
                NbModuleProject.NAMESPACE_SHARED);
149
            String cnb = Util.findText(cnbEl);
150
            String cnb = XMLUtil.findText(cnbEl);
150
            deps.add(cnb);
151
            deps.add(cnb);
151
        }
152
        }
152
        return deps.toArray(new String[deps.size()]);
153
        return deps.toArray(new String[deps.size()]);
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java (-16 / +16 lines)
Lines 201-208 Link Here
201
        if (data == null) {
201
        if (data == null) {
202
            throw new IOException("Not an NBM project in " + basedir); // NOI18N
202
            throw new IOException("Not an NBM project in " + basedir); // NOI18N
203
        }
203
        }
204
        boolean suiteComponent = Util.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
204
        boolean suiteComponent = XMLUtil.findElement(data, "suite-component", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
205
        boolean standalone = Util.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
205
        boolean standalone = XMLUtil.findElement(data, "standalone", NbModuleProject.NAMESPACE_SHARED) != null; // NOI18N
206
        assert !(suiteComponent && standalone) : basedir;
206
        assert !(suiteComponent && standalone) : basedir;
207
        if (suiteComponent) {
207
        if (suiteComponent) {
208
            PropertyEvaluator eval = parseProperties(basedir, null, NbModuleType.SUITE_COMPONENT, "irrelevant"); // NOI18N
208
            PropertyEvaluator eval = parseProperties(basedir, null, NbModuleType.SUITE_COMPONENT, "irrelevant"); // NOI18N
Lines 528-550 Link Here
528
        }
528
        }
529
        assert root != null ^ type != NbModuleType.NETBEANS_ORG;
529
        assert root != null ^ type != NbModuleType.NETBEANS_ORG;
530
        assert path != null ^ type != NbModuleType.NETBEANS_ORG;
530
        assert path != null ^ type != NbModuleType.NETBEANS_ORG;
531
        String cnb = Util.findText(Util.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
531
        String cnb = XMLUtil.findText(XMLUtil.findElement(data, "code-name-base", NbModuleProject.NAMESPACE_SHARED)); // NOI18N
532
        PropertyEvaluator eval = parseProperties(basedir, root, type, cnb);
532
        PropertyEvaluator eval = parseProperties(basedir, root, type, cnb);
533
        String module = eval.getProperty("module.jar"); // NOI18N
533
        String module = eval.getProperty("module.jar"); // NOI18N
534
        // Cf. ParseProjectXml.computeClasspath:
534
        // Cf. ParseProjectXml.computeClasspath:
535
        StringBuffer cpextra = new StringBuffer();
535
        StringBuffer cpextra = new StringBuffer();
536
        for (Element ext : Util.findSubElements(data)) {
536
        for (Element ext : XMLUtil.findSubElements(data)) {
537
            if (!ext.getLocalName().equals("class-path-extension")) { // NOI18N
537
            if (!ext.getLocalName().equals("class-path-extension")) { // NOI18N
538
                continue;
538
                continue;
539
            }
539
            }
540
            Element binaryOrigin = Util.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
540
            Element binaryOrigin = XMLUtil.findElement(ext, "binary-origin", NbModuleProject.NAMESPACE_SHARED); // NOI18N
541
            String text;
541
            String text;
542
            if (binaryOrigin != null) {
542
            if (binaryOrigin != null) {
543
                text = Util.findText(binaryOrigin);
543
                text = XMLUtil.findText(binaryOrigin);
544
            } else {
544
            } else {
545
                Element runtimeRelativePath = Util.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
545
                Element runtimeRelativePath = XMLUtil.findElement(ext, "runtime-relative-path", NbModuleProject.NAMESPACE_SHARED); // NOI18N
546
                assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
546
                assert runtimeRelativePath != null : "Malformed <class-path-extension> in " + basedir;
547
                String reltext = Util.findText(runtimeRelativePath);
547
                String reltext = XMLUtil.findText(runtimeRelativePath);
548
                // XXX assumes that module.jar is not overridden independently of module.jar.dir:
548
                // XXX assumes that module.jar is not overridden independently of module.jar.dir:
549
                text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
549
                text = "${cluster}/${module.jar.dir}/" + reltext; // NOI18N
550
            }
550
            }
Lines 967-975 Link Here
967
            } catch (SAXException e) {
967
            } catch (SAXException e) {
968
                throw (IOException) new IOException(e.toString()).initCause(e);
968
                throw (IOException) new IOException(e.toString()).initCause(e);
969
            }
969
            }
970
            for (Element moduleVersion : Util.findSubElements(doc.getDocumentElement())) {
970
            for (Element moduleVersion : XMLUtil.findSubElements(doc.getDocumentElement())) {
971
                if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
971
                if (moduleVersion.getTagName().equals("module_version") && moduleVersion.getAttribute("last").equals("true")) { // NOI18N
972
                    for (Element fileEl : Util.findSubElements(moduleVersion)) {
972
                    for (Element fileEl : XMLUtil.findSubElements(moduleVersion)) {
973
                        if (fileEl.getTagName().equals("file")) { // NOI18N
973
                        if (fileEl.getTagName().equals("file")) { // NOI18N
974
                            String name = fileEl.getAttribute("name"); // NOI18N
974
                            String name = fileEl.getAttribute("name"); // NOI18N
975
                            File f = new File(cluster, name.replace('/', File.separatorChar));
975
                            File f = new File(cluster, name.replace('/', File.separatorChar));
Lines 1007-1024 Link Here
1007
            throw (IOException) new IOException(projectXml + ": " + e.toString()).initCause(e); // NOI18N
1007
            throw (IOException) new IOException(projectXml + ": " + e.toString()).initCause(e); // NOI18N
1008
        }
1008
        }
1009
        Element docel = doc.getDocumentElement();
1009
        Element docel = doc.getDocumentElement();
1010
        Element type = Util.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
1010
        Element type = XMLUtil.findElement(docel, "type", "http://www.netbeans.org/ns/project/1"); // NOI18N
1011
        if (!Util.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
1011
        if (!XMLUtil.findText(type).equals("org.netbeans.modules.apisupport.project")) { // NOI18N
1012
            return null;
1012
            return null;
1013
        }
1013
        }
1014
        Element cfg = Util.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
1014
        Element cfg = XMLUtil.findElement(docel, "configuration", "http://www.netbeans.org/ns/project/1"); // NOI18N
1015
        Element data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1015
        Element data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED); // NOI18N
1016
        if (data != null) {
1016
        if (data != null) {
1017
            return data;
1017
            return data;
1018
        } else {
1018
        } else {
1019
            data = Util.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
1019
            data = XMLUtil.findElement(cfg, "data", NbModuleProject.NAMESPACE_SHARED_2); // NOI18N
1020
            if (data != null) {
1020
            if (data != null) {
1021
                return Util.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
1021
                return XMLUtil.translateXML(data, NbModuleProject.NAMESPACE_SHARED);
1022
            } else {
1022
            } else {
1023
                return null;
1023
                return null;
1024
            }
1024
            }
(-)a/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ProjectXMLManagerTest.java (-2 / +2 lines)
Lines 303-310 Link Here
303
                    Document doc = XMLUtil.parse(new InputSource(projectXML.toURI().toString()),
303
                    Document doc = XMLUtil.parse(new InputSource(projectXML.toURI().toString()),
304
                            false, true, null, null);
304
                            false, true, null, null);
305
                    Element project = doc.getDocumentElement();
305
                    Element project = doc.getDocumentElement();
306
                    Element config = Util.findElement(project, "configuration", null); // NOI18N
306
                    Element config = XMLUtil.findElement(project, "configuration", null); // NOI18N
307
                    data = Util.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
307
                    data = XMLUtil.findElement(config, "data", NbModuleProject.NAMESPACE_SHARED);
308
                } catch (IOException e) {
308
                } catch (IOException e) {
309
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
309
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
310
                } catch (SAXException e) {
310
                } catch (SAXException e) {
(-)a/j2ee.archive/nbproject/project.xml (-1 / +1 lines)
Lines 294-300 Link Here
294
                    <build-prerequisite/>
294
                    <build-prerequisite/>
295
                    <compile-dependency/>
295
                    <compile-dependency/>
296
                    <run-dependency>
296
                    <run-dependency>
297
                        <specification-version>8.0</specification-version>
297
                        <specification-version>8.3</specification-version>
298
                    </run-dependency>
298
                    </run-dependency>
299
                </dependency>
299
                </dependency>
300
                <dependency>
300
                <dependency>
(-)a/j2ee.archive/src/org/netbeans/modules/j2ee/archive/project/UpdateHelper.java (-34 / +3 lines)
Lines 61-66 Link Here
61
import org.netbeans.spi.project.AuxiliaryConfiguration;
61
import org.netbeans.spi.project.AuxiliaryConfiguration;
62
import org.netbeans.spi.project.support.ant.AntProjectHelper;
62
import org.netbeans.spi.project.support.ant.AntProjectHelper;
63
import org.netbeans.spi.project.support.ant.EditableProperties;
63
import org.netbeans.spi.project.support.ant.EditableProperties;
64
import org.openide.xml.XMLUtil;
64
65
65
66
66
/**
67
/**
Lines 277-283 Link Here
277
            if (oldRoot != null) {
278
            if (oldRoot != null) {
278
                Document doc = oldRoot.getOwnerDocument();
279
                Document doc = oldRoot.getOwnerDocument();
279
                Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
280
                Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
280
                copyDocument (doc, oldRoot, newRoot);
281
                XMLUtil.copyDocument (oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS);
281
                Element sourceRoots = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,"source-roots");  //NOI18N
282
                Element sourceRoots = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,"source-roots");  //NOI18N
282
                Element root = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,"root");   //NOI18N
283
                Element root = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,"root");   //NOI18N
283
                root.setAttribute ("id","src.dir");   //NOI18N
284
                root.setAttribute ("id","src.dir");   //NOI18N
Lines 294-300 Link Here
294
                if (oldRoot != null) {
295
                if (oldRoot != null) {
295
                    Document doc = oldRoot.getOwnerDocument();
296
                    Document doc = oldRoot.getOwnerDocument();
296
                    Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
297
                    Element newRoot = doc.createElementNS (ArchiveProjectType.PROJECT_CONFIGURATION_NS,DATA); //NOI18N
297
                    copyDocument (doc, oldRoot, newRoot);
298
                    XMLUtil.copyDocument (oldRoot, newRoot, ArchiveProjectType.PROJECT_CONFIGURATION_NS);
298
                    cachedElement = updateMinAntVersion (newRoot, doc);
299
                    cachedElement = updateMinAntVersion (newRoot, doc);
299
                }
300
                }
300
            }
301
            }
Lines 317-354 Link Here
317
        return cachedProperties;
318
        return cachedProperties;
318
    }
319
    }
319
320
320
    private static void copyDocument (Document doc, Element from, Element to) {
321
        NodeList nl = from.getChildNodes();
322
        int length = nl.getLength();
323
        for (int i=0; i< length; i++) {
324
            Node node = nl.item (i);
325
            Node newNode = null;
326
            switch (node.getNodeType()) {
327
                case Node.ELEMENT_NODE:
328
                    Element oldElement = (Element) node;
329
                    newNode = doc.createElementNS(ArchiveProjectType.PROJECT_CONFIGURATION_NS,oldElement.getTagName());
330
                    NamedNodeMap m = oldElement.getAttributes();
331
                    Element newElement = (Element) newNode;
332
                    for (int index = 0; index < m.getLength(); index++) {
333
                        Node attr = m.item(index);
334
                          newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
335
                    }
336
                    copyDocument(doc,oldElement,newElement);
337
                    break;
338
                case Node.TEXT_NODE:
339
                    Text oldText = (Text) node;
340
                    newNode = doc.createTextNode(oldText.getData());
341
                    break;
342
                case Node.COMMENT_NODE:
343
                    Comment oldComment = (Comment) node;
344
                    newNode = doc.createComment(oldComment.getData());
345
                    break;
346
            }
347
            if (newNode != null) {
348
                to.appendChild (newNode);
349
            }
350
        }
351
    }
352
    public static final String MINIMUM_ANT_VERSION = "1.6.5"; // NOI18N
321
    public static final String MINIMUM_ANT_VERSION = "1.6.5"; // NOI18N
353
    
322
    
354
    private static Element updateMinAntVersion (final Element root, final Document doc) {
323
    private static Element updateMinAntVersion (final Element root, final Document doc) {
(-)a/j2ee.clientproject/nbproject/project.xml (-25 / +34 lines)
Lines 375-381 Link Here
375
                    <build-prerequisite/>
375
                    <build-prerequisite/>
376
                    <compile-dependency/>
376
                    <compile-dependency/>
377
                    <run-dependency>
377
                    <run-dependency>
378
                        <specification-version>8.0</specification-version>
378
                        <specification-version>8.3</specification-version>
379
                    </run-dependency>
379
                    </run-dependency>
380
                </dependency>
380
                </dependency>
381
                <dependency>
381
                <dependency>
Lines 399-409 Link Here
399
                <test-type>
399
                <test-type>
400
                    <name>unit</name>
400
                    <name>unit</name>
401
                    <test-dependency>
401
                    <test-dependency>
402
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
403
                        <compile-dependency/>
404
                    </test-dependency>
405
                    <test-dependency>
402
                        <code-name-base>org.netbeans.modules.j2ee.clientproject</code-name-base>
406
                        <code-name-base>org.netbeans.modules.j2ee.clientproject</code-name-base>
403
                        <recursive/>
407
                        <recursive/>
404
                        <compile-dependency/>
408
                        <compile-dependency/>
405
                    </test-dependency>
409
                    </test-dependency>
406
                    <test-dependency>
410
                    <test-dependency>
411
                        <code-name-base>org.netbeans.modules.j2ee.sun.ddui</code-name-base>
412
                    </test-dependency>
413
                    <test-dependency>
414
                        <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
415
                        <test/>
416
                    </test-dependency>
417
                    <test-dependency>
418
                        <code-name-base>org.netbeans.modules.java.project</code-name-base>
419
                    </test-dependency>
420
                    <test-dependency>
421
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
422
                    </test-dependency>
423
                    <test-dependency>
424
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
425
                        <recursive/>
426
                        <compile-dependency/>
427
                    </test-dependency>
428
                    <test-dependency>
429
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
430
                        <compile-dependency/>
431
                        <test/>
432
                    </test-dependency>
433
                    <test-dependency>
434
                        <code-name-base>org.netbeans.modules.websvc.core</code-name-base>
435
                    </test-dependency>
436
                    <test-dependency>
437
                        <code-name-base>org.netbeans.modules.websvc.projectapi</code-name-base>
438
                    </test-dependency>
439
                    <test-dependency>
407
                        <code-name-base>org.openide.util</code-name-base>
440
                        <code-name-base>org.openide.util</code-name-base>
408
                        <compile-dependency/>
441
                        <compile-dependency/>
409
                        <test/>
442
                        <test/>
Lines 413-442 Link Here
413
                        <compile-dependency/>
446
                        <compile-dependency/>
414
                        <test/>
447
                        <test/>
415
                    </test-dependency>
448
                    </test-dependency>
416
                    <test-dependency>
417
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
418
                        <compile-dependency/>
419
                        <test/>
420
                    </test-dependency>
421
                    <test-dependency>
422
                        <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
423
                        <test/>
424
                    </test-dependency>
425
                    <test-dependency>
426
                        <code-name-base>org.netbeans.modules.j2ee.sun.ddui</code-name-base>
427
                    </test-dependency>
428
                    <test-dependency>
429
                        <code-name-base>org.netbeans.modules.java.project</code-name-base>
430
                    </test-dependency>
431
                    <test-dependency>
432
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
433
                    </test-dependency>
434
                    <test-dependency>
435
                        <code-name-base>org.netbeans.modules.websvc.core</code-name-base>
436
                    </test-dependency>
437
                    <test-dependency>
438
                        <code-name-base>org.netbeans.modules.websvc.projectapi</code-name-base>
439
                    </test-dependency>
440
                </test-type>
449
                </test-type>
441
            </test-dependencies>
450
            </test-dependencies>
442
            <friend-packages>
451
            <friend-packages>
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/UpdateProjectImpl.java (-35 / +3 lines)
Lines 53-58 Link Here
53
import org.openide.DialogDisplayer;
53
import org.openide.DialogDisplayer;
54
import org.openide.NotifyDescriptor;
54
import org.openide.NotifyDescriptor;
55
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
56
import org.openide.xml.XMLUtil;
56
import org.w3c.dom.Comment;
57
import org.w3c.dom.Comment;
57
import org.w3c.dom.Document;
58
import org.w3c.dom.Document;
58
import org.w3c.dom.Element;
59
import org.w3c.dom.Element;
Lines 147-153 Link Here
147
            if (oldRoot != null) {
148
            if (oldRoot != null) {
148
                Document doc = oldRoot.getOwnerDocument();
149
                Document doc = oldRoot.getOwnerDocument();
149
                Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
150
                Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
150
                copyDocument (doc, oldRoot, newRoot);
151
                XMLUtil.copyDocument (oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
151
                Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
152
                Element sourceRoots = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
152
                Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
153
                Element root = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
153
                root.setAttribute ("id","src.dir");   //NOI18N
154
                root.setAttribute ("id","src.dir");   //NOI18N
Lines 164-170 Link Here
164
                if (oldRoot != null) {
165
                if (oldRoot != null) {
165
                    Document doc = oldRoot.getOwnerDocument();
166
                    Document doc = oldRoot.getOwnerDocument();
166
                    Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
167
                    Element newRoot = doc.createElementNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
167
                    copyDocument (doc, oldRoot, newRoot);
168
                    XMLUtil.copyDocument (oldRoot, newRoot, AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE);
168
                    cachedElement = updateMinAntVersion (newRoot, doc);
169
                    cachedElement = updateMinAntVersion (newRoot, doc);
169
                }
170
                }
170
            }
171
            }
Lines 187-225 Link Here
187
        return cachedProperties;
188
        return cachedProperties;
188
    }
189
    }
189
190
190
    private static void copyDocument (Document doc, Element from, Element to) {
191
        NodeList nl = from.getChildNodes();
192
        int length = nl.getLength();
193
        for (int i=0; i< length; i++) {
194
            Node node = nl.item (i);
195
            Node newNode = null;
196
            switch (node.getNodeType()) {
197
                case Node.ELEMENT_NODE:
198
                    Element oldElement = (Element) node;
199
                    newNode = doc.createElementNS(AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
200
                    NamedNodeMap m = oldElement.getAttributes();
201
                    Element newElement = (Element) newNode;
202
                    for (int index = 0; index < m.getLength(); index++) {
203
                        Node attr = m.item(index);
204
                          newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
205
                    }
206
                    copyDocument(doc,oldElement,newElement);
207
                    break;
208
                case Node.TEXT_NODE:
209
                    Text oldText = (Text) node;
210
                    newNode = doc.createTextNode(oldText.getData());
211
                    break;
212
                case Node.COMMENT_NODE:
213
                    Comment oldComment = (Comment) node;
214
                    newNode = doc.createComment(oldComment.getData());
215
                    break;
216
            }
217
            if (newNode != null) {
218
                to.appendChild (newNode);
219
            }
220
        }
221
    }
222
    
223
    private static Element updateMinAntVersion (final Element root, final Document doc) {
191
    private static Element updateMinAntVersion (final Element root, final Document doc) {
224
        NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
192
        NodeList list = root.getElementsByTagNameNS (AppClientProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
225
        if (list.getLength() == 1) {
193
        if (list.getLength() == 1) {
(-)a/j2ee.clientproject/src/org/netbeans/modules/j2ee/clientproject/classpath/ClassPathSupportCallbackImpl.java (-19 / +2 lines)
Lines 51-61 Link Here
51
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
51
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
52
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
52
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
53
import org.netbeans.spi.project.support.ant.AntProjectHelper;
54
import org.openide.xml.XMLUtil;
54
import org.w3c.dom.Document;
55
import org.w3c.dom.Document;
55
import org.w3c.dom.Element;
56
import org.w3c.dom.Element;
56
import org.w3c.dom.Node;
57
import org.w3c.dom.Node;
57
import org.w3c.dom.NodeList;
58
import org.w3c.dom.NodeList;
58
import org.w3c.dom.Text;
59
59
60
/**
60
/**
61
 *
61
 *
Lines 91-97 Link Here
91
        for ( int i = 0; i < libs.getLength(); i++ ) {
91
        for ( int i = 0; i < libs.getLength(); i++ ) {
92
            Element item = (Element)libs.item( i );
92
            Element item = (Element)libs.item( i );
93
            // appclient is different from other j2ee projects - it stores reference without ${ and }
93
            // appclient is different from other j2ee projects - it stores reference without ${ and }
94
            String ref = "${"+findText( item )+"}";
94
            String ref = "${"+XMLUtil.findText( item )+"}";
95
            libraries.add(ref); // NOI18N
95
            libraries.add(ref); // NOI18N
96
            String dirs = item.getAttribute(ATTR_DIRS);
96
            String dirs = item.getAttribute(ATTR_DIRS);
97
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
97
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
Lines 140-162 Link Here
140
        return libraryElement;
140
        return libraryElement;
141
    }
141
    }
142
       
142
       
143
    /**
144
     * Extracts <b>the first</b> nested text from an element.
145
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
146
     * @param parent a parent element
147
     * @return the nested text, or null if none was found
148
     */
149
    private static String findText( Element parent ) {
150
        NodeList l = parent.getChildNodes();
151
        for ( int i = 0; i < l.getLength(); i++ ) {
152
            if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
153
                Text text = (Text)l.item( i );
154
                return text.getNodeValue();
155
            }
156
        }
157
        return null;
158
    }
159
160
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
143
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
161
        Map<String, String> destination = new HashMap<String, String>();
144
        Map<String, String> destination = new HashMap<String, String>();
162
        List<String> l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);
145
        List<String> l = getIncludedLibraries(antProjectHelper, projectXMLElement, destination);
(-)a/j2ee.earproject/nbproject/project.xml (-29 / +38 lines)
Lines 347-353 Link Here
347
                    <build-prerequisite/>
347
                    <build-prerequisite/>
348
                    <compile-dependency/>
348
                    <compile-dependency/>
349
                    <run-dependency>
349
                    <run-dependency>
350
                        <specification-version>8.0</specification-version>
350
                        <specification-version>8.3</specification-version>
351
                    </run-dependency>
351
                    </run-dependency>
352
                </dependency>
352
                </dependency>
353
                <dependency>
353
                <dependency>
Lines 363-373 Link Here
363
                <test-type>
363
                <test-type>
364
                    <name>unit</name>
364
                    <name>unit</name>
365
                    <test-dependency>
365
                    <test-dependency>
366
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
367
                        <compile-dependency/>
368
                    </test-dependency>
369
                    <test-dependency>
366
                        <code-name-base>org.netbeans.modules.j2ee.earproject</code-name-base>
370
                        <code-name-base>org.netbeans.modules.j2ee.earproject</code-name-base>
367
                        <recursive/>
371
                        <recursive/>
368
                        <compile-dependency/>
372
                        <compile-dependency/>
369
                    </test-dependency>
373
                    </test-dependency>
370
                    <test-dependency>
374
                    <test-dependency>
375
                        <code-name-base>org.netbeans.modules.j2ee.sun.dd</code-name-base>
376
                    </test-dependency>
377
                    <test-dependency>
378
                        <code-name-base>org.netbeans.modules.j2ee.sun.ddui</code-name-base>
379
                    </test-dependency>
380
                    <test-dependency>
381
                        <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
382
                        <test/>
383
                    </test-dependency>
384
                    <test-dependency>
385
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
386
                    </test-dependency>
387
                    <test-dependency>
388
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
389
                        <recursive/>
390
                        <compile-dependency/>
391
                    </test-dependency>
392
                    <test-dependency>
393
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
394
                        <compile-dependency/>
395
                        <test/>
396
                    </test-dependency>
397
                    <test-dependency>
398
                        <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
399
                        <compile-dependency/>
400
                    </test-dependency>
401
                    <test-dependency>
402
                        <code-name-base>org.netbeans.modules.web.core</code-name-base>
403
                    </test-dependency>
404
                    <test-dependency>
405
                        <code-name-base>org.netbeans.modules.web.core.syntax</code-name-base>
406
                    </test-dependency>
407
                    <test-dependency>
371
                        <code-name-base>org.openide.util</code-name-base>
408
                        <code-name-base>org.openide.util</code-name-base>
372
                        <compile-dependency/>
409
                        <compile-dependency/>
373
                        <test/>
410
                        <test/>
Lines 377-410 Link Here
377
                        <compile-dependency/>
414
                        <compile-dependency/>
378
                        <test/>
415
                        <test/>
379
                    </test-dependency>
416
                    </test-dependency>
380
                    <test-dependency>
381
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
382
                        <compile-dependency/>
383
                        <test/>
384
                    </test-dependency>
385
                    <test-dependency>
386
                        <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
387
                        <test/>
388
                    </test-dependency>
389
                    <test-dependency>
390
                        <code-name-base>org.netbeans.modules.j2ee.sun.dd</code-name-base>
391
                    </test-dependency>
392
                    <test-dependency>
393
                        <code-name-base>org.netbeans.modules.j2ee.sun.ddui</code-name-base>
394
                    </test-dependency>
395
                    <test-dependency>
396
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
397
                    </test-dependency>
398
                    <test-dependency>
399
                        <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
400
                        <compile-dependency/>
401
                    </test-dependency>
402
                    <test-dependency>
403
                        <code-name-base>org.netbeans.modules.web.core</code-name-base>
404
                    </test-dependency>
405
                    <test-dependency>
406
                        <code-name-base>org.netbeans.modules.web.core.syntax</code-name-base>
407
                    </test-dependency>
408
                </test-type>
417
                </test-type>
409
            </test-dependencies>
418
            </test-dependencies>
410
            <public-packages/>
419
            <public-packages/>
(-)a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/UpdateProjectImpl.java (-56 / +3 lines)
Lines 60-71 Link Here
60
import org.netbeans.spi.project.support.ant.EditableProperties;
60
import org.netbeans.spi.project.support.ant.EditableProperties;
61
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileUtil;
62
import org.openide.filesystems.FileUtil;
63
import org.w3c.dom.Comment;
63
import org.openide.xml.XMLUtil;
64
import org.w3c.dom.Document;
64
import org.w3c.dom.Document;
65
import org.w3c.dom.NamedNodeMap;
66
import org.w3c.dom.Node;
65
import org.w3c.dom.Node;
67
import org.w3c.dom.NodeList;
66
import org.w3c.dom.NodeList;
68
import org.w3c.dom.Text;
69
67
70
68
71
/**
69
/**
Lines 159-165 Link Here
159
            if(oldRoot != null) {
157
            if(oldRoot != null) {
160
                Document doc = oldRoot.getOwnerDocument();
158
                Document doc = oldRoot.getOwnerDocument();
161
                Element newRoot = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
159
                Element newRoot = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
162
                copyDocument(doc, oldRoot, newRoot);
160
                XMLUtil.copyDocument(oldRoot, newRoot, EarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
163
                
161
                
164
                //update <web-module-/additional/-libraries/> to <j2ee-module-/additional/-libraries/>
162
                //update <web-module-/additional/-libraries/> to <j2ee-module-/additional/-libraries/>
165
//                NodeList contList = newRoot.getElementsByTagNameNS(ns, "web-module-libraries");
163
//                NodeList contList = newRoot.getElementsByTagNameNS(ns, "web-module-libraries");
Lines 173-179 Link Here
173
                        Element library = (Element) libList.item(i);
171
                        Element library = (Element) libList.item(i);
174
                        Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
172
                        Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
175
                        //remove ${ and } from the beginning and end
173
                        //remove ${ and } from the beginning and end
176
                        String webFileText = findText(webFile);
174
                        String webFileText = XMLUtil.findText(webFile);
177
                        webFileText = webFileText.substring(2, webFileText.length() - 1);
175
                        webFileText = webFileText.substring(2, webFileText.length() - 1);
178
                        if (webFileText.startsWith("libs.")) {
176
                        if (webFileText.startsWith("libs.")) {
179
                            String libName = webFileText.substring(5, webFileText.indexOf(".classpath")); //NOI18N
177
                            String libName = webFileText.substring(5, webFileText.indexOf(".classpath")); //NOI18N
Lines 209-265 Link Here
209
        return cachedElement;
207
        return cachedElement;
210
    }
208
    }
211
209
212
    private static void copyDocument (Document doc, Element from, Element to) {
213
        NodeList nl = from.getChildNodes();
214
        int length = nl.getLength();
215
        for (int i=0; i< length; i++) {
216
            Node node = nl.item (i);
217
            Node newNode = null;
218
            switch (node.getNodeType()) {
219
                case Node.ELEMENT_NODE:
220
                    Element oldElement = (Element) node;
221
                    newNode = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
222
                    NamedNodeMap m = oldElement.getAttributes();
223
                    Element newElement = (Element) newNode;
224
                    for (int index = 0; index < m.getLength(); index++) {
225
                        Node attr = m.item(index);
226
                        newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
227
                    }
228
                    copyDocument(doc,oldElement,(Element)newNode);
229
                    break;
230
                case Node.TEXT_NODE:
231
                    Text oldText = (Text) node;
232
                    newNode = doc.createTextNode(oldText.getData());
233
                    break;
234
                case Node.COMMENT_NODE:
235
                    Comment oldComment = (Comment) node;
236
                    newNode = doc.createComment(oldComment.getData());
237
                    break;
238
            }
239
            if (newNode != null) {
240
                to.appendChild (newNode);
241
            }
242
        }
243
    }
244
245
    /**
246
     * Extract nested text from a node.
247
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
248
     * @param parent a parent node
249
     * @return the nested text, or null if none was found
250
     */
251
    private static String findText(Node parent) {
252
        NodeList l = parent.getChildNodes();
253
        for (int i = 0; i < l.getLength(); i++) {
254
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
255
                Text text = (Text)l.item(i);
256
                return text.getNodeValue();
257
            }
258
        }
259
        return null;
260
    }
261
262
    
263
    public EditableProperties getUpdatedProjectProperties() {
210
    public EditableProperties getUpdatedProjectProperties() {
264
        return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
211
        return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
265
    }
212
    }
(-)a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/classpath/ClassPathSupportCallbackImpl.java (-15 / +3 lines)
Lines 41-60 Link Here
41
41
42
package org.netbeans.modules.j2ee.earproject.classpath;
42
package org.netbeans.modules.j2ee.earproject.classpath;
43
43
44
import java.util.ArrayList;
45
import java.util.LinkedHashMap;
44
import java.util.LinkedHashMap;
46
import java.util.List;
45
import java.util.List;
47
import java.util.Map;
46
import java.util.Map;
48
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
47
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
49
import org.netbeans.modules.j2ee.common.project.ui.J2EEProjectProperties;
50
import org.netbeans.modules.j2ee.earproject.EarProjectType;
48
import org.netbeans.modules.j2ee.earproject.EarProjectType;
51
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
49
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
50
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.openide.xml.XMLUtil;
53
import org.w3c.dom.Document;
52
import org.w3c.dom.Document;
54
import org.w3c.dom.Element;
53
import org.w3c.dom.Element;
55
import org.w3c.dom.Node;
54
import org.w3c.dom.Node;
56
import org.w3c.dom.NodeList;
55
import org.w3c.dom.NodeList;
57
import org.w3c.dom.Text;
58
56
59
/**
57
/**
60
 * Defines the various class paths for a web project.
58
 * Defines the various class paths for a web project.
Lines 135-142 Link Here
135
                        Element library = (Element) ch.item(i);
133
                        Element library = (Element) ch.item(i);
136
                        Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
134
                        Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
137
                        NodeList pathInEarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_EAR);
135
                        NodeList pathInEarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_EAR);
138
                        earIncludesMap.put(findText(webFile), pathInEarElements.getLength() > 0 ?
136
                        earIncludesMap.put(XMLUtil.findText(webFile), pathInEarElements.getLength() > 0 ?
139
                            findText(pathInEarElements.item(0)) : null);
137
                            XMLUtil.findText(pathInEarElements.item(0)) : null);
140
                    }
138
                    }
141
                }
139
                }
142
            }
140
            }
Lines 144-158 Link Here
144
        return earIncludesMap;
142
        return earIncludesMap;
145
    }
143
    }
146
144
147
    private static String findText(Node parent) {
148
        NodeList l = parent.getChildNodes();
149
        for (int i = 0; i < l.getLength(); i++) {
150
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
151
                Text text = (Text)l.item(i);
152
                return text.getNodeValue();
153
            }
154
        }
155
        return null;
156
    }
157
}
145
}
158
146
(-)a/j2ee.ejbjarproject/nbproject/project.xml (-1 / +10 lines)
Lines 450-456 Link Here
450
                    <build-prerequisite/>
450
                    <build-prerequisite/>
451
                    <compile-dependency/>
451
                    <compile-dependency/>
452
                    <run-dependency>
452
                    <run-dependency>
453
                        <specification-version>8.0</specification-version>
453
                        <specification-version>8.3</specification-version>
454
                    </run-dependency>
454
                    </run-dependency>
455
                </dependency>
455
                </dependency>
456
                <dependency>
456
                <dependency>
Lines 474-479 Link Here
474
                <test-type>
474
                <test-type>
475
                    <name>unit</name>
475
                    <name>unit</name>
476
                    <test-dependency>
476
                    <test-dependency>
477
                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
478
                        <compile-dependency/>
479
                    </test-dependency>
480
                    <test-dependency>
477
                        <code-name-base>org.netbeans.modules.j2ee.ejbjarproject</code-name-base>
481
                        <code-name-base>org.netbeans.modules.j2ee.ejbjarproject</code-name-base>
478
                        <recursive/>
482
                        <recursive/>
479
                        <compile-dependency/>
483
                        <compile-dependency/>
Lines 482-487 Link Here
482
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
486
                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
483
                    </test-dependency>
487
                    </test-dependency>
484
                    <test-dependency>
488
                    <test-dependency>
489
                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
490
                        <recursive/>
491
                        <compile-dependency/>
492
                    </test-dependency>
493
                    <test-dependency>
485
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
494
                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
486
                    </test-dependency>
495
                    </test-dependency>
487
                    <test-dependency>
496
                    <test-dependency>
(-)a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/EjbJarProject.java (-28 / +2 lines)
Lines 172-177 Link Here
172
import org.openide.filesystems.FileStateInvalidException;
172
import org.openide.filesystems.FileStateInvalidException;
173
import org.openide.filesystems.FileSystem.AtomicAction;
173
import org.openide.filesystems.FileSystem.AtomicAction;
174
import org.openide.util.Exceptions;
174
import org.openide.util.Exceptions;
175
import org.openide.xml.XMLUtil;
175
176
176
/**
177
/**
177
 * Represents one ejb module project
178
 * Represents one ejb module project
Lines 627-633 Link Here
627
        if (element != null) {
628
        if (element != null) {
628
            Document doc = element.getOwnerDocument();
629
            Document doc = element.getOwnerDocument();
629
            Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
630
            Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
630
            copyDocument (doc, element, newRoot);
631
            XMLUtil.copyDocument (element, newRoot, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
631
            Element srcRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots");  //NOI18N
632
            Element srcRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "source-roots");  //NOI18N
632
            Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
633
            Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root");   //NOI18N
633
            root.setAttribute ("id","src.dir");   //NOI18N
634
            root.setAttribute ("id","src.dir");   //NOI18N
Lines 643-675 Link Here
643
        }
644
        }
644
    }
645
    }
645
646
646
    private static void copyDocument (Document doc, Element from, Element to) {
647
        NodeList nl = from.getChildNodes();
648
        int length = nl.getLength();
649
        for (int i=0; i< length; i++) {
650
            Node node = nl.item (i);
651
            Node newNode = null;
652
            switch (node.getNodeType()) {
653
                case Node.ELEMENT_NODE:
654
                    Element oldElement = (Element) node;
655
                    newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
656
                    copyDocument(doc,oldElement,(Element)newNode);
657
                    break;
658
                case Node.TEXT_NODE:
659
                    Text oldText = (Text) node;
660
                    newNode = doc.createTextNode(oldText.getData());
661
                    break;
662
                case Node.COMMENT_NODE:
663
                    Comment oldComment = (Comment) node;
664
                    newNode = doc.createComment(oldComment.getData());
665
                    break;
666
            }
667
            if (newNode != null) {
668
                to.appendChild (newNode);
669
            }
670
        }
671
    }
672
673
    public void fileAttributeChanged (org.openide.filesystems.FileAttributeEvent fe) {
647
    public void fileAttributeChanged (org.openide.filesystems.FileAttributeEvent fe) {
674
    }    
648
    }    
675
    
649
    
(-)a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/UpdateProjectImpl.java (-56 / +3 lines)
Lines 59-71 Link Here
59
import org.openide.filesystems.FileUtil;
59
import org.openide.filesystems.FileUtil;
60
import org.openide.util.Mutex;
60
import org.openide.util.Mutex;
61
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
62
import org.w3c.dom.Comment;
62
import org.openide.xml.XMLUtil;
63
import org.w3c.dom.Document;
63
import org.w3c.dom.Document;
64
import org.w3c.dom.Element;
64
import org.w3c.dom.Element;
65
import org.w3c.dom.NamedNodeMap;
66
import org.w3c.dom.Node;
65
import org.w3c.dom.Node;
67
import org.w3c.dom.NodeList;
66
import org.w3c.dom.NodeList;
68
import org.w3c.dom.Text;
69
67
70
/**
68
/**
71
 *
69
 *
Lines 191-197 Link Here
191
            if (oldRoot != null) {
189
            if (oldRoot != null) {
192
                Document doc = oldRoot.getOwnerDocument();
190
                Document doc = oldRoot.getOwnerDocument();
193
                Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
191
                Element newRoot = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
194
                copyDocument (doc, oldRoot, newRoot);
192
                XMLUtil.copyDocument (oldRoot, newRoot, EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE);
195
                if(version == 1) {
193
                if(version == 1) {
196
                    //1=>2 upgrade
194
                    //1=>2 upgrade
197
                    Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
195
                    Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
Lines 211-217 Link Here
211
                    for (int i = 0; i < libList.getLength(); i++) {
209
                    for (int i = 0; i < libList.getLength(); i++) {
212
                        if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
210
                        if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) {
213
                            Element library = (Element) libList.item(i);
211
                            Element library = (Element) libList.item(i);
214
                            String fileText = findText(library);
212
                            String fileText = XMLUtil.findText(library);
215
                            if (fileText.startsWith ("libs.")) {
213
                            if (fileText.startsWith ("libs.")) {
216
                                String libName = fileText.substring(6, fileText.indexOf(".classpath")); //NOI18N
214
                                String libName = fileText.substring(6, fileText.indexOf(".classpath")); //NOI18N
217
                                List/*<URL>*/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
215
                                List/*<URL>*/ roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N
Lines 253-292 Link Here
253
        return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
251
        return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
254
    }
252
    }
255
253
256
    private static void copyDocument (Document doc, Element from, Element to) {
257
        NodeList nl = from.getChildNodes();
258
        int length = nl.getLength();
259
        for (int i=0; i< length; i++) {
260
            Node node = nl.item (i);
261
            Node newNode = null;
262
            switch (node.getNodeType()) {
263
                case Node.ELEMENT_NODE:
264
                    Element oldElement = (Element) node;
265
                    newNode = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
266
                    //copy attributes
267
                    NamedNodeMap m = oldElement.getAttributes();
268
                    Element newElement = (Element) newNode;
269
                    for (int index = 0; index < m.getLength(); index++) {
270
                        Node attr = m.item(index);
271
                        newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
272
                    }
273
                    copyDocument(doc,oldElement,(Element)newNode);
274
                    break;
275
                case Node.TEXT_NODE:
276
                    Text oldText = (Text) node;
277
                    newNode = doc.createTextNode(oldText.getData());
278
                    break;
279
                case Node.COMMENT_NODE:
280
                    Comment oldComment = (Comment) node;
281
                    newNode = doc.createComment(oldComment.getData());
282
                    break;
283
            }
284
            if (newNode != null) {
285
                to.appendChild (newNode);
286
            }
287
        }
288
    }
289
    
290
    private static Element updateMinAntVersion (final Element root, final Document doc) {
254
    private static Element updateMinAntVersion (final Element root, final Document doc) {
291
        NodeList list = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
255
        NodeList list = root.getElementsByTagNameNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,MINIMUM_ANT_VERSION_ELEMENT);
292
        if (list.getLength() == 1) {
256
        if (list.getLength() == 1) {
Lines 301-323 Link Here
301
        return root;
265
        return root;
302
    }
266
    }
303
    
267
    
304
    /**
305
     * Extract nested text from a node.
306
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
307
     * @param parent a parent node
308
     * @return the nested text, or null if none was found
309
     */
310
    private static String findText(Node parent) {
311
        NodeList l = parent.getChildNodes();
312
        for (int i = 0; i < l.getLength(); i++) {
313
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
314
                Text text = (Text)l.item(i);
315
                return text.getNodeValue();
316
            }
317
        }
318
        return null;
319
    }
320
    
321
    private boolean showUpdateDialog() {
268
    private boolean showUpdateDialog() {
322
        return DialogDisplayer.getDefault().notify(
269
        return DialogDisplayer.getDefault().notify(
323
            new NotifyDescriptor.Confirmation (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate",BUILD_NUMBER),
270
            new NotifyDescriptor.Confirmation (NbBundle.getMessage(UpdateProjectImpl.class,"TXT_ProjectUpdate",BUILD_NUMBER),
(-)a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/classpath/ClassPathSupportCallbackImpl.java (-79 / +3 lines)
Lines 42-50 Link Here
42
package org.netbeans.modules.j2ee.ejbjarproject.classpath;
42
package org.netbeans.modules.j2ee.ejbjarproject.classpath;
43
43
44
import java.util.ArrayList;
44
import java.util.ArrayList;
45
import java.util.Arrays;
46
import java.util.HashMap;
45
import java.util.HashMap;
47
import java.util.Iterator;
48
import java.util.List;
46
import java.util.List;
49
import java.util.Map;
47
import java.util.Map;
50
import org.netbeans.modules.j2ee.common.Util;
48
import org.netbeans.modules.j2ee.common.Util;
Lines 55-63 Link Here
55
import org.w3c.dom.Element;
53
import org.w3c.dom.Element;
56
import org.w3c.dom.Node;
54
import org.w3c.dom.Node;
57
import org.w3c.dom.NodeList;
55
import org.w3c.dom.NodeList;
58
import org.w3c.dom.Text;
59
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
56
import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
60
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
57
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
58
import org.openide.xml.XMLUtil;
61
59
62
/**
60
/**
63
 *
61
 *
Lines 95-101 Link Here
95
        for ( int i = 0; i < libs.getLength(); i++ ) {
93
        for ( int i = 0; i < libs.getLength(); i++ ) {
96
            Element item = (Element)libs.item( i );
94
            Element item = (Element)libs.item( i );
97
            // ejbjar is different from other j2ee projects - it stores reference without ${ and }
95
            // ejbjar is different from other j2ee projects - it stores reference without ${ and }
98
            String ref = "${"+findText( item )+"}";
96
            String ref = "${"+XMLUtil.findText( item )+"}";
99
            libraries.add(ref); // NOI18N
97
            libraries.add(ref); // NOI18N
100
            String dirs = item.getAttribute(ATTR_DIRS);
98
            String dirs = item.getAttribute(ATTR_DIRS);
101
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
99
            if (Util.DESTINATION_DIRECTORY_ROOT.equals(dirs) ||
Lines 125-131 Link Here
125
        Document doc = data.getOwnerDocument();
123
        Document doc = data.getOwnerDocument();
126
        for (ClassPathSupport.Item item : classpath) {
124
        for (ClassPathSupport.Item item : classpath) {
127
            if("true".equals(item.getAdditionalProperty(INCLUDE_IN_DEPLOYMENT))) { // NOI18N
125
            if("true".equals(item.getAdditionalProperty(INCLUDE_IN_DEPLOYMENT))) { // NOI18N
128
                appendChildElement(data, 
126
                XMLUtil.appendChildElement(data,
129
                    createLibraryElement(antProjectHelper, doc, item, includedLibrariesElement), 
127
                    createLibraryElement(antProjectHelper, doc, item, includedLibrariesElement), 
130
                    ejbjarElemOrder);
128
                    ejbjarElemOrder);
131
            }
129
            }
Lines 134-195 Link Here
134
        antProjectHelper.putPrimaryConfigurationData( data, true );
132
        antProjectHelper.putPrimaryConfigurationData( data, true );
135
    }
133
    }
136
    
134
    
137
    /**
138
     * Find all direct child elements of an element.
139
     * More useful than {@link Element#getElementsByTagNameNS} because it does
140
     * not recurse into recursive child elements.
141
     * Children which are all-whitespace text nodes are ignored; others cause
142
     * an exception to be thrown.
143
     * @param parent a parent element in a DOM tree
144
     * @return a list of direct child elements (may be empty)
145
     * @throws IllegalArgumentException if there are non-element children besides whitespace
146
     */
147
    private static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
148
        NodeList l = parent.getChildNodes();
149
        List<Element> elements = new ArrayList<Element>(l.getLength());
150
        for (int i = 0; i < l.getLength(); i++) {
151
            Node n = l.item(i);
152
            if (n.getNodeType() == Node.ELEMENT_NODE) {
153
                elements.add((Element)n);
154
            } else if (n.getNodeType() == Node.TEXT_NODE) {
155
                String text = ((Text)n).getNodeValue();
156
                if (text.trim().length() > 0) {
157
                    throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
158
                }
159
            } else if (n.getNodeType() == Node.COMMENT_NODE) {
160
                // skip
161
            } else {
162
                throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
163
            }
164
        }
165
        return elements;
166
    }
167
    
168
    /**
169
     * Append child element to the correct position according to given
170
     * order.
171
     * @param parent parent to which the child will be added
172
     * @param el element to be added
173
     * @param order order of the elements which must be followed
174
     */
175
    private static void appendChildElement(Element parent, Element el, String[] order) {
176
        Element insertBefore = null;
177
        List l = Arrays.asList(order);
178
        int index = l.indexOf(el.getLocalName());
179
        assert index != -1 : el.getLocalName()+" was not found in "+l; // NOI18N
180
        Iterator it = findSubElements(parent).iterator();
181
        while (it.hasNext()) {
182
            Element e = (Element)it.next();
183
            int index2 = l.indexOf(e.getLocalName());
184
            assert index2 != -1 : e.getLocalName()+" was not found in "+l; // NOI18N
185
            if (index2 > index) {
186
                insertBefore = e;
187
                break;
188
            }
189
        }
190
        parent.insertBefore(el, insertBefore);
191
    }
192
        
193
    private static Element createLibraryElement(AntProjectHelper antProjectHelper, Document doc, Item item, String includedLibrariesElement) {
135
    private static Element createLibraryElement(AntProjectHelper antProjectHelper, Document doc, Item item, String includedLibrariesElement) {
194
        Element libraryElement = doc.createElementNS( EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, includedLibrariesElement );
136
        Element libraryElement = doc.createElementNS( EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, includedLibrariesElement );
195
        // ejbjar is different from other j2ee projects - it stores reference without ${ and }
137
        // ejbjar is different from other j2ee projects - it stores reference without ${ and }
Lines 198-221 Link Here
198
        return libraryElement;
140
        return libraryElement;
199
    }
141
    }
200
       
142
       
201
    /**
202
     * Extracts <b>the first</b> nested text from an element.
203
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
204
     * @param parent a parent element
205
     * @return the nested text, or null if none was found
206
     */
207
    private static String findText( Element parent ) {
208
        NodeList l = parent.getChildNodes();
209
        for ( int i = 0; i < l.getLength(); i++ ) {
210
            if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
211
                Text text = (Text)l.item( i );
212
                return text.getNodeValue();
213
            }
214
        }
215
        return null;
216
    }
217
        
218
219
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
143
    public void readAdditionalProperties(List<Item> items, String projectXMLElement) {
220
        Map<String, String> destination = new HashMap<String, String>();
144
        Map<String, String> destination = new HashMap<String, String>();
221
        List<String> l = getIncludedLibraries(helper, projectXMLElement, destination);
145
        List<String> l = getIncludedLibraries(helper, projectXMLElement, destination);
(-)a/java.freeform/nbproject/project.xml (-1 / +1 lines)
Lines 200-206 Link Here
200
                    <build-prerequisite/>
200
                    <build-prerequisite/>
201
                    <compile-dependency/>
201
                    <compile-dependency/>
202
                    <run-dependency>
202
                    <run-dependency>
203
                        <specification-version>8.0</specification-version>
203
                        <specification-version>8.3</specification-version>
204
                    </run-dependency>
204
                    </run-dependency>
205
                </dependency>
205
                </dependency>
206
                <dependency>
206
                <dependency>
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/Classpaths.java (-22 / +23 lines)
Lines 89-94 Link Here
89
import org.openide.util.Mutex;
89
import org.openide.util.Mutex;
90
import org.openide.util.Utilities;
90
import org.openide.util.Utilities;
91
import org.openide.util.WeakListeners;
91
import org.openide.util.WeakListeners;
92
import org.openide.xml.XMLUtil;
92
import org.w3c.dom.Element;
93
import org.w3c.dom.Element;
93
94
94
/**
95
/**
Lines 193-199 Link Here
193
        if (java == null) {
194
        if (java == null) {
194
            return null;
195
            return null;
195
        }
196
        }
196
        List<Element> compilationUnits = Util.findSubElements(java);
197
        List<Element> compilationUnits = XMLUtil.findSubElements(java);
197
        it = compilationUnits.iterator();
198
        it = compilationUnits.iterator();
198
        while (it.hasNext()) {
199
        while (it.hasNext()) {
199
            Element compilationUnitEl = (Element)it.next();
200
            Element compilationUnitEl = (Element)it.next();
Lines 258-264 Link Here
258
            if (java == null) {
259
            if (java == null) {
259
                return;
260
                return;
260
            }
261
            }
261
            for (Element compilationUnitEl : Util.findSubElements(java)) {
262
            for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
262
                assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
263
                assert compilationUnitEl.getLocalName().equals("compilation-unit") : compilationUnitEl;
263
                // For each compilation unit, find the package roots first.
264
                // For each compilation unit, find the package roots first.
264
                List<FileObject> packageRoots = findPackageRoots(helper, evaluator, compilationUnitEl);
265
                List<FileObject> packageRoots = findPackageRoots(helper, evaluator, compilationUnitEl);
Lines 337-349 Link Here
337
    
338
    
338
    static List<String> findPackageRootNames(Element compilationUnitEl) {
339
    static List<String> findPackageRootNames(Element compilationUnitEl) {
339
        List<String> names = new ArrayList<String>();
340
        List<String> names = new ArrayList<String>();
340
        Iterator it = Util.findSubElements(compilationUnitEl).iterator();
341
        Iterator it = XMLUtil.findSubElements(compilationUnitEl).iterator();
341
        while (it.hasNext()) {
342
        while (it.hasNext()) {
342
            Element e = (Element) it.next();
343
            Element e = (Element) it.next();
343
            if (!e.getLocalName().equals("package-root")) { // NOI18N
344
            if (!e.getLocalName().equals("package-root")) { // NOI18N
344
                continue;
345
                continue;
345
            }
346
            }
346
            String location = Util.findText(e);
347
            String location = XMLUtil.findText(e);
347
            names.add(location);
348
            names.add(location);
348
        }
349
        }
349
        return names;
350
        return names;
Lines 421-427 Link Here
421
    }
422
    }
422
    
423
    
423
    private List<URL> createCompileClasspath(Element compilationUnitEl) {
424
    private List<URL> createCompileClasspath(Element compilationUnitEl) {
424
        for (Element e : Util.findSubElements(compilationUnitEl)) {
425
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
425
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("compile")) { // NOI18N
426
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("compile")) { // NOI18N
426
                return createClasspath(e);
427
                return createClasspath(e);
427
            }
428
            }
Lines 434-440 Link Here
434
     * Create a classpath from a &lt;classpath&gt; element.
435
     * Create a classpath from a &lt;classpath&gt; element.
435
     */
436
     */
436
    private List<URL> createClasspath(Element classpathEl) {
437
    private List<URL> createClasspath(Element classpathEl) {
437
        String cp = Util.findText(classpathEl);
438
        String cp = XMLUtil.findText(classpathEl);
438
        if (cp == null) {
439
        if (cp == null) {
439
            cp = "";
440
            cp = "";
440
        }
441
        }
Lines 456-462 Link Here
456
    }
457
    }
457
    
458
    
458
    private List<URL> createExecuteClasspath(List<String> packageRoots, Element compilationUnitEl) {
459
    private List<URL> createExecuteClasspath(List<String> packageRoots, Element compilationUnitEl) {
459
        for (Element e : Util.findSubElements(compilationUnitEl)) {
460
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
460
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
461
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
461
                return createClasspath(e);
462
                return createClasspath(e);
462
            }
463
            }
Lines 466-477 Link Here
466
        List<URL> urls = new ArrayList<URL>();
467
        List<URL> urls = new ArrayList<URL>();
467
        urls.addAll(createCompileClasspath(compilationUnitEl));
468
        urls.addAll(createCompileClasspath(compilationUnitEl));
468
        boolean foundBuiltTos = false;
469
        boolean foundBuiltTos = false;
469
        for (Element builtTo : Util.findSubElements(compilationUnitEl)) {
470
        for (Element builtTo : XMLUtil.findSubElements(compilationUnitEl)) {
470
            if (!builtTo.getLocalName().equals("built-to")) { // NOI18N
471
            if (!builtTo.getLocalName().equals("built-to")) { // NOI18N
471
                continue;
472
                continue;
472
            }
473
            }
473
            foundBuiltTos = true;
474
            foundBuiltTos = true;
474
            String rawtext = Util.findText(builtTo);
475
            String rawtext = XMLUtil.findText(builtTo);
475
            assert rawtext != null : "Must have nonempty text inside <built-to>";
476
            assert rawtext != null : "Must have nonempty text inside <built-to>";
476
            String text = evaluator.evaluate(rawtext);
477
            String text = evaluator.evaluate(rawtext);
477
            if (text == null) {
478
            if (text == null) {
Lines 486-492 Link Here
486
    }
487
    }
487
    
488
    
488
    private List<URL> createProcessorClasspath(Element compilationUnitEl) {
489
    private List<URL> createProcessorClasspath(Element compilationUnitEl) {
489
        for (Element e : Util.findSubElements(compilationUnitEl)) {
490
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
490
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("processor")) { // NOI18N
491
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("processor")) { // NOI18N
491
                return createClasspath(e);
492
                return createClasspath(e);
492
            }
493
            }
Lines 496-502 Link Here
496
    }
497
    }
497
498
498
    private List<URL> createBootClasspath(Element compilationUnitEl) {
499
    private List<URL> createBootClasspath(Element compilationUnitEl) {
499
        for (Element e : Util.findSubElements(compilationUnitEl)) {
500
        for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
500
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("boot")) { // NOI18N
501
            if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("boot")) { // NOI18N
501
                return createClasspath(e);
502
                return createClasspath(e);
502
            }
503
            }
Lines 571-577 Link Here
571
            if (java == null) {
572
            if (java == null) {
572
                return null;
573
                return null;
573
            }
574
            }
574
            List<Element> compilationUnits = Util.findSubElements(java);
575
            List<Element> compilationUnits = XMLUtil.findSubElements(java);
575
            Iterator it = compilationUnits.iterator();
576
            Iterator it = compilationUnits.iterator();
576
            while (it.hasNext()) {
577
            while (it.hasNext()) {
577
                Element compilationUnitEl = (Element)it.next();
578
                Element compilationUnitEl = (Element)it.next();
Lines 680-707 Link Here
680
                rootFolder = null;
681
                rootFolder = null;
681
            }
682
            }
682
            Element genldata = Util.getPrimaryConfigurationData(helper);
683
            Element genldata = Util.getPrimaryConfigurationData(helper);
683
            Element foldersE = Util.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
684
            Element foldersE = XMLUtil.findElement(genldata, "folders", Util.NAMESPACE); // NOI18N
684
            if (foldersE != null) {
685
            if (foldersE != null) {
685
                for (Element folderE : Util.findSubElements(foldersE)) {
686
                for (Element folderE : XMLUtil.findSubElements(foldersE)) {
686
                    if (folderE.getLocalName().equals("source-folder")) {
687
                    if (folderE.getLocalName().equals("source-folder")) {
687
                        Element typeE = Util.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
688
                        Element typeE = XMLUtil.findElement(folderE, "type", Util.NAMESPACE); // NOI18N
688
                        if (typeE != null) {
689
                        if (typeE != null) {
689
                            String type = Util.findText(typeE);
690
                            String type = XMLUtil.findText(typeE);
690
                            if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
691
                            if (type.equals(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
691
                                Element locationE = Util.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
692
                                Element locationE = XMLUtil.findElement(folderE, "location", Util.NAMESPACE); // NOI18N
692
                                String location = evaluator.evaluate(Util.findText(locationE));
693
                                String location = evaluator.evaluate(XMLUtil.findText(locationE));
693
                                if (location != null && helper.resolveFile(location).equals(rootFolder)) {
694
                                if (location != null && helper.resolveFile(location).equals(rootFolder)) {
694
                                    Element includesE = Util.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
695
                                    Element includesE = XMLUtil.findElement(folderE, "includes", Util.NAMESPACE); // NOI18N
695
                                    if (includesE != null) {
696
                                    if (includesE != null) {
696
                                        incl = evaluator.evaluate(Util.findText(includesE));
697
                                        incl = evaluator.evaluate(XMLUtil.findText(includesE));
697
                                        if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
698
                                        if (incl != null && incl.matches("\\$\\{[^}]+\\}")) { // NOI18N
698
                                            // Clearly intended to mean "include everything".
699
                                            // Clearly intended to mean "include everything".
699
                                            incl = null;
700
                                            incl = null;
700
                                        }
701
                                        }
701
                                    }
702
                                    }
702
                                    Element excludesE = Util.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
703
                                    Element excludesE = XMLUtil.findElement(folderE, "excludes", Util.NAMESPACE); // NOI18N
703
                                    if (excludesE != null) {
704
                                    if (excludesE != null) {
704
                                        excl = evaluator.evaluate(Util.findText(excludesE));
705
                                        excl = evaluator.evaluate(XMLUtil.findText(excludesE));
705
                                    }
706
                                    }
706
                                }
707
                                }
707
                            }
708
                            }
(-)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_3);
748
            Element sourceLevel = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
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 (-66 / +67 lines)
Lines 60-65 Link Here
60
import org.openide.filesystems.FileUtil;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.modules.SpecificationVersion;
61
import org.openide.modules.SpecificationVersion;
62
import org.openide.util.Exceptions;
62
import org.openide.util.Exceptions;
63
import org.openide.xml.XMLUtil;
63
import org.w3c.dom.Document;
64
import org.w3c.dom.Document;
64
import org.w3c.dom.Element;
65
import org.w3c.dom.Element;
65
66
Lines 113-150 Link Here
113
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
114
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
114
        List<SourceFolder> list = new ArrayList<SourceFolder>();
115
        List<SourceFolder> list = new ArrayList<SourceFolder>();
115
        Element data = Util.getPrimaryConfigurationData(helper);
116
        Element data = Util.getPrimaryConfigurationData(helper);
116
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
117
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
117
        if (foldersEl == null) {
118
        if (foldersEl == null) {
118
            return list;
119
            return list;
119
        }
120
        }
120
        for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
121
        for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
121
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
122
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
122
                continue;
123
                continue;
123
            }
124
            }
124
            SourceFolder sf = new SourceFolder();
125
            SourceFolder sf = new SourceFolder();
125
            Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
126
            Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
126
            if (el != null) {
127
            if (el != null) {
127
                sf.label = Util.findText(el);
128
                sf.label = XMLUtil.findText(el);
128
            }
129
            }
129
            el = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
130
            el = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
130
            if (el != null) {
131
            if (el != null) {
131
                sf.type = Util.findText(el);
132
                sf.type = XMLUtil.findText(el);
132
            }
133
            }
133
            el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
134
            el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
134
            if (el != null) {
135
            if (el != null) {
135
                sf.location = Util.findText(el);
136
                sf.location = XMLUtil.findText(el);
136
            }
137
            }
137
            el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
138
            el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
138
            if (el != null) {
139
            if (el != null) {
139
                sf.includes = Util.findText(el);
140
                sf.includes = XMLUtil.findText(el);
140
            }
141
            }
141
            el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
142
            el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
142
            if (el != null) {
143
            if (el != null) {
143
                sf.excludes = Util.findText(el);
144
                sf.excludes = XMLUtil.findText(el);
144
            }
145
            }
145
            el = Util.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
146
            el = XMLUtil.findElement(sourceFolderEl, "encoding", Util.NAMESPACE); // NOI18N
146
            if (el != null) {
147
            if (el != null) {
147
                sf.encoding = Util.findText(el);
148
                sf.encoding = XMLUtil.findText(el);
148
            }
149
            }
149
            if (type == null || type.equals(sf.type)) {
150
            if (type == null || type.equals(sf.type)) {
150
                if (sf.label == null || sf.label.length() == 0) {
151
                if (sf.label == null || sf.label.length() == 0) {
Lines 173-193 Link Here
173
        //assert ProjectManager.mutex().isWriteAccess();
174
        //assert ProjectManager.mutex().isWriteAccess();
174
        Element data = Util.getPrimaryConfigurationData(helper);
175
        Element data = Util.getPrimaryConfigurationData(helper);
175
        Document doc = data.getOwnerDocument();
176
        Document doc = data.getOwnerDocument();
176
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
177
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
177
        if (foldersEl == null) {
178
        if (foldersEl == null) {
178
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
179
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
179
            Util.appendChildElement(data, foldersEl, rootElementsOrder);
180
            XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
180
        } else {
181
        } else {
181
            for (Element sourceFolderEl : Util.findSubElements(foldersEl)) {
182
            for (Element sourceFolderEl : XMLUtil.findSubElements(foldersEl)) {
182
                if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
183
                if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
183
                    continue;
184
                    continue;
184
                }
185
                }
185
                if (type == null) {
186
                if (type == null) {
186
                    foldersEl.removeChild(sourceFolderEl);
187
                    foldersEl.removeChild(sourceFolderEl);
187
                } else {
188
                } else {
188
                    Element typeEl = Util.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
189
                    Element typeEl = XMLUtil.findElement(sourceFolderEl, "type", Util.NAMESPACE); // NOI18N
189
                    if (typeEl != null) {
190
                    if (typeEl != null) {
190
                        String typeElValue = Util.findText(typeEl);
191
                        String typeElValue = XMLUtil.findText(typeEl);
191
                        if (type.equals(typeElValue)) {
192
                        if (type.equals(typeElValue)) {
192
                            foldersEl.removeChild(sourceFolderEl);
193
                            foldersEl.removeChild(sourceFolderEl);
193
                        }
194
                        }
Lines 232-238 Link Here
232
                el.appendChild(doc.createTextNode(sf.encoding)); // NOI18N
233
                el.appendChild(doc.createTextNode(sf.encoding)); // NOI18N
233
                sourceFolderEl.appendChild(el);
234
                sourceFolderEl.appendChild(el);
234
            }
235
            }
235
            Util.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
236
            XMLUtil.appendChildElement(foldersEl, sourceFolderEl, folderElementsOrder);
236
        }
237
        }
237
        Util.putPrimaryConfigurationData(helper, data);
238
        Util.putPrimaryConfigurationData(helper, data);
238
    }
239
    }
Lines 249-284 Link Here
249
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
250
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
250
        List<SourceFolder> list = new ArrayList<SourceFolder>();
251
        List<SourceFolder> list = new ArrayList<SourceFolder>();
251
        Element data = Util.getPrimaryConfigurationData(helper);
252
        Element data = Util.getPrimaryConfigurationData(helper);
252
        Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
253
        Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
253
        if (viewEl == null) {
254
        if (viewEl == null) {
254
            return list;
255
            return list;
255
        }
256
        }
256
        Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
257
        Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
257
        if (itemsEl == null) {
258
        if (itemsEl == null) {
258
            return list;
259
            return list;
259
        }
260
        }
260
        for (Element sourceFolderEl : Util.findSubElements(itemsEl)) {
261
        for (Element sourceFolderEl : XMLUtil.findSubElements(itemsEl)) {
261
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
262
            if (!sourceFolderEl.getLocalName().equals("source-folder")) { // NOI18N
262
                continue;
263
                continue;
263
            }
264
            }
264
            SourceFolder sf = new SourceFolder();
265
            SourceFolder sf = new SourceFolder();
265
            sf.style = sourceFolderEl.getAttribute("style"); // NOI18N
266
            sf.style = sourceFolderEl.getAttribute("style"); // NOI18N
266
            assert sf.style != null && sf.style.length() > 0 : "Bad style attr on <source-folder> in " + helper; // NOI18N
267
            assert sf.style != null && sf.style.length() > 0 : "Bad style attr on <source-folder> in " + helper; // NOI18N
267
            Element el = Util.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
268
            Element el = XMLUtil.findElement(sourceFolderEl, "label", Util.NAMESPACE); // NOI18N
268
            if (el != null) {
269
            if (el != null) {
269
                sf.label = Util.findText(el);
270
                sf.label = XMLUtil.findText(el);
270
            }
271
            }
271
            el = Util.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
272
            el = XMLUtil.findElement(sourceFolderEl, "location", Util.NAMESPACE); // NOI18N
272
            if (el != null) {
273
            if (el != null) {
273
                sf.location = Util.findText(el);
274
                sf.location = XMLUtil.findText(el);
274
            }
275
            }
275
            el = Util.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
276
            el = XMLUtil.findElement(sourceFolderEl, "includes", Util.NAMESPACE); // NOI18N
276
            if (el != null) {
277
            if (el != null) {
277
                sf.includes = Util.findText(el);
278
                sf.includes = XMLUtil.findText(el);
278
            }
279
            }
279
            el = Util.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
280
            el = XMLUtil.findElement(sourceFolderEl, "excludes", Util.NAMESPACE); // NOI18N
280
            if (el != null) {
281
            if (el != null) {
281
                sf.excludes = Util.findText(el);
282
                sf.excludes = XMLUtil.findText(el);
282
            }
283
            }
283
            if (style == null || style.equals(sf.style)) {
284
            if (style == null || style.equals(sf.style)) {
284
                list.add(sf);
285
                list.add(sf);
Lines 303-319 Link Here
303
        ArrayList list = new ArrayList();
304
        ArrayList list = new ArrayList();
304
        Element data = Util.getPrimaryConfigurationData(helper);
305
        Element data = Util.getPrimaryConfigurationData(helper);
305
        Document doc = data.getOwnerDocument();
306
        Document doc = data.getOwnerDocument();
306
        Element viewEl = Util.findElement(data, "view", Util.NAMESPACE); // NOI18N
307
        Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
307
        if (viewEl == null) {
308
        if (viewEl == null) {
308
            viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
309
            viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
309
            Util.appendChildElement(data, viewEl, rootElementsOrder);
310
            XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
310
        }
311
        }
311
        Element itemsEl = Util.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
312
        Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
312
        if (itemsEl == null) {
313
        if (itemsEl == null) {
313
            itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
314
            itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
314
            Util.appendChildElement(viewEl, itemsEl, viewElementsOrder);
315
            XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
315
        }
316
        }
316
        List<Element> sourceViews = Util.findSubElements(itemsEl);
317
        List<Element> sourceViews = XMLUtil.findSubElements(itemsEl);
317
        Iterator it = sourceViews.iterator();
318
        Iterator it = sourceViews.iterator();
318
        while (it.hasNext()) {
319
        while (it.hasNext()) {
319
            Element sourceViewEl = (Element)it.next();
320
            Element sourceViewEl = (Element)it.next();
Lines 355-361 Link Here
355
                el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
356
                el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
356
                sourceFolderEl.appendChild(el);
357
                sourceFolderEl.appendChild(el);
357
            }
358
            }
358
            Util.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
359
            XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
359
        }
360
        }
360
        Util.putPrimaryConfigurationData(helper, data);
361
        Util.putPrimaryConfigurationData(helper, data);
361
    }
362
    }
Lines 390-409 Link Here
390
        if (data == null) {
391
        if (data == null) {
391
            return list;
392
            return list;
392
        }
393
        }
393
        for (Element cuEl : Util.findSubElements(data)) {
394
        for (Element cuEl : XMLUtil.findSubElements(data)) {
394
            JavaCompilationUnit cu = new JavaCompilationUnit();
395
            JavaCompilationUnit cu = new JavaCompilationUnit();
395
            List<String> outputs = new ArrayList<String>();
396
            List<String> outputs = new ArrayList<String>();
396
            List<String> javadoc = new ArrayList<String>();
397
            List<String> javadoc = new ArrayList<String>();
397
            List<JavaCompilationUnit.CP> cps = new ArrayList<JavaCompilationUnit.CP>();
398
            List<JavaCompilationUnit.CP> cps = new ArrayList<JavaCompilationUnit.CP>();
398
            List<String> packageRoots = new ArrayList<String>();
399
            List<String> packageRoots = new ArrayList<String>();
399
            for (Element el : Util.findSubElements(cuEl)) {
400
            for (Element el : XMLUtil.findSubElements(cuEl)) {
400
                if (el.getLocalName().equals("package-root")) { // NOI18N
401
                if (el.getLocalName().equals("package-root")) { // NOI18N
401
                    packageRoots.add(Util.findText(el));
402
                    packageRoots.add(XMLUtil.findText(el));
402
                    continue;
403
                    continue;
403
                }
404
                }
404
                if (el.getLocalName().equals("classpath")) { // NOI18N
405
                if (el.getLocalName().equals("classpath")) { // NOI18N
405
                    JavaCompilationUnit.CP cp = new JavaCompilationUnit.CP();
406
                    JavaCompilationUnit.CP cp = new JavaCompilationUnit.CP();
406
                    cp.classpath = Util.findText(el);
407
                    cp.classpath = XMLUtil.findText(el);
407
                    cp.mode = el.getAttribute("mode"); // NOI18N
408
                    cp.mode = el.getAttribute("mode"); // NOI18N
408
                    if (cp.mode != null && cp.classpath != null) {
409
                    if (cp.mode != null && cp.classpath != null) {
409
                        cps.add(cp);
410
                        cps.add(cp);
Lines 411-425 Link Here
411
                    continue;
412
                    continue;
412
                }
413
                }
413
                if (el.getLocalName().equals("built-to")) { // NOI18N
414
                if (el.getLocalName().equals("built-to")) { // NOI18N
414
                    outputs.add(Util.findText(el));
415
                    outputs.add(XMLUtil.findText(el));
415
                    continue;
416
                    continue;
416
                }
417
                }
417
                if (el.getLocalName().equals("javadoc-built-to")) { // NOI18N
418
                if (el.getLocalName().equals("javadoc-built-to")) { // NOI18N
418
                    javadoc.add(Util.findText(el));
419
                    javadoc.add(XMLUtil.findText(el));
419
                    continue;
420
                    continue;
420
                }
421
                }
421
                if (el.getLocalName().equals("source-level")) { // NOI18N
422
                if (el.getLocalName().equals("source-level")) { // NOI18N
422
                    cu.sourceLevel = Util.findText(el);
423
                    cu.sourceLevel = XMLUtil.findText(el);
423
                }
424
                }
424
                if (el.getLocalName().equals("unit-tests")) { // NOI18N
425
                if (el.getLocalName().equals("unit-tests")) { // NOI18N
425
                    cu.isTests = true;
426
                    cu.isTests = true;
Lines 503-509 Link Here
503
            }
504
            }
504
        }
505
        }
505
        Document doc = data.getOwnerDocument();
506
        Document doc = data.getOwnerDocument();
506
        for (Element cuEl : Util.findSubElements(data)) {
507
        for (Element cuEl : XMLUtil.findSubElements(data)) {
507
            data.removeChild(cuEl);
508
            data.removeChild(cuEl);
508
        }
509
        }
509
        for (JavaCompilationUnit cu : compUnits) {
510
        for (JavaCompilationUnit cu : compUnits) {
Lines 656-662 Link Here
656
        ArrayList list = new ArrayList();
657
        ArrayList list = new ArrayList();
657
        Element data = Util.getPrimaryConfigurationData(helper);
658
        Element data = Util.getPrimaryConfigurationData(helper);
658
        Document doc = data.getOwnerDocument();
659
        Document doc = data.getOwnerDocument();
659
        Iterator it = Util.findSubElements(data).iterator();
660
        Iterator it = XMLUtil.findSubElements(data).iterator();
660
        while (it.hasNext()) {
661
        while (it.hasNext()) {
661
            Element exportEl = (Element)it.next();
662
            Element exportEl = (Element)it.next();
662
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
663
            if (!exportEl.getLocalName().equals("export")) { // NOI18N
Lines 688-694 Link Here
688
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
689
                el.appendChild(doc.createTextNode(export.cleanTarget)); // NOI18N
689
                exportEl.appendChild(el);
690
                exportEl.appendChild(el);
690
            }
691
            }
691
            Util.appendChildElement(data, exportEl, rootElementsOrder);
692
            XMLUtil.appendChildElement(data, exportEl, rootElementsOrder);
692
        }
693
        }
693
        Util.putPrimaryConfigurationData(helper, data);
694
        Util.putPrimaryConfigurationData(helper, data);
694
    }
695
    }
Lines 736-747 Link Here
736
        ArrayList list = new ArrayList();
737
        ArrayList list = new ArrayList();
737
        Element data = Util.getPrimaryConfigurationData(helper);
738
        Element data = Util.getPrimaryConfigurationData(helper);
738
        Document doc = data.getOwnerDocument();
739
        Document doc = data.getOwnerDocument();
739
        Element subproject = Util.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
740
        Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
740
        if (subproject != null) {
741
        if (subproject != null) {
741
            data.removeChild(subproject);
742
            data.removeChild(subproject);
742
        }
743
        }
743
        subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
744
        subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
744
        Util.appendChildElement(data, subproject, rootElementsOrder);
745
        XMLUtil.appendChildElement(data, subproject, rootElementsOrder);
745
        
746
        
746
        Iterator it = subprojects.iterator();
747
        Iterator it = subprojects.iterator();
747
        while (it.hasNext()) {
748
        while (it.hasNext()) {
Lines 819-830 Link Here
819
    private static void putBuildElement(AntProjectHelper helper, List<String> buildFolders, String elemName) {
820
    private static void putBuildElement(AntProjectHelper helper, List<String> buildFolders, String elemName) {
820
        Element data = Util.getPrimaryConfigurationData(helper);
821
        Element data = Util.getPrimaryConfigurationData(helper);
821
        Document doc = data.getOwnerDocument();
822
        Document doc = data.getOwnerDocument();
822
        Element foldersEl = Util.findElement(data, "folders", Util.NAMESPACE); // NOI18N
823
        Element foldersEl = XMLUtil.findElement(data, "folders", Util.NAMESPACE); // NOI18N
823
        if (foldersEl == null) {
824
        if (foldersEl == null) {
824
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
825
            foldersEl = doc.createElementNS(Util.NAMESPACE, "folders"); // NOI18N
825
            Util.appendChildElement(data, foldersEl, rootElementsOrder);
826
            XMLUtil.appendChildElement(data, foldersEl, rootElementsOrder);
826
        } else {
827
        } else {
827
            List<Element> folders = Util.findSubElements(foldersEl);
828
            List<Element> folders = XMLUtil.findSubElements(foldersEl);
828
            Iterator it = folders.iterator();
829
            Iterator it = folders.iterator();
829
            while (it.hasNext()) {
830
            while (it.hasNext()) {
830
                Element buildFolderEl = (Element)it.next();
831
                Element buildFolderEl = (Element)it.next();
Lines 841-847 Link Here
841
            Element locationEl = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
842
            Element locationEl = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
842
            locationEl.appendChild(doc.createTextNode(location));
843
            locationEl.appendChild(doc.createTextNode(location));
843
            buildFolderEl.appendChild(locationEl);
844
            buildFolderEl.appendChild(locationEl);
844
            Util.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
845
            XMLUtil.appendChildElement(foldersEl, buildFolderEl, folderElementsOrder);
845
        }
846
        }
846
        Util.putPrimaryConfigurationData(helper, data);
847
        Util.putPrimaryConfigurationData(helper, data);
847
    }
848
    }
Lines 900-946 Link Here
900
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
901
        //assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess();
901
        List<TargetMapping> list = new ArrayList<TargetMapping>();
902
        List<TargetMapping> list = new ArrayList<TargetMapping>();
902
        Element genldata = Util.getPrimaryConfigurationData(helper);
903
        Element genldata = Util.getPrimaryConfigurationData(helper);
903
        Element actionsEl = Util.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
904
        Element actionsEl = XMLUtil.findElement(genldata, "ide-actions", Util.NAMESPACE); // NOI18N
904
        if (actionsEl == null) {
905
        if (actionsEl == null) {
905
            return list;
906
            return list;
906
        }
907
        }
907
        for (Element actionEl : Util.findSubElements(actionsEl)) {
908
        for (Element actionEl : XMLUtil.findSubElements(actionsEl)) {
908
            TargetMapping tm = new TargetMapping();
909
            TargetMapping tm = new TargetMapping();
909
            tm.name = actionEl.getAttribute("name"); // NOI18N
910
            tm.name = actionEl.getAttribute("name"); // NOI18N
910
            List<String> targetNames = new ArrayList<String>();
911
            List<String> targetNames = new ArrayList<String>();
911
            EditableProperties props = new EditableProperties(false);
912
            EditableProperties props = new EditableProperties(false);
912
            for (Element subEl : Util.findSubElements(actionEl)) {
913
            for (Element subEl : XMLUtil.findSubElements(actionEl)) {
913
                if (subEl.getLocalName().equals("target")) { // NOI18N
914
                if (subEl.getLocalName().equals("target")) { // NOI18N
914
                    targetNames.add(Util.findText(subEl));
915
                    targetNames.add(XMLUtil.findText(subEl));
915
                    continue;
916
                    continue;
916
                }
917
                }
917
                if (subEl.getLocalName().equals("script")) { // NOI18N
918
                if (subEl.getLocalName().equals("script")) { // NOI18N
918
                    tm.script = Util.findText(subEl);
919
                    tm.script = XMLUtil.findText(subEl);
919
                    continue;
920
                    continue;
920
                }
921
                }
921
                if (subEl.getLocalName().equals("context")) { // NOI18N
922
                if (subEl.getLocalName().equals("context")) { // NOI18N
922
                    TargetMapping.Context ctx = new TargetMapping.Context();
923
                    TargetMapping.Context ctx = new TargetMapping.Context();
923
                    for (Element contextSubEl : Util.findSubElements(subEl)) {
924
                    for (Element contextSubEl : XMLUtil.findSubElements(subEl)) {
924
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
925
                        if (contextSubEl.getLocalName().equals("property")) { // NOI18N
925
                            ctx.property = Util.findText(contextSubEl);
926
                            ctx.property = XMLUtil.findText(contextSubEl);
926
                            continue;
927
                            continue;
927
                        }
928
                        }
928
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
929
                        if (contextSubEl.getLocalName().equals("format")) { // NOI18N
929
                            ctx.format = Util.findText(contextSubEl);
930
                            ctx.format = XMLUtil.findText(contextSubEl);
930
                            continue;
931
                            continue;
931
                        }
932
                        }
932
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
933
                        if (contextSubEl.getLocalName().equals("folder")) { // NOI18N
933
                            ctx.folder = Util.findText(contextSubEl);
934
                            ctx.folder = XMLUtil.findText(contextSubEl);
934
                            continue;
935
                            continue;
935
                        }
936
                        }
936
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
937
                        if (contextSubEl.getLocalName().equals("pattern")) { // NOI18N
937
                            ctx.pattern = Util.findText(contextSubEl);
938
                            ctx.pattern = XMLUtil.findText(contextSubEl);
938
                            continue;
939
                            continue;
939
                        }
940
                        }
940
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
941
                        if (contextSubEl.getLocalName().equals("arity")) { // NOI18N
941
                            Element sepFilesEl = Util.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
942
                            Element sepFilesEl = XMLUtil.findElement(contextSubEl, "separated-files", Util.NAMESPACE); // NOI18N
942
                            if (sepFilesEl != null) {
943
                            if (sepFilesEl != null) {
943
                                ctx.separator = Util.findText(sepFilesEl);
944
                                ctx.separator = XMLUtil.findText(sepFilesEl);
944
                            }
945
                            }
945
                            continue;
946
                            continue;
946
                        }
947
                        }
Lines 994-1000 Link Here
994
    
995
    
995
    private static void readProperty(Element propertyElement, EditableProperties props) {
996
    private static void readProperty(Element propertyElement, EditableProperties props) {
996
        String key = propertyElement.getAttribute("name"); // NOI18N
997
        String key = propertyElement.getAttribute("name"); // NOI18N
997
        String value = Util.findText(propertyElement);
998
        String value = XMLUtil.findText(propertyElement);
998
        props.setProperty(key, value);
999
        props.setProperty(key, value);
999
    }
1000
    }
1000
1001
(-)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_3, true);
75
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
76
        if (data != null) {
76
        if (data != null) {
77
            for (Element cu : Util.findSubElements(data)) {
77
            for (Element cu : 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_3);
136
        Element sourceLevelEl = XMLUtil.findElement(compilationUnitEl, "source-level", JavaProjectNature.NS_JAVA_3);
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_3, true);
118
        Element data = aux.getConfigurationFragment(JavaProjectNature.EL_JAVA, JavaProjectNature.NS_JAVA_3, true);
119
        if (data != null) {
119
        if (data != null) {
120
            for (Element cu : Util.findSubElements(data)) {
120
            for (Element cu : 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_3) != null; // NOI18N
122
                boolean isTests = XMLUtil.findElement(cu, "unit-tests", JavaProjectNature.NS_JAVA_3) != 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 51-57 Link Here
51
import org.netbeans.api.project.ProjectUtils;
51
import org.netbeans.api.project.ProjectUtils;
52
import org.netbeans.modules.ant.freeform.spi.ProjectAccessor;
52
import org.netbeans.modules.ant.freeform.spi.ProjectAccessor;
53
import org.netbeans.modules.ant.freeform.spi.ProjectConstants;
53
import org.netbeans.modules.ant.freeform.spi.ProjectConstants;
54
import org.netbeans.modules.ant.freeform.spi.support.Util;
55
import org.netbeans.spi.project.AuxiliaryConfiguration;
54
import org.netbeans.spi.project.AuxiliaryConfiguration;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
55
import org.netbeans.spi.project.support.ant.AntProjectHelper;
57
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
56
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
Lines 61-66 Link Here
61
import org.openide.util.Exceptions;
60
import org.openide.util.Exceptions;
62
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
63
import org.openide.util.RequestProcessor;
62
import org.openide.util.RequestProcessor;
63
import org.openide.xml.XMLUtil;
64
import org.w3c.dom.Element;
64
import org.w3c.dom.Element;
65
65
66
/**
66
/**
Lines 109-126 Link Here
109
        Set<String> classpathEntries = new HashSet<String>();
109
        Set<String> classpathEntries = new HashSet<String>();
110
        Element java = JavaProjectGenerator.getJavaCompilationUnits(aux);
110
        Element java = JavaProjectGenerator.getJavaCompilationUnits(aux);
111
        if (java != null) {
111
        if (java != null) {
112
            for (Element compilationUnitEl : Util.findSubElements(java)) {
112
            for (Element compilationUnitEl : XMLUtil.findSubElements(java)) {
113
                compilationUnits++;
113
                compilationUnits++;
114
                int builtTos = 0;
114
                int builtTos = 0;
115
                int roots = 0;
115
                int roots = 0;
116
                for (Element other : Util.findSubElements(compilationUnitEl)) {
116
                for (Element other : XMLUtil.findSubElements(compilationUnitEl)) {
117
                    String name = other.getLocalName();
117
                    String name = other.getLocalName();
118
                    if (name.equals("package-root")) { // NOI18N
118
                    if (name.equals("package-root")) { // NOI18N
119
                        roots++;
119
                        roots++;
120
                    } else if (name.equals("built-to")) { // NOI18N
120
                    } else if (name.equals("built-to")) { // NOI18N
121
                        builtTos++;
121
                        builtTos++;
122
                    } else if (name.equals("classpath")) { // NOI18N
122
                    } else if (name.equals("classpath")) { // NOI18N
123
                        String text = Util.findText(other);
123
                        String text = XMLUtil.findText(other);
124
                        if (text != null) {
124
                        if (text != null) {
125
                            String textEval = eval.evaluate(text);
125
                            String textEval = eval.evaluate(text);
126
                            if (textEval != null) {
126
                            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", "