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

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


    }
    if (textEditor != null) {
      IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
      IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
      if (model != null) {
        ModelQuery modelQuery = null;
        try {
          modelQuery = ModelQueryUtil.getModelQuery(model);
        }
        finally {
          model.releaseFromRead();
        }
        Document domDocument = ((IDOMModel) model).getDocument();
        if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
          modelQuery.getCMDocumentManager().getCMDocumentCache().clear();
          // TODO... need to figure out how to access the
          // DOMObserver via ModelQuery
          // ...why?
          CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(domDocument, modelQuery);
          loader.loadCMDocuments();
View Full Code Here


      if(region != null) {
        shouldSpellcheck = region instanceof Comment;
        if (!shouldSpellcheck && region instanceof Text) {
          final Node parent = ((Text) (region)).getParentNode();
          if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
            final ModelQuery mq = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
            if (mq != null) {
              final CMElementDeclaration decl = mq.getCMElementDeclaration((Element) parent);
              if (decl != null) {
                final CMDataType type= decl.getDataType();
                shouldSpellcheck = type == null || type.getEnumeratedValues() == null || type.getEnumeratedValues().length == 0;
              }
            }
View Full Code Here

            null, null, XMLRelevanceConstants.R_END_TAG_NAME);
      contentAssistRequest.addProposal(proposal);
    }
    else {
      IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
      Node aNode = contentAssistRequest.getNode();
      String matchString = contentAssistRequest.getMatchString();
      if (matchString.startsWith("</")) {
        matchString = matchString.substring(2);
      }
      while (aNode != null) {
        if (aNode.getNodeType() == Node.ELEMENT_NODE) {
          if (aNode.getNodeName().startsWith(matchString)) {
            IDOMNode aXMLNode = (IDOMNode) aNode;
            CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode);
            if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) {
              String replacementText = aNode.getNodeName();
              String displayText = replacementText;
              String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
              if(!contentAssistRequest.getDocumentRegion().isEnded()) {
View Full Code Here

      if ((regionText != null) && regionText.startsWith("&")) { //$NON-NLS-1$                
        String key = (nodeOffset > 0) ? regionText.substring(1, nodeOffset) : ""; //$NON-NLS-1$

        // get entity proposals, passing in the appropriate start
        // string
        ModelQuery mq = ModelQueryUtil.getModelQuery(((Node) treeNode).getOwnerDocument());
        if (mq != null) {
          CMDocument xmlDoc = mq.getCorrespondingCMDocument(treeNode);
          CMNamedNodeMap cmmap = null;
          Properties entities = null;
          if (xmlDoc != null) {
            cmmap = xmlDoc.getEntities();
          }
View Full Code Here

  // returns a list of ModelQueryActions
  protected List getAvailableChildrenAtIndex(Element parent, int index, int validityChecking) {
    List list = new ArrayList();
    CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
    if (parentDecl != null) {
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
      // taken from ActionManagers
      // int editMode = modelQuery.getEditMode();
      int editMode = ModelQuery.EDIT_MODE_UNCONSTRAINED;
      int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES | ModelQuery.INCLUDE_SEQUENCE_GROUPS : ModelQuery.INCLUDE_CHILD_NODES;
      modelQuery.getInsertActions(parent, parentDecl, index, ic, validityChecking, list);
    }
    return list;
  }
View Full Code Here

        return new ArrayList(0);
      }
    }

    list = new ArrayList(1);
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
    if (modelQuery != null) {
      CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
      if (cmdoc != null) {
        if (rootName != null) {
          CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
          if (rootDecl != null) {
            list.add(rootDecl);
View Full Code Here

  }

  protected CMElementDeclaration getCMElementDeclaration(Node node) {
    CMElementDeclaration result = null;
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
      if (modelQuery != null) {
        result = modelQuery.getCMElementDeclaration((Element) node);
      }
    }
    return result;
  }
View Full Code Here

      Element element = (Element) node;
      String[] dataTypeValues = null;
      // The ModelQuery may not be available if the corresponding
      // adapter
      // is absent
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
      if (modelQuery != null) {
        dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
      }
      else {
        if (ad.getAttrType() != null) {
          dataTypeValues = ad.getAttrType().getEnumeratedValues();
        }
View Full Code Here

            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

          }
          idResolver = new XMLCatalogIdResolver(baseLocation, null);
        }

        CMDocumentCache cmDocumentCache = new CMDocumentCache();
        ModelQuery modelQuery = new XMLModelQueryImpl(cmDocumentCache, idResolver);

        // cs todo...
        // for now we create a CMDocumentCache on a 'per editor' basis
        // in the future we need to support a CMDocumentCache that is
        // shared between editors
        // nsd comment: may not be appropriate depending on
        CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
        if (documentManager != null) {
          configureDocumentManager(documentManager);
        }
        modelQueryAdapterImpl = new ModelQueryAdapterImpl(cmDocumentCache, modelQuery, idResolver);
      }
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.