Package org.olat.core.gui.components.form.flexible.impl.elements.table

Source Code of org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer

/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) 1999-2006 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.gui.components.form.flexible.impl.elements.table;


import java.util.Date;

import org.olat.core.gui.components.Component;
import org.olat.core.gui.render.RenderResult;
import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.RenderingState;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Formatter;

/**
* Render value with toString. Render Date value with Formatter depending on locale.
* @author Christian Guretzki
*/
class TextFlexiCellRenderer implements FlexiCellRenderer {

  /**
   * @see org.olat.core.gui.components.ComponentRenderer#render(org.olat.core.gui.render.Renderer,
   *      org.olat.core.gui.render.StringOutput,
   *      org.olat.core.gui.components.Component,
   *      org.olat.core.gui.render.URLBuilder,
   *      org.olat.core.gui.translator.Translator,
   *      org.olat.core.gui.render.RenderResult, java.lang.String[])
   */
  @SuppressWarnings("unused")
  public void render(Renderer renderer, StringOutput target, Component source,
      URLBuilder ubu, Translator translator, RenderResult renderResult,
      String[] args) {

  }

  /**
   * @see org.olat.core.gui.components.ComponentRenderer#renderBodyOnLoadJSFunctionCall(org.olat.core.gui.render.Renderer,
   *      org.olat.core.gui.render.StringOutput,
   *      org.olat.core.gui.components.Component,
   *      org.olat.core.gui.render.RenderingState)
   */
  @SuppressWarnings("unused")
  public void renderBodyOnLoadJSFunctionCall(Renderer renderer,
      StringOutput sb, Component source, RenderingState rstate) {
    // TODO Auto-generated method stub

  }

  /**
   * @see org.olat.core.gui.components.ComponentRenderer#renderHeaderIncludes(org.olat.core.gui.render.Renderer,
   *      org.olat.core.gui.render.StringOutput,
   *      org.olat.core.gui.components.Component,
   *      org.olat.core.gui.render.URLBuilder,
   *      org.olat.core.gui.translator.Translator,
   *      org.olat.core.gui.render.RenderingState)
   */
  @SuppressWarnings("unused")
  public void renderHeaderIncludes(Renderer renderer, StringOutput sb,
      Component source, URLBuilder ubu, Translator translator,
      RenderingState rstate) {
    // TODO Auto-generated method stub

  }

  /**
   * Render Date type with Formatter depending on locale. Render all other types with toString.
   * @param target
   * @param cellValue
   * @param translator
   */ 
  public void render(StringOutput target, Object cellValue, Translator translator) {
    if (cellValue instanceof Date) {
      Formatter formatter = Formatter.getInstance(translator.getLocale());
      target.append( formatter.formatDateAndTime((Date)cellValue) );
    } else {
      target.append( cellValue.toString() );
    }
  }

}
TOP

Related Classes of org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer

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.