测试rcp 和 rap 何时触发 组建.addListener(SWT.xxx, new Listener() )的方法
程序员文章站
2022-05-18 12:14:27
...
- 直接通过反射让组建监听所有的SWT.xxx
- Class userClass;
- try {
- userClass = Class.forName(SWT.class .getName());
- //加载类
- Field[] fields = userClass.getDeclaredFields();//获得对象方法集合
- String fdname = null ;
- for ( final Field field : fields) { // 遍历该数组
- field.setAccessible(true );
- fdname = field.getName();
- if ( true ) {
- try {
- Integer value = (Integer) field.get(userClass);
- this .addListener(value, new Listener() {
- @Override
- public void handleEvent(Event event) {
- System.err.println("group---->>" + field.getName());
- }
- });
- }
- catch (Exception e) {
- System.out.println(fdname + " is char" );
- }
- }
- }
- }
- catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- }
- catch (IllegalArgumentException e) {
- e.printStackTrace();
-
}