Lines 45-50
Link Here
|
45 |
import org.openide.util.Exceptions; |
45 |
import org.openide.util.Exceptions; |
46 |
import org.openide.util.HelpCtx; |
46 |
import org.openide.util.HelpCtx; |
47 |
import org.openide.util.Utilities; |
47 |
import org.openide.util.Utilities; |
|
|
48 |
import org.openide.util.Lookup; |
49 |
import org.openide.util.lookup.InstanceContent; |
50 |
import org.openide.util.lookup.ProxyLookup; |
51 |
import org.openide.util.lookup.AbstractLookup; |
48 |
import org.openide.util.WeakListeners; |
52 |
import org.openide.util.WeakListeners; |
49 |
import org.openide.util.actions.SystemAction; |
53 |
import org.openide.util.actions.SystemAction; |
50 |
|
54 |
|
Lines 83-88
Link Here
|
83 |
|
87 |
|
84 |
/** is synchronization of name in progress */ |
88 |
/** is synchronization of name in progress */ |
85 |
private boolean synchronizeName; |
89 |
private boolean synchronizeName; |
|
|
90 |
|
91 |
/** If there was no provided lookup, this field is null |
92 |
* and the bean is placed into CookieSet. |
93 |
* If there was a lookup, it is wrapped into proxy |
94 |
* with this instanceContent as second delegate. |
95 |
* The bean is then registered here. |
96 |
*/ |
97 |
private InstanceContent beanHolder; |
86 |
|
98 |
|
87 |
// init .................................................................................................................. |
99 |
// init .................................................................................................................. |
88 |
|
100 |
|
Lines 94-100
Link Here
|
94 |
* @throws IntrospectionException if the bean cannot be analyzed |
106 |
* @throws IntrospectionException if the bean cannot be analyzed |
95 |
*/ |
107 |
*/ |
96 |
public BeanNode(T bean) throws IntrospectionException { |
108 |
public BeanNode(T bean) throws IntrospectionException { |
97 |
this(bean, getChildren(bean)); |
109 |
this(bean, null, null); |
98 |
} |
110 |
} |
99 |
|
111 |
|
100 |
/** Constructs a node for a JavaBean with a defined child list. |
112 |
/** Constructs a node for a JavaBean with a defined child list. |
Lines 105-111
Link Here
|
105 |
*/ |
117 |
*/ |
106 |
protected BeanNode(T bean, Children children) |
118 |
protected BeanNode(T bean, Children children) |
107 |
throws IntrospectionException { |
119 |
throws IntrospectionException { |
108 |
super((children == null) ? getChildren(bean) : children); |
120 |
this(bean, children, null); |
|
|
121 |
} |
122 |
|
123 |
/** Constructs a node for a JavaBean with a defined child list. |
124 |
* Intended for use by subclasses with different strategies for computing the children. |
125 |
* @param bean the bean this node will be based on |
126 |
* @param children children for the node (default if null) |
127 |
* @param lkp the lookup to provide content of {@link #getLookup} |
128 |
* and also {@link #getCookie} |
129 |
* @throws IntrospectionException if the bean cannot be analyzed |
130 |
* @since 6.xx |
131 |
*/ |
132 |
protected BeanNode(T bean, Children children, Lookup lkp) |
133 |
throws IntrospectionException { |
134 |
super((children == null) ? getChildren(bean) : children, lkp); |
109 |
|
135 |
|
110 |
if (bean == null) { |
136 |
if (bean == null) { |
111 |
throw new NullPointerException("cannot make a node for a null bean"); // NOI18N |
137 |
throw new NullPointerException("cannot make a node for a null bean"); // NOI18N |
Lines 123-128
Link Here
|
123 |
throw mkie(le); |
149 |
throw mkie(le); |
124 |
} |
150 |
} |
125 |
} |
151 |
} |
|
|
152 |
|
153 |
final Lookup replaceProvidedLookup(Lookup lookup) { |
154 |
if (lookup == null) return null; |
155 |
beanHolder = new InstanceContent(); |
156 |
AbstractLookup al = new AbstractLookup(beanHolder); |
157 |
return new ProxyLookup(new Lookup[] { lookup, al }); |
158 |
} |
126 |
|
159 |
|
127 |
private static Children getChildren(Object bean) { |
160 |
private static Children getChildren(Object bean) { |
128 |
if (bean instanceof BeanContext) { |
161 |
if (bean instanceof BeanContext) { |
Lines 573-579
Link Here
|
573 |
Node.Cookie instanceCookie = TMUtil.createInstanceCookie(bean); |
606 |
Node.Cookie instanceCookie = TMUtil.createInstanceCookie(bean); |
574 |
|
607 |
|
575 |
if (instanceCookie != null) { |
608 |
if (instanceCookie != null) { |
576 |
getCookieSet().add(instanceCookie); |
609 |
if (beanHolder == null) { |
|
|
610 |
getCookieSet().add(instanceCookie); |
611 |
} else { |
612 |
beanHolder.add(instanceCookie); |
613 |
} |
577 |
} |
614 |
} |
578 |
} |
615 |
} |
579 |
|
616 |
|