Package org.pentaho.reporting.engine.classic.core.function.formula

Source Code of org.pentaho.reporting.engine.classic.core.function.formula.DashboardModeFunction

package org.pentaho.reporting.engine.classic.core.function.formula;

import org.pentaho.reporting.engine.classic.core.function.ReportFormulaContext;
import org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlTableModule;
import org.pentaho.reporting.libraries.formula.EvaluationException;
import org.pentaho.reporting.libraries.formula.FormulaContext;
import org.pentaho.reporting.libraries.formula.function.Function;
import org.pentaho.reporting.libraries.formula.function.ParameterCallback;
import org.pentaho.reporting.libraries.formula.lvalues.TypeValuePair;
import org.pentaho.reporting.libraries.formula.typing.coretypes.LogicalType;

/**
* Todo: Document me!
* <p/>
* Date: 13.08.2010
* Time: 17:08:12
*
* @author Thomas Morgner.
*/
public class DashboardModeFunction implements Function
{
  public DashboardModeFunction()
  {
  }

  public String getCanonicalName()
  {
    return "DASHBOARDMODE";
  }

  public TypeValuePair evaluate(final FormulaContext context,
                                final ParameterCallback parameters) throws EvaluationException
  {
    final ReportFormulaContext rfc = (ReportFormulaContext) context;
    if (isDashboardMode(rfc))
    {
      return new TypeValuePair(LogicalType.TYPE, Boolean.TRUE);
    }
    return new TypeValuePair(LogicalType.TYPE, Boolean.FALSE);
  }

  public static boolean isDashboardMode(final ReportFormulaContext rfc)
  {
    final boolean value = "true".equals(rfc.getConfiguration().getConfigProperty(HtmlTableModule.BODY_FRAGMENT));

    if (value)
    {
      final String exportType = rfc.getExportType();
      if (exportType.startsWith("table/html") &&
          HtmlTableModule.ZIP_HTML_EXPORT_TYPE.equals(exportType) == false)
      {
        return true;
      }
    }
    return false;
  }
}
TOP

Related Classes of org.pentaho.reporting.engine.classic.core.function.formula.DashboardModeFunction

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.