package kz.cafe.admin.panels.components;

import java.text.*;
import java.util.*;
import kz.cafe.admin.panels.model.*;
import com.vaadin.data.*;
import com.vaadin.ui.*;


public class ExtendedTable extends Table{
   private static final long serialVersionUID = -2040290287589688584L;
   

   
   private CustomDescriptor descriptor;
   
   
   public ExtendedTable(CustomDescriptor descriptor){
      this.descriptor = descriptor;
   }







   @Override
   protected String formatPropertyValue(Object rowId, Object colId, Property property){
      Object v = property.getValue();
      if(v instanceof Date){
         Date dateValue = (Date) v;
         CustomDateField cstDateField = (CustomDateField) descriptor.mapNames.get("" + colId);
         
         return new SimpleDateFormat(cstDateField.format).format(dateValue);
      }
      
      else if(property.getType() == Boolean.class){
         if(property.getValue() == null){
            return "";
         }
         else if((Boolean) property.getValue()){
            return "да";
         }
         else{
            return "";
         }
      }
      
      return super.formatPropertyValue(rowId, colId, property);
   }
};
