Package org.eclipse.wst.xml.core.internal.contentmodel.modelquery

Examples of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery


  private Object parent = null;

  public Object[] getChildren(Object o) {
    if (o instanceof Element) {
      Element node = (Element) o;
      ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
      if (mq != null) {
        CMElementDeclaration decl = mq.getCMElementDeclaration(node);
        CMListWorkbenchAdapter adapter = new CMListWorkbenchAdapter(decl);
        return new Object[] { adapter };
      }
    }
    return EMPTY;
View Full Code Here


  }

  protected List getRequiredAttrs(Node node) {
    List result = new ArrayList();

    ModelQuery modelQuery = getModelQuery(node);
    if (modelQuery != null) {
      CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
      if (elementDecl != null) {
        CMNamedNodeMap attrMap = elementDecl.getAttributes();

        CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
        List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element)node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
View Full Code Here

  public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) {
    IPropertyDescriptor result = null;

    String attributeName = attr.getName();

    ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument());

    if (mq != null) {
      CMAttributeDeclaration ad = mq.getCMAttributeDeclaration(attr);
      if (ad != null) {
        String[] valuesArray = mq.getPossibleDataTypeValues(attr.getOwnerElement(), ad);
        if ((valuesArray != null) && (valuesArray.length > 0)) {
          result = new EnumeratedStringPropertyDescriptor(attributeName, attributeName, valuesArray);
        }
      }
    }
View Full Code Here

      if (selection instanceof IStructuredSelection) {
        currentSelection = (IStructuredSelection) selection;
        if (!selection.isEmpty()
            && (currentSelection.getFirstElement() instanceof Node)) {
          Node node = (Node) currentSelection.getFirstElement();
          ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
          if (mq != null) {
            cmNode = mq.getCMNode(node);
            MarkupTagInfoProvider tagInfo = new MarkupTagInfoProvider();
            xmlDoc = tagInfo.getInfo(cmNode);
          }
          else {
            xmlDoc = XMLUIMessages.Documentation_view_default_msg;
View Full Code Here

        if (parentNode != null) {
          int index = getIndex(parentNode, node);
          Assert.isTrue(parentNode.getNodeType() == Node.ELEMENT_NODE);
          Element parentElement = (Element) parentNode;
         
          ModelQuery modelQuery = ModelQueryUtil.getModelQuery(model);
          CMElementDeclaration parentED = modelQuery.getCMElementDeclaration(parentElement);
          if (parentED != null) {
            int editMode = modelQuery.getEditMode();
            int ic = ModelQuery.INCLUDE_CHILD_NODES;
            int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT : ModelQuery.VALIDITY_NONE;

            List modelQueryActionList = new ArrayList();
            modelQuery.getInsertActions(parentElement, parentED, index + 1, ic, vc, modelQueryActionList);
            addActionHelper(modelQueryActionList);
          }
        }
      }
    });
View Full Code Here

          boolean hasName = false;
          Node shownAttribute = null;
          // try to get content model element
          // declaration
          CMElementDeclaration elementDecl = null;
          ModelQuery mq = ModelQueryUtil.getModelQuery(element
              .getOwnerDocument());
          if (mq != null) {
            elementDecl = mq.getCMElementDeclaration(element);
          }
          // find an attribute of type (or just named)
          // ID
          if (elementDecl != null) {
            int i = 0;
View Full Code Here

   * @param parent The Node that will get newChild as a new child node
   * @param newChild The Node that wants to be appended to parent
   * @return the element that is placed after newChild or null if newChild can be appended at last position
   */
  protected Node getNextExistentElement(Element parent, Element newChild) {
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
    List<CMNode> cmNodes = getAvailableChildrenAtIndex(parent, 0, 0);
   
    //get CMNode representation of newChild
    CMNode newChildCmNode = null;
    for (CMNode cmNode : cmNodes) {
      String curModelNodeName = cmNode.getNodeName();
     
      if (curModelNodeName.equals(newChild.getNodeName())) {
        newChildCmNode = cmNode;
        break;
      }
    }
   
    //CMNode had been found, check all existent elements if newChild can be inserted before them
    if (newChildCmNode != null) {
      NodeList nodeList = parent.getChildNodes();
      int len = nodeList.getLength();
      for (int i=0; i<len; i++) {
        try {
          if (modelQuery.canInsert(parent, newChildCmNode, i, ModelQuery.VALIDITY_STRICT)) {
            return nodeList.item(i);
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

 
  private List<CMNode> getAvailableChildrenAtIndex(Element parent, int index, int validityChecking) {
    List<CMNode> list = null;
    try {
      list = new ArrayList<CMNode>();
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
      CMElementDeclaration parentDecl = modelQuery.getCMElementDeclaration(parent);
      list = modelQuery.getAvailableContent(parent, parentDecl, ModelQuery.INCLUDE_CHILD_NODES);
    } catch (Exception e) {
      Logger.logException("Cannot query model. Missing WTP DTD or XSD Plugin?", e);
    }
    return list;
 
View Full Code Here

                    boolean hasName = false;
                    Node shownAttribute = null;
                    // try to get content model element
                    // declaration
                    CMElementDeclaration elementDecl = null;
                    ModelQuery mq = ModelQueryUtil.getModelQuery(element
                            .getOwnerDocument());
                    if (mq != null) {
                        elementDecl = mq.getCMElementDeclaration(element);
                    }
                    // find an attribute of type (or just named)
                    // ID
                    if (elementDecl != null) {
                        int i = 0;
View Full Code Here

      factoryRegistry.addFactory(factory);
    }

    // Stuff from super method (inferred grammar support)
    if (structuredModel != null) {
      ModelQuery modelQuery = ModelQueryUtil
          .getModelQuery(structuredModel);
      if (modelQuery != null) {
        CMDocumentManager documentManager = modelQuery
            .getCMDocumentManager();
        if (documentManager != null) {
          IPreferenceStore store = XMLUIPlugin.getDefault()
              .getPreferenceStore();
          boolean useInferredGrammar = (store != null) ? store
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery

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.