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

(-)a/collab.ui/src/org/netbeans/modules/collab/ui/beaninfo/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.modules.collab.ui.beaninfo;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5
(-)a/collab.ui/src/org/netbeans/modules/collab/ui/options/AccountNode.java (-37 / +3 lines)
Lines 43-62 Link Here
43
 */
43
 */
44
package org.netbeans.modules.collab.ui.options;
44
package org.netbeans.modules.collab.ui.options;
45
45
46
import com.sun.collablet.*;
46
import java.awt.Image;
47
import java.awt.Image;
47
import java.beans.*;
48
import java.beans.*;
48
import java.io.IOException;
49
import java.io.IOException;
49
import java.util.*;
50
import org.netbeans.modules.collab.core.Debug;
50
51
import org.netbeans.modules.collab.ui.actions.*;
51
import org.openide.actions.*;
52
import org.openide.actions.*;
52
import org.openide.nodes.*;
53
import org.openide.nodes.*;
53
import org.openide.util.*;
54
import org.openide.util.*;
54
import org.openide.util.actions.SystemAction;
55
import org.openide.util.actions.SystemAction;
55
56
56
import com.sun.collablet.*;
57
import org.netbeans.modules.collab.core.Debug;
58
import org.netbeans.modules.collab.ui.actions.*;
59
60
/**
57
/**
61
 *
58
 *
62
 *
59
 *
Lines 79-115 Link Here
79
        };
76
        };
80
77
81
    ////////////////////////////////////////////////////////////////////////////
78
    ////////////////////////////////////////////////////////////////////////////
82
    // Static initializer
83
    ////////////////////////////////////////////////////////////////////////////
84
    static {
85
        // Add our own bean info search path, since we want to provide BeanInfo
86
        // for the Account class, but it's in another package. Note, this code 
87
        // goes here because this class may be referenced before others in the 
88
        // module (including DefaultUserInterface).  If, however, other classes 
89
        // also want to provide alternate BeanInfo, then this code may need to 
90
        // move to the first class likely to be loaded.
91
        final String BEAN_INFO_PATH = "org.netbeans.modules.collab.ui.beaninfo"; // NOI18N
92
93
        boolean found = false;
94
95
        String[] paths = Introspector.getBeanInfoSearchPath();
96
97
        for (int i = 0; i < paths.length; i++) {
98
            if (paths[i].equals(BEAN_INFO_PATH)) {
99
                found = true;
100
101
                break;
102
            }
103
        }
104
105
        if (!found) {
106
            List pathList = new ArrayList(Arrays.asList(paths));
107
            pathList.add(BEAN_INFO_PATH);
108
            Introspector.setBeanInfoSearchPath((String[]) pathList.toArray(new String[pathList.size()]));
109
        }
110
    }
111
112
    ////////////////////////////////////////////////////////////////////////////
113
    // Instance variables
79
    // Instance variables
114
    ////////////////////////////////////////////////////////////////////////////
80
    ////////////////////////////////////////////////////////////////////////////
115
    private Account account;
81
    private Account account;
(-)a/core.execution/src/org/netbeans/core/execution/Install.java (-23 lines)
Lines 110-132 Link Here
110
@OnStart
110
@OnStart
111
public class Install implements Runnable {
111
public class Install implements Runnable {
112
    
112
    
113
    private static final String BEANINFO_PATH
114
            = "org.netbeans.core.execution.beaninfo"; // NOI18N
115
116
    private static final Logger LOG = Logger.getLogger(Install.class.getName());
113
    private static final Logger LOG = Logger.getLogger(Install.class.getName());
117
    
114
    
118
    public @Override void run() {
115
    public @Override void run() {
119
        TopSecurityManager.register(SecMan.DEFAULT);
116
        TopSecurityManager.register(SecMan.DEFAULT);
120
        
121
        // Add beaninfo search path.
122
        String[] sp = Introspector.getBeanInfoSearchPath();
123
        java.util.List<String> paths = Arrays.asList(sp);
124
        if(!paths.contains(BEANINFO_PATH)) {
125
            paths = new ArrayList<String>(paths);
126
            paths.add(BEANINFO_PATH);
127
            Introspector.setBeanInfoSearchPath(
128
                    paths.toArray(new String[0]));
129
        }
130
    }
117
    }
131
    
118
    
132
    @OnStop
119
    @OnStop
Lines 136-151 Link Here
136
            showPendingTasks();
123
            showPendingTasks();
137
124
138
            TopSecurityManager.unregister(SecMan.DEFAULT);
125
            TopSecurityManager.unregister(SecMan.DEFAULT);
139
140
            // Remove beaninfo search path.
141
            String[] sp = Introspector.getBeanInfoSearchPath();
142
            java.util.List<String> paths = Arrays.asList(sp);
143
            if(paths.contains(BEANINFO_PATH)) {
144
                paths = new ArrayList<String>(paths);
145
                paths.remove(BEANINFO_PATH);
146
                Introspector.setBeanInfoSearchPath(
147
                        paths.toArray(new String[0]));
148
            }
149
        }
126
        }
150
    }
127
    }
151
128
(-)a/core.execution/src/org/netbeans/core/execution/beaninfo/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.core.execution.beaninfo;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5
(-)a/core.startup/apichanges.xml (+15 lines)
Lines 56-61 Link Here
56
<!-- ACTUAL CHANGES BEGIN HERE: -->
56
<!-- ACTUAL CHANGES BEGIN HERE: -->
57
57
58
  <changes>
58
  <changes>
59
      <change id="registerBeanInfoSearchPath">
60
        <api name="bridge"/>
61
        <summary>getDefault</summary>
62
        <version major="1" minor="45"/>
63
        <date day="22" month="11" year="2012"/>
64
        <author login="jhorvath"/>
65
        <compatibility addition="yes" binary="incompatible" semantic="compatible" />
66
        <description>
67
        <p>
68
            Adding a new method <code>registerBeanInfoSearchPath</code> to <code>CoreBridge</code>.
69
        </p>
70
        </description>
71
        <class package="org.netbeans.core.startup" name="CoreBridge"/>
72
        <issue number="210323"/>
73
    </change>
59
     <change id="async-shutdown">
74
     <change id="async-shutdown">
60
        <api name="bridge"/>
75
        <api name="bridge"/>
61
        <summary>getDefault</summary>
76
        <summary>getDefault</summary>
(-)a/core.startup/manifest.mf (-1 / +1 lines)
Lines 3-7 Link Here
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/core/startup/Bundle.properties
4
OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/core/startup/layer.xml
5
OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator
5
OpenIDE-Module-Provides: org.openide.modules.InstalledFileLocator
6
OpenIDE-Module-Specification-Version: 1.44
6
OpenIDE-Module-Specification-Version: 1.45
7
7
(-)a/core.startup/src/org/netbeans/core/startup/CoreBridge.java (+7 lines)
Lines 85-90 Link Here
85
    /** Abstracts away from definition of property editors. 
85
    /** Abstracts away from definition of property editors. 
86
     * @since 1.7 */
86
     * @since 1.7 */
87
    public abstract void registerPropertyEditors();
87
    public abstract void registerPropertyEditors();
88
    
89
    /**
90
     * @since 1.45 */
91
    public abstract void registerBeanInfoSearchPath();
88
92
89
    public abstract Lookup lookupCacheLoad ();
93
    public abstract Lookup lookupCacheLoad ();
90
    
94
    
Lines 153-158 Link Here
153
157
154
        public void registerPropertyEditors() {
158
        public void registerPropertyEditors() {
155
        }
159
        }
160
        
161
        public void registerBeanInfoSearchPath() {
162
        }
156
163
157
        public int cli(String[] string, InputStream inputStream, OutputStream outputStream, OutputStream errorStream, File file) {
164
        public int cli(String[] string, InputStream inputStream, OutputStream outputStream, OutputStream errorStream, File file) {
158
            return 0;
165
            return 0;
(-)a/core.startup/src/org/netbeans/core/startup/Main.java (-13 / +5 lines)
Lines 250-267 Link Here
250
250
251
    InstalledFileLocatorImpl.prepareCache();
251
    InstalledFileLocatorImpl.prepareCache();
252
252
253
    // Initialize beans - [PENDING - better place for this ?]
254
    //                    [PENDING - can PropertyEditorManager garbage collect ?]
255
    String[] sysbisp = Introspector.getBeanInfoSearchPath();
256
    String[] nbbisp = new String[] {
257
        "org.netbeans.beaninfo", // NOI18N
258
    };
259
    String[] allbisp = new String[sysbisp.length + nbbisp.length];
260
    System.arraycopy(nbbisp, 0, allbisp, 0, nbbisp.length);
261
    System.arraycopy(sysbisp, 0, allbisp, nbbisp.length, sysbisp.length);
262
    Introspector.setBeanInfoSearchPath(allbisp);
263
264
265
    try {
253
    try {
266
        if (!Boolean.getBoolean("netbeans.full.hack") && !Boolean.getBoolean("netbeans.close")) {
254
        if (!Boolean.getBoolean("netbeans.full.hack") && !Boolean.getBoolean("netbeans.close")) {
267
	    // -----------------------------------------------------------------------------------------------------
255
	    // -----------------------------------------------------------------------------------------------------
Lines 307-313 Link Here
307
    // property editors are registered in modules, so wait a while before loading them
295
    // property editors are registered in modules, so wait a while before loading them
308
    CoreBridge.getDefault().registerPropertyEditors();
296
    CoreBridge.getDefault().registerPropertyEditors();
309
    StartLog.logProgress ("PropertyEditors registered"); // NOI18N
297
    StartLog.logProgress ("PropertyEditors registered"); // NOI18N
310
298
    
299
    // BeanInfo search paths are registered in module layers. Wait till all modules are loaded
300
    CoreBridge.getDefault().registerBeanInfoSearchPath();
301
    StartLog.logProgress ("BeanInfo search path registered"); // NOI18N
302
    
311
    org.netbeans.Main.finishInitialization();
303
    org.netbeans.Main.finishInitialization();
312
    StartLog.logProgress("Ran any delayed command-line options"); // NOI18N
304
    StartLog.logProgress("Ran any delayed command-line options"); // NOI18N
313
    
305
    
(-)a/form/src/org/netbeans/modules/form/FormEditorModule.java (-23 lines)
Lines 45-54 Link Here
45
package org.netbeans.modules.form;
45
package org.netbeans.modules.form;
46
46
47
import java.beans.Beans;
47
import java.beans.Beans;
48
import java.beans.Introspector;
49
import java.util.ArrayList;
50
import java.util.Arrays;
51
import java.util.List;
52
import org.openide.modules.ModuleInstall;
48
import org.openide.modules.ModuleInstall;
53
49
54
/**
50
/**
Lines 56-64 Link Here
56
 */
52
 */
57
public class FormEditorModule extends ModuleInstall {
53
public class FormEditorModule extends ModuleInstall {
58
54
59
    private static final String BEANINFO_PATH_AWT = "org.netbeans.modules.form.beaninfo.awt"; // NOI18N
60
    private static final String BEANINFO_PATH_SWING = "org.netbeans.modules.form.beaninfo.swing"; // NOI18N
61
62
    @Override
55
    @Override
63
    public void restored() {
56
    public void restored() {
64
        Beans.setDesignTime(true);
57
        Beans.setDesignTime(true);
Lines 69-94 Link Here
69
            javax.swing.KeyStroke.class,
62
            javax.swing.KeyStroke.class,
70
            org.netbeans.modules.form.editors.KeyStrokeEditor.class);
63
            org.netbeans.modules.form.editors.KeyStrokeEditor.class);
71
64
72
        // Add beaninfo search path.
73
        String[] sp = Introspector.getBeanInfoSearchPath();
74
        List<String> paths = new ArrayList<String>(Arrays.asList(sp));
75
        if (!paths.contains(BEANINFO_PATH_AWT)) {
76
            paths.add(BEANINFO_PATH_AWT);
77
        }
78
        if (!paths.contains(BEANINFO_PATH_SWING)) {
79
            paths.add(BEANINFO_PATH_SWING);
80
        }
81
        Introspector.setBeanInfoSearchPath(paths.toArray(new String[paths.size()]));
82
    }
65
    }
83
66
84
    @Override
67
    @Override
85
    public void uninstalled() {
68
    public void uninstalled() {
86
        // Remove beaninfo search path.
87
        String[] sp = Introspector.getBeanInfoSearchPath();
88
        List<String> paths = new ArrayList<String>(Arrays.asList(sp));
89
        paths.remove(BEANINFO_PATH_AWT);
90
        paths.remove(BEANINFO_PATH_SWING);
91
        Introspector.setBeanInfoSearchPath(paths.toArray(new String[paths.size()]));
92
    }
69
    }
93
70
94
}
71
}
(-)a/form/src/org/netbeans/modules/form/beaninfo/awt/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.modules.form.beaninfo.awt;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5
(-)a/form/src/org/netbeans/modules/form/beaninfo/swing/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.modules.form.beaninfo.swing;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5
(-)a/ide.kit/test/qa-functional/data/whitelist_1.txt (-5 / +9 lines)
Lines 1-12 Link Here
1
#OK on Nov 22, 2012, was #218044
1
#OK on Nov 22, 2012, was #218044
2
org.netbeans.modules.javascript2.editor.ModuleInstaller
2
org.netbeans.modules.javascript2.editor.ModuleInstaller
3
3
4
#OK on Nov 22, 2012, was #210323 
5
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$BeanInfoReg
6
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$BeanInfoRegistration
7
4
#OK on Oct 29, 2012, was #220904
8
#OK on Oct 29, 2012, was #220904
5
org.netbeans.modules.openide.nodes.PERegistrationSupport
9
org.netbeans.modules.openide.nodes.NodesRegistrationSupport
6
org.netbeans.modules.openide.nodes.PERegistrationSupport$ClassReg
10
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$ClassReg
7
org.netbeans.modules.openide.nodes.PERegistrationSupport$PEClassRegistration
11
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PEClassRegistration
8
org.netbeans.modules.openide.nodes.PERegistrationSupport$PEPackageRegistration
12
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PEPackageRegistration
9
org.netbeans.modules.openide.nodes.PERegistrationSupport$PkgReg
13
org.netbeans.modules.openide.nodes.NodesRegistrationSupport$PkgReg
10
14
11
#OK on Oct 31, 2012, needed because of enabled logging due to #220899
15
#OK on Oct 31, 2012, needed because of enabled logging due to #220899
12
org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory
16
org.eclipse.core.runtime.internal.adaptor.EclipseLogFactory
(-)a/o.n.core/src/org/netbeans/beaninfo/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.beaninfo;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5
(-)a/o.n.core/src/org/netbeans/core/CoreBridgeImpl.java (+4 lines)
Lines 163-168 Link Here
163
    public void registerPropertyEditors() {
163
    public void registerPropertyEditors() {
164
        doRegisterPropertyEditors();
164
        doRegisterPropertyEditors();
165
    }
165
    }
166
    
167
    public void registerBeanInfoSearchPath() {
168
        NodeOp.registerBeanInfoSearchPath();
169
    }
166
170
167
    /**Flag to avoid multiple adds of the same path to the
171
    /**Flag to avoid multiple adds of the same path to the
168
     * of PropertyEditorManager if multiple tests call 
172
     * of PropertyEditorManager if multiple tests call 
(-)a/openide.nodes/apichanges.xml (+17 lines)
Lines 49-54 Link Here
49
<apidef name="nodes">Nodes API</apidef>
49
<apidef name="nodes">Nodes API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="BeanInfoSearchPath">
53
        <api name="nodes"/>
54
        <summary>Adding <code>@BeanInfoSearchPath</code> annotation</summary>
55
        <version major="7" minor="32"/>
56
        <date year="2012" month="11" day="22"/>
57
        <author login="jhorvath"/>
58
        <compatibility addition="yes" binary="compatible" source="compatible" deprecation="no" deletion="no"/>
59
        <description>
60
            <p>
61
                Adding <code>@BeanInfoSearchPath</code> annotation
62
                to allow convenient way of registering BeanInfo search path.
63
            </p>
64
        </description>
65
        <class package="org.openide.nodes" name="NodeOp"/>
66
        <class package="org.openide.nodes" name="BeanInfoSearchPath"/>
67
        <issue number="210323"/>
68
    </change>
52
    <change id="PropertyEditorRegistration">
69
    <change id="PropertyEditorRegistration">
53
        <api name="nodes"/>
70
        <api name="nodes"/>
54
        <summary>Adding <code>@PropertyEditorRegistration</code> and <code>@PropertyEditorSearchPath</code> annotations</summary>
71
        <summary>Adding <code>@PropertyEditorRegistration</code> and <code>@PropertyEditorSearchPath</code> annotations</summary>
(-)a/openide.nodes/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.openide.nodes
2
OpenIDE-Module: org.openide.nodes
3
OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/nodes/Bundle.properties
4
AutoUpdate-Essential-Module: true
4
AutoUpdate-Essential-Module: true
5
OpenIDE-Module-Specification-Version: 7.31
5
OpenIDE-Module-Specification-Version: 7.32
6
6
(-)a/openide.nodes/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessor.java (-10 / +29 lines)
Lines 64-69 Link Here
64
import org.openide.filesystems.annotations.LayerBuilder;
64
import org.openide.filesystems.annotations.LayerBuilder;
65
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
65
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
66
import org.openide.filesystems.annotations.LayerGenerationException;
66
import org.openide.filesystems.annotations.LayerGenerationException;
67
import org.openide.nodes.BeanInfoSearchPath;
67
import org.openide.nodes.PropertyEditorRegistration;
68
import org.openide.nodes.PropertyEditorRegistration;
68
import org.openide.nodes.PropertyEditorSearchPath;
69
import org.openide.nodes.PropertyEditorSearchPath;
69
import org.openide.util.lookup.ServiceProvider;
70
import org.openide.util.lookup.ServiceProvider;
Lines 76-84 Link Here
76
 */
77
 */
77
@ServiceProvider(service=Processor.class)
78
@ServiceProvider(service=Processor.class)
78
@SupportedSourceVersion(SourceVersion.RELEASE_6)
79
@SupportedSourceVersion(SourceVersion.RELEASE_6)
79
public class PEAnnotationProcessor extends LayerGeneratingProcessor {
80
public class NodesAnnotationProcessor extends LayerGeneratingProcessor {
80
81
81
    public PEAnnotationProcessor() {
82
    public NodesAnnotationProcessor() {
82
    }
83
    }
83
84
84
    @Override
85
    @Override
Lines 86-91 Link Here
86
        Set<String> set = new HashSet<String>();
87
        Set<String> set = new HashSet<String>();
87
        set.add(PropertyEditorSearchPath.class.getName());
88
        set.add(PropertyEditorSearchPath.class.getName());
88
        set.add(PropertyEditorRegistration.class.getName());
89
        set.add(PropertyEditorRegistration.class.getName());
90
        set.add(BeanInfoSearchPath.class.getName());
89
        return set;
91
        return set;
90
    }
92
    }
91
93
Lines 93-111 Link Here
93
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) 
95
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) 
94
            throws LayerGenerationException {
96
            throws LayerGenerationException {
95
        Messager messager = processingEnv.getMessager();
97
        Messager messager = processingEnv.getMessager();
98
        
99
        // handle @PropertyEditorSearchPath
96
        for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorSearchPath.class)) {
100
        for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorSearchPath.class)) {
97
            String pkg = findPackage(e);
101
            String pkg = findPackage(e);
98
            String pkgFilename = pkg.replace(".", "-"); //NOI18N
102
            String pkgFilename = pkg.replace(".", "-"); //NOI18N
99
            LayerBuilder builder = layer(e);
103
            LayerBuilder builder = layer(e);
100
            LayerBuilder.File file = builder.file(PERegistrationSupport.LOOKUP_PATH 
104
            LayerBuilder.File file = builder.file(NodesRegistrationSupport.PE_LOOKUP_PATH 
101
                    + "/Package-" + pkgFilename + ".instance"); //NOI18N
105
                    + "/Package-" + pkgFilename + ".instance"); //NOI18N
102
            file.methodvalue("instanceCreate", PERegistrationSupport.class.getName(), 
106
            file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), 
103
                    "createPackageRegistration"); //NOI18N
107
                    "createPackageRegistration"); //NOI18N
104
            file.stringvalue(PERegistrationSupport.PACKAGE, pkg);
108
            file.stringvalue(NodesRegistrationSupport.PACKAGE, pkg);
105
            file.stringvalue("instanceOf", PERegistrationSupport.PEPackageRegistration.class.getName());
109
            file.stringvalue("instanceOf", NodesRegistrationSupport.PEPackageRegistration.class.getName());
106
            file.write();
110
            file.write();
107
        }
111
        }
108
112
113
        // handle @PropertyEditorRegistration
109
        for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorRegistration.class)) {
114
        for (Element e : roundEnv.getElementsAnnotatedWith(PropertyEditorRegistration.class)) {
110
            if (e.getKind() == ElementKind.CLASS) {
115
            if (e.getKind() == ElementKind.CLASS) {
111
                String className = ((TypeElement) e).getQualifiedName().toString();
116
                String className = ((TypeElement) e).getQualifiedName().toString();
Lines 130-139 Link Here
130
135
131
                LayerBuilder builder = layer(e);
136
                LayerBuilder builder = layer(e);
132
                String clsFileName = className.replace(".", "-"); //NOI18N
137
                String clsFileName = className.replace(".", "-"); //NOI18N
133
                LayerBuilder.File file = builder.instanceFile(PERegistrationSupport.LOOKUP_PATH, "Class-" + clsFileName); //NOI18N
138
                LayerBuilder.File file = builder.instanceFile(NodesRegistrationSupport.PE_LOOKUP_PATH, "Class-" + clsFileName); //NOI18N
134
                file.methodvalue("instanceCreate", PERegistrationSupport.class.getName(), "createClassRegistration"); //NOI18N
139
                file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), "createClassRegistration"); //NOI18N
135
                file.stringvalue(PERegistrationSupport.EDITOR_CLASS, className); //NOI18N
140
                file.stringvalue(NodesRegistrationSupport.EDITOR_CLASS, className); //NOI18N
136
                file.stringvalue("instanceOf", PERegistrationSupport.PEClassRegistration.class.getName());
141
                file.stringvalue("instanceOf", NodesRegistrationSupport.PEClassRegistration.class.getName());
137
                int i = 1;
142
                int i = 1;
138
                for (AnnotationValue type : targetTypes) {
143
                for (AnnotationValue type : targetTypes) {
139
                    String clsName = type.accept(new SimpleAnnotationValueVisitor6<String, Object>() {
144
                    String clsName = type.accept(new SimpleAnnotationValueVisitor6<String, Object>() {
Lines 149-154 Link Here
149
                file.write();
154
                file.write();
150
            }
155
            }
151
        }
156
        }
157
        
158
        // handle @BeanInfoSearchPath
159
        for (Element e : roundEnv.getElementsAnnotatedWith(BeanInfoSearchPath.class)) {
160
            String pkg = findPackage(e);
161
            String pkgFilename = pkg.replace(".", "-"); //NOI18N
162
            LayerBuilder builder = layer(e);
163
            LayerBuilder.File file = builder.file(NodesRegistrationSupport.BEANINFO_LOOKUP_PATH 
164
                    + "/BeanInfo-" + pkgFilename + ".instance"); //NOI18N
165
            file.methodvalue("instanceCreate", NodesRegistrationSupport.class.getName(), 
166
                    "createBeanInfoRegistration"); //NOI18N
167
            file.stringvalue(NodesRegistrationSupport.PACKAGE, pkg);
168
            file.stringvalue("instanceOf", NodesRegistrationSupport.BeanInfoRegistration.class.getName());
169
            file.write();
170
        }
152
        return true;
171
        return true;
153
    }
172
    }
154
173
(-)a/openide.nodes/src/org/netbeans/modules/openide/nodes/PERegistrationSupport.java (-9 / +61 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.openide.nodes;
42
package org.netbeans.modules.openide.nodes;
43
43
44
import java.beans.Introspector;
44
import java.beans.PropertyEditorManager;
45
import java.beans.PropertyEditorManager;
45
import java.lang.reflect.Array;
46
import java.lang.reflect.Array;
46
import java.util.Arrays;
47
import java.util.Arrays;
Lines 59-72 Link Here
59
 * 
60
 * 
60
 * @author Jan Horvath <jhorvath@netbeans.org>
61
 * @author Jan Horvath <jhorvath@netbeans.org>
61
 */
62
 */
62
public final class PERegistrationSupport {
63
public final class NodesRegistrationSupport {
63
    
64
    
64
    static final String LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N
65
    static final String PE_LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N
66
    static final String BEANINFO_LOOKUP_PATH = "Services/Introspector"; //NOI18N
65
    static final String PACKAGE = "packagePath"; //NOI18N
67
    static final String PACKAGE = "packagePath"; //NOI18N
66
    static final String EDITOR_CLASS = "propertyEditorClass"; //NOI18N
68
    static final String EDITOR_CLASS = "propertyEditorClass"; //NOI18N
67
    
69
    
68
    static ClassReg clsReg = null;
70
    private static ClassReg clsReg = null;
69
    static PkgReg pkgReg = null;
71
    private static PkgReg pkgReg = null;
72
    private static BeanInfoReg beanInfoReg = null;
70
    
73
    
71
    public static synchronized void registerPropertyEditors() {
74
    public static synchronized void registerPropertyEditors() {
72
        if (clsReg == null) {
75
        if (clsReg == null) {
Lines 77-82 Link Here
77
        }
80
        }
78
    }
81
    }
79
    
82
    
83
    public static void registerBeanInfoSearchPath() {
84
        if (beanInfoReg == null) {
85
            beanInfoReg = new BeanInfoReg();
86
        }
87
    }
88
    
80
    /**
89
    /**
81
     * Creates instance of <code>PEPackageRegistration</code> based on layer.xml
90
     * Creates instance of <code>PEPackageRegistration</code> based on layer.xml
82
     * attribute values
91
     * attribute values
Lines 109-114 Link Here
109
        return new PEClassRegistration(editorClass, targetTypes);
118
        return new PEClassRegistration(editorClass, targetTypes);
110
    }
119
    }
111
    
120
    
121
    public static BeanInfoRegistration createBeanInfoRegistration(final Map attrs) {
122
        String pkg = (String) attrs.get(PACKAGE);
123
        return new BeanInfoRegistration(pkg);
124
    }
125
    
112
    /**
126
    /**
113
     * returns Class from canonical class name like <code>java.lang.String[]</code>
127
     * returns Class from canonical class name like <code>java.lang.String[]</code>
114
     */
128
     */
Lines 149-155 Link Here
149
        }
163
        }
150
        return result;
164
        return result;
151
    }
165
    }
152
    
166
153
    public static class PEPackageRegistration {
167
    public static class PEPackageRegistration {
154
        final String pkg;
168
        final String pkg;
155
169
Lines 168-184 Link Here
168
        }
182
        }
169
    }
183
    }
170
    
184
    
185
    public static class BeanInfoRegistration {
186
        final String searchPath;
187
        
188
        BeanInfoRegistration(String searchPath) {
189
            this.searchPath = searchPath;
190
        }
191
    }
192
    
171
    private static final class ClassReg implements LookupListener {
193
    private static final class ClassReg implements LookupListener {
172
        Result<PEClassRegistration> lookupResult = null;
194
        Result<PEClassRegistration> lookupResult = null;
173
        
195
        
174
        ClassReg() {
196
        ClassReg() {
175
            lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class);
197
            lookupResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEClassRegistration.class);
176
            register();
198
            register();
177
            lookupResult.addLookupListener(this);
199
            lookupResult.addLookupListener(this);
178
        }
200
        }
179
                
201
                
180
        synchronized void register() {
202
        synchronized void register() {
181
            lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class);
203
            lookupResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEClassRegistration.class);
182
            ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
204
            ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
183
            
205
            
184
            for (PEClassRegistration clsReg : lookupResult.allInstances()) {
206
            for (PEClassRegistration clsReg : lookupResult.allInstances()) {
Lines 208-220 Link Here
208
            if (originalPath == null) {
230
            if (originalPath == null) {
209
                originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath());
231
                originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath());
210
            }
232
            }
211
            pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class);
233
            pkgResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEPackageRegistration.class);
212
            register();
234
            register();
213
            pkgResult.addLookupListener(this);
235
            pkgResult.addLookupListener(this);
214
        }
236
        }
215
        
237
        
216
        synchronized void register() {
238
        synchronized void register() {
217
            pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class);
239
            pkgResult = Lookup.getDefault().lookupResult(NodesRegistrationSupport.PEPackageRegistration.class);
218
            Set<String> newPath = new LinkedHashSet<String> ();
240
            Set<String> newPath = new LinkedHashSet<String> ();
219
            for (PEPackageRegistration pkgReg : pkgResult.allInstances()) {
241
            for (PEPackageRegistration pkgReg : pkgResult.allInstances()) {
220
                newPath.add(pkgReg.pkg);
242
                newPath.add(pkgReg.pkg);
Lines 228-231 Link Here
228
            register();
250
            register();
229
        }
251
        }
230
    }
252
    }
253
    
254
    static final class BeanInfoReg implements LookupListener {
255
        Result<BeanInfoRegistration> beanInfoResult;
256
        private static List<String> originalPath = null;
257
        
258
        BeanInfoReg() {
259
            if (originalPath == null) {
260
                originalPath = Arrays.asList(Introspector.getBeanInfoSearchPath());
261
            }
262
            beanInfoResult = Lookup.getDefault().lookupResult(BeanInfoRegistration.class);
263
            register();
264
            beanInfoResult.addLookupListener(this);
265
        }
266
        
267
        synchronized void register() {
268
            beanInfoResult = Lookup.getDefault().lookupResult(BeanInfoRegistration.class);
269
            Set<String> newPath = new LinkedHashSet<String> ();
270
            for (BeanInfoRegistration biReg : beanInfoResult.allInstances()) {
271
                newPath.add(biReg.searchPath);
272
            }
273
            newPath.addAll(originalPath);
274
            Introspector.setBeanInfoSearchPath(newPath.toArray(new String[newPath.size()]));
275
        }
276
277
        @Override
278
        public void resultChanged(LookupEvent ev) {
279
            register();
280
        }
281
    }
282
    
231
}
283
}
(-)a/openide.nodes/src/org/openide/nodes/BeanInfoSearchPath.java (+59 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.openide.nodes;
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
49
/** 
50
 * Add the annotated package to the list of package names that will be used for finding BeanInfo. 
51
 * 
52
 * @since 7.32
53
 * @author Jan Horvath <jhorvath@netbeans.org>
54
 */
55
@Retention(RetentionPolicy.SOURCE)
56
@Target(ElementType.PACKAGE)
57
public @interface BeanInfoSearchPath {  
58
59
}
(-)a/openide.nodes/src/org/openide/nodes/NodeOp.java (-2 / +10 lines)
Lines 56-62 Link Here
56
import java.util.logging.Logger;
56
import java.util.logging.Logger;
57
import javax.swing.Action;
57
import javax.swing.Action;
58
import javax.swing.JPopupMenu;
58
import javax.swing.JPopupMenu;
59
import org.netbeans.modules.openide.nodes.PERegistrationSupport;
59
import org.netbeans.modules.openide.nodes.NodesRegistrationSupport;
60
import org.openide.util.Enumerations;
60
import org.openide.util.Enumerations;
61
import org.openide.util.Lookup;
61
import org.openide.util.Lookup;
62
import org.openide.util.Utilities;
62
import org.openide.util.Utilities;
Lines 468-474 Link Here
468
     * @since 7.30
468
     * @since 7.30
469
     */
469
     */
470
    public static void registerPropertyEditors() {
470
    public static void registerPropertyEditors() {
471
        PERegistrationSupport.registerPropertyEditors();
471
        NodesRegistrationSupport.registerPropertyEditors();
472
    }
473
    
474
    /** Registers BeanInfo search path collected from <code>@BeanInfoSearchPath</code> annotations
475
     * 
476
     * @since 7.32
477
     */
478
    public static void registerBeanInfoSearchPath() {
479
        NodesRegistrationSupport.registerBeanInfoSearchPath();
472
    }
480
    }
473
481
474
    /** more info in class javadoc.
482
    /** more info in class javadoc.
(-)a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java (-2 / +15 lines)
Lines 41-54 Link Here
41
 */
41
 */
42
package org.netbeans.modules.openide.nodes;
42
package org.netbeans.modules.openide.nodes;
43
43
44
import java.beans.Introspector;
44
import java.beans.PropertyEditor;
45
import java.beans.PropertyEditor;
45
import java.beans.PropertyEditorManager;
46
import java.beans.PropertyEditorManager;
46
import java.io.ByteArrayOutputStream;
47
import java.io.ByteArrayOutputStream;
47
import java.io.IOException;
48
import java.io.IOException;
48
import java.util.Collection;
49
import java.util.Collection;
49
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.junit.NbTestCase;
50
import org.netbeans.modules.openide.nodes.PERegistrationSupport.PEClassRegistration;
51
import org.netbeans.modules.openide.nodes.NodesRegistrationSupport.PEClassRegistration;
51
import org.netbeans.modules.openide.nodes.PERegistrationSupport.PEPackageRegistration;
52
import org.netbeans.modules.openide.nodes.NodesRegistrationSupport.PEPackageRegistration;
52
import org.openide.nodes.NodeOp;
53
import org.openide.nodes.NodeOp;
53
import org.openide.util.Lookup;
54
import org.openide.util.Lookup;
54
import org.openide.util.test.AnnotationProcessorTestUtils;
55
import org.openide.util.test.AnnotationProcessorTestUtils;
Lines 147-151 Link Here
147
        PEPackageRegistration pkgReg = lookup.iterator().next();
148
        PEPackageRegistration pkgReg = lookup.iterator().next();
148
        assertEquals("org.netbeans.modules.openide.nodes", pkgReg.pkg);
149
        assertEquals("org.netbeans.modules.openide.nodes", pkgReg.pkg);
149
    }
150
    }
151
    
152
    public void testBeanInfoRegistration() {
153
        String[] path = Introspector.getBeanInfoSearchPath();
154
        int l = path.length;
155
        NodeOp.registerBeanInfoSearchPath();
156
        path = Introspector.getBeanInfoSearchPath();
157
        assertTrue(path.length == l + 1);
158
        for (int i = 0; i < path.length; i++) {
159
            System.out.println("- " + path[i]);
160
            
161
        }
162
    }
150
        
163
        
151
}
164
}
(-)a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PELookupTest.java (-2 / +2 lines)
Lines 62-70 Link Here
62
    }
62
    }
63
    
63
    
64
    public void testPackageUnregistering() {
64
    public void testPackageUnregistering() {
65
        MockLookup.setInstances(new PERegistrationSupport.PEPackageRegistration("test1.pkg"));
65
        MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test1.pkg"));
66
        NodeOp.registerPropertyEditors();
66
        NodeOp.registerPropertyEditors();
67
        MockLookup.setInstances(new PERegistrationSupport.PEPackageRegistration("test2.pkg"));
67
        MockLookup.setInstances(new NodesRegistrationSupport.PEPackageRegistration("test2.pkg"));
68
        
68
        
69
        String[] editorSearchPath = PropertyEditorManager.getEditorSearchPath();
69
        String[] editorSearchPath = PropertyEditorManager.getEditorSearchPath();
70
        int count = 0;
70
        int count = 0;
(-)a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PERegistrationSupportTest.java (-1 / +1 lines)
Lines 54-60 Link Here
54
    }
54
    }
55
    
55
    
56
    public void doTest(String type) throws ClassNotFoundException {
56
    public void doTest(String type) throws ClassNotFoundException {
57
        Class<?> cls = PERegistrationSupport.getClassFromCanonicalName(type);
57
        Class<?> cls = NodesRegistrationSupport.getClassFromCanonicalName(type);
58
        assertEquals(type, cls.getCanonicalName());
58
        assertEquals(type, cls.getCanonicalName());
59
    }
59
    }
60
    
60
    
(-)a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/package-info.java (+2 lines)
Lines 1-5 Link Here
1
@PropertyEditorSearchPath
1
@PropertyEditorSearchPath
2
@BeanInfoSearchPath
2
package org.netbeans.modules.openide.nodes;
3
package org.netbeans.modules.openide.nodes;
3
4
5
import org.openide.nodes.BeanInfoSearchPath;
4
import org.openide.nodes.PropertyEditorSearchPath;
6
import org.openide.nodes.PropertyEditorSearchPath;
5
7
(-)a/xml.tax/src/org/netbeans/modules/xml/tax/TAXModuleInstall.java (-85 lines)
Lines 1-85 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.modules.xml.tax;
45
46
import java.beans.*;
47
import java.util.Arrays;
48
import java.util.LinkedList;
49
import java.util.List;
50
import org.openide.modules.OnStart;
51
import org.openide.modules.OnStop;
52
53
/**
54
 * Module installation class for tax module.
55
 *
56
 * @author Libor Kramolis
57
 */
58
@OnStart
59
public class TAXModuleInstall implements Runnable {
60
61
    private static final String BEANINFO_PATH = "org.netbeans.modules.xml.tax.beans.beaninfo"; // NOI18N
62
63
    @Override
64
    public void run () {
65
        String[] sp = Introspector.getBeanInfoSearchPath();
66
        String[] newSP = new String[sp.length + 1];
67
        System.arraycopy(sp, 0, newSP, 0, sp.length);
68
        newSP[newSP.length - 1] = BEANINFO_PATH;
69
        Introspector.setBeanInfoSearchPath(newSP);
70
    }
71
72
    @OnStop
73
    public static final class Down implements Runnable{
74
        
75
        @Override
76
        public void run () {
77
            List searchPath;
78
79
            searchPath = new LinkedList (Arrays.asList (Introspector.getBeanInfoSearchPath()));
80
            searchPath.remove (BEANINFO_PATH);
81
            Introspector.setBeanInfoSearchPath ((String[])searchPath.toArray (new String[0]));
82
        }
83
    }
84
    
85
}
(-)a/xml.tax/src/org/netbeans/modules/xml/tax/beans/beaninfo/package-info.java (+5 lines)
Line 0 Link Here
1
@BeanInfoSearchPath
2
package org.netbeans.modules.xml.tax.beans.beaninfo;
3
4
import org.openide.nodes.BeanInfoSearchPath;
5

Return to bug 210323