当前位置: 首页>>代码示例>>Java>>正文


Java BeanInfo.getEventSetDescriptors方法代码示例

本文整理汇总了Java中java.beans.BeanInfo.getEventSetDescriptors方法的典型用法代码示例。如果您正苦于以下问题:Java BeanInfo.getEventSetDescriptors方法的具体用法?Java BeanInfo.getEventSetDescriptors怎么用?Java BeanInfo.getEventSetDescriptors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.BeanInfo的用法示例。


在下文中一共展示了BeanInfo.getEventSetDescriptors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initPList

import java.beans.BeanInfo; //导入方法依赖的package包/类
/** try to register PropertyChangeListener to instance to fire its changes.
 * @param bean     */
private void initPList (Object bean, BeanInfo bInfo, BeanNode.Descriptor descr) {
    EventSetDescriptor[] descs  = bInfo.getEventSetDescriptors();
    try {
        Method setter = null;
        for (int i = 0; descs != null && i < descs.length; i++) {
            setter = descs[i].getAddListenerMethod();
            if (setter != null && setter.getName().equals("addPropertyChangeListener")) { // NOI18N                    
                propertyChangeListener = new PropL(createSupportedPropertyNames(descr));
                setter.invoke(bean, new Object[] {WeakListeners.propertyChange(propertyChangeListener, bean)});
                setSettingsInstance(bean);
            }
        }
    } catch (Exception ex) {
        // ignore
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SerialDataNode.java

示例2: setResourceListeners

import java.beans.BeanInfo; //导入方法依赖的package包/类
/**
 * Adds listeners to a resource.
 * @param listeners The listeners to be registered with the resource. A
 * {@link java.util.Map} that maps from fully qualified class name (as a
 * string) to listener (of the type declared by the key).
 * @param resource the resource that listeners will be registered to.
 */
public static void setResourceListeners(Resource resource, Map<String, ? extends Object> listeners)
throws
  IntrospectionException, InvocationTargetException,
  IllegalAccessException, GateException
{
  // get the beaninfo for the resource bean, excluding data about Object
  BeanInfo resBeanInfo = getBeanInfo(resource.getClass());

  // get all the events the bean can fire
  EventSetDescriptor[] events = resBeanInfo.getEventSetDescriptors();

  // add the listeners
  if (events != null) {
    EventSetDescriptor event;
    for(int i = 0; i < events.length; i++) {
      event = events[i];

      // did we get such a listener?
      Object listener =
        listeners.get(event.getListenerType().getName());
      if(listener != null) {
        Method addListener = event.getAddListenerMethod();

        // call the set method with the parameter value
        Object[] args = new Object[1];
        args[0] = listener;
        addListener.invoke(resource, args);
      }
    } // for each event
  }   // if events != null
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:39,代码来源:AbstractResource.java

示例3: removeResourceListeners

import java.beans.BeanInfo; //导入方法依赖的package包/类
/**
 * Removes listeners from a resource.
 * @param listeners The listeners to be removed from the resource. A
 * {@link java.util.Map} that maps from fully qualified class name
 * (as a string) to listener (of the type declared by the key).
 * @param resource the resource that listeners will be removed from.
 */
public static void removeResourceListeners(Resource resource, Map<String, ? extends Object> listeners)
                   throws IntrospectionException, InvocationTargetException,
                          IllegalAccessException, GateException{

  // get the beaninfo for the resource bean, excluding data about Object
  BeanInfo resBeanInfo = getBeanInfo(resource.getClass());

  // get all the events the bean can fire
  EventSetDescriptor[] events = resBeanInfo.getEventSetDescriptors();

  //remove the listeners
  if(events != null) {
    EventSetDescriptor event;
    for(int i = 0; i < events.length; i++) {
      event = events[i];

      // did we get such a listener?
      Object listener =
        listeners.get(event.getListenerType().getName());
      if(listener != null) {
        Method removeListener = event.getRemoveListenerMethod();

        // call the set method with the parameter value
        Object[] args = new Object[1];
        args[0] = listener;
        removeListener.invoke(resource, args);
      }
    } // for each event
  }   // if events != null
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:38,代码来源:AbstractResource.java


注:本文中的java.beans.BeanInfo.getEventSetDescriptors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。