Lines 25-32
Link Here
|
25 |
import javax.swing.event.ChangeListener; |
25 |
import javax.swing.event.ChangeListener; |
26 |
import javax.swing.event.ChangeEvent; |
26 |
import javax.swing.event.ChangeEvent; |
27 |
import javax.swing.Timer; |
27 |
import javax.swing.Timer; |
28 |
import java.lang.reflect.Modifier; |
28 |
import java.lang.reflect.*; |
29 |
import java.lang.reflect.InvocationTargetException; |
|
|
30 |
import java.beans.PropertyEditorSupport; |
29 |
import java.beans.PropertyEditorSupport; |
31 |
import java.beans.PropertyChangeEvent; |
30 |
import java.beans.PropertyChangeEvent; |
32 |
import java.beans.PropertyChangeListener; |
31 |
import java.beans.PropertyChangeListener; |
Lines 40-45
Link Here
|
40 |
import org.openide.nodes.*; |
39 |
import org.openide.nodes.*; |
41 |
import org.openide.src.nodes.SourceChildren; |
40 |
import org.openide.src.nodes.SourceChildren; |
42 |
import org.openide.src.nodes.ClassCustomizer; |
41 |
import org.openide.src.nodes.ClassCustomizer; |
|
|
42 |
import org.openide.src.nodes.ElementNodeFactory; |
43 |
import org.openide.filesystems.FileObject; |
43 |
import org.openide.filesystems.FileObject; |
44 |
import org.openide.ErrorManager; |
44 |
import org.openide.ErrorManager; |
45 |
import org.openide.NotifyDescriptor; |
45 |
import org.openide.NotifyDescriptor; |
Lines 149-161
Link Here
|
149 |
// T.B.: Workaround for issue #28623 - aggresively creating source element, classloading |
149 |
// T.B.: Workaround for issue #28623 - aggresively creating source element, classloading |
150 |
private static final class JavaSourceChildren extends SourceChildren { |
150 |
private static final class JavaSourceChildren extends SourceChildren { |
151 |
JavaDataObject jdo; |
151 |
JavaDataObject jdo; |
|
|
152 |
private LazyElementNodeFactory factory; |
152 |
|
153 |
|
153 |
public JavaSourceChildren (JavaDataObject jdo) { |
154 |
public JavaSourceChildren (JavaDataObject jdo) { |
154 |
super (JavaDataObject.getExplorerFactory()); |
155 |
this(jdo, new LazyElementNodeFactory()); |
|
|
156 |
} |
157 |
|
158 |
private JavaSourceChildren(JavaDataObject jdo, LazyElementNodeFactory factory) { |
159 |
super(factory.createProxy()); |
155 |
this.jdo = jdo; |
160 |
this.jdo = jdo; |
|
|
161 |
this.factory = factory; |
156 |
} |
162 |
} |
157 |
|
163 |
|
158 |
protected void addNotify() { |
164 |
protected void addNotify() { |
|
|
165 |
factory.setElementNodeFactory(JavaDataObject.getExplorerFactory()); |
159 |
setElement (jdo.getSource()); |
166 |
setElement (jdo.getSource()); |
160 |
super.addNotify(); |
167 |
super.addNotify(); |
161 |
} |
168 |
} |
Lines 163-168
Link Here
|
163 |
protected void removeNotify() { |
170 |
protected void removeNotify() { |
164 |
super.removeNotify(); |
171 |
super.removeNotify(); |
165 |
setElement (null); |
172 |
setElement (null); |
|
|
173 |
factory.setElementNodeFactory(null); |
174 |
} |
175 |
} |
176 |
|
177 |
/** A proxy to ElementNodeFactory. Allows to postpone ElementNodeFactory creation to JavaSourceChildren.addNotify |
178 |
* in order to prevent a starvation. See issue #36855. |
179 |
*/ |
180 |
private static final class LazyElementNodeFactory implements InvocationHandler { |
181 |
|
182 |
private ElementNodeFactory factory; |
183 |
|
184 |
public LazyElementNodeFactory() {} |
185 |
|
186 |
public ElementNodeFactory createProxy() { |
187 |
return (ElementNodeFactory) Proxy.newProxyInstance( |
188 |
LazyElementNodeFactory.class.getClassLoader(), |
189 |
new Class[]{ElementNodeFactory.class}, |
190 |
new LazyElementNodeFactory() |
191 |
); |
192 |
} |
193 |
|
194 |
public void setElementNodeFactory(ElementNodeFactory enf) { |
195 |
this.factory = enf; |
196 |
} |
197 |
|
198 |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { |
199 |
if (factory != null) { |
200 |
return method.invoke(factory, args); |
201 |
} else { |
202 |
throw new IllegalStateException("it's too early"); // NOI18N |
203 |
} |
166 |
} |
204 |
} |
167 |
} |
205 |
} |
168 |
|
206 |
|