Package org.eclipse.e4.xwt.internal.xml

Examples of org.eclipse.e4.xwt.internal.xml.Element


        IUserDataConstants.XWT_RESOURCES_KEY);
  }

  public static void setObjectName(Object object, String name) {
    Widget widget = getWidget(object);
    ScopeKeeper nameScoped;
    if (UserData.findElementByName(widget, name) != null) {
      // throw an exception or log a message?
      return;
    }
    Widget parent = UserData.getTreeParent(widget);
    UserData dataDictionary = (UserData) parent
        .getData(IUserDataConstants.XWT_USER_DATA_KEY);
    if (dataDictionary != null) {
      if (dataDictionary.getData(IUserDataConstants.XWT_NAMECONTEXT_KEY) != null) {
        nameScoped = (ScopeKeeper) dataDictionary
            .getData(IUserDataConstants.XWT_NAMECONTEXT_KEY);
      } else {
        ScopeKeeper parentNameScope = findScopeKeeper(parent);
        nameScoped = new ScopeKeeper(parentNameScope, widget);
        bindNameContext(parent, nameScoped);
      }
      nameScoped.addNamedObject(name, widget);
    }
    // throw an exception or log a message?
View Full Code Here


  protected void autoLayout(Composite composite, Element element) {
    if (element == null) {
      return;
    }
    Attribute bounds = element.getAttribute("bounds");
    if (bounds == null) {
      bounds = element.getAttribute("bounds", IConstants.XWT_NAMESPACE);
    }
    Attribute size = element.getAttribute("size");
    if (size == null) {
      size = element.getAttribute("size", IConstants.XWT_NAMESPACE);
    }
    if (bounds == null && size == null) {
      composite.pack();
View Full Code Here

        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)) {
View Full Code Here

    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("\\.");
View Full Code Here

    // Detect from url or file path.
    long start = System.currentTimeMillis();
    Control control = null;
    ElementManager manager = new ElementManager();
    if (input != null) {
      Element element = null;
      if (stream == null) {
        element = manager.load(input, (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK));
      }
      else {
        IBeforeParsingCallback callback = (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK);
View Full Code Here

  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() + ">";
          }
        }
View Full Code Here

  }

  protected Object getStaticValue(DocumentObject child) {
    DocumentObject[] children = child.getChildren();
    if (children.length == 1) {
      Element element = (Element) children[0];
      if (element != null) {
        return ClassLoaderUtil.loadStaticMember(context
            .getLoadingContext(), element);
      }
    }
View Full Code Here

  }

  public static List<DocumentObject> sortWithAttr(DocumentObject[] sourceArray, Comparator<Element> comparator, String attrName) {
    List<DocumentObject> columnsList = new LinkedList<DocumentObject>();
    for (DocumentObject column : sourceArray) {
      Element columnElement = (Element) column;
      Attribute indexAttr = columnElement.getAttribute(attrName);
      if (indexAttr == null) {
        columnsList.add(column);
      }
    }

    List<Element> tempList = new LinkedList<Element>();
    for (DocumentObject column : sourceArray) {
      Element columnElement = (Element) column;
      Attribute indexAttr = columnElement.getAttribute(attrName);
      if (indexAttr != null) {
        tempList.add(columnElement);
      }
    }

    if (comparator == null) {
      comparator = new AttrComparator(attrName);
    }
    Collections.sort(tempList, comparator);

    for (Element columnElement : tempList) {
      Attribute indexAttr = columnElement.getAttribute(attrName);
      try {
        int index = Integer.parseInt(indexAttr.getContent());
        columnsList.add(index, columnElement);
      } catch (Exception e) {
        columnsList.add(columnsList.size(), columnElement);
View Full Code Here

      if (IConstants.XAML_X_TYPE.equalsIgnoreCase(name)
          && constraintType != null && constraintType == Class.class) {
        DocumentObject[] children = element.getChildren();
        if (children != null && children.length > 0) {
          if (children[0] instanceof Element) {
            Element type = (Element) children[0];
            IMetaclass metaclass = loader.getMetaclass(type
                .getName(), type.getNamespace());
            if (metaclass != null) {
              return metaclass.getType();
            }
          }
        } else {
          String content = element.getContent();
          return loader.convertFrom(Class.class, content);
        }
      }
      return null;
    }
    IMetaclass metaclass = loader.getMetaclass(name, namespace);
    if (constraintType != null
        && !(IBinding.class.isAssignableFrom(metaclass.getType()))
        && (!constraintType.isAssignableFrom(metaclass.getType()))) {
      if (!constraintType.isArray()
          || !constraintType.getComponentType().isAssignableFrom(
              metaclass.getType())) {
        return null;
      }
    }
    Object targetObject = null;
    Integer styleValue = getStyleValue(element, styles);

    if (parent == null || metaclass.getType() == Shell.class) {
      if (dataBindingTrack != null) {
        dataBindingTrack.addWidgetElement(element);
      }
      Shell shell = null;
      if (styleValue == null || styleValue == -1) {
        styleValue = SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX
            | SWT.RESIZE;
      }
      Display display = Display.getDefault();
      shell = new Shell(display, styleValue);
      targetObject = shell;
      invokeCreatededAction(element, targetObject);
      loadData.setCurrentWidget(shell);

      if (metaclass.getType() != Shell.class) {
        shell.setLayout(new FillLayout());
        return doCreate(targetObject, element, constraintType, options);
      } else {
        if (bindingContext != null) {
          setBindingContext(metaclass, targetObject, dico,
              bindingContext);
        }
        if (dataContext != null) {
          setDataContext(metaclass, targetObject, dico, dataContext);
        }
      }
      pushStack(parent);

      // for Shell
      Attribute classAttribute = element.getAttribute(
          IConstants.XWT_X_NAMESPACE, IConstants.XAML_X_CLASS);
      if (classAttribute != null) {
        String className = classAttribute.getContent();
        loadShellCLR(className, shell);
      }

    } else {
      pushStack(parent);

      //
      // load the content in case of UserControl
      //
      Class<?> type = metaclass.getType();
      URL file = type.getResource(type.getSimpleName()
          + IConstants.XWT_EXTENSION_SUFFIX);
      if (file != null && nameScoped != null) {
        if (parent instanceof Composite) {
          Object childDataContext = getDataContext(element,
              (Widget) parent);
View Full Code Here

            dico = new ResourceDictionary();
            UserData.setResources(widget, dico);
          }

          for (DocumentObject doc : attribute.getChildren()) {
            Element elem = (Element) doc;
            Object doCreate = doCreate(widget, elem, null,
                EMPTY_MAP);
            Attribute keyAttribute = elem.getAttribute(
                IConstants.XWT_X_NAMESPACE,
                IConstants.XAML_X_KEY);
            if (keyAttribute == null) {
              keyAttribute = elem.getAttribute(
                  IConstants.XWT_X_NAMESPACE,
                  IConstants.XAML_X_TYPE);
            }
            if (keyAttribute != null) {
              dico.put(keyAttribute.getContent(), doCreate);
View Full Code Here

TOP

Related Classes of org.eclipse.e4.xwt.internal.xml.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.