package kz.cafe.admin.panels.components;

import kz.cafe.admin.*;
import kz.cafe.admin.panels.*;
import com.vaadin.ui.*;


@SuppressWarnings({ "unchecked" })
public class RelationButton extends Button implements java.io.Serializable{
   private static final long serialVersionUID = 1593403290856686152L;

   
   private final AdminMain adminMain;
   private final int ID;
   private final AbstractTab abstractTab;
   private final String sName;
   
   
   @SuppressWarnings("unused")
   private String sValue = null;
   
   
   

   private Window window;


   public RelationButton(AdminMain adminMain, 
                         int ID,
                         AbstractTab abstractTab,
                         String sName){
      this.adminMain = adminMain;
      this.ID = ID;
      this.abstractTab = abstractTab; 
      this.sName = sName;

      this.addListener(new LClick());
   }






   protected void setInternalValue(Object newValue){
      setCaption("" + newValue);
      this.sValue = "" + newValue;
   }






   public Boolean getValue(){
      return false;
   }







   private class LClick implements Button.ClickListener{
      private static final long serialVersionUID = 202894149232905560L;



      public void buttonClick(ClickEvent event){
//         AbstractDBPanel panelDefault = new DBSingle(adminMain,
//                                                     classDB,
//                                                     ID,
//                                                     customDescriptor,
//                                                     Dimension.get05(adminMain),
//                                                     false
//                                                    );
         
         
         AbstractDBPanel<?> panelDefault = abstractTab.build(ID);
         
         
         window = new Window(sName);
         window.setContent(panelDefault);
         window.setSizeUndefined();
         window.setModal(true);
         window.center();
         adminMain.getMainWindow().addWindow(window);
      }
   }
}
