pruebaimportarexcel.PantallaPrincipal.java Source code

Java tutorial

Introduction

Here is the source code for pruebaimportarexcel.PantallaPrincipal.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pruebaimportarexcel;

import java.awt.Color;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.apache.poi.ss.usermodel.Sheet;
import pruebaimportarexcel.database.DBScheme;
import pruebaimportarexcel.excel.Excel;
import pruebaimportarexcel.excel.ExcelUtils;
import pruebaimportarexcel.excel.Excels;
import pruebaimportarexcel.util.SwingUtil;

/**
 *
 * @author Emilio
 */
public class PantallaPrincipal extends javax.swing.JFrame {

    private Excel excelFile;
    private DBScheme baseDatos;
    private Path excelPath;
    private Color defaulColor;

    /**
     * Creates new form PantallaPrincipal
     */
    public PantallaPrincipal() {
        baseDatos = null;
        initComponents();
        setLocationRelativeTo(null);

        this.defaulColor = this.jToggleButton1.getBackground();
        this.activarDesactivarOpcionesBaseDatos();
        this.activarDesactivarOpcionesExcel();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel_Excel = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox<>();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel_DB = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jToggleButton1 = new javax.swing.JToggleButton();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox<>();
        jButton3 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox<>();
        jButton4 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel_ExcelToDB = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jButton8 = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList<>();
        jScrollPane4 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList<>();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jButton14 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Importar Excel");

        jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jTabbedPane1StateChanged(evt);
            }
        });

        jButton1.setText("Obtener Excel");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jTextField1.setText("Fichero Cargado");
        jTextField1.setDisabledTextColor(new java.awt.Color(102, 102, 102));
        jTextField1.setEnabled(false);

        jLabel3.setText("Paginas:");

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel<>());

        jButton5.setText("Seleccionar Pagina");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Cargar Paginas");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Contenido de la Pagina "));

        jTable1.setModel(new javax.swing.table.DefaultTableModel());
        jTable1.setEnabled(false);
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout
                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane1).addContainerGap()));
        jPanel1Layout
                .setVerticalGroup(
                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout
                                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane1,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                                        .addContainerGap()));

        javax.swing.GroupLayout jPanel_ExcelLayout = new javax.swing.GroupLayout(jPanel_Excel);
        jPanel_Excel.setLayout(jPanel_ExcelLayout);
        jPanel_ExcelLayout.setHorizontalGroup(jPanel_ExcelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_ExcelLayout.createSequentialGroup().addContainerGap().addGroup(jPanel_ExcelLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel_ExcelLayout.createSequentialGroup()
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 155,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18).addComponent(jTextField1))
                        .addGroup(jPanel_ExcelLayout.createSequentialGroup().addComponent(jLabel3)
                                .addGap(10, 10, 10).addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        629, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_ExcelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
                                .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE));
        jPanel_ExcelLayout.setVerticalGroup(jPanel_ExcelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_ExcelLayout.createSequentialGroup().addContainerGap().addGroup(jPanel_ExcelLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton1)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton6)).addGap(18, 18, 18)
                        .addGroup(jPanel_ExcelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel3).addComponent(jButton5))
                        .addGap(18, 18, 18).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("FICHERO EXCEL", jPanel_Excel);

        jButton2.setText("Configurar Base de Datos");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextField2.setText("Estado: Sin Configurar");
        jTextField2.setDisabledTextColor(new java.awt.Color(102, 102, 102));
        jTextField2.setEnabled(false);

        jToggleButton1.setText("Conectar");
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Esquemas:");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>());

        jButton3.setText("Seleccionar Esquema");
        jButton3.setToolTipText("");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel2.setText("Tablas:");

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>());

        jButton4.setText("Seleccionar Tabla");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Tabla Seleccionada"));

        jTable2.setModel(new javax.swing.table.DefaultTableModel());
        jTable2.setEnabled(false);
        jScrollPane2.setViewportView(jTable2);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout
                        .createSequentialGroup().addContainerGap().addComponent(jScrollPane2).addContainerGap()));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
                        .addContainerGap()));

        javax.swing.GroupLayout jPanel_DBLayout = new javax.swing.GroupLayout(jPanel_DB);
        jPanel_DB.setLayout(jPanel_DBLayout);
        jPanel_DBLayout.setHorizontalGroup(jPanel_DBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel_DBLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel_DBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel_DBLayout.createSequentialGroup()
                                        .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 209,
                                                Short.MAX_VALUE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 515,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(jToggleButton1,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 103,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                        jPanel_DBLayout.createSequentialGroup().addGroup(jPanel_DBLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                        jPanel_DBLayout.createSequentialGroup()
                                                                .addComponent(jLabel2).addGap(26, 26, 26)
                                                                .addComponent(jComboBox2, 0,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                .addGroup(jPanel_DBLayout.createSequentialGroup()
                                                        .addComponent(jLabel1).addGap(18, 18, 18).addComponent(
                                                                jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)))
                                                .addGap(18, 18, 18)
                                                .addGroup(jPanel_DBLayout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING, false)
                                                        .addComponent(
                                                                jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 152,
                                                                Short.MAX_VALUE)
                                                        .addComponent(jButton4,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE))))
                        .addContainerGap())
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE));
        jPanel_DBLayout.setVerticalGroup(jPanel_DBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_DBLayout.createSequentialGroup().addContainerGap().addGroup(jPanel_DBLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton2)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jToggleButton1)).addGap(18, 18, 18)
                        .addGroup(jPanel_DBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1)
                                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel_DBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2).addComponent(jButton4))
                        .addGap(18, 18, 18).addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));

        jTabbedPane1.addTab("BASE DE DATOS", jPanel_DB);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Excel"));

        jButton7.setText("Generar Fichero .SQL");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout
                .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 373, Short.MAX_VALUE)
                                .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel3Layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton7).addContainerGap()));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Base de Datos"));

        jButton8.setText("Generar Pantilla Excel");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout
                .setHorizontalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap()
                                .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
                                .addContainerGap()));
        jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel4Layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton8).addContainerGap()));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Excel >>> Base de Datos"));
        jPanel5.setToolTipText("");

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Informacion"));
        jPanel6.setToolTipText("");

        jLabel4.setText("Excel:");
        jLabel4.setEnabled(false);

        jLabel5.setText("Base de Datos:");
        jLabel5.setEnabled(false);

        jTextField3.setEnabled(false);

        jTextField4.setEnabled(false);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(jPanel6Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel4).addGap(18, 18, 18)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 752,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jLabel5).addGap(18, 18, 18)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 708,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jList1.setBorder(javax.swing.BorderFactory.createTitledBorder("Todas Las Paginas Del Excel Actual"));
        jList1.setModel(new DefaultListModel<String>());
        jScrollPane3.setViewportView(jList1);

        jList2.setBorder(
                javax.swing.BorderFactory.createTitledBorder("Orden y Paginas a Importar a Base de Datos"));
        jList2.setModel(new DefaultListModel<String>());
        jScrollPane4.setViewportView(jList2);

        jButton9.setText(">");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText(">>");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jButton12.setText("<");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton11.setText("<<");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton13.setText("Importar");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(jPanel5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addGroup(jPanel5Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton13, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel5Layout.createSequentialGroup()
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 350,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(
                                        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18).addComponent(jScrollPane4,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 350,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap()));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel5Layout.createSequentialGroup().addComponent(jButton9)
                                        .addGap(18, 18, 18).addComponent(jButton10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42,
                                                Short.MAX_VALUE)
                                        .addComponent(jButton11).addGap(18, 18, 18).addComponent(jButton12))
                                .addComponent(jScrollPane4).addComponent(jScrollPane3))
                        .addGap(18, 18, 18).addComponent(jButton13).addContainerGap()));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("BD >>> Excel"));

        jButton14.setText("Exportar BD");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(jPanel7Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap().addComponent(jButton14,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap()));
        jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                        jPanel7Layout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton14).addContainerGap()));

        javax.swing.GroupLayout jPanel_ExcelToDBLayout = new javax.swing.GroupLayout(jPanel_ExcelToDB);
        jPanel_ExcelToDB.setLayout(jPanel_ExcelToDBLayout);
        jPanel_ExcelToDBLayout.setHorizontalGroup(jPanel_ExcelToDBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_ExcelToDBLayout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel_ExcelToDBLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(jPanel_ExcelToDBLayout.createSequentialGroup()
                                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel_ExcelToDBLayout.setVerticalGroup(jPanel_ExcelToDBLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel_ExcelToDBLayout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel_ExcelToDBLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        jTabbedPane1.addTab("OPERACIONES", jPanel_ExcelToDB);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                layout.createSequentialGroup().addContainerGap().addComponent(jTabbedPane1).addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addContainerGap().addComponent(jTabbedPane1).addContainerGap()));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        //Creacion u configuracion del Selector de ficheros.
        JFileChooser fileChooser = new JFileChooser(
                System.getProperty("user.home") + System.getProperty("file.separator") + "pruebasExcel");
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EXCEL FILES", "xls", "xlsx");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.setFileFilter(filter);
        fileChooser.setDialogTitle("Selecciona un fichero excel.");
        fileChooser.setMultiSelectionEnabled(false);

        //Se abre el selector de ficheros y si se comprueba se se seleccione uno.
        if (JFileChooser.APPROVE_OPTION == fileChooser.showOpenDialog(this)) {
            //Borrado de la tabla.
            this.jTable1.setModel(SwingUtil.initTableModel(null, null));

            //Comporbacion de que el fichero seleccionado sea un Excel.
            this.excelPath = fileChooser.getSelectedFile().toPath();
            try {
                if (Excels.isFileExcel(excelPath)) {
                    this.jTextField1.setText(this.excelPath.toString());
                } else {
                    this.excelPath = null;
                    this.jTextField1.setText("Seleccione un fichero.");
                    JOptionPane.showMessageDialog(this, "El Fichero seleccionado no es un excel", "Informacion",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            } catch (IOException ex) {
                this.excelPath = null;
                this.jTextField1.setText("Seleccione un fichero.");
                JOptionPane.showMessageDialog(this, "El Fichero seleccionado no es un excel", "Informacion",
                        JOptionPane.INFORMATION_MESSAGE);
            } finally {
                this.activarDesactivarOpcionesExcel();
            }

        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        DialogConfigurarBaseDatos dialogConfigBD = new DialogConfigurarBaseDatos(this, true);
        dialogConfigBD.setVisible(true);
        this.baseDatos = dialogConfigBD.getBaseDatos();
        this.activarDesactivarOpcionesBaseDatos();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed
        String mensaje = this.jTextField2.getText();
        if (this.jToggleButton1.isSelected()) {
            try {
                this.conectarBD();
                mensaje = "Estado: Conectado - " + this.baseDatos.getURL();
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                this.jTextField2.setText(mensaje);
            }
        } else {
            try {
                this.desconectarBD();
                mensaje = "Estado: Desconectado - " + this.baseDatos.getURL();
            } catch (Exception ex) {
                Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                this.jTextField2.setText(mensaje);
                SwingUtil.initComboBoxModel(this.jComboBox1.getModel(), new ArrayList());
                SwingUtil.initComboBoxModel(this.jComboBox2.getModel(), new ArrayList());
            }
        }
    }//GEN-LAST:event_jToggleButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            this.baseDatos.useCatalog((String) this.jComboBox1.getSelectedItem());
            SwingUtil.initComboBoxModel(this.jComboBox2.getModel(), new LinkedList(this.baseDatos.getTableNames()));
            this.activarDesactivarOpcionesBaseDatos();
            this.jTextField2.setText("Estado: Conectado - " + this.baseDatos.getURL() + " - Esquema: "
                    + this.baseDatos.getCatalogName());

        } catch (SQLException ex) {
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        //Creacion del Objeto Excel y cargado de las diferentes pginas.
        try {
            this.excelFile = Excel.getInstance(excelPath);
            SwingUtil.initComboBoxModel(this.jComboBox3.getModel(), this.excelFile.getSheets());
            this.jList1.setModel(SwingUtil.initListModel(this.excelFile.getSheets()));
        } catch (IOException ex) {
            this.excelFile = null;
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            this.activarDesactivarOpcionesExcel();
        }
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        List<Object> columnsName;
        List<List<Object>> datas;

        Sheet sheet = this.excelFile.getSheet((String) this.jComboBox3.getSelectedItem());
        //Row row = this.excelFile.getRow(sheet, 0);

        try {
            columnsName = Excels.getColumnsName(excelFile, (String) this.jComboBox3.getSelectedItem());

            datas = Excels.getDatasSheet(excelFile, (String) this.jComboBox3.getSelectedItem(), columnsName.size());

            this.jTable1.setModel(SwingUtil.initTableModel(columnsName, datas));
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this,
                    "La pagina " + sheet.getSheetName() + ".\n No es apta para ser importada a una base de datos.",
                    "Informacion", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            Instant i1 = Instant.now();
            //            this.jTable2.setModel(DBScheme.resultSetToJTable(this.baseDatos.selectAllFrom((String) this.jComboBox2.getSelectedItem())));
            this.jTable2.setModel(this.baseDatos.dbTableToJTable((String) this.jComboBox2.getSelectedItem()));
            Instant i2 = Instant.now();
            System.out.println("Tiempo - " + java.time.Duration.between(i1, i2).getNano());
        } catch (SQLException ex) {
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        String path;
        try {
            JFileChooser fileChooser = SwingUtil.generateFileChooser("SQL", "sql");
            int i = fileChooser.showOpenDialog(this);
            if (i == JFileChooser.APPROVE_OPTION) {
                path = fileChooser.getSelectedFile().getAbsolutePath();
                Path sqlFile = Paths.get(path);
                Excels.excelToSQL(sqlFile, excelFile, null);
                JOptionPane.showConfirmDialog(this, "Archivo SQL guardado en: \n" + sqlFile, "Informacin",
                        JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (IOException ex) {
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showConfirmDialog(this, "Problemas al exportar al fichero.", "Error - IO",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
        } catch (NullPointerException ex) {
            JOptionPane.showConfirmDialog(this, "El Excel introducido no se puede pasar a SQL.",
                    "Error - Fichero Fuera de Formato", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        String path;
        try {
            JFileChooser fileChooser = SwingUtil.generateExcelFileChooser();
            int i = fileChooser.showOpenDialog(this);
            if (i == JFileChooser.APPROVE_OPTION) {
                path = fileChooser.getSelectedFile().getAbsolutePath();
                Path templateDB = Paths.get(path);
                ExcelUtils.saveDBtoExcelTemplate(this.baseDatos, path);
                JOptionPane.showConfirmDialog(this, "Plantilla guardada en: \n" + templateDB, "Informacin",
                        JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (SQLException ex) {
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showConfirmDialog(this, "Problemas al obtener la informacin de la Base de datos.",
                    "Error - BD", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
        } catch (IOException ex) {
            Logger.getLogger(PantallaPrincipal.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showConfirmDialog(this, "Problemas al guardar la plantilla.", "Error - IO",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
        if (this.jTabbedPane1.getSelectedIndex() == 2) {
            this.enabledComponentesGenerales((this.excelFile != null && this.baseDatos != null));
        }
    }//GEN-LAST:event_jTabbedPane1StateChanged

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        DefaultListModel<String> model1 = (DefaultListModel<String>) this.jList1.getModel();
        DefaultListModel<String> model2 = (DefaultListModel<String>) this.jList2.getModel();
        if (!this.jList1.isSelectionEmpty()) {
            model2.addElement(this.jList1.getSelectedValue());
            model1.remove(this.jList1.getSelectedIndex());
        }
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        DefaultListModel<String> model1 = (DefaultListModel<String>) this.jList1.getModel();
        DefaultListModel<String> model2 = (DefaultListModel<String>) this.jList2.getModel();
        if (!this.jList2.isSelectionEmpty()) {
            model1.addElement(this.jList2.getSelectedValue());
            model2.remove(this.jList2.getSelectedIndex());
        }
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        DefaultListModel<String> model1 = (DefaultListModel<String>) this.jList1.getModel();
        DefaultListModel<String> model2 = (DefaultListModel<String>) this.jList2.getModel();

        for (int i = 0; i < model1.size(); i++) {
            model2.addElement(model1.elementAt(i));
        }

        model1.clear();
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        DefaultListModel<String> model1 = (DefaultListModel<String>) this.jList1.getModel();
        DefaultListModel<String> model2 = (DefaultListModel<String>) this.jList2.getModel();

        for (int i = 0; i < model2.size(); i++) {
            model1.addElement(model2.elementAt(i));
        }

        model2.clear();
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        List<String> results = Excels.excelToDB(this.excelFile, this.baseDatos,
                SwingUtil.listModelToList(this.jList2.getModel()));
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        JFileChooser fileChooser = SwingUtil.generateExcelFileChooser();
        int i = fileChooser.showOpenDialog(this);
        if (i == JFileChooser.APPROVE_OPTION) {
            String path = fileChooser.getSelectedFile().getAbsolutePath();
            try {
                ExcelUtils.saveDBtoExcel(this.baseDatos, path);
            } catch (IOException | SQLException ex) {
                Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(this,
                        "Ha ocurrido un error al exportar la base de datos:\n" + ex.getMessage(), "ERROR",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_jButton14ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PantallaPrincipal().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JComboBox<String> jComboBox1;
    private javax.swing.JComboBox<String> jComboBox2;
    private javax.swing.JComboBox<String> jComboBox3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JList<String> jList1;
    private javax.swing.JList<String> jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel_DB;
    private javax.swing.JPanel jPanel_Excel;
    private javax.swing.JPanel jPanel_ExcelToDB;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables

    private void activarDesactivarOpcionesBaseDatos() {
        if (this.baseDatos == null) {
            //Cambiar el mensaje de estado de base de datos.
            this.jTextField2.setText("Estado: Sin Configurar.");
            this.jTextField4.setText("");
            //Desacctivar Opciones de Base de datos.
            SwingUtil.enabledComponnects(false, this.jToggleButton1);
            this.enabledComponentesBD(false);
        } else {
            this.jTextField2.setText("Estado: Configurado - " + this.baseDatos.getURL());
            this.jTextField4.setText("URL Conexion: " + this.baseDatos.getURL());
            SwingUtil.enabledComponnects(true, this.jToggleButton1);
            if (this.jToggleButton1.isSelected()) {
                this.enabledComponentesBD(true);
            } else {
                //Desacctivar Opciones de Base de datos.
                this.enabledComponentesBD(false);
                this.jTextField4.setText("");
            }
        }
    }

    private void activarDesactivarOpcionesExcel() {
        if (this.excelPath == null) {
            this.enabledComponentesExcel(false);
            this.jTextField3.setText("");
        } else {
            SwingUtil.enabledComponnects(true, this.jButton6);

            if (this.excelFile != null) {
                this.enabledComponentesExcel(true);
                this.jTextField3.setText("Nombre del fichero: " + this.excelPath);
            } else {
                SwingUtil.enabledComponnects(false, this.jButton5, this.jLabel3, this.jComboBox3);

                this.jTextField3.setText("");
            }
        }
    }

    private void enabledComponentesBD(boolean option) {
        SwingUtil.enabledComponnects(option, this.jLabel1, this.jLabel2, this.jComboBox1, this.jComboBox2,
                this.jButton3, this.jButton4, this.jButton8, this.jButton14);
    }

    private void enabledComponentesExcel(boolean option) {
        SwingUtil.enabledComponnects(option, this.jButton5, this.jButton6, this.jLabel3, this.jComboBox3,
                this.jButton7);
    }

    private void enabledComponentesGenerales(boolean option) {
        SwingUtil.enabledComponnects(option, this.jList1, this.jList2, this.jButton9, this.jButton10,
                this.jButton11, this.jButton12, this.jButton13);
    }

    private void conectarBD()
            throws ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
        this.baseDatos.openConnexion();
        this.jToggleButton1.setText("Desconectar");
        this.jToggleButton1.setBackground(Color.GREEN);
        SwingUtil.initComboBoxModel(this.jComboBox1.getModel(), this.baseDatos.getDataBaseSchemas());
        SwingUtil.enabledComponnects(true, this.jLabel1, this.jComboBox1, this.jButton3);
    }

    private void desconectarBD() throws Exception {
        this.baseDatos.close();
        this.jToggleButton1.setText("Conectar");
        this.jToggleButton1.setBackground(this.defaulColor);
        this.activarDesactivarOpcionesBaseDatos();
    }

}