public void registerEvent(IObservableValueListener manager, IProperty property) { Object host = manager.getHost(); IEventController controller = UserData.findEventController(host); if (controller == null) { controller = UserData.updateEventController(host); } IMetaclass metaclass = XWT.getMetaclass(host); EventProperty reaisedEventProperty = (EventProperty) property; String raisedName = reaisedEventProperty.getEvent().getName(); for (String name : getEventNames()) { if (name.equalsIgnoreCase(raisedName)) { continue; } String eventPropertyName = IEventConstants.getEventPropertyName(name); String eventName = IEventConstants.getEventName(name); IEvent event = metaclass.findEvent(eventName); IProperty eventProperty = metaclass.findProperty(eventPropertyName); try { controller.setEvent( event, UserData.getWidget(host), manager, eventProperty, IObservableValueListener.class.getDeclaredMethod( "changeValueHandle", Object.class, org.eclipse.swt.widgets.Event.class)); } catch (Exception e) { LoggerManager.log(e); return; } } }
public static Object getObserveData(Object dataContext, String path) { try { Class<?> dataContextClass = dataContext.getClass(); Method getMethod = ObjectUtil.findGetter(dataContextClass, path, null); if (getMethod != null) { return getMethod.invoke(dataContext); } } catch (SecurityException e) { LoggerManager.log(e); } catch (IllegalArgumentException e) { LoggerManager.log(e); } catch (IllegalAccessException e) { LoggerManager.log(e); } catch (InvocationTargetException e) { LoggerManager.log(e); } return null; }