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

(-)a/ant.freeform/nbproject/project.xml (-24 lines)
Lines 123-149 Link Here
123
                    </run-dependency>
123
                    </run-dependency>
124
                </dependency>
124
                </dependency>
125
                <dependency>
125
                <dependency>
126
                    <code-name-base>org.openide.explorer</code-name-base>
127
                    <build-prerequisite/>
128
                    <compile-dependency/>
129
                    <run-dependency>
130
                        <specification-version>6.8</specification-version>
131
                    </run-dependency>
132
                </dependency>
133
                <dependency>
134
                    <code-name-base>org.openide.filesystems</code-name-base>
126
                    <code-name-base>org.openide.filesystems</code-name-base>
135
                    <build-prerequisite/>
127
                    <build-prerequisite/>
136
                    <compile-dependency/>
128
                    <compile-dependency/>
137
                    <run-dependency>
129
                    <run-dependency>
138
                        <specification-version>6.2</specification-version>
130
                        <specification-version>6.2</specification-version>
139
                    </run-dependency>
140
                </dependency>
141
                <dependency>
142
                    <code-name-base>org.openide.io</code-name-base>
143
                    <build-prerequisite/>
144
                    <compile-dependency/>
145
                    <run-dependency>
146
                        <specification-version>1.2</specification-version>
147
                    </run-dependency>
131
                    </run-dependency>
148
                </dependency>
132
                </dependency>
149
                <dependency>
133
                <dependency>
Lines 158-171 Link Here
158
                    <compile-dependency/>
142
                    <compile-dependency/>
159
                    <run-dependency>
143
                    <run-dependency>
160
                        <specification-version>6.2</specification-version>
144
                        <specification-version>6.2</specification-version>
161
                    </run-dependency>
162
                </dependency>
163
                <dependency>
164
                    <code-name-base>org.openide.text</code-name-base>
165
                    <build-prerequisite/>
166
                    <compile-dependency/>
167
                    <run-dependency>
168
                        <specification-version>6.16</specification-version>
169
                    </run-dependency>
145
                    </run-dependency>
170
                </dependency>
146
                </dependency>
171
                <dependency>
147
                <dependency>
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java (-1 lines)
Lines 86-92 Link Here
86
        eval = new FreeformEvaluator(this);
86
        eval = new FreeformEvaluator(this);
87
        lookup = initLookup();
87
        lookup = initLookup();
88
        Logger.getLogger(FreeformProject.class.getName()).log(Level.FINER, "Initializing project in {0} with {1}", new Object[] {helper, lookup});
88
        Logger.getLogger(FreeformProject.class.getName()).log(Level.FINER, "Initializing project in {0} with {1}", new Object[] {helper, lookup});
89
        new ProjectXmlValidator(helper.resolveFileObject(AntProjectHelper.PROJECT_XML_PATH));
90
    }
89
    }
91
    
90
    
92
    public AntProjectHelper helper() {
91
    public AntProjectHelper helper() {
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/ProjectXmlValidator.java (-245 lines)
Lines 1-245 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.ant.freeform;
43
44
import java.io.IOException;
45
import java.net.MalformedURLException;
46
import java.net.URL;
47
import java.util.Iterator;
48
import java.util.Set;
49
import java.util.TreeSet;
50
import javax.xml.parsers.SAXParser;
51
import javax.xml.parsers.SAXParserFactory;
52
import org.netbeans.modules.ant.freeform.spi.ProjectNature;
53
import org.openide.ErrorManager;
54
import org.openide.cookies.EditorCookie;
55
import org.openide.filesystems.FileAttributeEvent;
56
import org.openide.filesystems.FileChangeListener;
57
import org.openide.filesystems.FileEvent;
58
import org.openide.filesystems.FileObject;
59
import org.openide.filesystems.FileRenameEvent;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.filesystems.URLMapper;
62
import org.openide.loaders.DataObject;
63
import org.openide.loaders.DataObjectNotFoundException;
64
import org.openide.text.Line;
65
import org.openide.util.Lookup;
66
import org.openide.util.NbBundle;
67
import org.openide.windows.IOProvider;
68
import org.openide.windows.InputOutput;
69
import org.openide.windows.OutputEvent;
70
import org.openide.windows.OutputListener;
71
import org.xml.sax.SAXException;
72
import org.xml.sax.SAXNotRecognizedException;
73
import org.xml.sax.SAXParseException;
74
import org.xml.sax.helpers.DefaultHandler;
75
76
/**
77
 * Checks validity of freeform project.xml files.
78
 * @see "#47288"
79
 * @author Jesse Glick
80
 */
81
final class ProjectXmlValidator extends DefaultHandler implements FileChangeListener {
82
    
83
    private final FileObject projectXml;
84
    private InputOutput io;
85
    
86
    public ProjectXmlValidator(FileObject projectXml) {
87
        this.projectXml = projectXml;
88
        projectXml.addFileChangeListener(this);
89
        validateProjectXml();
90
    }
91
    
92
    private void validateProjectXml() {
93
        if (System.getProperty("netbeans.user") == null) { // NOI18N
94
            // Probably in a unit test; skip it.
95
            return;
96
        }
97
        open();
98
        try {
99
            // XXX may want to preinitialize the desired SAXParserFactory and keep it statically, for speed
100
            SAXParserFactory f = SAXParserFactory.newInstance();
101
            f.setNamespaceAware(true);
102
            f.setValidating(true);
103
            SAXParser p = f.newSAXParser();
104
            p.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", // NOI18N
105
                          "http://www.w3.org/2001/XMLSchema"); // NOI18N
106
            p.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", getSchemas()); // NOI18N
107
            p.parse(projectXml.getURL().toString(), this);
108
        } catch (SAXParseException e) {
109
            log(e);
110
        } catch (Exception e) {
111
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
112
        } finally {
113
            close();
114
        }
115
    }
116
117
    /**
118
     * Compute a list of XML schema locations to be used for validating project.xml files.
119
     */
120
    private static String[] getSchemas() {
121
        Set<String> schemas = new TreeSet<String>();
122
        // XXX should not refer to schema in another module; wait for #42686 to solve properly
123
        schemas.add("nbres:/org/netbeans/modules/project/ant/project.xsd"); // NOI18N
124
        schemas.add("nbres:/org/netbeans/modules/ant/freeform/resources/freeform-project-general.xsd"); // NOI18N
125
        schemas.add("nbres:/org/netbeans/modules/ant/freeform/resources/freeform-project-general-2.xsd"); // NOI18N
126
        for (ProjectNature nature : FreeformProject.PROJECT_NATURES.allInstances()) {
127
            schemas.addAll(nature.getSchemas());
128
        }
129
        return schemas.toArray(new String[schemas.size()]);
130
    }
131
    
132
    public void fileChanged(FileEvent fe) {
133
        validateProjectXml();
134
    }
135
136
    public void fileRenamed(FileRenameEvent fe) {}
137
138
    public void fileAttributeChanged(FileAttributeEvent fe) {}
139
140
    public void fileFolderCreated(FileEvent fe) {}
141
142
    public void fileDeleted(FileEvent fe) {}
143
144
    public void fileDataCreated(FileEvent fe) {}
145
146
    public void warning(SAXParseException e) throws SAXException {
147
        log(e);
148
    }
149
150
    public void error(SAXParseException e) throws SAXException {
151
        log(e);
152
    }
153
154
    public void fatalError(SAXParseException e) throws SAXException {
155
        throw e;
156
    }
157
    
158
    /** Close any old error tab. */
159
    private void open() {
160
        if (io != null) {
161
            io.closeInputOutput();
162
            io = null;
163
        }
164
    }
165
166
    /** Log a parse error, opening error tab as needed. */
167
    private void log(SAXParseException e) {
168
        if (io == null) {
169
            String title = NbBundle.getMessage(ProjectXmlValidator.class, "LBL_project.xml_errors", FileUtil.getFileDisplayName(projectXml));
170
            io = IOProvider.getDefault().getIO(title, true);
171
            io.select();
172
        }
173
        try {
174
            io.getErr().println(e.getLocalizedMessage(), new Hyperlink(e.getSystemId(), e.getLineNumber(), e.getColumnNumber()));
175
        } catch (IOException x) {
176
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, x);
177
        }
178
    }
179
180
    /** Close the stream for the error tab, if one is open, but leave it visible. */
181
    private void close() {
182
        if (io != null) {
183
            io.getErr().close();
184
            io.getOut().close(); // XXX why is this necessary?
185
        }
186
    }
187
188
    private static final class Hyperlink implements OutputListener {
189
        
190
        private final String uri;
191
        private final int line, column;
192
        
193
        public Hyperlink(String uri, int line, int column) {
194
            this.uri = uri;
195
            this.line = line;
196
            this.column = column;
197
        }
198
        
199
        public void outputLineAction(OutputEvent ev) {
200
            FileObject fo;
201
            try {
202
                fo = URLMapper.findFileObject(new URL(uri));
203
            } catch (MalformedURLException e) {
204
                assert false : e;
205
                return;
206
            }
207
            if (fo == null) {
208
                return;
209
            }
210
            DataObject d;
211
            try {
212
                d = DataObject.find(fo);
213
            } catch (DataObjectNotFoundException e) {
214
                assert false : e;
215
                return;
216
            }
217
            EditorCookie ec = d.getCookie(EditorCookie.class);
218
            if (ec == null) {
219
                return;
220
            }
221
            if (line != -1) {
222
                try {
223
                    // XXX do we need to call ec.openDocument as in org.apache.tools.ant.module.run.Hyperlink?
224
                    Line l = ec.getLineSet().getOriginal(line - 1);
225
                    if (column != -1) {
226
                        l.show(Line.SHOW_GOTO, column - 1);
227
                    } else {
228
                        l.show(Line.SHOW_GOTO);
229
                    }
230
                } catch (IndexOutOfBoundsException e) {
231
                    // forget it
232
                    ec.open();
233
                }
234
            } else {
235
                ec.open();
236
            }
237
        }
238
        
239
        public void outputLineSelected(OutputEvent ev) {}
240
        
241
        public void outputLineCleared(OutputEvent ev) {}
242
        
243
    }
244
    
245
}
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/resources/layer.xml (-1 / +6 lines)
Lines 59-63 Link Here
59
            </folder>    
59
            </folder>    
60
         </folder>
60
         </folder>
61
    </folder>
61
    </folder>
62
    
62
    <folder name="ProjectXMLCatalog">
63
        <folder name="freeform-project">
64
            <file name="1.xsd" url="freeform-project-general.xsd"/>
65
            <file name="2.xsd" url="freeform-project-general-2.xsd"/>
66
        </folder>
67
    </folder>
63
</filesystem>
68
</filesystem>
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/ProjectNature.java (-7 lines)
Lines 49-55 Link Here
49
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
49
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
50
import org.openide.filesystems.FileObject;
50
import org.openide.filesystems.FileObject;
51
import org.openide.nodes.Node;
51
import org.openide.nodes.Node;
52
import org.openide.util.Lookup;
53
52
54
/**
53
/**
55
 * Description of base freeform project extension. Instances should be
54
 * Description of base freeform project extension. Instances should be
Lines 69-80 Link Here
69
     * @return a list of {@link TargetDescriptor}s (can be empty but not null)
68
     * @return a list of {@link TargetDescriptor}s (can be empty but not null)
70
     */
69
     */
71
    List<TargetDescriptor> getExtraTargets(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux);
70
    List<TargetDescriptor> getExtraTargets(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux);
72
    
73
    /**
74
     * Returns set of XML schemas describing syntax of <code>project.xml</code> defined by this project extension.
75
     * @return set of <code>String</code>s whose value is URL of XML schema file
76
     */
77
    Set<String> getSchemas();
78
    
71
    
79
    /**
72
    /**
80
     * Get a set of view styles supported by the nature for displaying source folders in the logical view.
73
     * Get a set of view styles supported by the nature for displaying source folders in the logical view.
(-)a/ant.freeform/src/org/netbeans/modules/ant/freeform/spi/support/Util.java (-54 / +3 lines)
Lines 45-59 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.Arrays;
47
import java.util.Arrays;
48
import java.util.HashMap;
49
import java.util.Iterator;
48
import java.util.Iterator;
50
import java.util.List;
49
import java.util.List;
51
import java.util.Map;
52
import javax.xml.XMLConstants;
50
import javax.xml.XMLConstants;
53
import javax.xml.transform.dom.DOMSource;
54
import javax.xml.validation.Schema;
51
import javax.xml.validation.Schema;
55
import javax.xml.validation.SchemaFactory;
52
import javax.xml.validation.SchemaFactory;
56
import javax.xml.validation.Validator;
57
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.Project;
58
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.api.project.ProjectManager;
59
import org.netbeans.api.queries.CollocationQuery;
55
import org.netbeans.api.queries.CollocationQuery;
Lines 70-76 Link Here
70
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileObject;
71
import org.openide.filesystems.FileUtil;
67
import org.openide.filesystems.FileUtil;
72
import org.openide.util.Mutex;
68
import org.openide.util.Mutex;
73
import org.w3c.dom.Attr;
69
import org.openide.xml.XMLUtil;
74
import org.w3c.dom.DOMException;
70
import org.w3c.dom.DOMException;
75
import org.w3c.dom.Document;
71
import org.w3c.dom.Document;
76
import org.w3c.dom.Element;
72
import org.w3c.dom.Element;
Lines 80-88 Link Here
80
import org.w3c.dom.Text;
76
import org.w3c.dom.Text;
81
import org.w3c.dom.ls.DOMImplementationLS;
77
import org.w3c.dom.ls.DOMImplementationLS;
82
import org.w3c.dom.ls.LSSerializer;
78
import org.w3c.dom.ls.LSSerializer;
83
import org.xml.sax.ErrorHandler;
84
import org.xml.sax.SAXException;
79
import org.xml.sax.SAXException;
85
import org.xml.sax.SAXParseException;
86
80
87
/**
81
/**
88
 * Miscellaneous helper methods.
82
 * Miscellaneous helper methods.
Lines 360-370 Link Here
360
            public Void run() {
354
            public Void run() {
361
                Element dataAs1 = translateXML(data, FreeformProjectType.NS_GENERAL_1);
355
                Element dataAs1 = translateXML(data, FreeformProjectType.NS_GENERAL_1);
362
                try {
356
                try {
363
                    validate(dataAs1, SCHEMA_1);
357
                    XMLUtil.validate(dataAs1, SCHEMA_1);
364
                    putPrimaryConfigurationDataAs1(helper, dataAs1);
358
                    putPrimaryConfigurationDataAs1(helper, dataAs1);
365
                } catch (SAXException x1) {
359
                } catch (SAXException x1) {
366
                    try {
360
                    try {
367
                        validate(data, SCHEMA_2);
361
                        XMLUtil.validate(data, SCHEMA_2);
368
                        putPrimaryConfigurationDataAs2(helper, data);
362
                        putPrimaryConfigurationDataAs2(helper, data);
369
                    } catch (SAXException x2) {
363
                    } catch (SAXException x2) {
370
                        assert false : x2.getMessage() + "; rejected content: " + format(data);
364
                        assert false : x2.getMessage() + "; rejected content: " + format(data);
Lines 398-448 Link Here
398
            throw new ExceptionInInitializerError(e);
392
            throw new ExceptionInInitializerError(e);
399
        }
393
        }
400
    }
394
    }
401
    private static void validate(Element data, Schema schema) throws SAXException {
402
        Validator v = schema.newValidator();
403
        final SAXException[] error = {null};
404
        v.setErrorHandler(new ErrorHandler() {
405
            public void warning(SAXParseException x) throws SAXException {}
406
            public void error(SAXParseException x) throws SAXException {
407
                // Just rethrowing it is bad because it will also print it to stderr.
408
                error[0] = x;
409
            }
410
            public void fatalError(SAXParseException x) throws SAXException {
411
                error[0] = x;
412
            }
413
        });
414
        try {
415
            v.validate(new DOMSource(fixupNoNamespaceAttrs(data)));
416
        } catch (IOException x) {
417
            assert false : x;
418
        }
419
        if (error[0] != null) {
420
            throw error[0];
421
        }
422
    }
423
    private static Element fixupNoNamespaceAttrs(Element root) {
424
        // XXX #6529766: some versions of JAXP reject attributes set using setAttribute
425
        // (rather than setAttributeNS) even though the schema calls for no-NS attrs!
426
        // JDK 5 is fine; JDK 6 broken; JDK 6u2 supposedly will be fixed; current JDK 7 broken
427
        Element copy = (Element) root.cloneNode(true);
428
        NodeList nl = copy.getElementsByTagName("*");
429
        for (int i = 0; i < nl.getLength(); i++) {
430
            Element e = (Element) nl.item(i);
431
            Map<String,String> replace = new HashMap<String,String>();
432
            NamedNodeMap attrs = e.getAttributes();
433
            for (int j = 0; j < attrs.getLength(); j++) {
434
                Attr attr = (Attr) attrs.item(j);
435
                if (attr.getNamespaceURI() == null) {
436
                    replace.put(attr.getName(), attr.getValue());
437
                }
438
            }
439
            for (Map.Entry<String,String> entry : replace.entrySet()) {
440
                e.removeAttribute(entry.getKey());
441
                e.setAttributeNS(null, entry.getKey(), entry.getValue());
442
            }
443
        }
444
        return copy;
445
    }
446
    private static String format(Element data) {
395
    private static String format(Element data) {
447
        LSSerializer ser = ((DOMImplementationLS) data.getOwnerDocument().getImplementation().getFeature("LS", "3.0")).createLSSerializer();
396
        LSSerializer ser = ((DOMImplementationLS) data.getOwnerDocument().getImplementation().getFeature("LS", "3.0")).createLSSerializer();
448
        try {
397
        try {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/JavaProjectNature.java (-8 lines)
Lines 43-51 Link Here
43
43
44
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeListener;
45
import java.util.ArrayList;
45
import java.util.ArrayList;
46
import java.util.Arrays;
47
import java.util.Collections;
46
import java.util.Collections;
48
import java.util.HashSet;
49
import java.util.List;
47
import java.util.List;
50
import java.util.Set;
48
import java.util.Set;
51
import javax.swing.Icon;
49
import javax.swing.Icon;
Lines 70-77 Link Here
70
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
68
    public static final String NS_JAVA_1 = "http://www.netbeans.org/ns/freeform-project-java/1"; // NOI18N
71
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
69
    public static final String NS_JAVA_2 = "http://www.netbeans.org/ns/freeform-project-java/2"; // NOI18N
72
    public static final String EL_JAVA = "java-data"; // NOI18N
70
    public static final String EL_JAVA = "java-data"; // NOI18N
73
    private static final String SCHEMA_1 = "nbres:/org/netbeans/modules/java/freeform/resources/freeform-project-java.xsd"; // NOI18N
74
    private static final String SCHEMA_2 = "nbres:/org/netbeans/modules/java/freeform/resources/freeform-project-java-2.xsd"; // NOI18N
75
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
71
    public static final String STYLE_PACKAGES = "packages"; // NOI18N
76
    
72
    
77
    
73
    
Lines 79-88 Link Here
79
    
75
    
80
    public List<TargetDescriptor> getExtraTargets(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux) {
76
    public List<TargetDescriptor> getExtraTargets(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux) {
81
        return new ArrayList<TargetDescriptor>();
77
        return new ArrayList<TargetDescriptor>();
82
    }
83
84
    public Set<String> getSchemas() {
85
        return new HashSet<String>(Arrays.asList(SCHEMA_1, SCHEMA_2));
86
    }
78
    }
87
79
88
    public Set<String> getSourceFolderViewStyles() {
80
    public Set<String> getSourceFolderViewStyles() {
(-)a/java.freeform/src/org/netbeans/modules/java/freeform/resources/layer.xml (-1 / +6 lines)
Lines 77-81 Link Here
77
            </folder>
77
            </folder>
78
        </folder>
78
        </folder>
79
    </folder>
79
    </folder>
80
    
80
    <folder name="ProjectXMLCatalog">
81
        <folder name="freeform-project-java">
82
            <file name="1.xsd" url="freeform-project-java.xsd"/>
83
            <file name="2.xsd" url="freeform-project-java-2.xsd"/>
84
        </folder>
85
    </folder>
81
</filesystem>
86
</filesystem>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/resources/layer.xml (+10 lines)
Lines 144-147 Link Here
144
            
144
            
145
        </folder>
145
        </folder>
146
    </folder>
146
    </folder>
147
    <folder name="ProjectXMLCatalog">
148
        <folder name="j2se-project">
149
            <file name="1.xsd" url="../../resources/j2se-project.xsd"/>
150
            <file name="2.xsd" url="../../resources/j2se-project2.xsd"/>
151
            <file name="3.xsd" url="../../resources/j2se-project3.xsd"/>
152
        </folder>
153
        <folder name="j2se-project-private">
154
            <file name="1.xsd" url="../../resources/j2se-project-private.xsd"/>
155
        </folder>
156
    </folder>
147
</filesystem>
157
</filesystem>
(-)a/openide.util/src/org/openide/xml/XMLUtil.java (-1 / +47 lines)
Lines 49-54 Link Here
49
import java.util.Set;
49
import java.util.Set;
50
import javax.xml.parsers.DocumentBuilder;
50
import javax.xml.parsers.DocumentBuilder;
51
import javax.xml.parsers.DocumentBuilderFactory;
51
import javax.xml.parsers.DocumentBuilderFactory;
52
import javax.xml.parsers.FactoryConfigurationError;
52
import javax.xml.parsers.ParserConfigurationException;
53
import javax.xml.parsers.ParserConfigurationException;
53
import javax.xml.parsers.SAXParserFactory;
54
import javax.xml.parsers.SAXParserFactory;
54
import javax.xml.transform.OutputKeys;
55
import javax.xml.transform.OutputKeys;
Lines 59-64 Link Here
59
import javax.xml.transform.dom.DOMSource;
60
import javax.xml.transform.dom.DOMSource;
60
import javax.xml.transform.stream.StreamResult;
61
import javax.xml.transform.stream.StreamResult;
61
import javax.xml.transform.stream.StreamSource;
62
import javax.xml.transform.stream.StreamSource;
63
import javax.xml.validation.Schema;
64
import javax.xml.validation.Validator;
62
import org.openide.util.Lookup;
65
import org.openide.util.Lookup;
63
import org.w3c.dom.CDATASection;
66
import org.w3c.dom.CDATASection;
64
import org.w3c.dom.DOMException;
67
import org.w3c.dom.DOMException;
Lines 73-78 Link Here
73
import org.xml.sax.ErrorHandler;
76
import org.xml.sax.ErrorHandler;
74
import org.xml.sax.InputSource;
77
import org.xml.sax.InputSource;
75
import org.xml.sax.SAXException;
78
import org.xml.sax.SAXException;
79
import org.xml.sax.SAXParseException;
76
import org.xml.sax.XMLReader;
80
import org.xml.sax.XMLReader;
77
81
78
/**
82
/**
Lines 455-461 Link Here
455
            collectCDATASections(children.item(i), cdataQNames);
459
            collectCDATASections(children.item(i), cdataQNames);
456
        }
460
        }
457
    }
461
    }
458
    
462
463
    /**
464
     * Check whether a DOM tree is valid according to a schema.
465
     * Example of usage:
466
     * <pre>
467
     * Element fragment = ...;
468
     * SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
469
     * Schema s = f.newSchema(This.class.getResource("something.xsd"));
470
     * try {
471
     *     XMLUtil.validate(fragment, s);
472
     *     // valid
473
     * } catch (SAXException x) {
474
     *     // invalid
475
     * }
476
     * </pre>
477
     * @param data a DOM tree
478
     * @param schema a parsed schema
479
     * @throws SAXException if validation failed
480
     * @since XXX
481
     */
482
    public static void validate(Element data, Schema schema) throws SAXException {
483
        Validator v = schema.newValidator();
484
        final SAXException[] error = {null};
485
        v.setErrorHandler(new ErrorHandler() {
486
            public void warning(SAXParseException x) throws SAXException {}
487
            public void error(SAXParseException x) throws SAXException {
488
                // Just rethrowing it is bad because it will also print it to stderr.
489
                error[0] = x;
490
            }
491
            public void fatalError(SAXParseException x) throws SAXException {
492
                error[0] = x;
493
            }
494
        });
495
        try {
496
            v.validate(new DOMSource(data));
497
        } catch (IOException x) {
498
            assert false : x;
499
        }
500
        if (error[0] != null) {
501
            throw error[0];
502
        }
503
    }
504
459
    /**
505
    /**
460
     * Escape passed string as XML attibute value
506
     * Escape passed string as XML attibute value
461
     * (<code>&lt;</code>, <code>&amp;</code>, <code>'</code> and <code>"</code>
507
     * (<code>&lt;</code>, <code>&amp;</code>, <code>'</code> and <code>"</code>
(-)a/openide.util/test/unit/src/org/openide/xml/XMLUtilTest.java (+37 lines)
Lines 47-53 Link Here
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.io.StringReader;
48
import java.io.StringReader;
49
import java.lang.ref.WeakReference;
49
import java.lang.ref.WeakReference;
50
import javax.xml.XMLConstants;
50
import javax.xml.parsers.DocumentBuilderFactory;
51
import javax.xml.parsers.DocumentBuilderFactory;
52
import javax.xml.transform.dom.DOMSource;
53
import javax.xml.transform.stream.StreamSource;
54
import javax.xml.validation.Schema;
55
import javax.xml.validation.SchemaFactory;
56
import javax.xml.validation.Validator;
51
import org.netbeans.junit.NbTestCase;
57
import org.netbeans.junit.NbTestCase;
52
import org.w3c.dom.CDATASection;
58
import org.w3c.dom.CDATASection;
53
import org.w3c.dom.Document;
59
import org.w3c.dom.Document;
Lines 153-158 Link Here
153
            String data = "<!ELEMENT foo (x+)><!ELEMENT x EMPTY>";
159
            String data = "<!ELEMENT foo (x+)><!ELEMENT x EMPTY>";
154
            return new InputSource(new StringReader(data));
160
            return new InputSource(new StringReader(data));
155
        }
161
        }
162
    }
163
164
    public void testValidate() throws Exception {
165
        Element r = XMLUtil.createDocument("root", "some://where", null, null).getDocumentElement();
166
        r.setAttribute("hello", "there");
167
        SchemaFactory f = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
168
        String xsd =
169
                "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema' targetNamespace='some://where' xmlns='some://where' elementFormDefault='qualified'>\n" +
170
                " <xsd:element name='root'>\n" +
171
                "  <xsd:complexType>\n" +
172
                "   <xsd:attribute name='hello' type='xsd:NMTOKEN' use='required'/>\n" +
173
                "  </xsd:complexType>\n" +
174
                " </xsd:element>\n" +
175
                "</xsd:schema>\n";
176
        Schema s = f.newSchema(new StreamSource(new StringReader(xsd)));
177
        XMLUtil.validate(r, s);
178
        r.setAttribute("goodbye", "now");
179
        try {
180
            XMLUtil.validate(r, s);
181
            fail();
182
        } catch (SAXException x) {/*OK*/}
183
        // Make sure Java #6529766 is fixed (no longer any need for fixupNoNamespaceAttrs):
184
        String xml = "<root xmlns='some://where'/>";
185
        r = XMLUtil.parse(new InputSource(new StringReader(xml)), false, true, null, null).getDocumentElement();
186
        r.setAttribute("hello", "there");
187
        XMLUtil.validate(r, s);
188
        r.setAttribute("goodbye", "now");
189
        try {
190
            XMLUtil.validate(r, s);
191
            fail();
192
        } catch (SAXException x) {/*OK*/}
156
    }
193
    }
157
    
194
    
158
    public void testToAttributeValue() throws IOException {
195
    public void testToAttributeValue() throws IOException {
(-)a/project.ant/nbproject/project.xml (+9 lines)
Lines 96-101 Link Here
96
                    <compile-dependency/>
96
                    <compile-dependency/>
97
                    <run-dependency>
97
                    <run-dependency>
98
                        <release-version>1</release-version>
98
                        <release-version>1</release-version>
99
                    </run-dependency>
100
                </dependency>
101
                <dependency>
102
                    <code-name-base>org.netbeans.modules.xml.catalog</code-name-base>
103
                    <build-prerequisite/>
104
                    <compile-dependency/>
105
                    <run-dependency>
106
                        <release-version>2</release-version>
107
                        <specification-version>1.14</specification-version>
99
                    </run-dependency>
108
                    </run-dependency>
100
                </dependency>
109
                </dependency>
101
                <dependency>
110
                <dependency>
(-)a/project.ant/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingleton.java (-4 / +6 lines)
Lines 163-180 Link Here
163
            return null;
163
            return null;
164
        }
164
        }
165
        Document projectXml;
165
        Document projectXml;
166
        Element projectEl;
166
        try {
167
        try {
167
            projectXml = XMLUtil.parse(new InputSource(projectDiskFile.toURI().toString()), false, true, Util.defaultErrorHandler(), null);
168
            projectXml = XMLUtil.parse(new InputSource(projectDiskFile.toURI().toString()), false, true, Util.defaultErrorHandler(), null);
169
            projectEl = projectXml.getDocumentElement();
170
            if (!"project".equals(projectEl.getLocalName()) || !PROJECT_NS.equals(projectEl.getNamespaceURI())) { // NOI18N
171
                return null;
172
            }
173
            ProjectXMLCatalogReader.validate(projectEl);
168
        } catch (SAXException e) {
174
        } catch (SAXException e) {
169
            IOException ioe = (IOException) new IOException(projectDiskFile + ": " + e.toString()).initCause(e);
175
            IOException ioe = (IOException) new IOException(projectDiskFile + ": " + e.toString()).initCause(e);
170
            Exceptions.attachLocalizedMessage(ioe, NbBundle.getMessage(AntBasedProjectFactorySingleton.class,
176
            Exceptions.attachLocalizedMessage(ioe, NbBundle.getMessage(AntBasedProjectFactorySingleton.class,
171
                                                                        "AntBasedProjectFactorySingleton.parseError",
177
                                                                        "AntBasedProjectFactorySingleton.parseError",
172
                                                                        projectDiskFile.getAbsolutePath(), e.getMessage()));
178
                                                                        projectDiskFile.getAbsolutePath(), e.getMessage()));
173
            throw ioe;
179
            throw ioe;
174
        }
175
        Element projectEl = projectXml.getDocumentElement();
176
        if (!"project".equals(projectEl.getLocalName()) || !PROJECT_NS.equals(projectEl.getNamespaceURI())) { // NOI18N
177
            return null;
178
        }
180
        }
179
        Element typeEl = Util.findElement(projectEl, "type", PROJECT_NS); // NOI18N
181
        Element typeEl = Util.findElement(projectEl, "type", PROJECT_NS); // NOI18N
180
        if (typeEl == null) {
182
        if (typeEl == null) {
(-)a/project.ant/src/org/netbeans/modules/project/ant/Bundle.properties (+4 lines)
Lines 84-86 Link Here
84
MSG_Invalid_Location=Valid location must be set
84
MSG_Invalid_Location=Valid location must be set
85
MSG_Variable_Already_Exists=Variable with this name already exists
85
MSG_Variable_Already_Exists=Variable with this name already exists
86
MSG_Invalid_Name=Valid name must be set
86
MSG_Invalid_Name=Valid name must be set
87
88
# ProjectXMLCatalogReader
89
LBL_project_xml_schemas=Project XML Schemas
90
HINT_project_xml_schemas=Permits validation of project.xml and private.xml files from the IDE.
(-)a/projectui/src/org/netbeans/modules/project/ui/ProjectXMLCatalogReader.java (-5 / +49 lines)
Lines 39-55 Link Here
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.modules.project.ui;
42
package org.netbeans.modules.project.ant;
43
43
44
import java.awt.Image;
44
import java.awt.Image;
45
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeListener;
46
import java.util.ArrayList;
46
import java.util.Collections;
47
import java.util.Collections;
47
import java.util.Iterator;
48
import java.util.Iterator;
49
import java.util.List;
50
import javax.xml.XMLConstants;
51
import javax.xml.transform.Source;
52
import javax.xml.transform.stream.StreamSource;
53
import javax.xml.validation.SchemaFactory;
48
import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor;
54
import org.netbeans.modules.xml.catalog.spi.CatalogDescriptor;
49
import org.netbeans.modules.xml.catalog.spi.CatalogListener;
55
import org.netbeans.modules.xml.catalog.spi.CatalogListener;
50
import org.netbeans.modules.xml.catalog.spi.CatalogReader;
56
import org.netbeans.modules.xml.catalog.spi.CatalogReader;
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileStateInvalidException;
59
import org.openide.filesystems.Repository;
60
import org.openide.util.Exceptions;
51
import org.openide.util.NbBundle;
61
import org.openide.util.NbBundle;
62
import org.openide.util.NbCollections;
52
import org.openide.util.Utilities;
63
import org.openide.util.Utilities;
64
import org.openide.xml.XMLUtil;
65
import org.w3c.dom.Element;
66
import org.xml.sax.SAXException;
53
67
54
/**
68
/**
55
 * Supplies a catalog which lets users validate against project-related XML schemas.
69
 * Supplies a catalog which lets users validate against project-related XML schemas.
Lines 59-75 Link Here
59
public class ProjectXMLCatalogReader implements CatalogReader, CatalogDescriptor {
73
public class ProjectXMLCatalogReader implements CatalogReader, CatalogDescriptor {
60
    
74
    
61
    private static final String PREFIX = "http://www.netbeans.org/ns/"; // NOI18N
75
    private static final String PREFIX = "http://www.netbeans.org/ns/"; // NOI18N
62
    private static final String SUFFIX = ".xsd"; // NOI18N
76
    private static final String EXTENSION = "xsd"; // NOI18N
77
    private static final String CATALOG = "ProjectXMLCatalog"; // NOI18N
63
    
78
    
64
    /** Default constructor for use from layer. */
79
    /** Default constructor for use from layer. */
65
    public ProjectXMLCatalogReader() {}
80
    public ProjectXMLCatalogReader() {}
66
81
67
    public String resolveURI(String name) {
82
    public String resolveURI(String name) {
68
        if (name.startsWith(PREFIX)) {
83
        if (name.startsWith(PREFIX)) {
69
            return name + SUFFIX;
84
            FileObject rsrc = Repository.getDefault().getDefaultFileSystem().findResource(CATALOG + "/" + name.substring(PREFIX.length()) + "." + EXTENSION);
70
        } else {
85
            if (rsrc != null) {
71
            return null;
86
                try {
87
                    return rsrc.getURL().toString();
88
                } catch (FileStateInvalidException x) {
89
                    Exceptions.printStackTrace(x);
90
                }
91
            }
72
        }
92
        }
93
        return null;
73
    }
94
    }
74
95
75
    public String resolvePublic(String publicId) {
96
    public String resolvePublic(String publicId) {
Lines 105-109 Link Here
105
    public String getDisplayName() {
126
    public String getDisplayName() {
106
        return NbBundle.getMessage(ProjectXMLCatalogReader.class, "LBL_project_xml_schemas");
127
        return NbBundle.getMessage(ProjectXMLCatalogReader.class, "LBL_project_xml_schemas");
107
    }
128
    }
129
130
    /**
131
     * Validate according to all *.xsd found in catalog.
132
     * @param dom DOM fragment to validate
133
     * @throws SAXException if schemas were malformed or the document was invalid
134
     */
135
    public static void validate(Element dom) throws SAXException {
136
        // XXX should cache schemas (but then needs to listen to changes in SFS in a tree)
137
        List<Source> sources = new ArrayList<Source>();
138
        FileObject root = Repository.getDefault().getDefaultFileSystem().findResource(CATALOG);
139
        if (root != null) {
140
            for (FileObject f : NbCollections.iterable(root.getChildren(true))) {
141
                if (f.isData() && f.hasExt(EXTENSION)) {
142
                    try {
143
                        sources.add(new StreamSource(f.getURL().toString()));
144
                    } catch (FileStateInvalidException x) {
145
                        Exceptions.printStackTrace(x);
146
                    }
147
                }
148
            }
149
        }
150
        XMLUtil.validate(dom, SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(sources.toArray(new Source[sources.size()])));
151
    }
108
    
152
    
109
}
153
}
(-)a/projectui/src/org/netbeans/modules/project/ui/ProjectXMLCatalogReaderBeanInfo.java (-1 / +1 lines)
Lines 39-45 Link Here
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
41
42
package org.netbeans.modules.project.ui;
42
package org.netbeans.modules.project.ant;
43
43
44
import java.beans.PropertyDescriptor;
44
import java.beans.PropertyDescriptor;
45
import java.beans.SimpleBeanInfo;
45
import java.beans.SimpleBeanInfo;
(-)a/project.ant/src/org/netbeans/modules/project/ant/resources/mf-layer.xml (-2 / +24 lines)
Lines 42-48 Link Here
42
-->
42
-->
43
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
43
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
44
<filesystem>
44
<filesystem>
45
46
    <folder name="Menu">
45
    <folder name="Menu">
47
        <folder name="Tools">
46
        <folder name="Tools">
48
            <file name="VariablesCustomizerAction.instance">
47
            <file name="VariablesCustomizerAction.instance">
Lines 51-55 Link Here
51
            </file>
50
            </file>
52
        </folder>
51
        </folder>
53
    </folder>
52
    </folder>
54
53
    <folder name="Plugins">
54
        <folder name="XML">
55
            <folder name="UserCatalogs">
56
                <file name="org-netbeans-modules-project-ant-ProjectXMLCatalogReader.instance">
57
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.xml.catalog.spi.CatalogReader"/>
58
                </file>
59
            </folder>
60
        </folder>
61
    </folder>
62
    <folder name="ProjectXMLCatalog">
63
        <folder name="ant-project-libraries">
64
            <file name="1.xsd" url="../ant-project-libraries-1.xsd"/>
65
        </folder>
66
        <folder name="ant-project-references">
67
            <file name="1.xsd" url="../ant-project-references.xsd"/>
68
            <file name="2.xsd" url="../ant-project-references2.xsd"/>
69
        </folder>
70
        <folder name="project">
71
            <file name="1.xsd" url="../project.xsd"/>
72
        </folder>
73
        <folder name="project-private">
74
            <file name="1.xsd" url="../project-private.xsd"/>
75
        </folder>
76
    </folder>
55
</filesystem>
77
</filesystem>
(-)a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java (-1 / +10 lines)
Lines 61-66 Link Here
61
import org.netbeans.modules.project.ant.FileChangeSupportEvent;
61
import org.netbeans.modules.project.ant.FileChangeSupportEvent;
62
import org.netbeans.modules.project.ant.FileChangeSupportListener;
62
import org.netbeans.modules.project.ant.FileChangeSupportListener;
63
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
63
import org.netbeans.modules.project.ant.ProjectLibraryProvider;
64
import org.netbeans.modules.project.ant.ProjectXMLCatalogReader;
64
import org.netbeans.modules.project.ant.UserQuestionHandler;
65
import org.netbeans.modules.project.ant.UserQuestionHandler;
65
import org.netbeans.modules.project.ant.Util;
66
import org.netbeans.modules.project.ant.Util;
66
import org.netbeans.spi.project.AuxiliaryConfiguration;
67
import org.netbeans.spi.project.AuxiliaryConfiguration;
Lines 277-283 Link Here
277
        File f = FileUtil.toFile(xml);
278
        File f = FileUtil.toFile(xml);
278
        assert f != null;
279
        assert f != null;
279
        try {
280
        try {
280
            return XMLUtil.parse(new InputSource(f.toURI().toString()), false, true, Util.defaultErrorHandler(), null);
281
            Document doc = XMLUtil.parse(new InputSource(f.toURI().toString()), false, true, Util.defaultErrorHandler(), null);
282
            ProjectXMLCatalogReader.validate(doc.getDocumentElement());
283
            return doc;
281
        } catch (IOException e) {
284
        } catch (IOException e) {
282
            if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) {
285
            if (!QUIETLY_SWALLOW_XML_LOAD_ERRORS) {
283
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
286
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
Lines 298-303 Link Here
298
        assert ProjectManager.mutex().isWriteAccess();
301
        assert ProjectManager.mutex().isWriteAccess();
299
        assert !writingXML;
302
        assert !writingXML;
300
        assert Thread.holdsLock(modifiedMetadataPaths);
303
        assert Thread.holdsLock(modifiedMetadataPaths);
304
        try {
305
            ProjectXMLCatalogReader.validate(doc.getDocumentElement());
306
        } catch (SAXException x) {
307
            throw (IOException) new IOException(x.getMessage()).initCause(x);
308
        }
301
        final FileLock[] _lock = new FileLock[1];
309
        final FileLock[] _lock = new FileLock[1];
302
        writingXML = true;
310
        writingXML = true;
303
        try {
311
        try {
Lines 778-783 Link Here
778
                        return ;
786
                        return ;
779
                    }
787
                    }
780
                    path = PROJECT_XML_PATH;
788
                    path = PROJECT_XML_PATH;
789
                    // XXX should rather set a separate flag but keep the (valid) content loaded
781
                    projectXml = null;
790
                    projectXml = null;
782
                } else if (f.equals(resolveFile(PRIVATE_XML_PATH))) {
791
                } else if (f.equals(resolveFile(PRIVATE_XML_PATH))) {
783
                    if (modifiedMetadataPaths.contains(PRIVATE_XML_PATH)) {
792
                    if (modifiedMetadataPaths.contains(PRIVATE_XML_PATH)) {
(-)a/project.ant/test/unit/src/org/netbeans/modules/project/ant/AntBasedProjectFactorySingletonTest.java (+4 lines)
Lines 116-120 Link Here
116
        
116
        
117
        assertTrue(getAntBasedProjectTypeMethod.invoke(helper) == type2);
117
        assertTrue(getAntBasedProjectTypeMethod.invoke(helper) == type2);
118
    }
118
    }
119
120
    public void testDoNotLoadInvalidProject() throws Exception {
121
        // XXX create malformed project.xml and check that loadProject dies
122
    }
119
    
123
    
120
}
124
}
(-)a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntProjectHelperTest.java (+2 lines)
Lines 190-195 Link Here
190
        assertNotNull("have <data>", data);
190
        assertNotNull("have <data>", data);
191
        Element details = Util.findElement(data, "details", "urn:test:shared");
191
        Element details = Util.findElement(data, "details", "urn:test:shared");
192
        assertNotNull("have <details>", details);
192
        assertNotNull("have <details>", details);
193
        // XXX test well-formed but invalid content
193
    }
194
    }
194
    
195
    
195
    /**
196
    /**
Lines 535-540 Link Here
535
        // XXX try modifying both XML files, or different parts of the same, and saving in a batch
536
        // XXX try modifying both XML files, or different parts of the same, and saving in a batch
536
        // XXX try storing unmodified XML fragments and see what happens
537
        // XXX try storing unmodified XML fragments and see what happens
537
        // XXX try storing a fresh Element not returned from getPrimaryConfigurationData
538
        // XXX try storing a fresh Element not returned from getPrimaryConfigurationData
539
        // XXX test storing invalid content
538
    }
540
    }
539
    
541
    
540
    /**
542
    /**
(-)a/projectapi/manifest.mf (+1 lines)
Lines 3-6 Link Here
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
3
OpenIDE-Module-Install: org/netbeans/modules/projectapi/Installer.class
4
OpenIDE-Module-Specification-Version: 1.18
4
OpenIDE-Module-Specification-Version: 1.18
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/projectapi/Bundle.properties
6
OpenIDE-Module-Layer: org/netbeans/modules/projectapi/layer.xml
6
7
(-)a/projectapi/src/org/netbeans/modules/projectapi/layer.xml (+12 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
3
<filesystem>
4
    <folder name="ProjectXMLCatalog">
5
        <folder name="auxiliary-configuration">
6
            <file name="1.xsd" url="auxiliary-configuration.xsd"/>
7
        </folder>
8
        <folder name="auxiliary-configuration-preferences">
9
            <file name="1.xsd" url="resources/auxiliary-configuration-preferences.xsd"/>
10
        </folder>
11
    </folder>
12
</filesystem>
(-)a/projectui/nbproject/project.xml (-9 lines)
Lines 115-129 Link Here
115
                    <compile-dependency/>
115
                    <compile-dependency/>
116
                    <run-dependency>
116
                    <run-dependency>
117
                        <release-version>1</release-version>
117
                        <release-version>1</release-version>
118
                    </run-dependency>
119
                </dependency>
120
                <dependency>
121
                    <code-name-base>org.netbeans.modules.xml.catalog</code-name-base>
122
                    <build-prerequisite/>
123
                    <compile-dependency/>
124
                    <run-dependency>
125
                        <release-version>2</release-version>
126
                        <specification-version>1.8</specification-version>
127
                    </run-dependency>
118
                    </run-dependency>
128
                </dependency>
119
                </dependency>
129
                <dependency>
120
                <dependency>
(-)a/projectui/src/org/netbeans/modules/project/ui/Bundle.properties (-4 lines)
Lines 44-53 Link Here
44
OpenIDE-Module-Long-Description=\
44
OpenIDE-Module-Long-Description=\
45
    GUI infrastructure for working with projects in the IDE: the Projects and Files tabs, \
45
    GUI infrastructure for working with projects in the IDE: the Projects and Files tabs, \
46
    the project chooser dialog, the project-sensitive New File wizard, etc.
46
    the project chooser dialog, the project-sensitive New File wizard, etc.
47
48
# ProjectXMLCatalogReader
49
LBL_project_xml_schemas=Project XML Schemas
50
HINT_project_xml_schemas=Permits validation of project.xml and private.xml files from the IDE.
51
47
52
#BrowseFolders
48
#BrowseFolders
53
BTN_BrowseFolders_Select_Option=&Select Folder
49
BTN_BrowseFolders_Select_Option=&Select Folder
(-)a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml (-11 / +5 lines)
Lines 622-637 Link Here
622
        </folder>
622
        </folder>
623
    </folder>
623
    </folder>
624
    
624
    
625
    <folder name="Plugins">
626
        <folder name="XML">
627
            <folder name="UserCatalogs">
628
                <file name="org-netbeans-modules-project-ui-ProjectXMLCatalogReader.instance">
629
                    <attr name="instanceOf" stringvalue="org.netbeans.modules.xml.catalog.spi.CatalogReader"/>
630
                </file>
631
            </folder>
632
        </folder>
633
    </folder>
634
    
635
    <folder name="ProjectsTabActions"> <!-- #57068; cf. ProjectsRootNode.ACTIONS_FOLDER -->
625
    <folder name="ProjectsTabActions"> <!-- #57068; cf. ProjectsRootNode.ACTIONS_FOLDER -->
636
        <file name="org-netbeans-modules-project-ui-NewProject.shadow">
626
        <file name="org-netbeans-modules-project-ui-NewProject.shadow">
637
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-NewProject.instance"/>
627
            <attr name="originalFile" stringvalue="Actions/Project/org-netbeans-modules-project-ui-NewProject.instance"/>
Lines 690-694 Link Here
690
            <attr name="position" intvalue="1500"/>
680
            <attr name="position" intvalue="1500"/>
691
        </file>
681
        </file>
692
    </folder>
682
    </folder>
693
        
683
    <folder name="ProjectXMLCatalog">
684
        <folder name="projectui-open-files">
685
            <file name="1.xsd" url="projectui-open-files.xsd"/>
686
        </folder>
687
    </folder>
694
</filesystem>
688
</filesystem>
(-)a/web.freeform/src/org/netbeans/modules/web/freeform/WebProjectNature.java (-7 lines)
Lines 43-49 Link Here
43
import java.util.ArrayList;
43
import java.util.ArrayList;
44
import java.util.Arrays;
44
import java.util.Arrays;
45
import java.util.Collections;
45
import java.util.Collections;
46
import java.util.HashSet;
47
import java.util.List;
46
import java.util.List;
48
import java.util.Set;
47
import java.util.Set;
49
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
Lines 63-72 Link Here
63
public class WebProjectNature implements ProjectNature {
62
public class WebProjectNature implements ProjectNature {
64
63
65
    public static final String NS_WEB_1 = "http://www.netbeans.org/ns/freeform-project-web/1"; // NOI18N
64
    public static final String NS_WEB_1 = "http://www.netbeans.org/ns/freeform-project-web/1"; // NOI18N
66
    private static final String SCHEMA_1 = "nbres:/org/netbeans/modules/web/freeform/resources/freeform-project-web.xsd"; // NOI18N
67
    public static final String EL_WEB = "web-data";
65
    public static final String EL_WEB = "web-data";
68
    public static final String NS_WEB_2 = "http://www.netbeans.org/ns/freeform-project-web/2"; // NOI18N
66
    public static final String NS_WEB_2 = "http://www.netbeans.org/ns/freeform-project-web/2"; // NOI18N
69
    private static final String SCHEMA_2 = "nbres:/org/netbeans/modules/web/freeform/resources/freeform-project-web-2.xsd"; // NOI18N
70
    
67
    
71
  
68
  
72
    public WebProjectNature() {}
69
    public WebProjectNature() {}
Lines 80-89 Link Here
80
        return l;
77
        return l;
81
    }
78
    }
82
    
79
    
83
    public Set<String> getSchemas() {
84
        return new HashSet<String>(Arrays.asList(SCHEMA_1, SCHEMA_2));
85
    }
86
87
    public Set<String> getSourceFolderViewStyles() {
80
    public Set<String> getSourceFolderViewStyles() {
88
        return Collections.<String>emptySet();
81
        return Collections.<String>emptySet();
89
    }
82
    }
(-)a/web.freeform/src/org/netbeans/modules/web/freeform/resources/layer.xml (-1 / +6 lines)
Lines 79-83 Link Here
79
                </folder>
79
                </folder>
80
        </folder>
80
        </folder>
81
    </folder>
81
    </folder>
82
    
82
    <folder name="ProjectXMLCatalog">
83
        <folder name="freeform-project-web">
84
            <file name="1.xsd" url="freeform-project-web.xsd"/>
85
            <file name="2.xsd" url="freeform-project-web-2.xsd"/>
86
        </folder>
87
    </folder>
83
</filesystem>
88
</filesystem>

Return to bug 42686