Package org.eclipse.jst.jsp.core.internal.contentmodel.tld

Examples of org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager$IncludeHelper


   * @param model
   * @param uri
   * @return null means this is tld is not declared in the jsp file
   */
  public static String getPrefix(IDOMModel model, String uri) {
    TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
        .getStructuredDocument());
    if (m == null) {
        // if the doc manager has nothing but the type is XML,
        // then see if the prefix is encoded as a namespace in
        // the doc root
        if (model.getDocument().isXMLType())
        {
            Element root = getRootElement(model);
              if (root != null){             
                  NamedNodeMap attrs = root.getAttributes();
                  for (int i=0;i<attrs.getLength();i++){
                      Attr a = (Attr)attrs.item(i);
                      //is the taglib uri already declared?
                      if (a.getValue().equals(uri)
                              && a.getName().startsWith("xmlns:")) //$NON-NLS-1$
                      {
                          String prefix =  a.getNodeName().substring("xmlns:".length()); //$NON-NLS-1$
                         
                          if ("".equals(prefix)) //$NON-NLS-1$
                          {
                              prefix = null;
                          }
                          return prefix;
                      }
                  }
              }
        }
      return null;
    }
    List trackers = m.getTaglibTrackers();
    for (Iterator iter = trackers.iterator(); iter.hasNext();) {
      TaglibTracker tracker = (TaglibTracker) iter.next();
      if (uri.equals(tracker.getURI())) {
        return tracker.getPrefix();
      }
View Full Code Here


   */
  public static String findUnusedPrefix(IDOMModel model, String suggestion) {
    if (suggestion == null) {
      suggestion = "p"; //$NON-NLS-1$
    }
    TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
        .getStructuredDocument());
    if (m == null) {
      return suggestion;
    }
    List trackers = m.getTaglibTrackers();
    Set map = new HashSet();
    for (Iterator iter = trackers.iterator(); iter.hasNext();) {
      TaglibTracker tracker = (TaglibTracker) iter.next();
      map.add(tracker.getPrefix());
    }
View Full Code Here

   */
  public static String findURIForPrefix(IDOMModel model, String prefix) {
    if (prefix == null || model == null) {
      return null;
    }
    TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
        .getStructuredDocument());
    if (m == null) {
      return null;
    }
    List trackers = m.getTaglibTrackers();
    for (Iterator iter = trackers.iterator(); iter.hasNext();) {
      TaglibTracker tracker = (TaglibTracker) iter.next();
      if (prefix.equals(tracker.getPrefix())) {
        CMDocument cmdoc = tracker.getDocument();
        if (cmdoc instanceof TLDDocument) {
View Full Code Here

      String prefix = node.getPrefix();

      if (result == null && prefix != null && prefix.length() > 0 && node instanceof IDOMNode) {
        // check position dependent
        IDOMNode xmlNode = (IDOMNode) node;
        TLDCMDocumentManager tldmgr = TaglibController.getTLDCMDocumentManager(xmlNode.getStructuredDocument());
        if (tldmgr != null) {
          List documents = tldmgr.getCMDocumentTrackers(node.getPrefix(), xmlNode.getStartOffset());
          // there shouldn't be more than one cmdocument returned
          if (documents != null && documents.size() > 0)
            result = (CMDocument) documents.get(0);
        }
      }
View Full Code Here

    DocumentInfo info = new DocumentInfo();
    info.document = (IStructuredDocument) document;
    info.textFileBuffer = null; // will be supplied later
    info.location = location;
    info.locationKind = locationKind;
    info.tldDocumentManager = new TLDCMDocumentManager();
    synchronized (_instance.fDocumentMap) {
      _instance.fDocumentMap.put(document, info);
    }
    info.tldDocumentManager.setSourceParser((XMLSourceParser) info.document.getParser());
    if (document instanceof BasicStructuredDocument && document.getLength() > 0) {
View Full Code Here

          info = new DocumentInfo();
          info.document = (IStructuredDocument) document;
          info.textFileBuffer = (ITextFileBuffer) buffer;
          info.location = buffer.getLocation();
          info.locationKind = LocationKind.NORMALIZE;
          info.tldDocumentManager = new TLDCMDocumentManager();
          info.tldDocumentManager.setSourceParser((XMLSourceParser) info.document.getParser());
          synchronized (_instance.fDocumentMap) {
            _instance.fDocumentMap.put(document, info);
          }
          if (document instanceof BasicStructuredDocument && document.getLength() > 0) {
View Full Code Here

        if (xmlNode != null && contents != null) {
          int additionalShifts = 0;
          // Be sure that custom tags from taglibs also show up
          // by
          // adding taglib declarations to the internal model.
          TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(xmlOuterModel.getStructuredDocument());
          if (mgr != null) {
            List trackers = mgr.getCMDocumentTrackers(contentAssistRequest.getReplacementBeginPosition());
            if (trackers != null) {
              for (i = 0; i < trackers.size(); i++) {
                CMDocumentTracker tracker = (CMDocumentTracker) trackers.get(i);
                String declaration = tracker.getStructuredDocumentRegion().getText();
                if (declaration != null) {
View Full Code Here

                }
                else {
                  /**
                   * Hyperlink custom tag to its TLD or tag file
                   */
                  TLDCMDocumentManager documentManager = TaglibController.getTLDCMDocumentManager(doc);
                  if (documentManager != null) {
                    List documentTrackers = documentManager.getCMDocumentTrackers(currentNode.getPrefix(), region.getOffset());
                    for (int i = 0; i < documentTrackers.size(); i++) {
                      TaglibTracker tracker = (TaglibTracker) documentTrackers.get(i);
                      CMElementDeclaration decl = (CMElementDeclaration) tracker.getElements().getNamedItem(currentNode.getNodeName());
                      if (decl != null) {
                        decl = (CMElementDeclaration) ((CMNodeWrapper) decl).getOriginNode();
View Full Code Here

      this.fTranslator.handleIncludeFile(fileLocation);
    }
    else if (isTaglibDirective(fTagname)) {
      // also add the ones created here to the parent document
      String prefix = getAttributeValue("prefix", sdRegion); //$NON-NLS-1$
      TLDCMDocumentManager documentManager = this.fTranslator.getTLDCMDocumentManager();
      if (documentManager != null) {
        List docs = documentManager.getCMDocumentTrackers(prefix, this.fTranslator.getCurrentNode().getStartOffset());
        Iterator it = docs.iterator();
        Iterator elements = null;
        CMNode node = null;
        CMDocument doc = null;
        BlockMarker marker = null;
View Full Code Here

          textInsertionOffset = ((IDOMNode) nodeAlreadyAtIndex).getEndOffset();
      }
      else {
        textInsertionOffset = ((IDOMNode) node).getStartOffset();
      }
      TLDCMDocumentManager mgr = TaglibController.getTLDCMDocumentManager(((IDOMNode) node).getStructuredDocument());
      if (mgr != null) {
        List moreCMDocuments = mgr.getCMDocumentTrackers(textInsertionOffset);
        if (moreCMDocuments != null) {
          for (int i = 0; i < moreCMDocuments.size(); i++) {
            CMDocument doc = (CMDocument) moreCMDocuments.get(i);
            CMNamedNodeMap elements = doc.getElements();
            if (elements != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager$IncludeHelper

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.