/* Author: Amay Agrawal
 * Project: Bacteria Cloud
 * Mentor: Prof. Manish K Gupta
 */
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.Border;

public class Mainframe2 extends JFrame {

    //public  JFrame frame1;

 
    // Buttons
    static JLabel lblBackgroundImage = new JLabel();
    ImageIcon ii = new ImageIcon("logo/main.jpg");
    JLabel lbl = new JLabel();
    JLabel label12 = new JLabel();
    public static JPanel pnlButton = new JPanel();
    public static JButton aboutbutton;
    public static JButton importbutton;
    public static JButton encodebutton;
    public static JButton importencodebutton;
    public static JButton okbutton;
    public static JButton mcsbutton;
    public static JButton clonebutton;
    public static JButton declonebutton;
    public static JButton manualbutton;
    public static JButton feedbackbutton;
    public static JButton demobutton;
    public static JButton facebookbutton;
    public static JButton youtubebutton;
    static String[] choices = { "pBR322","pUC18", "pUC19","pUC57","pUC118","pUC119","pUAST","LITMUS28","LITMUS28i","LITMUS29","LITMUS38","LITMUS38i","LITMUS39","M13mp18","M13mp19","pACYC177","pACYC184","pAN7-1","pANT7_cGST","pANT7_nHA","pBC KS(-)","pBC KS(+)","pBC SK(-)","pBC SK(+)","pBluescript II KS(-)","pBluescript II KS(+)","pBluescript II SK(-)","pBluescript II SK(+)","pBluescript KS(-)","pBluescript KS(+)","pBluescript SK(-)","pBluescript SK(+)","pBS KS(-)","pBS KS(+)","pBS SK(-)","pBS SK(+)","pBS(-)","pBS(+)","pcDNA3.1(-)","pcDNA3.1(+)","pcDNA3","pDD","pDNR-Dual","pDNR-LIB","pEX1","pEX-1","pEX2","pEX3","pEX-A","pEX-C-GST","pEX-C-His","pEX-K","pEX-N-GST","pEX-N-His","pEX-N-His-GST","pEZ BAC","pEZSeq-Amp","pEZSeq-Kan","pF1A T7","pF1K T7","pF25A ICE T7","pF25K ICE T7","pFC7A (HQ)","pFC7K (HQ)","pFC20A HaloTag T7 SP6","pFC20K HaloTag T7 SP6","pFC30A His6HaloTag T7","pFC30K His6HaloTag T7","pFN2A (GST)","pFN2K (GST)","pFN6A (HQ)","pFN6K (HQ)","pFN18A HaloTag T7","pFN18K HaloTag T7","pFN19A HaloTag T7 SP6","pFN19K HaloTag T7 SP6","pFN29A His6HaloTag T7","pFN29K His6HaloTag T7","pGEM-3Z","pGEM-3Zf(-)","pGEM-3Zf(+)","pGEM-4Z","pGEM-5Zf(+)","pGEM-7Zf(-)","pGEM-7Zf(+)","pGEM-9Zf(-)","pGEM-11Zf(-)","pGEM-11Zf(+)","pGEM-T","pGS-21a","pH6HTC His6HaloTag T7","pH6HTN His6HaloTag T7","pHSG298","pHSG299","pHSG396","pHSG398","pHY300PLK","pInvRecA","pJAZZ-OC","pJAZZ-OK","pJET1.2","pJW168","pKF 18k-2","pKF 19k-2","pLEXX-AK","pMAL-c5E","pMAL-c5G","pMAL-c5X","pMAL-p5E","pMAL-p5G","pMAL-p5X","pMCS5","pMiniT","pNEB193","pOSIP-CH","pOSIP-CO","pOSIP-CT","pOSIP-KC","pOSIP-KH","pOSIP-KL","pOSIP-KO","pOSIP-KP","pOSIP-KT","pOSIP-TH","pOSIP-TO","pOSIP-TT","pPCR-Script Amp SK(+)","pPCR-Script Cam SK(+)","pRANGER-BTB-1","pRANGER-BTB-2","pRANGER-BTB-3","pRANGER-BTB-5","pRHA-67","pRHA-109","pRHA-113","pRSET A","pRSET B","pRSET C","pSB1C3","pSC101","pSEAP2-Basic","pSF-Core","pSMART BAC v2.0","pSMART HCAmp","pSMART HCKan","pSMART LCAmp","pSMART LCKan","pSP64 Poly(A)","pSP72","pSP73","pSpark Done (linearized)","pSpark I (linearized)","pSpark II (linearized)","pSpark III (linearized)","pSpark IV (linearized)","pSpark V (linearized)","pSTBlue-1","pSTV28","pSTV29","pT7Blue","pT7Blue-2","pT7Blue-3","pTrcHis A","pTrcHis B","pTrcHis C","pTrcHis2 A","pTrcHis2 B","pTrcHis2 C","pTV 118N","pTWV228","pTXB1","pTYB21","pTZ19R","pTZ19U","pTZ57R","pZErO-2"};
    static String[] choices1 = { "Unique Cutters","Unique 6+ Cutters", "Unique & Dual_Cutters","restriction_enzymes","6+ Cutters"};
    public static JPanel p;
    
    
    public Mainframe2() throws IOException {
    	JFrame frame1 = new JFrame("Bacteria Plasmid Storage System");
        frame1.setSize(800, 600);
        frame1.setLocationRelativeTo(null);
        frame1.setExtendedState(MAXIMIZED_BOTH);
        frame1.getContentPane().setBackground(Color.WHITE);
        frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //lblBackgroundImage.setIcon(new ImageIcon("C:\\Users\\HP\\workspace\\3DNA\\icons\\platonic.jpg"));
        //frame1.setLayout(new BorderLayout());
        
        BufferedImage bf = ImageIO.read(new File("logo/bacteria1234.png"));
        frame1.setContentPane(new backImage(bf));
        
        lbl.setIcon(new ImageIcon("logo/main.jpg"));
        lbl.setLocation(500,350);
        lbl.setSize(340, 192);
        //lable1.setIcon(new javax.swing.ImageIcon(getClass().getResource("logo/main.jpg"))); // NOI18
        lbl.setVisible(true);
        frame1.add(lbl);
        
        label12.setFont(new Font("Times new Roman",Font.PLAIN,30));
        label12.setForeground(Color.BLUE);
        label12.setText("<html><u>Bacteria Cloud : A Tool For Archival Data Storage</u></html>");
        label12.setLocation(340, 550);
        label12.setSize(700, 70);
        label12.setVisible(true);
        frame1.add(label12);
        
        JToolBar toolBar=new JToolBar("Quick Links");
        toolBar.setVisible(true);
        toolBar.setSize(1400, 65);
        toolBar.setBackground(Color.DARK_GRAY);
        frame1.add(toolBar,BorderLayout.EAST);
        pnlButton.setLayout(null);
        
        ImageIcon import1 = new ImageIcon("logo/import.png");
        ImageIcon about = new ImageIcon("logo/about.png");
        ImageIcon encode = new ImageIcon("logo/save.png");
        ImageIcon importencode = new ImageIcon("logo/importencode1.png");
        ImageIcon ok = new ImageIcon("logo/success.png");
        ImageIcon mcs = new ImageIcon("logo/mcs1.png");
        ImageIcon clone = new ImageIcon("logo/clone3.png");
        ImageIcon declone = new ImageIcon("logo/declone4.png");
        ImageIcon feedback = new ImageIcon("logo/feedback.png");
        ImageIcon demo = new ImageIcon("logo/demo.png");
        ImageIcon manual = new ImageIcon("logo/user-maunal.png");
        //ImageIcon facebook = new ImageIcon("logo/about.png");
        ImageIcon youtube = new ImageIcon("logo/youtube.png");
        
        
        importbutton = new JButton(import1);
        importbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        importbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        importbutton.setBackground(Color.DARK_GRAY);
        importbutton.setToolTipText("Import text file");
        //importbutton.setBorder(null);
        importbutton.setBorderPainted(false);
        importbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                importbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
                importbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        encodebutton = new JButton(encode);
        //encodebutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        //encodebutton.setHorizontalTextPosition(AbstractButton.CENTER);
        encodebutton.setBackground(Color.DARK_GRAY);
        encodebutton.setToolTipText("Encode Data");
        encodebutton.setBorderPainted(false);
        encodebutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	encodebutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	encodebutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        importencodebutton = new JButton(importencode);
        importencodebutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        importencodebutton.setHorizontalTextPosition(AbstractButton.CENTER);
        importencodebutton.setBackground(Color.DARK_GRAY);
        importencodebutton.setToolTipText("Import Encoded data");
        importencodebutton.setBorderPainted(false);
        importencodebutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	importencodebutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	importencodebutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        okbutton = new JButton(ok);
        okbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        okbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        okbutton.setBackground(Color.DARK_GRAY);
        okbutton.setToolTipText("OK");
        okbutton.setBorderPainted(false);
        okbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	okbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	okbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        mcsbutton = new JButton(mcs);
        mcsbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        mcsbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        mcsbutton.setBackground(Color.DARK_GRAY);
        mcsbutton.setToolTipText("MCS & Restriction Enzyme");
        mcsbutton.setBorderPainted(false);
        mcsbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	mcsbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	mcsbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        clonebutton = new JButton(clone);
        clonebutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        clonebutton.setHorizontalTextPosition(AbstractButton.CENTER);
        clonebutton.setBackground(Color.DARK_GRAY);
        clonebutton.setToolTipText("Clone data");
        clonebutton.setBorderPainted(false);
        clonebutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	clonebutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	clonebutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        declonebutton = new JButton(declone);
        declonebutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        declonebutton.setHorizontalTextPosition(AbstractButton.CENTER);
        declonebutton.setBackground(Color.DARK_GRAY);
        declonebutton.setToolTipText("Delone data");
        declonebutton.setBorderPainted(false);
        declonebutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	declonebutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	declonebutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        aboutbutton = new JButton(about);
        aboutbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        aboutbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        aboutbutton.setBackground(Color.DARK_GRAY);
        aboutbutton.setToolTipText("About Bacteria_Cloud");
        aboutbutton.setBorderPainted(false);
        aboutbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	aboutbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	aboutbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        manualbutton = new JButton(manual);
        manualbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        manualbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        manualbutton.setBackground(Color.DARK_GRAY);
        manualbutton.setToolTipText("Bacteria Cloud User Manual");
        manualbutton.setBorderPainted(false);
        manualbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	manualbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	manualbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        feedbackbutton = new JButton(feedback);
        feedbackbutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        feedbackbutton.setHorizontalTextPosition(AbstractButton.CENTER);
        feedbackbutton.setBackground(Color.DARK_GRAY);
        feedbackbutton.setToolTipText("Bacteria Cloud Feedback Form");
        feedbackbutton.setBorderPainted(false);
        feedbackbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	feedbackbutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	feedbackbutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        demobutton = new JButton(demo);
        demobutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        demobutton.setHorizontalTextPosition(AbstractButton.CENTER);
        demobutton.setBackground(Color.DARK_GRAY);
        demobutton.setToolTipText("Bacteria Cloud Demo");
        demobutton.setBorderPainted(false);
        demobutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	demobutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	demobutton.setBackground(Color.DARK_GRAY);
            }
        });
        
        youtubebutton = new JButton(youtube);
        youtubebutton.setVerticalTextPosition(AbstractButton.BOTTOM);
        youtubebutton.setHorizontalTextPosition(AbstractButton.CENTER);
        youtubebutton.setBackground(Color.DARK_GRAY);
        youtubebutton.setBorderPainted(false);
        youtubebutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
            	youtubebutton.setBackground(Color.GREEN);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
            	youtubebutton.setBackground(Color.DARK_GRAY);
            }
        });
        //importbutton.setToolTipText("Import text file");
       
        JComboBox<String> cb = new JComboBox<String>(choices);
        JComboBox<String> cb1 = new JComboBox<String>(choices1);
        
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(importbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(encodebutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(importencodebutton);
        toolBar.addSeparator();
        //toolBar.addSeparator();
        JLabel label = new JLabel("Select Plasmid");
        label.setFont(new Font("Dialog", Font.PLAIN, 14));
        label.setForeground(Color.white);
        toolBar.add(label);
        toolBar.addSeparator();
        //Dimension d = cb.getPreferredSize();
        cb.setMaximumSize(new Dimension( 100, 20 ));
        cb.setMinimumSize(new Dimension( 50, 20 ));
        cb.setPreferredSize(new Dimension( 50, 20 ));
        toolBar.add(cb);
        toolBar.addSeparator();
        JLabel label1 = new JLabel("Select Restriction Enzyme");
        label1.setFont(new Font("Dialog", Font.PLAIN, 14));
        label1.setForeground(Color.WHITE);   
        toolBar.add(label1);
        toolBar.addSeparator();
        cb1.setMaximumSize(new Dimension( 130, 20 ));
        toolBar.add(cb1);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(okbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(mcsbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(clonebutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(declonebutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(aboutbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(manualbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(feedbackbutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(demobutton);
        toolBar.add(Box.createHorizontalStrut(15));
        toolBar.add(youtubebutton);
        
        //frame1.add(p);
        frame1.setVisible(true);
        importbutton.addActionListener(new ImportActionListener());
        ImportActionListener i = new ImportActionListener(frame1,importencodebutton,pnlButton,lbl,label12);
        encodebutton.addActionListener(new EncodeActionListener());
        EncodeActionListener e = new EncodeActionListener(frame1,pnlButton);
        okbutton.addActionListener(new OkActionListener(cb,cb1));
        OkActionListener o = new OkActionListener(frame1,pnlButton);
        mcsbutton.addActionListener(new McsActionListener());
    	clonebutton.addActionListener(new CloneActionListener());
    	CloneActionListener c = new CloneActionListener(frame1,pnlButton);
    	declonebutton.addActionListener(new DecloneActionListener());
        DecloneActionListener d = new DecloneActionListener(frame1,pnlButton);
        importencodebutton.addActionListener(new DecodeActionListener(importbutton,encodebutton,declonebutton,frame1,pnlButton,lbl,label12));
        aboutbutton.addActionListener(new AboutActionListener());
        feedbackbutton.addActionListener(new ProductFeedbackActionListener());
    	manualbutton.addActionListener(new UserManualActionListener());
    	youtubebutton.addActionListener(new YoutubeActionListener());
    	demobutton.addActionListener(new ProductDemoActionListener());
      }
    public static void main(String[] args) throws IOException {
        new Mainframe2();
    }
}