示例#1
0
  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;
      }
    }
  }
示例#2
0
 public static DataContext getDataContext(Object widget) {
   if (widget == null) {
     return null;
   }
   try {
     Object dataContext = XWT.getDataContext(widget);
     Map<?, ?> resources = UserData.getResources(widget);
     if (resources == null) {
       return null;
     }
     if (dataContext != null && !resources.isEmpty()) {
       Set<?> entrySet = resources.entrySet();
       for (Object object : entrySet) {
         Entry<?, ?> entry = (Entry<?, ?>) object;
         Object value = entry.getValue();
         if (!dataContext.equals(value)) {
           continue;
         }
         Object key = entry.getKey();
         return new DataContext(key.toString(), value);
       }
     } else {
       Set<?> entrySet = resources.entrySet();
       for (Object object : entrySet) {
         Entry<?, ?> entry = (Entry<?, ?>) object;
         Object key = entry.getKey();
         Object value = entry.getValue();
         return new DataContext(key.toString(), value);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
示例#3
0
 private String getWidgetName(Object widget) {
   ScopeKeeper nameContext = UserData.findScopeKeeper(widget);
   if (nameContext != null) {
     for (String name : nameContext.names()) {
       if (widget == nameContext.getNamedObject(name)) {
         return name;
       }
     }
   }
   return null;
 }
示例#4
0
 private String getCreateName(Object model, CompoundCommand commands) {
   if (!(model instanceof Widget)) {
     return null;
   }
   Widget widget = (Widget) model;
   String original = getWidgetName(widget);
   if (original != null) {
     return original;
   }
   String elementName = getElementName();
   if (elementName == null) {
     elementName = NamedCommand.generateName(widget);
   }
   commands.add(new NamedCommand(widget, elementName));
   UserData.setObjectName(widget, elementName);
   return elementName;
 }
示例#5
0
 private static void collectBindings(Object component, List<BindingInfo> bindings) {
   if (component == null) {
     return;
   }
   List<BindingInfo> childBindings = getBindings(component);
   if (childBindings != null) {
     bindings.addAll(childBindings);
   }
   if (JFacesHelper.isViewer(component)) {
     // If JFace Viewer, just come here.
     return;
   }
   Viewer viewer = UserData.getLocalViewer(component);
   if (viewer != null) {
     collectBindings(viewer, bindings);
   }
   if (component instanceof Widget) {
     Widget[] children = SWTTools.getChildren((Widget) component);
     for (Widget widget : children) {
       collectBindings(widget, bindings);
     }
   }
 }