Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 196452
Collapse All | Expand All

(-)a/javahelp/nbproject/project.xml (-1 / +1 lines)
 Lines 79-85    Link Here 
79
                    <build-prerequisite/>
79
                    <build-prerequisite/>
80
                    <compile-dependency/>
80
                    <compile-dependency/>
81
                    <run-dependency>
81
                    <run-dependency>
82
                        <specification-version>7.50</specification-version>
82
                        <specification-version>7.51</specification-version>
83
                    </run-dependency>
83
                    </run-dependency>
84
                </dependency>
84
                </dependency>
85
                <dependency>
85
                <dependency>
(-)a/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java (-9 / +4 lines)
 Lines 45-51    Link Here 
45
import com.sun.java.help.search.Indexer;
45
import com.sun.java.help.search.Indexer;
46
import java.io.File;
46
import java.io.File;
47
import java.io.FileInputStream;
47
import java.io.FileInputStream;
48
import java.io.FileNotFoundException;
49
import java.io.FileOutputStream;
48
import java.io.FileOutputStream;
50
import java.io.IOException;
49
import java.io.IOException;
51
import java.io.InputStream;
50
import java.io.InputStream;
 Lines 68-73    Link Here 
68
import javax.tools.StandardLocation;
67
import javax.tools.StandardLocation;
69
import org.netbeans.api.javahelp.HelpSetRegistration;
68
import org.netbeans.api.javahelp.HelpSetRegistration;
70
import org.openide.filesystems.FileUtil;
69
import org.openide.filesystems.FileUtil;
70
import org.openide.filesystems.annotations.LayerBuilder;
71
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
71
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
72
import org.openide.filesystems.annotations.LayerGenerationException;
72
import org.openide.filesystems.annotations.LayerGenerationException;
73
import org.openide.util.lookup.ServiceProvider;
73
import org.openide.util.lookup.ServiceProvider;
 Lines 94-100    Link Here 
94
            HelpSetRegistration r = e.getAnnotation(HelpSetRegistration.class);
94
            HelpSetRegistration r = e.getAnnotation(HelpSetRegistration.class);
95
            String pkg = ((PackageElement) e).getQualifiedName().toString();
95
            String pkg = ((PackageElement) e).getQualifiedName().toString();
96
            String hs = pkg.replace('.', '/') + '/' + r.helpSet();
96
            String hs = pkg.replace('.', '/') + '/' + r.helpSet();
97
            layer(e).file("Services/JavaHelp/" + pkg.replace('.', '-') + ".xml").contents(""
97
            LayerBuilder builder = layer(e);
98
            builder.file("Services/JavaHelp/" + pkg.replace('.', '-') + ".xml").contents(""
98
                    + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
99
                    + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
99
                    + "<!DOCTYPE helpsetref PUBLIC \"-//NetBeans//DTD JavaHelp Help Set Reference 1.0//EN\" \"http://www.netbeans.org/dtds/helpsetref-1_0.dtd\">\n"
100
                    + "<!DOCTYPE helpsetref PUBLIC \"-//NetBeans//DTD JavaHelp Help Set Reference 1.0//EN\" \"http://www.netbeans.org/dtds/helpsetref-1_0.dtd\">\n"
100
                    + "<helpsetref url=\"nbdocs:/" + hs + "\" merge=\"" + r.merge() + "\"/>\n"
101
                    + "<helpsetref url=\"nbdocs:/" + hs + "\" merge=\"" + r.merge() + "\"/>\n"
 Lines 103-115    Link Here 
103
            Document doc;
104
            Document doc;
104
            URI loc;
105
            URI loc;
105
            try {
106
            try {
106
                FileObject hsf = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", hs);
107
                loc = builder.validateResource(hs, e, r, "helpSet", false).toUri();
107
                try { // #181355
108
                    hsf.openInputStream().close();
109
                } catch (FileNotFoundException x) {
110
                    hsf = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", hs);
111
                }
112
                loc = hsf.toUri();
113
                if (loc.getScheme() == null) {
108
                if (loc.getScheme() == null) {
114
                    // JDK #6419926: FileObject.toUri() generates URI without schema
109
                    // JDK #6419926: FileObject.toUri() generates URI without schema
115
                    loc = new File(loc.toString()).toURI();
110
                    loc = new File(loc.toString()).toURI();
(-)a/openide.awt/nbproject/project.xml (-1 / +1 lines)
 Lines 54-60    Link Here 
54
                    <build-prerequisite/>
54
                    <build-prerequisite/>
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <specification-version>7.50</specification-version>
57
                        <specification-version>7.51</specification-version>
58
                    </run-dependency>
58
                    </run-dependency>
59
                </dependency>
59
                </dependency>
60
                <dependency>
60
                <dependency>
(-)a/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java (-21 / +5 lines)
 Lines 40-46    Link Here 
40
package org.netbeans.modules.openide.awt;
40
package org.netbeans.modules.openide.awt;
41
41
42
import java.awt.event.ActionListener;
42
import java.awt.event.ActionListener;
43
import java.io.IOException;
44
import java.util.Collections;
43
import java.util.Collections;
45
import java.util.HashSet;
44
import java.util.HashSet;
46
import java.util.Set;
45
import java.util.Set;
 Lines 64-75    Link Here 
64
import javax.swing.Action;
63
import javax.swing.Action;
65
import javax.swing.JSeparator;
64
import javax.swing.JSeparator;
66
import javax.swing.KeyStroke;
65
import javax.swing.KeyStroke;
67
import javax.tools.StandardLocation;
68
import org.openide.awt.ActionID;
66
import org.openide.awt.ActionID;
69
import org.openide.awt.ActionReference;
67
import org.openide.awt.ActionReference;
70
import org.openide.awt.ActionReferences;
68
import org.openide.awt.ActionReferences;
71
import org.openide.awt.ActionRegistration;
69
import org.openide.awt.ActionRegistration;
72
import org.openide.awt.DynamicMenuContent;
70
import org.openide.awt.DynamicMenuContent;
71
import org.openide.filesystems.annotations.LayerBuilder;
73
import org.openide.filesystems.annotations.LayerBuilder.File;
72
import org.openide.filesystems.annotations.LayerBuilder.File;
74
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
73
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
75
import org.openide.filesystems.annotations.LayerGenerationException;
74
import org.openide.filesystems.annotations.LayerGenerationException;
 Lines 186-192    Link Here 
186
                throw new LayerGenerationException("@ActionID id() must be valid fully qualified name", e, processingEnv, aid, "id");
185
                throw new LayerGenerationException("@ActionID id() must be valid fully qualified name", e, processingEnv, aid, "id");
187
            }
186
            }
188
            String id = aid.id().replace('.', '-');
187
            String id = aid.id().replace('.', '-');
189
            File f = layer(e).file("Actions/" + aid.category() + "/" + id + ".instance");
188
            LayerBuilder builder = layer(e);
189
            File f = builder.file("Actions/" + aid.category() + "/" + id + ".instance");
190
            f.bundlevalue("displayName", ar.displayName(), ar, "displayName");
190
            f.bundlevalue("displayName", ar.displayName(), ar, "displayName");
191
            
191
            
192
            String menuText = ar.menuText();
192
            String menuText = ar.menuText();
 Lines 228-234    Link Here 
228
                key = ar.key();
228
                key = ar.key();
229
            } else {
229
            } else {
230
                assert e.getKind() == ElementKind.METHOD : e;
230
                assert e.getKind() == ElementKind.METHOD : e;
231
                layer(e).instanceFile("dummy", null, ActionListener.class, ar, null);
231
                builder.instanceFile("dummy", null, ActionListener.class, ar, null);
232
                key = ar.key();
232
                key = ar.key();
233
            }
233
            }
234
234
 Lines 263-285    Link Here 
263
                    }
263
                    }
264
                }
264
                }
265
                if (ar.iconBase().length() > 0) {
265
                if (ar.iconBase().length() > 0) {
266
                    boolean found = false;
266
                    builder.validateResource(ar.iconBase(), e, ar, "iconBase", true);
267
                    for (StandardLocation l : StandardLocation.values()) {
268
                        try {
269
                            processingEnv.getFiler().getResource(l, "", ar.iconBase());
270
                            found = true;
271
                            break;
272
                        } catch (IOException ex) {
273
                            continue;
274
                        } catch (IllegalArgumentException x) {
275
                            throw new LayerGenerationException("Problem with " + ar.iconBase() + " (should be resource path with no leading slash)", e, processingEnv, ar, "iconBase");
276
                        }
277
                    }
278
                    if (!found) {
279
                        throw new LayerGenerationException(
280
                            "Cannot find iconBase file at " + ar.iconBase(), e, processingEnv, ar, "iconBase"
281
                        );
282
                    }
283
                    f.stringvalue("iconBase", ar.iconBase());
267
                    f.stringvalue("iconBase", ar.iconBase());
284
                }
268
                }
285
                f.boolvalue("noIconInMenu", !ar.iconInMenu());
269
                f.boolvalue("noIconInMenu", !ar.iconInMenu());
(-)a/openide.filesystems/apichanges.xml (+16 lines)
 Lines 49-54    Link Here 
49
        <apidef name="filesystems">Filesystems API</apidef>
49
        <apidef name="filesystems">Filesystems API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
        <change id="validateResource_196452">
53
            <api name="filesystems"/>
54
            <summary><code>LayerBuilder</code> can validate resources</summary>
55
            <version major="7" minor="51"/>
56
            <date day="25" month="7" year="2011"/>
57
            <author login="jglick"/>
58
            <compatibility addition="yes"/>
59
            <description>
60
                <p>
61
                    <code>LayerBuilder</code> has a new <code>validateResource</code> method.
62
                    <code>absolutizeResource</code> was also added.
63
                </p>
64
            </description>
65
            <class package="org.openide.filesystems.annotations" name="LayerBuilder"/>
66
            <issue number="196452"/>
67
        </change>
52
        <change id="LayerGenerationException_194545">
68
        <change id="LayerGenerationException_194545">
53
            <api name="filesystems"/>
69
            <api name="filesystems"/>
54
            <summary><code>LayerGenerationException</code> has new constructors</summary>
70
            <summary><code>LayerGenerationException</code> has new constructors</summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
 Lines 2-6    Link Here 
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
5
OpenIDE-Module-Specification-Version: 7.50
5
OpenIDE-Module-Specification-Version: 7.51
6
6
(-)a/openide.filesystems/src/org/openide/filesystems/annotations/LayerBuilder.java (-13 / +94 lines)
 Lines 45-52    Link Here 
45
import java.io.FileNotFoundException;
45
import java.io.FileNotFoundException;
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.io.InputStream;
47
import java.io.InputStream;
48
import java.io.ObjectOutputStream;
48
import java.lang.annotation.Annotation;
49
import java.lang.annotation.Annotation;
49
import java.net.URI;
50
import java.net.URI;
51
import java.net.URISyntaxException;
50
import java.util.Arrays;
52
import java.util.Arrays;
51
import java.util.LinkedHashMap;
53
import java.util.LinkedHashMap;
52
import java.util.LinkedList;
54
import java.util.LinkedList;
 Lines 66-71    Link Here 
66
import javax.lang.model.type.TypeMirror;
68
import javax.lang.model.type.TypeMirror;
67
import javax.lang.model.util.ElementFilter;
69
import javax.lang.model.util.ElementFilter;
68
import javax.tools.Diagnostic.Kind;
70
import javax.tools.Diagnostic.Kind;
71
import javax.tools.FileObject;
72
import javax.tools.JavaFileManager.Location;
69
import javax.tools.StandardLocation;
73
import javax.tools.StandardLocation;
70
import org.openide.util.NbBundle.Messages;
74
import org.openide.util.NbBundle.Messages;
71
import org.w3c.dom.Document;
75
import org.w3c.dom.Document;
 Lines 310-315    Link Here 
310
    }
314
    }
311
315
312
    /**
316
    /**
317
     * Validates a resource named in an annotation.
318
     * <p>Note that resources found in the binary classpath (if permitted)
319
     * cannot actually be located when running inside javac on JDK 6 (see #196933 for discussion), in which case
320
     * no exception is thrown but the return value may not permit {@link FileObject#openInputStream}.
321
     * <p>Also remember that the binary compilation classpath for an Ant-based NetBeans module does
322
     * not include non-public packages or indeed any non-classfiles from module dependencies.
323
     * The processorpath does contain all of these but it is not consulted.
324
     * The classpath for a Maven-based module does also contain resources from dependencies.
325
     * @param resource an absolute resource path with no leading slash (perhaps the output of {@link #absolutizeResource})
326
     * @param originatingElement the annotated element; used both for error reporting, and (optionally) for its package
327
     * @param annotation as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
328
     * @param annotationMethod as in {@link LayerGenerationException#LayerGenerationException(String,Element,ProcessingEnvironment,Annotation,String)}
329
     * @param searchClasspath true to search in the binary classpath and not just source path (see caveat about JDK 6)
330
     * @return the content of the resource, for further validation
331
     * @throws LayerGenerationException if no such resource can be found
332
     * @since 7.51
333
     */
334
    public FileObject validateResource(String resource, Element originatingElement, Annotation annotation, String annotationMethod, boolean searchClasspath) throws LayerGenerationException {
335
        if (resource.startsWith("/")) {
336
            throw new LayerGenerationException("do not use leading slashes on resource paths", originatingElement, processingEnv, annotation, annotationMethod);
337
        }
338
        if (searchClasspath) {
339
            for (Location loc : new Location[] {StandardLocation.SOURCE_PATH, /* #181355 */StandardLocation.CLASS_OUTPUT, StandardLocation.CLASS_PATH, StandardLocation.PLATFORM_CLASS_PATH}) {
340
                try {
341
                    return processingEnv.getFiler().getResource(loc, "", resource);
342
                } catch (IOException ex) {
343
                    continue;
344
                }
345
            }
346
            throw new LayerGenerationException("Cannot find resource " + resource, originatingElement, processingEnv, annotation, annotationMethod);
347
        } else {
348
            try {
349
                try {
350
                    FileObject f = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", resource);
351
                    f.openInputStream().close();
352
                    return f;
353
                } catch (FileNotFoundException x) {
354
                    try {
355
                        FileObject f = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
356
                        f.openInputStream().close();
357
                        return f;
358
                    } catch (IOException x2) {
359
                        throw x;
360
                    }
361
                }
362
            } catch (IOException x) {
363
                throw new LayerGenerationException("Cannot find resource " + resource, originatingElement, processingEnv, annotation, annotationMethod);
364
            }
365
        }
366
    }
367
368
    /**
369
     * Allows a processor to accept relative resource paths.
370
     * For example, to produce the output value {@code net/nowhere/lib/icon.png}
371
     * given an element in the package {@code net.nowhere.app}, the following inputs are permitted:
372
     * <ul>
373
     * <li>{@code ../lib/icon.png}
374
     * <li>{@code /net/nowhere/lib/icon.png}
375
     * </ul>
376
     * @param originatingElement the annotated element, used for its package
377
     * @param resource a possibly relative resource path
378
     * @return an absolute resource path (with no leading slash)
379
     * @throws LayerGenerationException in case the resource path is malformed
380
     * @since 7.51
381
     */
382
    public static String absolutizeResource(Element originatingElement, String resource) throws LayerGenerationException {
383
        if (resource.startsWith("/")) {
384
            return resource.substring(1);
385
        } else {
386
            try {
387
                return new URI(null, findPackage(originatingElement).replace('.', '/') + "/", null).resolve(new URI(null, resource, null)).getPath();
388
            } catch (URISyntaxException x) {
389
                throw new LayerGenerationException(x.toString(), originatingElement);
390
            }
391
        }
392
    }
393
    private static String findPackage(Element e) {
394
        switch (e.getKind()) {
395
        case PACKAGE:
396
            return ((PackageElement) e).getQualifiedName().toString();
397
        default:
398
            return findPackage(e.getEnclosingElement());
399
        }
400
    }
401
402
403
    /**
313
     * Builder for creating a single file entry.
404
     * Builder for creating a single file entry.
314
     */
405
     */
315
    public final class File {
406
    public final class File {
 Lines 627-655    Link Here 
627
                    }
718
                    }
628
                }
719
                }
629
            }
720
            }
630
            String resource = bundle.replace('.', '/') + ".properties";
631
            try {
721
            try {
632
                InputStream is;
722
                InputStream is = validateResource(bundle.replace('.', '/') + ".properties", originatingElement, null, null, false).openInputStream();
633
                try {
634
                    is = processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", resource).openInputStream();
635
                } catch (FileNotFoundException x) { // #181355
636
                    try {
637
                        is = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource).openInputStream();
638
                    } catch (IOException x2) {
639
                        throw x;
640
                    }
641
                }
642
                try {
723
                try {
643
                    Properties p = new Properties();
724
                    Properties p = new Properties();
644
                    p.load(is);
725
                    p.load(is);
645
                    if (p.getProperty(key) == null) {
726
                    if (p.getProperty(key) == null) {
646
                        throw new LayerGenerationException("No key '" + key + "' found in " + resource, originatingElement, processingEnv, annotation, annotationMethod);
727
                        throw new LayerGenerationException("No key '" + key + "' found in " + bundle, originatingElement, processingEnv, annotation, annotationMethod);
647
                    }
728
                    }
648
                } finally {
729
                } finally {
649
                    is.close();
730
                    is.close();
650
                }
731
                }
651
            } catch (IOException x) {
732
            } catch (IOException x) {
652
                throw new LayerGenerationException("Could not open " + resource + ": " + x, originatingElement, processingEnv, annotation, annotationMethod);
733
                throw new LayerGenerationException("Could not open " + bundle + ": " + x, originatingElement, processingEnv, annotation, annotationMethod);
653
            }
734
            }
654
        }
735
        }
655
736
(-)a/openide.filesystems/test/unit/src/org/openide/filesystems/annotations/LayerBuilderTest.java (+19 lines)
 Lines 46-51    Link Here 
46
import java.io.File;
46
import java.io.File;
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.lang.annotation.Annotation;
48
import java.lang.annotation.Annotation;
49
import java.net.URL;
50
import java.net.URLClassLoader;
49
import java.util.Collections;
51
import java.util.Collections;
50
import java.util.List;
52
import java.util.List;
51
import java.util.Set;
53
import java.util.Set;
 Lines 61-66    Link Here 
61
import javax.lang.model.element.Name;
63
import javax.lang.model.element.Name;
62
import javax.lang.model.element.TypeElement;
64
import javax.lang.model.element.TypeElement;
63
import javax.lang.model.type.TypeMirror;
65
import javax.lang.model.type.TypeMirror;
66
import javax.tools.ToolProvider;
64
import org.netbeans.junit.NbTestCase;
67
import org.netbeans.junit.NbTestCase;
65
import org.openide.util.lookup.ServiceProvider;
68
import org.openide.util.lookup.ServiceProvider;
66
import org.openide.util.test.AnnotationProcessorTestUtils;
69
import org.openide.util.test.AnnotationProcessorTestUtils;
 Lines 295-298    Link Here 
295
        }
298
        }
296
    }
299
    }
297
300
301
    public void testValidateResourceExistent() throws Exception {
302
        // XXX
303
    }
304
305
    public void testValidateResourceNonexistent() throws Exception {
306
        if (new URLClassLoader(new URL[] {ToolProvider.getSystemJavaCompiler().getClass().getProtectionDomain().getCodeSource().getLocation()}).findResource("com/sun/tools/javac/util/Filter.class") == null) {
307
            System.err.println("#196933: testValidateResourceNonexistent will only pass when using JDK 7 javac, skipping");
308
            return;
309
        }
310
        // XXX
311
    }
312
313
    public void testAbsolutizeResource() throws Exception {
314
        // XXX
315
    }
316
298
}
317
}
(-)a/options.api/nbproject/project.xml (-1 / +1 lines)
 Lines 120-126    Link Here 
120
                    <build-prerequisite/>
120
                    <build-prerequisite/>
121
                    <compile-dependency/>
121
                    <compile-dependency/>
122
                    <run-dependency>
122
                    <run-dependency>
123
                        <specification-version>7.50</specification-version>
123
                        <specification-version>7.51</specification-version>
124
                    </run-dependency>
124
                    </run-dependency>
125
                </dependency>
125
                </dependency>
126
                <dependency>
126
                <dependency>
(-)a/options.api/src/org/netbeans/modules/options/OptionsPanelControllerProcessor.java (-21 / +9 lines)
 Lines 42-49    Link Here 
42
42
43
package org.netbeans.modules.options;
43
package org.netbeans.modules.options;
44
44
45
import java.io.FileNotFoundException;
46
import java.io.IOException;
47
import java.lang.annotation.Annotation;
45
import java.lang.annotation.Annotation;
48
import java.util.Arrays;
46
import java.util.Arrays;
49
import java.util.HashSet;
47
import java.util.HashSet;
 Lines 54-66    Link Here 
54
import javax.lang.model.SourceVersion;
52
import javax.lang.model.SourceVersion;
55
import javax.lang.model.element.Element;
53
import javax.lang.model.element.Element;
56
import javax.lang.model.element.TypeElement;
54
import javax.lang.model.element.TypeElement;
57
import javax.tools.StandardLocation;
58
import org.netbeans.spi.options.AdvancedOption;
55
import org.netbeans.spi.options.AdvancedOption;
59
import org.netbeans.spi.options.OptionsCategory;
56
import org.netbeans.spi.options.OptionsCategory;
60
import org.netbeans.spi.options.OptionsPanelController;
57
import org.netbeans.spi.options.OptionsPanelController;
61
import org.netbeans.spi.options.OptionsPanelController.ContainerRegistration;
58
import org.netbeans.spi.options.OptionsPanelController.ContainerRegistration;
62
import org.netbeans.spi.options.OptionsPanelController.SubRegistration;
59
import org.netbeans.spi.options.OptionsPanelController.SubRegistration;
63
import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration;
60
import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration;
61
import org.openide.filesystems.annotations.LayerBuilder;
64
import org.openide.filesystems.annotations.LayerBuilder.File;
62
import org.openide.filesystems.annotations.LayerBuilder.File;
65
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
63
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
66
import org.openide.filesystems.annotations.LayerGenerationException;
64
import org.openide.filesystems.annotations.LayerGenerationException;
 Lines 84-95    Link Here 
84
        }
82
        }
85
        for (Element e : roundEnv.getElementsAnnotatedWith(TopLevelRegistration.class)) {
83
        for (Element e : roundEnv.getElementsAnnotatedWith(TopLevelRegistration.class)) {
86
            TopLevelRegistration r = e.getAnnotation(TopLevelRegistration.class);
84
            TopLevelRegistration r = e.getAnnotation(TopLevelRegistration.class);
87
            File file = layer(e).instanceFile("OptionsDialog", r.id().length() > 0 ? r.id() : null, r, null).
85
            LayerBuilder builder = layer(e);
86
            File file = builder.instanceFile("OptionsDialog", r.id().length() > 0 ? r.id() : null, r, null).
88
                    methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
87
                    methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
89
                    instanceAttribute("controller", OptionsPanelController.class).
88
                    instanceAttribute("controller", OptionsPanelController.class).
90
                    bundlevalue("categoryName", r.categoryName()).
89
                    bundlevalue("categoryName", r.categoryName()).
91
                    position(r.position());
90
                    position(r.position());
92
            iconBase(e, r.iconBase(), r, file);
91
            iconBase(e, r.iconBase(), r, file, builder);
93
            keywords(e, r.keywords(), r.keywordsCategory(), r, file);
92
            keywords(e, r.keywords(), r.keywordsCategory(), r, file);
94
            file.write();
93
            file.write();
95
        }
94
        }
 Lines 108-119    Link Here 
108
        }
107
        }
109
        for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) {
108
        for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) {
110
            ContainerRegistration r = e.getAnnotation(ContainerRegistration.class);
109
            ContainerRegistration r = e.getAnnotation(ContainerRegistration.class);
111
            File file = layer(e).file("OptionsDialog/" + r.id() + ".instance").
110
            LayerBuilder builder = layer(e);
111
            File file = builder.file("OptionsDialog/" + r.id() + ".instance").
112
                    methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
112
                    methodvalue("instanceCreate", OptionsCategory.class.getName(), "createCategory").
113
                    stringvalue("advancedOptionsFolder", "OptionsDialog/" + r.id()).
113
                    stringvalue("advancedOptionsFolder", "OptionsDialog/" + r.id()).
114
                    bundlevalue("categoryName", r.categoryName()).
114
                    bundlevalue("categoryName", r.categoryName()).
115
                    position(r.position());
115
                    position(r.position());
116
            iconBase(e, r.iconBase(), r, file);
116
            iconBase(e, r.iconBase(), r, file, builder);
117
            keywords(e, r.keywords(), r.keywordsCategory(), r, file);
117
            keywords(e, r.keywords(), r.keywordsCategory(), r, file);
118
            file.write();
118
            file.write();
119
            layer(e).folder("OptionsDialog/" + r.id()).position(0).write();
119
            layer(e).folder("OptionsDialog/" + r.id()).position(0).write();
 Lines 121-140    Link Here 
121
        return true;
121
        return true;
122
    }
122
    }
123
123
124
    private void iconBase(Element e, String iconBase, Annotation r, File file) throws LayerGenerationException {
124
    private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException {
125
        try { // XXX should probably be made a utility method in LayerBuilder
125
        builder.validateResource(iconBase, e, r, "iconBase", false);
126
            try {
127
                processingEnv.getFiler().getResource(StandardLocation.SOURCE_PATH, "", iconBase).openInputStream().close();
128
            } catch (FileNotFoundException x) {
129
                try {
130
                    processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", iconBase).openInputStream().close();
131
                } catch (IOException x2) {
132
                    throw x;
133
                }
134
            }
135
        } catch (IOException x) {
136
            throw new LayerGenerationException("Could not open " + iconBase + ": " + x, e, processingEnv, r, "iconBase");
137
        }
138
        file.stringvalue("iconBase", iconBase);
126
        file.stringvalue("iconBase", iconBase);
139
    }
127
    }
140
128
(-)a/schema2beans/src/org/netbeans/modules/schema2beansdev/Schema2BeansProcessor.java (+1 lines)
 Lines 189-194    Link Here 
189
    }
189
    }
190
190
191
    private FileObject findResource(String path, String pkg) throws URISyntaxException, IOException {
191
    private FileObject findResource(String path, String pkg) throws URISyntaxException, IOException {
192
        // XXX LayerBuilder has standard versions of this logic now
192
        String abspath;
193
        String abspath;
193
        if (path.startsWith("/")) {
194
        if (path.startsWith("/")) {
194
            abspath = path.substring(1);
195
            abspath = path.substring(1);

Return to bug 196452
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo