package kz.cafe.admin.panel_extensions;


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

public class ExtraPanelImageViewer extends AbstractExtendedPanel implements java.io.Serializable{
   private static final long serialVersionUID = 711754256190346567L;

   private final Table table;
   private final CustomField field;
   private int height = 100;
   
   public ExtraPanelImageViewer(DBListPanel<?> panel, CustomField field){
      this.table = panel.table;
      this.field = field;
      this.height = field.style.height;
      
      AbstractLayout panelLayout = (AbstractLayout) getContent();
      panelLayout.setMargin(false);      
      
      this.setImmediate(true);
   }
   

   
   
   public ExtraPanelImageViewer(DBListPanel<?> panel, CustomField field, int height){
      this.table = panel.table;
      this.field = field;
      this.height = height;
      
      AbstractLayout panelLayout = (AbstractLayout) getContent();
      panelLayout.setMargin(false);      
      
      this.setImmediate(true);
   }
   
   

   


   @Override
   public void changeFocus(){
      this.removeAllComponents();
      
      
      try{
         this.addComponent(image2ClickableLabel(
                     "" + table.getItem(table.getValue()).getItemProperty(ExtraPanelImageViewer.this.field.name), height)
                  );
      }
      catch (Throwable e){
      }
   }
}
