package kz.cafe.admin;

import java.util.*;
import kz.cafe.admin.constants.AccessConstants.EditMode;
import kz.cafe.admin.panels.*;
import kz.cafe.admin.panels.model.*;
import kz.cafe.db.model.*;

/**
 * Main application class.
 */
public class TabLog extends AbstractTab{
   private static final long serialVersionUID = -6573713082176493774L;




   public TabLog(AdminMain application, Set<EditMode> setMode){
      super(application, setMode);
   }
   
   
   

   @Override
   public DBListPanel<MLog> build(){
		CustomDescriptor dscr = new CustomDescriptor();
		
		
		
		CustomField field = new CustomField();
		field.visible = true;
		field.search.mode = CustomField.Search.SEARCH_MODES.INTEGER;
		field.name = "ID";
      field.db = "ID";
      field.isEditable = false;
      field.style.width = 50;
		field.isSortable = true;
		field.search.row = 0;
      dscr.addField(field);
      
      
      
      CustomDateField dateField = new CustomDateField();
      dateField.visible = true;
      dateField.name = "Дата";
      dateField.db = "created";
      dateField.isEditable = false;
      dateField.style.width = 120;
      dateField.isSortable = true;
      dateField.search.mode = CustomField.Search.SEARCH_MODES.DATE_RANGE; 
      dateField.search.row = 2;
      dscr.addField(dateField);
      

		
		
      field = new CustomField();
      field.visible = true;
      field.name = "Экран";
      field.db = "screen";
      field.isEditable = true;
      field.style.width = 100;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      dscr.addField(field);
      
      
      
      
      CustomRelationFieldFlexable crff = new CustomRelationFieldFlexable("Класс объекта", "Объект (ID)");
      crff.visible = false;
      crff.name = "Объект (ID)";
      crff.db = "OID";
      crff.isEditable = true;
      crff.style.width = 30;
      crff.isMust = true;
      crff.search.mode = CustomField.Search.SEARCH_MODES.INTEGER;
      crff.search.row = 1;
      dscr.addField(crff);
      
      
      
      
      crff = new CustomRelationFieldFlexable("Класс объекта", "Объект (ID)");
      crff.visible = false;
      crff.name = "Класс объекта";
      crff.db = "relatedClass";
      crff.isEditable = true;
      crff.style.width = 50;
      crff.isMust = true;
      crff.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      crff.search.row = 1;
      dscr.addField(crff);
      
      
      
      crff = new CustomRelationFieldFlexable("Класс объекта", "Объект (ID)");
      crff.visible = true;
      crff.name = "Объект";
      crff.db = "object";
      crff.isEditable = true;
      crff.style.width = 200;
      crff.isMust = true;
      crff.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      crff.search.row = 1;
      dscr.addField(crff);
      
      
      
      

      
      field = new CustomField();
      field.visible = true;
      field.name = "Поле";
      field.db = "name";
      field.isEditable = true;
      field.style.width = 100;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      dscr.addField(field);
      
      
      

      
      
      CustomFixedComboField ccf = new CustomFixedComboField();
      ccf.visible = true;
      ccf.name = "Изменил";
      ccf.db = "UID";
      ccf.isEditable = false;
      ccf.style.width = 120;
      ccf.isMust = true;
      //ccf.search.mode = CustomField.Search.SEARCH_MODES.NONE;
      ccf.search.row = 2;
      dscr.addField(ccf);
      
      
      
      
      
      
//      CustomRelationField crf = new CustomRelationField(MUser.class, "Пользователь (ID)");
//      crf.visible = false;
//      crf.name = "Пользователь (ID)";
//      crf.db = "UID";
//      crf.isEditable = true;
//      crf.style.width = 30;
//      crf.isMust = true;
//      crf.search.mode = CustomField.Search.SEARCH_MODES.INTEGER;
//      crf.search.row = 1;
//      dscr.addField(crf);
//      
//      
//      
//      
//      crf = new CustomRelationField(MUser.class, "Пользователь (ID)");
//      crf.visible = true;
//      crf.name = "Пользователь";
//      crf.db = "login";
//      crf.isEditable = true;
//      crf.style.width = 100;
//      crf.isMust = true;
//      crf.search.mode = CustomField.Search.SEARCH_MODES.STRING;
//      crf.search.row = 1;
//      dscr.addField(crf);
      
      

      
      
      
      field = new CustomField();
      field.visible = true;
      field.name = "Язык";
      field.db = "language";
      field.isEditable = true;
      field.style.width = 30;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      field.search.row = 1;
      dscr.addField(field);
      
      
      
      
      

      field = new CustomField();
      field.visible = true;
      field.name = "Старое значение";
      field.db = "old_value";
      field.isEditable = true;
      //field.style.width = 200;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      field.search.row = 1;
      dscr.addField(field);
      
      
      
      field = new CustomField();
      field.visible = true;
      field.name = "Новое Значение";
      field.db = "new_value";
      field.isEditable = true;
      //sfield.style.width = 200;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.STRING;
      field.search.row = 1;
      dscr.addField(field);
      
      
      
      
      
      DBListPanel<MLog> panel = new DBListPanel<MLog>(application,
                                          MLog.class,
                                          dscr,
                                          Dimension.getFull(application),
                                          setMode,
                                          new Order(Order.LESS, MAbstractDataElement.F_CREATED, "Дата"));
		return panel;
	}




   @Override
   public DBSingle build(int ID){
      // TODO Auto-generated method stub
      return null;
   }
}

