Save This Page
Home » pentaho-reporting-engine-classic-0.8.10 » org » jfree » report » demo » invoice » [javadoc | source]
    1   /**
    2    * ========================================
    3    * JFreeReport : a free Java report library
    4    * ========================================
    5    *
    6    * Project Info:  http://www.jfree.org/jfreereport/index.html
    7    * Project Lead:  Thomas Morgner (taquera@sherito.org);
    8    *
    9    * (C) Copyright 2000-2004, by Simba Management Limited and Contributors.
   10    *
   11    * This library is free software; you can redistribute it and/or modify it under the terms
   12    * of the GNU Lesser General Public License as published by the Free Software Foundation;
   13    * either version 2.1 of the License, or (at your option) any later version.
   14    *
   15    * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
   16    * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   17    * See the GNU Lesser General Public License for more details.
   18    *
   19    * You should have received a copy of the GNU Lesser General Public License along with this
   20    * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
   21    * Boston, MA 02111-1307, USA.
   22    *
   23    * ------------------------------
   24    * HideArticleDetailsFunction.java
   25    * ------------------------------
   26    * (C)opyright 2004, by Thomas Morgner and Contributors.
   27    *
   28    * Original Author:  Thomas Morgner;
   29    * Contributor(s):   David Gilbert (for Simba Management Limited);
   30    *
   31    * $Id: HideArticleDetailsFunction.java,v 1.1.2.2 2004/10/13 18:42:15 taqua Exp $
   32    *
   33    * Changes 
   34    * -------------------------
   35    * 26.03.2004 : Initial version
   36    *  
   37    */
   38   
   39   package org.jfree.report.demo.invoice;
   40   
   41   import org.jfree.report.Element;
   42   import org.jfree.report.event.ReportEvent;
   43   import org.jfree.report.function.AbstractFunction;
   44   import org.jfree.report.function.FunctionUtilities;
   45   import org.jfree.report.util.Log;
   46   
   47   public class HideArticleDetailsFunction extends AbstractFunction
   48   {
   49     /**
   50      * Creates an unnamed function. Make sure the name of the function is set using {@link
   51      * #setName} before the function is added to the report's function collection.
   52      */
   53     public HideArticleDetailsFunction ()
   54     {
   55     }
   56   
   57     /**
   58      * Receives notification that a row of data is being processed.
   59      *
   60      * @param event the event.
   61      */
   62     public void itemsAdvanced (final ReportEvent event)
   63     {
   64       final Element e = FunctionUtilities.findElement
   65               (event.getReport().getItemBand(), "details");
   66       if (e == null)
   67       {
   68         Log.warn ("HideArticleDetailsFunction: No 'detail' element found in the itemband.");
   69         return;
   70       }
   71   
   72       // now hide the element if there are no details ...
   73       e.setVisible(event.getDataRow().get("article.details") != null);
   74     }
   75   
   76     /**
   77      * Return the current expression value. <P> The value depends (obviously) on the
   78      * expression implementation.
   79      *
   80      * @return the value of the function.
   81      */
   82     public Object getValue ()
   83     {
   84       // we don't have to return a value, as this function does no computation
   85       return null;
   86     }
   87   }

Save This Page
Home » pentaho-reporting-engine-classic-0.8.10 » org » jfree » report » demo » invoice » [javadoc | source]