Package org.cast.isi.page

Examples of org.cast.isi.page.SectionLinkFactory


    for(ISIXmlSection page = currentSection.firstPage(); page != null; page = page.getNext(), pageNumDisplay++) {
      WebMarkupContainer pageLinkContainer = new WebMarkupContainer(pageRepeater.newChildId());
      pageRepeater.add(pageLinkContainer);
     
      BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkToPage("pageLink", page);
      pageLinkContainer.add(link);
      link.setVisible(ISIApplication.get().isPageNumbersOn());
      link.add(new Label("pageNum", String.valueOf(pageNumDisplay)).setRenderBodyOnly(true));

      feedbackRequired = false;
View Full Code Here


      // According to NIMAS, href should be in the form "filename.xml#ID"  or just "#ID" for within-file link
      // For authors' convenience, we accept simple "ID" as well.
      int hashLocation = href.indexOf('#');
      if (hashLocation > 0) {
        // filename#ID case
        return new SectionLinkFactory().linkTo(wicketId, href.substring(0, hashLocation), href.substring(hashLocation+1));
      }
      // "#ID" or "ID" case:
      String file = getModel().getObject().getXmlDocument().getName(); // same file as we're currently viewing
      String id = href.substring(hashLocation+1)// start at index 0 or 1
      return new SectionLinkFactory().linkTo(wicketId, file, id);

    } else if (wicketId.startsWith("popupLink_")) {
      String href = elt.getAttribute("href");
      // According to NIMAS, href should be in the form "filename.xml#ID"  or just "#ID" for within-file link
      // For authors' convenience, we accept simple "ID" as well.
      int hashLocation = href.indexOf('#');
      String file;
      if (hashLocation > 0) {
        file = href.substring(0, hashLocation);
      } else { // "#ID" or "ID" case:
        file = getModel().getObject().getXmlDocument().getName(); // same file as we're currently viewing
      }
      XmlDocument document = xmlService.getDocument(file);
      String xmlId = href.substring(hashLocation+1);
      XmlSection section = document.getById(xmlId);
      XmlSectionModel mSection = new XmlSectionModel(section);
      return new AuthoredPopupLink(wicketId, xmlId, mSection);
     
    } else if (wicketId.startsWith("noteBackLink_")) {
      // Link back from a note to its (first) noteref.
      String idref = elt.getAttribute("idref");
      // Find candidate noterefs in this chapter
      XmlSection sec = getModel().getObject();
      XPath xPath = XPathFactory.newInstance().newXPath();
      xPath.setNamespaceContext(XmlService.get().getNamespaceContext());
      XmlSection linkSection = null;
      String linkText = "?";
      try {
        String path = String.format("//dtb:noteref[@idref='#%s']", idref);
        NodeList nl = (NodeList) xPath.evaluate(path, sec.getXmlDocument().getDocument().getDocumentElement(), XPathConstants.NODESET);
        if (nl.getLength() > 0) {
          Element node = null;
          node = (Element) nl.item(0);
          linkText = node.getTextContent();
          // Scan parents until you find the smallest enclosing XML Section.
          while (linkSection == null && node.getParentNode() != null) {
            String id = node.getAttributeNS(null, "id");
            if (id != null) {
              linkSection = sec.getXmlDocument().getById(id);
            }
            node = (Element) node.getParentNode();
          }
        }
      } catch (XPathExpressionException e) {
        e.printStackTrace()// malformed expression - shouldn't happen
      }
      if (linkSection != null) {
        BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkTo(wicketId, linkSection, "note_"+idref);
        link.add(new AttributeRemover("idref"));
        link.add(new Label("text", linkText));
        return link;
      } else {
        log.debug("Could not find noteref for note: idref={}", idref);
        return new SectionLinkFactory().linkToPage(wicketId, null);
      }
     
    } else if (wicketId.startsWith("fileLink_")) {
      // link to file in content directory
      return new ResourceLink<Object> (wicketId, getRelativeRef(elt.getAttribute("href")));
View Full Code Here

        boolean current = section.equals(currentSection);

        WebMarkupContainer sectionContainer = new WebMarkupContainer(newChildId());
        add(sectionContainer);

        BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkToPage("sectionLink", section);
        sectionContainer.add(link);
        if (current) {
          link.setEnabled(false);
          link.add(new ClassAttributeModifier("current"));
          link.add(new IconContainer("iconContainer", section, iconFactory));
View Full Code Here

TOP

Related Classes of org.cast.isi.page.SectionLinkFactory

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.