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/src/org/netbeans/core/startup/Main.java (-12 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
	    // -----------------------------------------------------------------------------------------------------
(-)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/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 (-56 / +104 lines)
Lines 41-49 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;
48
import java.util.Iterator;
47
import java.util.LinkedHashSet;
49
import java.util.LinkedHashSet;
48
import java.util.List;
50
import java.util.List;
49
import java.util.Map;
51
import java.util.Map;
Lines 59-79 Link Here
59
 * 
61
 * 
60
 * @author Jan Horvath <jhorvath@netbeans.org>
62
 * @author Jan Horvath <jhorvath@netbeans.org>
61
 */
63
 */
62
public final class PERegistrationSupport {
64
public final class NodesRegistrationSupport {
63
    
65
    
64
    static final String LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N
66
    static final String PE_LOOKUP_PATH = "Services/PropertyEditorManager"; //NOI18N
67
    static final String BEANINFO_LOOKUP_PATH = "Services/Introspector"; //NOI18N
65
    static final String PACKAGE = "packagePath"; //NOI18N
68
    static final String PACKAGE = "packagePath"; //NOI18N
66
    static final String EDITOR_CLASS = "propertyEditorClass"; //NOI18N
69
    static final String EDITOR_CLASS = "propertyEditorClass"; //NOI18N
67
    
70
    
68
    static ClassReg clsReg = null;
71
    private static AbstractRegistrator clsReg = null;
69
    static PkgReg pkgReg = null;
72
    private static AbstractRegistrator beanInfoReg = null;
73
    private static AbstractRegistrator pkgReg = null;
70
    
74
    
71
    public static synchronized void registerPropertyEditors() {
75
    public static synchronized void registerPropertyEditors() {
76
        
72
        if (clsReg == null) {
77
        if (clsReg == null) {
73
            clsReg = new ClassReg();
78
            clsReg = new AbstractRegistrator(PEClassRegistration.class) {
79
80
                @Override
81
                void register() {
82
                    ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
83
                    for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
84
                        PEClassRegistration clsReg = (PEClassRegistration) it.next();
85
                        for (String type : clsReg.targetTypes) {
86
                            try {
87
                                Class<?> cls = getClassFromCanonicalName(type);
88
                                Class<?> editorCls = Class.forName(clsReg.editorClass, true, clsLoader);
89
                                PropertyEditorManager.registerEditor(cls, editorCls);
90
                            } catch (ClassNotFoundException ex) {
91
                                Exceptions.printStackTrace(ex);
92
                            }
93
                        }
94
                    }
95
                }
96
97
                @Override
98
                void init() {
99
                }
100
            };
74
        }
101
        }
102
        
75
        if (pkgReg == null) {
103
        if (pkgReg == null) {
76
            pkgReg = new PkgReg();
104
            pkgReg = new AbstractRegistrator(PEPackageRegistration.class) {
105
                private List<String> originalPath = null;
106
107
                @Override
108
                void register() {
109
                    Set<String> newPath = new LinkedHashSet<String> ();
110
                    for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
111
                        PEPackageRegistration pkgReg = (PEPackageRegistration) it.next();
112
                        newPath.add(pkgReg.pkg);
113
                    }
114
                    newPath.addAll(originalPath);
115
                    PropertyEditorManager.setEditorSearchPath(newPath.toArray(new String[newPath.size()]));
116
                }
117
118
                @Override
119
                void init() {
120
                    if (originalPath == null) {
121
                        originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath());
122
                    }
123
                }
124
            };
125
        }
126
        
127
        if (beanInfoReg == null) {
128
            beanInfoReg = new AbstractRegistrator(BeanInfoRegistration.class) {
129
                private List<String> originalPath = null;
130
131
                @Override
132
                void register() {
133
                    Set<String> newPath = new LinkedHashSet<String> ();
134
                    for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
135
                        BeanInfoRegistration biReg = (BeanInfoRegistration) it.next();
136
                        newPath.add(biReg.searchPath);
137
                    }
138
                    newPath.addAll(originalPath);
139
                    Introspector.setBeanInfoSearchPath(newPath.toArray(new String[newPath.size()]));
140
                }
141
142
                @Override
143
                void init() {
144
                    if (originalPath == null) {
145
                    originalPath = Arrays.asList(Introspector.getBeanInfoSearchPath());
146
                    }
147
                }
148
            };
77
        }
149
        }
78
    }
150
    }
79
    
151
    
Lines 109-114 Link Here
109
        return new PEClassRegistration(editorClass, targetTypes);
181
        return new PEClassRegistration(editorClass, targetTypes);
110
    }
182
    }
111
    
183
    
184
    public static BeanInfoRegistration createBeanInfoRegistration(final Map attrs) {
185
        String pkg = (String) attrs.get(PACKAGE);
186
        return new BeanInfoRegistration(pkg);
187
    }
188
    
112
    /**
189
    /**
113
     * returns Class from canonical class name like <code>java.lang.String[]</code>
190
     * returns Class from canonical class name like <code>java.lang.String[]</code>
114
     */
191
     */
Lines 149-155 Link Here
149
        }
226
        }
150
        return result;
227
        return result;
151
    }
228
    }
152
    
229
153
    public static class PEPackageRegistration {
230
    public static class PEPackageRegistration {
154
        final String pkg;
231
        final String pkg;
155
232
Lines 168-231 Link Here
168
        }
245
        }
169
    }
246
    }
170
    
247
    
171
    private static final class ClassReg implements LookupListener {
248
    public static class BeanInfoRegistration {
172
        Result<PEClassRegistration> lookupResult = null;
249
        final String searchPath;
173
        
250
        
174
        ClassReg() {
251
        BeanInfoRegistration(String searchPath) {
175
            lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class);
252
            this.searchPath = searchPath;
253
        }
254
    }
255
    
256
    private static abstract class AbstractRegistrator implements LookupListener {
257
        Result lookupResult;
258
        private final Class cls;
259
        
260
        AbstractRegistrator(Class cls) {
261
            this.cls = cls;
262
            init();
263
            lookupResult = Lookup.getDefault().lookupResult(cls);
176
            register();
264
            register();
177
            lookupResult.addLookupListener(this);
265
            lookupResult.addLookupListener(this);
178
        }
266
        }
179
                
267
        
180
        synchronized void register() {
268
        abstract void register();
181
            lookupResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEClassRegistration.class);
269
        
182
            ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
270
        abstract void init();
183
            
184
            for (PEClassRegistration clsReg : lookupResult.allInstances()) {
185
                for (String type : clsReg.targetTypes) {
186
                    try {
187
                        Class<?> cls = getClassFromCanonicalName(type);
188
                        Class<?> editorCls = Class.forName(clsReg.editorClass, true, clsLoader);
189
                        PropertyEditorManager.registerEditor(cls, editorCls);
190
                    } catch (ClassNotFoundException ex) {
191
                        Exceptions.printStackTrace(ex);
192
                    }
193
                }
194
            }
195
        }
196
        
271
        
197
        @Override
272
        @Override
198
        public void resultChanged(LookupEvent ev) {
273
        public void resultChanged(LookupEvent ev) {
274
            lookupResult = Lookup.getDefault().lookupResult(cls);
199
            register();
275
            register();
200
        }
276
        }
201
    }
277
    }
202
    
278
    
203
    static final class PkgReg implements LookupListener {
204
        Result<PEPackageRegistration> pkgResult;
205
        private static List<String> originalPath = null;
206
        
207
        PkgReg() {
208
            if (originalPath == null) {
209
                originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath());
210
            }
211
            pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class);
212
            register();
213
            pkgResult.addLookupListener(this);
214
        }
215
        
216
        synchronized void register() {
217
            pkgResult = Lookup.getDefault().lookupResult(PERegistrationSupport.PEPackageRegistration.class);
218
            Set<String> newPath = new LinkedHashSet<String> ();
219
            for (PEPackageRegistration pkgReg : pkgResult.allInstances()) {
220
                newPath.add(pkgReg.pkg);
221
            }
222
            newPath.addAll(originalPath);
223
            PropertyEditorManager.setEditorSearchPath(newPath.toArray(new String[newPath.size()]));
224
        }
225
226
        @Override
227
        public void resultChanged(LookupEvent ev) {
228
            register();
229
        }
230
    }
231
}
279
}
(-)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
 * The package will be registered using <code>Introspector.setBeanInfoSearchPath()</code> 
51
 * during the IDE startup
52
 * 
53
 * @since 7.32
54
 * @author Jan Horvath <jhorvath@netbeans.org>
55
 */
56
@Retention(RetentionPolicy.SOURCE)
57
@Target(ElementType.PACKAGE)
58
public @interface BeanInfoSearchPath {
59
}
(-)a/openide.nodes/src/org/openide/nodes/NodeOp.java (-2 / +2 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
    }
472
    }
473
473
474
    /** more info in class javadoc.
474
    /** more info in class javadoc.
(-)a/openide.nodes/test/unit/src/org/netbeans/modules/openide/nodes/PEAnnotationProcessorTest.java (-4 / +21 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 58-64 Link Here
58
 * @author Jan Horvath <jhorvath@netbeans.org>
59
 * @author Jan Horvath <jhorvath@netbeans.org>
59
 */
60
 */
60
public class PEAnnotationProcessorTest extends NbTestCase {
61
public class PEAnnotationProcessorTest extends NbTestCase {
61
    
62
62
    static {
63
    static {
63
        System.setProperty("org.openide.util.Lookup.paths", "Services");
64
        System.setProperty("org.openide.util.Lookup.paths", "Services");
64
    }
65
    }
Lines 83-89 Link Here
83
                count++;
84
                count++;
84
            }
85
            }
85
        }
86
        }
86
        assertEquals("Package path is registered multiple times", 1, count);
87
        assertFalse("Package path is registered multiple times", count > 1);
88
        assertFalse("Package path is not registered", count == 0);
87
    }
89
    }
88
        
90
        
89
    public void testPERegistered() {
91
    public void testPERegistered() {
Lines 147-151 Link Here
147
        PEPackageRegistration pkgReg = lookup.iterator().next();
149
        PEPackageRegistration pkgReg = lookup.iterator().next();
148
        assertEquals("org.netbeans.modules.openide.nodes", pkgReg.pkg);
150
        assertEquals("org.netbeans.modules.openide.nodes", pkgReg.pkg);
149
    }
151
    }
152
    
153
    public void testBeanInfoRegistration() {
154
        NodeOp.registerPropertyEditors();
155
        NodeOp.registerPropertyEditors();
156
        
157
        int count = 0;
158
        String[] path = Introspector.getBeanInfoSearchPath();
159
        for (int i = 0; i < path.length; i++) {
160
            if ("org.netbeans.modules.openide.nodes".equals(path[i])) {
161
                count++;
162
            }
163
        }
164
        assertFalse("Package path is registered multiple times", count > 1);
165
        assertFalse("Package path is not registered", count == 0);
166
    }
150
        
167
        
151
}
168
}
(-)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
}

Return to bug 210323