package kz.cafe.admin;

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


public class TabRoleDelete extends AbstractTab{
   private static final long serialVersionUID = 6848484607125250160L;





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

   @Override
   public DBListPanel<MRole> 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);

		
		
      field = new CustomField();
      field.visible = true;
      field.name = "Название";
      field.db = "name";
      field.isEditable = true;
      field.style.width = 150;
      field.isMust = true;
      field.search.mode = CustomField.Search.SEARCH_MODES.LOCALIZED_STRING;
      dscr.addField(field);
      
      
      
      CustomFixedComboField ccf = new CustomFixedComboField();
      ccf.visible = true;
      ccf.name = "Экраны";
      ccf.db = "screenDelete";
      ccf.isEditable = true;
      ccf.search.mode = CustomField.Search.SEARCH_MODES.NONE;
      
      for(int ID : application.mapMenuID.keySet()){
         MenuElement menuElement = application.mapMenuID.get(ID);
         ccf.add(new CustomFixedComboField.Element(menuElement.ID, menuElement.name, null));
      }
      ccf.isMust = true;
      dscr.addField(ccf);      
      
      
      Set<Integer> setBlockedRecords = Collections.singleton(0);
      
      
      DBListPanel<MRole> panel = new DBListPanel<MRole>(application,
                                          MRole.class,
                                          dscr,
                                          Dimension.getFull(application),
                                          setMode,
                                          new Constraint(),
                                          setBlockedRecords);
      return panel;
   }



   

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

   
   
   
   
   
   
   
   
   
//   public static DBListPanel buildWrite(AdminMain application, ViewConstants.EditMode editMode){
//      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);
//
//      
//      
//      field = new CustomField();
//      field.visible = true;
//      field.name = "Название";
//      field.db = "name";
//      field.isEditable = true;
//      field.style.width = 150;
//      field.isMust = true;
//      field.search.mode = CustomField.Search.SEARCH_MODES.LOCALIZED_STRING;
//      dscr.addField(field);
//      
//      
//      
//      CustomComboField ccf = new CustomComboField();
//      ccf.visible = true;
//      ccf.name = "Экраны";
//      ccf.db = "screenWrite";
//      ccf.isEditable = true;
//      ccf.search.mode = CustomField.Search.SEARCH_MODES.NONE;
//      
//      for(int ID : application.mapMenuID.keySet()){
//         MenuElement menuElement = application.mapMenuID.get(ID);
//         ccf.add(new CustomComboField.Element(menuElement.ID, menuElement.name, null));
//      }
//      ccf.isMust = true;
//      dscr.addField(ccf);      
//      
//      
//      Set<Integer> setBlockedRecords = Collections.singleton(0);
//      
//      
//      DBListPanel panel = new DBListPanel(application,
//                                          MRole.class,
//                                          dscr,
//                                          Dimension.getFull(application),
//                                          setMode,
//                                          new Constraint(),
//                                          setBlockedRecords);
//      return panel;
//   }
}

