コード例 #1
0
 public String getDataBindMessage() {
   StringBuffer message = new StringBuffer("");
   Iterator<Element> widgetIt = widgetList.iterator();
   Set<Element> keys = bindingMap.keySet();
   while (widgetIt.hasNext()) {
     Element element = widgetIt.next();
     int parentHasError = validateParentElementError(element);
     if (parentHasError == 0) {
       String content = getCurrentWidgetPosition(element);
       if (!message.toString().equals("")) {
         content += "+ ";
       }
       content = content + element.getName();
       if (XWT.isTracking(Tracking.NAME)) {
         Attribute nameAttr = element.getAttribute("Name");
         if (nameAttr == null) {
           nameAttr = element.getAttribute(IConstants.XWT_X_NAMESPACE, "Name");
         }
         if (nameAttr != null) {
           content += " <" + nameAttr.getContent() + ">";
         }
       }
       message.append(content);
       if (XWT.isTracking(Tracking.DATABINDING)) {
         if (keys.contains(element)) {
           message.append(bindingMap.get(element));
         } else {
           message.append("\n");
         }
       }
     }
   }
   return message.toString();
 }
コード例 #2
0
 public void tracking(Object swtObject, Element element, Object dataContext) {
   String bindingMessage = "";
   if (swtObject instanceof Binding) {
     String error = "";
     Binding newInstance = (Binding) swtObject;
     String path = null;
     Attribute attr = element.getAttribute("Path");
     if (null == attr) attr = element.getAttribute("path");
     if (null != attr) path = attr.getContent();
     Object dataContext2 = null;
     try {
       dataContext2 = newInstance.getValue(null);
       if (path != null && path.length() > 0) {
         String[] paths = path.trim().split("\\.");
         if (paths.length > 1) {
           String path1 = "";
           for (int i = 0; i < paths.length - 1; i++) {
             path1 = paths[i];
             if (dataContext2 != null) {
               dataContext2 = getObserveData(dataContext2, path1);
             }
           }
         }
       }
     } catch (Exception ex) {
       addErrorWidgetId(element.getParent().getParent().getId());
       setBindingErrorMessage("-> Error");
       error = "-> Error";
     }
     if (dataContext2 != null) {
       bindingMessage =
           " (DataContext="
               + dataContext2.getClass().getSimpleName()
               + ", Path="
               + path
               + ")"
               + error
               + "\n";
       addBindingMessageToMap(
           (Element) element.getParent().getParent(),
           bindingMessage); // bindingMap.put((Element) element.getParent().getParent(),
                            // bindingMessage);
     }
   } else if (swtObject instanceof Widget) {
     addWidgetElement(element);
     if (dataContext != null) {
       bindingMessage = " (DataContext=" + dataContext.getClass().getSimpleName() + ")\n";
       addBindingMessageToMap(element, bindingMessage);
     }
   } else if (JFacesHelper.isViewer(swtObject)) {
     if (dataContext != null) {
       bindingMessage = " (DataContext=" + dataContext.getClass().getSimpleName() + ")\n";
       addBindingMessageToMap(element, bindingMessage); // bindingMap.put(element, bindingMessage);
     }
   } else if (element.attributeNames(IConstants.XWT_X_NAMESPACE).length > 0) {
     // ??
     if (element.getParent() != null && element.getParent().getParent() != null) {
       bindingMessage = " (DataContext=" + element.getName() + ")\n";
       addBindingMessageToMap(
           (Element) element.getParent().getParent(),
           bindingMessage); // bindingMap.put((Element) element.getParent().getParent(),
                            // bindingMessage);
     }
   }
 }