Package org.dbwiki.web.html

Examples of org.dbwiki.web.html.HtmlLinePrinter


 
  /** Generates HTML lines corresponding to the nodes in list.
   * versionParameter says which version(s) to use.
   */
  public HtmlPage getLinesForNodeList(SchemaNodeList list, RequestParameterVersion versionParameter) throws org.dbwiki.exception.WikiException {
    HtmlLinePrinter content = new HtmlLinePrinter();
    boolean hasContent = false;
   
    SchemaLayout layout = _layouter.get(list.schema());

    // Dispatching based on layout style for this node's type
    if ((layout.getDisplayStyle().isGroupStyle()) || ((layout.getDisplayStyle().isTableStyle()) && (list.schema().isAttribute()))) {
      hasContent = printNodesInGroupStyle(list, versionParameter, layout, content);
    } else if (layout.getDisplayStyle().isListStyle()) {
      hasContent = printNodesInListStyle(list, versionParameter, layout, content);
    } else if (layout.getDisplayStyle().isTableStyle()) {
      hasContent = printNodesInTableStyle(list, versionParameter, layout, content);
    }
   
    if (hasContent) {
      return content.lines();
    } else {
      return new HtmlPage();
    }
  }
View Full Code Here


    /**  FIXME #wiki: Clean this up and make queries independent of database.
     * Implements printing queries by finding the database associated with the printer and querying it.
     */
    @Override
    public void print(Printer printer) {
      HtmlLinePrinter body = new HtmlLinePrinter();
     
        PageContentPrinter contentPrinter = (PageContentPrinter)((ExtendedPrinter) printer).getExtension();
        Database database = contentPrinter.getDatabase();
     
      try {     
        String query = _queryString;
        if(query.toLowerCase().startsWith("ignore:")) {
          return;
        }
        else if(query.toLowerCase().startsWith("chart:") || query.toLowerCase().startsWith("chart(")) {
          // FIXME: should parse the arguments to charts in a more
          // sensible scalable way.
          query = query.substring("chart".length());
          String xSize = "800";
          String ySize = "600";
          if(query.startsWith("(")) {
            int comma = query.indexOf(",");
            int closeParen = query.indexOf(")", comma);
            int colon = query.indexOf(":", closeParen);
           
            if(comma == -1 || closeParen == -1 || colon != closeParen+1)
              throw new WikiQueryException(WikiQueryException.UnknownQueryFormat, _queryString);
           
            xSize = query.substring(1, comma);
            ySize = query.substring(comma+1, closeParen);
            query = query.substring(colon+1);
          } else {
            query = query.substring(1);
          }
          QueryResultSet rs = database.query(query);
          body.openPARAGRAPH(CSS.CSSPageText);
          drawChart(ChartType.Column, xSize, ySize, rs, body);
        } else if(query.toLowerCase().startsWith("pie:") || query.toLowerCase().startsWith("pie(")) {
          // FIXME: should parse the arguments to charts in a more
          // sensible scalable way.
          query = query.substring("pie".length());
          String xSize = "800";
          String ySize = "600";
          if(query.startsWith("(")) {
            int comma = query.indexOf(",");
            int closeParen = query.indexOf(")", comma);
            int colon = query.indexOf(":", closeParen);

            if(comma == -1 || closeParen == -1 || colon != closeParen+1)
              throw new WikiQueryException(WikiQueryException.UnknownQueryFormat, _queryString);

            xSize = query.substring(1, comma);
            ySize = query.substring(comma+1, closeParen);
            query = query.substring(colon+1);
          } else {
            query = query.substring(1);
          }
          QueryResultSet rs = database.query(query);
          body.openPARAGRAPH(CSS.CSSPageText);
          drawChart(ChartType.Pie, xSize, ySize, rs, body);
        } else if(query.toLowerCase().startsWith("map:")) {
          query = query.substring("map:".length());
          QueryResultSet rs = database.query(query);
          body.openPARAGRAPH(CSS.CSSPageText);
          drawMap(rs, body);
        } else {
          QueryResultSet rs = database.query(query);
          if (!rs.isEmpty()) {
            body.openPARAGRAPH(CSS.CSSPageText);
            if (rs.isElement()) {
              RequestParameterVersion versionParameter = null;
              if (rs.hasTimestamp()) {
                versionParameter = new RequestParameterVersionTimestamp(rs.getTimestamp());
              } else {
                versionParameter = new RequestParameterVersionCurrent();
              }
              body.add(contentPrinter.getLinesForNodeList(new SchemaNodeList(rs),
                                    versionParameter));
            } else {
              for (int i = 0; i < rs.size(); i++) {
                contentPrinter.printTextNode((DatabaseTextNode)rs.get(i), body);
              }
            }
          }
        }
    } catch (org.dbwiki.exception.data.WikiQueryException queryException) {
      queryException.printStackTrace();
      body.paragraph("<b> " + queryException.toString() + "</b>", CSS.CSSPageText);
    } catch (WikiException e) {
      e.printStackTrace();
      // don't throw exception because we can't
    }
     
    HtmlPage lines = body.lines();
    for(int i = 0; i < lines.size(); i++)
      printer.print(lines.get(i));
    }
View Full Code Here

   */
 
  public void print(String key, Vector<String> args, HtmlPage page, String indention) throws org.dbwiki.exception.WikiException {

    if (_contentPrinter.containsKey(key)) {
      _contentPrinter.get(key).print(new HtmlLinePrinter(page, indention),args);
    }
  }
View Full Code Here

TOP

Related Classes of org.dbwiki.web.html.HtmlLinePrinter

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.