Examples of UAElement


Examples of org.eclipse.help.internal.UAElement

        // filter the content
        if (domProcessor == null) {
          domProcessor = new DocumentProcessor(new ProcessorHandler[] { new FilterHandler(IntroEvaluationContext.getContext()) });
        }
        UAElement element = UAElementFactory.newElement(dom.getDocumentElement());
        domProcessor.process(element, null);
       
        // and resolve includes.
        resolveIncludes();
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

   */
  private class LinkHandler extends ProcessorHandler {
    public short handle(UAElement element, String id) {
      if (element instanceof Link) {
        Link link = (Link)element;
        UAElement parent = link.getParentElement();
        if (parent != null) {
          String toc = link.getToc();
          if (toc != null) {
            TocContribution destContribution = getContribution(id);
            TocContribution srcContribution = getContribution(HrefUtil.normalizeHref(destContribution.getContributorId(), toc));
            if (srcContribution != null) {
              process(srcContribution);
              IUAElement[] children = srcContribution.getToc().getChildren();
              for (int i=0;i<children.length;++i) {
                parent.insertBefore((UAElement)children[i], link);
              }
              addExtraDocuments(destContribution, srcContribution.getExtraDocuments());
            }
            parent.removeChild(link);
          }
        }
        return HANDLED_SKIP;
      }
      return UNHANDLED;
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

   */
  private class AnchorHandler extends ProcessorHandler {
    public short handle(UAElement element, String id) {
      if (element instanceof Anchor) {
        Anchor anchor = (Anchor)element;
        UAElement parent = anchor.getParentElement();
        if (parent != null) {
          String anchorId = anchor.getId();
          if (anchorId != null) {
            // add to set of known anchors
            if (anchorsByContributionId == null) {
              anchorsByContributionId = new HashMap();
            }
            Set set = (Set)anchorsByContributionId.get(id);
            if (set == null) {
              set = new HashSet();
              anchorsByContributionId.put(id, set);
            }
            set.add(anchorId);
           
            // process contributions
            TocContribution destContribution = getContribution(id);
            if (destContribution != null) {
              TocContribution[] srcContributions = getAnchorContributions(destContribution.getId() + '#' +  anchorId);
              for (int i=0;i<srcContributions.length;++i) {
                process(srcContributions[i]);
                IUAElement[] children = srcContributions[i].getToc().getChildren();
                for (int j=0;j<children.length;++j) {
                  parent.insertBefore((UAElement)children[j], anchor);
                }
                addExtraDocuments(destContribution, srcContributions[i].getExtraDocuments());
              }
            }
          }
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

 
  public synchronized int[] getTopicPath(String href) {
    Topic topic = getTopic(href);
    if (topic != null) {
      List path = new ArrayList();
      UAElement element = topic;
      while (!(element instanceof Toc)) {
        UAElement parent = element.getParentElement();
        path.add(new Integer(indexOf(parent, (Topic)element)));
        element = parent;
      }
      Toc[] tocs = getTocs(Platform.getNL());
      for (int i=0;i<tocs.length;++i) {
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

      InputStream in = ResourceLocator.openFromPlugin(descriptor.getBundleId(), descriptor.getFile(), locale);
        if (in != null) {
        if (reader == null) {
          reader = new DocumentReader();
        }
        UAElement root = reader.read(in);
        if ("contexts".equals(root.getElementName())) { //$NON-NLS-1$
          // process dynamic content
          if (processor == null) {
            processor = new DocumentProcessor(new ProcessorHandler[] {
              new ValidationHandler(getRequiredAttributes()),
              new NormalizeHandler(),
              new IncludeHandler(reader, locale),
              new ExtensionHandler(reader, locale)
            });
          }
          processor.process(root, '/' + descriptor.getBundleId() + '/' + descriptor.getFile());
         
          // build map
          IUAElement[] children = root.getChildren();
          Map contexts = new HashMap();
          for (int i=0;i<children.length;++i) {
            if (children[i] instanceof Context) {
              Context context = (Context)children[i];
              String id = context.getId();
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

    // create data structures for fast lookup
    Map entriesByKeyword = new HashMap();
    Set topicHrefs = new HashSet();
    IUAElement[] childrenA = a.getChildren();
    for (int i=0;i<childrenA.length;++i) {
      UAElement childA = (UAElement)childrenA[i];
      if (childA instanceof IndexEntry) {
        entriesByKeyword.put(childA.getAttribute(IndexEntry.ATTRIBUTE_KEYWORD), childA);
      }
      else if (childA instanceof Topic) {
        topicHrefs.add(childA.getAttribute(Topic.ATTRIBUTE_HREF));
      }
    }
   
    // now do the merge
    IUAElement[] childrenB = b.getChildren();
    for (int i=0;i<childrenB.length;++i) {
      UAElement childB = (UAElement)childrenB[i];
      if (childB instanceof IndexEntry) {
        String keyword = childB.getAttribute(IndexEntry.ATTRIBUTE_KEYWORD);
        if (entriesByKeyword.containsKey(keyword)) {
          // duplicate keyword; merge children
          mergeChildren((IndexEntry)entriesByKeyword.get(keyword), childB);
        }
        else {
          // wasn't a duplicate
          a.appendChild(childB);
          entriesByKeyword.put(keyword, childB);
        }
      }
      else if (childB instanceof Topic) {
        String href = childB.getAttribute(Topic.ATTRIBUTE_HREF);
        if (!topicHrefs.contains(href)) {
          // add topic only if href doesn't exist yet
          a.appendChild(childB);
          topicHrefs.add(href);
        }
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

    String href = '/' + bundleId + '/' + relativePath;
    InputStream in = HelpSystem.getHelpContent(href, locale);
    try {
      if (nodeId != null) {
        Element element = findElement(in, nodeId);
        processor.process(new UAElement(element), href);
        return new Node[] { element };
      }
      Element body = findBody(in);
      List children = new ArrayList();
      Node node = body.getFirstChild();
      while (node != null) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {
          processor.process(new UAElement((Element)node), href);
        }
        children.add(node);
        node = node.getNextSibling();
      }
      return (Node[])children.toArray(new Node[children.size()]);
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

   */
  public UAElement resolve(String bundleId, String relativePath, String elementId) throws IOException, SAXException, ParserConfigurationException {
    String href = '/' + bundleId + '/' + relativePath;
    InputStream in = HelpSystem.getHelpContent(href, locale);
    try {
      UAElement element = findElement(in, elementId);
      processor.process(element, href);
      return element;
    }
    finally {
      try {
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

 
  /*
   * Finds the specified element from the given XML input stream.
   */
  private UAElement findElement(InputStream in, String elementId) throws IOException, SAXException, ParserConfigurationException {
    UAElement element = reader.read(in);
    return findElement(element, elementId);
  }
View Full Code Here

Examples of org.eclipse.help.internal.UAElement

    if (id != null && id.equals(elementId)) {
      return element;
    }
    IUAElement[] children = element.getChildren();
    for (int i=0;i<children.length;++i) {
      UAElement result = findElement((UAElement)children[i], elementId);
      if (result != null) {
        return result;
      }
    }
    return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.