當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。