Coverage Report - wjhk.jupload2.gui.filepanel.DateRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
DateRenderer
44 %
4/9
0 %
0/2
1,5
 
 1  
 //
 2  
 // $Id: DateRenderer.java 95 2007-05-02 03:27:05Z
 3  
 // /C=DE/ST=Baden-Wuerttemberg/O=ISDN4Linux/OU=Fritz
 4  
 // Elfert/CN=svn-felfert@isdn4linux.de/emailAddress=fritz@fritz-elfert.de $
 5  
 //
 6  
 // jupload - A file upload applet.
 7  
 // Copyright 2007 The JUpload Team
 8  
 //
 9  
 // Created: ?
 10  
 // Creator: William JinHua Kwong
 11  
 // Last modified: $Date: 2015-03-10 20:59:42 +0100 (mar., 10 mars 2015) $
 12  
 //
 13  
 // This program is free software; you can redistribute it and/or modify it under
 14  
 // the terms of the GNU General Public License as published by the Free Software
 15  
 // Foundation; either version 2 of the License, or (at your option) any later
 16  
 // version. This program is distributed in the hope that it will be useful, but
 17  
 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 18  
 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 19  
 // details. You should have received a copy of the GNU General Public License
 20  
 // along with this program; if not, write to the Free Software Foundation, Inc.,
 21  
 // 675 Mass Ave, Cambridge, MA 02139, USA.
 22  
 
 23  
 package wjhk.jupload2.gui.filepanel;
 24  
 
 25  
 import java.awt.Component;
 26  
 import java.text.SimpleDateFormat;
 27  
 import java.util.Date;
 28  
 
 29  
 import javax.swing.JTable;
 30  
 import javax.swing.table.DefaultTableCellRenderer;
 31  
 
 32  
 import wjhk.jupload2.policies.UploadPolicy;
 33  
 
 34  
 /**
 35  
  * Technical class, used to display dates. Used in
 36  
  * {@link wjhk.jupload2.gui.filepanel.FilePanelJFlatTable}.
 37  
  */
 38  
 public class DateRenderer extends DefaultTableCellRenderer {
 39  
     /** A generated serialVersionUID, to avoid warning during compilation */
 40  
     private static final long serialVersionUID = -7171473761133675782L;
 41  
 
 42  
     private SimpleDateFormat df;
 43  
 
 44  
     /**
 45  
      * Creates a new instance.
 46  
      * 
 47  
      * @param uploadPolicy The policy to be used for providing the translated
 48  
      *            format string.
 49  
      */
 50  
     public DateRenderer(UploadPolicy uploadPolicy) {
 51  40
         super();
 52  40
         this.df = new SimpleDateFormat(uploadPolicy
 53  40
                 .getLocalizedString("dateformat"));
 54  40
     }
 55  
 
 56  
     /**
 57  
      * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
 58  
      *      java.lang.Object, boolean, boolean, int, int)
 59  
      */
 60  
     @Override
 61  
     public Component getTableCellRendererComponent(JTable table, Object value,
 62  
             boolean isSelected, boolean hasFocus, int row, int column) {
 63  0
         Component cell = super.getTableCellRendererComponent(table, value,
 64  
                 isSelected, hasFocus, row, column);
 65  
 
 66  0
         if (value instanceof Date)
 67  0
             setValue(this.df.format(value));
 68  0
         super.setHorizontalAlignment(RIGHT);
 69  0
         return cell;
 70  
     }
 71  
 }