本文整理汇总了Java中java.beans.beancontext.BeanContext类的典型用法代码示例。如果您正苦于以下问题:Java BeanContext类的具体用法?Java BeanContext怎么用?Java BeanContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeanContext类属于java.beans.beancontext包,在下文中一共展示了BeanContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildren
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private static Children getChildren(DataObject dobj, boolean noBeanInfo) {
if (noBeanInfo) {
return Children.LEAF;
}
InstanceCookie inst = (InstanceCookie)dobj.getCookie(InstanceCookie.class);
if (inst == null) return Children.LEAF;
try {
Class clazz = inst.instanceClass();
if (BeanContext.class.isAssignableFrom(clazz) ||
BeanContextProxy.class.isAssignableFrom(clazz)) {
return new InstanceChildren ();
} else {
return Children.LEAF;
}
} catch (Exception ex) {
return Children.LEAF;
}
}
示例2: init
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private void init() {
try {
InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
if (ic == null) {
bean = null;
return;
}
Class clazz = ic.instanceClass();
if (BeanContext.class.isAssignableFrom(clazz)) {
bean = ic.instanceCreate();
} else if (BeanContextProxy.class.isAssignableFrom(clazz)) {
bean = ((BeanContextProxy) ic.instanceCreate()).getBeanContextProxy();
} else {
bean = null;
}
} catch (Exception ex) {
bean = null;
Exceptions.printStackTrace(ex);
}
if (bean != null) {
// attaches a listener to the bean
((BeanContext) bean).addBeanContextMembershipListener (contextL);
}
updateKeys();
}
示例3: createNodes
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
/** Create nodes for a given key.
* @param key the key
* @return child nodes for this key or null if there should be no
* nodes for this key
*/
protected Node[] createNodes(Object key) {
Object ctx = bean;
if (bean == null) return new Node[0];
try {
if (key instanceof BeanContextSupport) {
BeanContextSupport bcs = (BeanContextSupport)key;
if (((BeanContext) ctx).contains (bcs.getBeanContextPeer())) {
// sometimes a BeanContextSupport occures in the list of
// beans children even there is its peer. we think that
// it is desirable to hide the context if the peer is
// also present
return new Node[0];
}
}
return new Node[] { new BeanContextNode (key, task) };
} catch (IntrospectionException ex) {
// ignore the exception
return new Node[0];
}
}
示例4: internalInstantiate
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Object internalInstantiate(ClassLoader cls, String beanName,
BeanContext context, Object initializer) throws IOException,
ClassNotFoundException {
// First try to load it from a serialization file.
Object result = null;
// If it didn't work, try to instantiate it from the given classloader
ClassLoader classLoader = cls == null ? ClassLoader
.getSystemClassLoader() : cls;
try {
result = Class.forName(beanName, true, classLoader).newInstance();
} catch (Exception e) {
throw new ClassNotFoundException(e.getClass() + ": " //$NON-NLS-1$
+ e.getMessage());
}
if (result != null) {
if (null != context) {
context.add(result);
}
}
return result;
}
示例5: assertEqualsSerially
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private void assertEqualsSerially(BeanContextServiceAvailableEvent orig,
BeanContextServiceAvailableEvent ser) {
assertNull(ser.getSource());
// check propagatedFrom
if (orig.getPropagatedFrom() instanceof Serializable) {
BeanContext origFrom = orig.getPropagatedFrom();
BeanContext serFrom = ser.getPropagatedFrom();
assertEquals(origFrom.getClass(), serFrom.getClass());
if (origFrom instanceof MockBeanContextDelegateS) {
assertEquals(((MockBeanContextDelegateS) origFrom).id,
((MockBeanContextDelegateS) serFrom).id);
}
}
// check serviceClass
assertEquals(orig.getServiceClass(), ser.getServiceClass());
}
示例6: assertEqualsSerially
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private void assertEqualsSerially(BeanContextMembershipEvent orig,
BeanContextMembershipEvent ser) {
assertNull(ser.getSource());
// check propagatedFrom
if (orig.getPropagatedFrom() instanceof Serializable) {
BeanContext origFrom = orig.getPropagatedFrom();
BeanContext serFrom = ser.getPropagatedFrom();
assertEquals(origFrom.getClass(), serFrom.getClass());
if (origFrom instanceof MockBeanContextDelegateS) {
assertEquals(((MockBeanContextDelegateS) origFrom).id,
((MockBeanContextDelegateS) serFrom).id);
}
}
// check children
Collection origChildren = (Collection) Utils.getField(orig, "children");
Collection serChildren = (Collection) Utils.getField(ser, "children");
assertEquals(origChildren, serChildren);
}
示例7: getChildren
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private static Children getChildren(DataObject dobj, boolean noBeanInfo) {
if (noBeanInfo) {
return Children.LEAF;
}
InstanceCookie inst = (InstanceCookie)dobj.getCookie(InstanceCookie.class);
if (inst == null) return Children.LEAF;
try {
Class clazz = inst.instanceClass();
if (BeanContext.class.isAssignableFrom(clazz) ||
BeanContextProxy.class.isAssignableFrom(clazz)) {
return new InstanceChildren ((InstanceDataObject) dobj);
} else {
return Children.LEAF;
}
} catch (Exception ex) {
return Children.LEAF;
}
}
示例8: getChildren
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private static Children getChildren(Object bean) {
if (bean instanceof BeanContext) {
return new BeanChildren((BeanContext) bean);
}
if (bean instanceof BeanContextProxy) {
BeanContextChild bch = ((BeanContextProxy) bean).getBeanContextProxy();
if (bch instanceof BeanContext) {
return new BeanChildren((BeanContext) bch);
}
}
return Children.LEAF;
}
示例9: removeNotify
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
protected void removeNotify () {
if (contextL != null && bean != null)
((BeanContext) bean).removeBeanContextMembershipListener (contextL);
contextL = null;
setKeys(Collections.emptySet());
}
示例10: updateKeys
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private void updateKeys() {
if (bean == null) {
setKeys(Collections.emptySet());
} else {
setKeys(((BeanContext) bean).toArray());
}
}
示例11: BeanContextMembershipEvent
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
/**
* Contruct a BeanContextMembershipEvent
*
* @param bc The BeanContext source
* @param changes The Children affected
* @throws NullPointerException if <CODE>changes</CODE> is <CODE>null</CODE>
*/
@SuppressWarnings("rawtypes")
public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
super(bc);
if (changes == null) throw new NullPointerException(
"BeanContextMembershipEvent constructor: changes is null.");
children = changes;
}
示例12: fill
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
private static BeanContext fill(BeanContext context) {
context.add(new JLabel("label"));
context.add(new JButton("button"));
JButton button = new JButton();
button.setText("another button");
context.add(button);
return context;
}
示例13: BeanContextMembershipEvent
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
/**
* Contruct a BeanContextMembershipEvent
*
* @param bc The BeanContext source
* @param changes The Children affected
* @throws NullPointerException if {@code changes} is {@code null}
*/
@SuppressWarnings("rawtypes")
public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
super(bc);
if (changes == null) throw new NullPointerException(
"BeanContextMembershipEvent constructor: changes is null.");
children = changes;
}
示例14: setBeanContext
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
/**
* Set a bean context for this bean
*
* @param bc a <code>BeanContext</code> value
*/
@Override
public void setBeanContext(BeanContext bc) {
m_beanContext = bc;
m_design = m_beanContext.isDesignTime();
if (m_design) {
appearanceDesign();
} else {
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!GraphicsEnvironment.isHeadless()) {
appearanceFinal();
}
}
}
示例15: setBeanContext
import java.beans.beancontext.BeanContext; //导入依赖的package包/类
/**
* Set a bean context for this bean
*
* @param bc a <code>BeanContext</code> value
*/
@Override
public void setBeanContext(BeanContext bc) {
super.setBeanContext(bc);
if (m_design) {
appearanceDesign();
} else {
appearanceFinal();
}
}