Package org.olat.core.gui.render

Examples of org.olat.core.gui.render.StringOutput


  protected static String getFormattedLimit(long millis) {
    long sSec = millis / 1000;
    long sMin = sSec / 60;
    sSec = sSec - (sMin * 60);
    StringOutput sb = new StringOutput();
    sb.append(sMin);
    sb.append("' ");
    sb.append(sSec);
    sb.append("\"");
    return sb.toString();
  }
View Full Code Here


    return sb.toString();
  }
 
  private StringOutput addItemLink(Renderer r, URLBuilder ubu ,Formatter formatter, ItemContext itc, int sectionPos, int itemPos,
   boolean clickable, boolean active, boolean info) {
    StringOutput sb = new StringOutput();

    String title = itc.getEl_item().attributeValue("title", "no title");
    String titleShort = Formatter.truncate(title, 27);
    long maxdur = itc.getDurationLimit();
    long start = itc.getTimeOfStart();
    long due = start + maxdur;
    boolean started = (start != -1);
    boolean timelimit = (maxdur != -1);
    String fdue = (started && timelimit ? formatter.formatTimeShort(new Date(due)) : null);
    sb.append("<div class=\"o_qti_menu_item\">");
    if (clickable) {
      sb.append("<a onclick=\"return o2cl()\" href=\"");
      ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "git" });
      sb.append("?itid="  + itemPos  + "&seid=" + sectionPos);
      sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(title) + "\">");
    }
    sb.append("<b>" + (sectionPos + 1) + "." + (itemPos + 1) + ".</b>&nbsp;");
    if (active) {
      sb.append("<strong>" + titleShort + "</strong>");
    } else {
      sb.append(titleShort);
    }
    if (clickable) {
      sb.append("</a>");
    }
    sb.append("</div>");

   
    if (!itc.isOpen()) {
      // add lock image
      sb.append("<div class=\"b_small_icon o_qti_closed_icon\" title=\"Closed\" ></div>");
    } else if (info) {
      // max duration info
      if (maxdur != -1) {
          sb.append("<div class=\"b_small_icon o_qti_timelimit_icon\" title=\"");
          if (!itc.isStarted()) {
            sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.initial", new String[] {getFormattedLimit(maxdur)})));
          } else  {
            sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.running", new String[] {fdue})));
          }
          sb.append("\" ></div>");
      }
     
      // attempts info
      int maxa = itc.getMaxAttempts();
      int attempts = itc.getTimesAnswered();
      if (maxa != -1) { // only limited times of answers
        sb.append("<div class=\"b_small_icon o_qti_attemptslimit_icon\" title=\"");
        sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("attemptsleft", new String[] {"" + (maxa - attempts)})));
        sb.append("\" ></div>");
      }
    }

    return sb;
  }
View Full Code Here

    return sb;
  }

  // menu stuff
  private StringOutput addSectionLink(Renderer r, URLBuilder ubu, Formatter formatter, SectionContext sc, int sectionPos, boolean clickable, boolean active) {
    StringOutput sb = new StringOutput();

    // section link
    String title = Formatter.truncate(sc.getTitle(), 30);
    long maxdur = sc.getDurationLimit();
    long start = sc.getTimeOfStart();
    long due = start + maxdur;
    boolean started = (start != -1);
    boolean timelimit = (maxdur != -1);
    String fdue = (started && timelimit ? formatter.formatTimeShort(new Date(due)) : null);
    sb.append("<div class=\"o_qti_menu_section\">");

    if (!sc.isOpen()) clickable = false;
    if (clickable) {
      sb.append("<a onclick=\"return o2cl()\" href=\"");
      ubu.buildURI(sb, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "gse" });
      sb.append("?seid=" + sectionPos);
      sb.append("\" title=\"" + StringEscapeUtils.escapeHtml(sc.getTitle()) + "\">");
    }
    sb.append("<b>" + (sectionPos + 1) + ".</b>&nbsp;");
    if (active) {
      sb.append("<strong>" + title + "</strong>");
    } else {
      sb.append(title);
    }
    if (clickable) {
      sb.append("</a>");
    }
    sb.append("</div>");


    if (!sc.isOpen()) {
      // add lock image
      sb.append("<div class=\"b_small_icon o_qti_closed_icon\" title=\"Section is closed.\" ></div>");
    } else {
      // max duration info
      if (maxdur != -1) {
          sb.append("<div class=\"b_small_icon o_qti_timelimit_icon\" title=\"");
          if (!sc.isStarted()) {
            sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.initial", new String[] {getFormattedLimit(maxdur)})));
          } else  {
            sb.append(StringEscapeUtils.escapeHtml(r.getTranslator().translate("timelimit.running", new String[] {fdue})));
          }
          sb.append("\" ></div>");
      }
    }
    return sb;
  }
View Full Code Here

   * Method buildMenu.
   *
   * @return DOCUMENT ME!
   */
  private StringOutput buildMenu(IQComponent comp, Translator translator, Renderer r, URLBuilder ubu) {
    StringOutput sb = new StringOutput();
    AssessmentInstance ai = comp.getAssessmentInstance();
    AssessmentContext ac = ai.getAssessmentContext();
    boolean renderSectionTitlesOnly = comp.getMenuDisplayConf().isRenderSectionsOnly();

    sb.append("<h4>");
    sb.append(ac.getTitle());
    sb.append("</h4>");

    // append assessment navigation
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    int scnt = ac.getSectionContextCount();
    for (int i = 0; i < scnt; i++) {
      SectionContext sc = ac.getSectionContext(i);
      boolean clickable = (ai.isSectionPage() && sc.isOpen()) || (!ai.isSectionPage());
      clickable = clickable && !ai.isClosed();
      clickable = clickable && ai.isMenu();
      sb.append("<ul><li class=\"o_qti_menu_section\">");
      sb.append(addSectionLink(r, ubu, formatter, sc, i, clickable, ac.getCurrentSectionContextPos() == i));
      sb.append("</li>");
     
      if (!renderSectionTitlesOnly) {
        //not only sections, but render questions to
        int icnt = sc.getItemContextCount();
        for (int j = 0; j < icnt; j++) {
          ItemContext itc = sc.getItemContext(j);
          clickable = !ai.isSectionPage() && sc.isOpen() && itc.isOpen();
          clickable = clickable && !ai.isClosed();
          clickable = clickable && ai.isMenu();
          sb.append("<li class=\"o_qti_menu_item\">");
          sb.append(addItemLink(r, ubu, formatter, itc, i, j, clickable,
              (ac.getCurrentSectionContextPos() == i && sc.getCurrentItemContextPos() == j), !ai.isSurvey()));
          sb.append("</li>");
        }
      }
      sb.append("</ul>");
    }
    return sb;
  }
View Full Code Here

    StringBuilder buffer = new StringBuilder(1000);
    Resolver resolver = ai.getResolver();
    RenderInstructions ri = new RenderInstructions();
    ri.put(RenderInstructions.KEY_STATICS_PATH, resolver.getStaticsBaseURI() + "/");
    ri.put(RenderInstructions.KEY_LOCALE, renderer.getTranslator().getLocale());
    StringOutput soCommandURI = new StringOutput(50);
    ubu.buildURI(soCommandURI, new String[] { VelocityContainer.COMMAND_ID }, new String[] { "sflash" });
    ri.put(RenderInstructions.KEY_APPLET_SUBMIT_URI, soCommandURI.toString());
    if (itc.getItemInput() != null)
      ri.put(RenderInstructions.KEY_ITEM_INPUT, itc.getItemInput());
    ri.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.valueOf(ai.isDisplayTitles()));
    itc.getQtiItem().render(buffer, ri);
    sb.append(buffer);
View Full Code Here

  public void setContentCSSFromTheme(Theme theme) {
    // Always use default content css, then add the one from the theme
    if (theme.getIdentifyer().equals("default")) {
      setContentCSS(theme.getBaseURI() + "all/content.css");     
    } else {
      StringOutput cssFiles = new StringOutput();
      StaticMediaDispatcher.renderStaticURI(cssFiles, "themes/default/all/content.css");
      cssFiles.append(",");
      cssFiles.append(theme.getBaseURI()).append("all/content.css");
      setContentCSS(cssFiles.toString());
    }
  }
View Full Code Here

    sb.append('\n');
    // data
    for (int r = 0; r < rcnt; r++) {
      for (int c = 0; c < (cdcnt-1); c++) { // skip last column (action)
        ColumnDescriptor cd = manageChecklistTable.getColumnDescriptor(c);
        StringOutput so = new StringOutput();
        cd.renderValue(so, r, null);
        String cellValue = so.toString();
        cellValue = StringHelper.stripLineBreaks(cellValue);
        sb.append('\t').append(cellValue);
      }
      sb.append('\n');
    }
View Full Code Here

    Windows.getWindows(ureq).registerWindow(currentWindow);
 
    // redirect to AuthenticatedDispatcher
    // IMPORTANT: windowID has changed due to re-registering current window -> do not use ureq.getWindowID() to build new URLBuilder.
    URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherAction.PATH_AUTHENTICATED, currentWindow.getInstanceId(), "1", null)
    StringOutput sout = new StringOutput(30);
    ubu.buildURI(sout, null, null);
    ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(sout.toString()));
   
    return LOGIN_OK;
  }
View Full Code Here

    //setExtensionURLBuilder(extension);
  }
 
  private void deployExtensionCSS() {
    File f = new File(WebappHelper.getContextRoot() + "/static/" + EXTENSIONS_SUBDIR + "/" + EXTENSIONS_CSS);
    StringOutput so = new StringOutput();
    for (Iterator iter = extensionCSSFiles.iterator(); iter.hasNext();) {
      String extensionCSS = (String) iter.next();
      so.append("@import url(");
      StaticMediaDispatcher.renderStaticURI(so, EXTENSIONS_SUBDIR + "/" + extensionCSS);
      so.append(");\n");
    }   
    FileUtils.save(f , so.toString(), "utf-8");
  }
View Full Code Here

   * @param prefix e.g. abc for "abc647547326" and so on
   * @return an prefixed id (e.g. f23748932) which is unique in the current render tree.
   *
   */
  public StringOutput getId(String prefix) {
    StringOutput sb = new StringOutput(16);
    sb.append("o_s").append(prefix).append(vc.getDispatchID());
    return sb;
  }
View Full Code Here

TOP

Related Classes of org.olat.core.gui.render.StringOutput

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.