/* 
* Copyright 2016 Agencia Estatal de Administración Tibutaria
*
* Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto
* sean aprobadas por la Comisión Europea– versiones
* posteriores de la EUPL (la «Licencia»);
* Solo podrá usarse esta obra si se respeta la Licencia.
* Puede obtenerse una copia de la Licencia en:
*  
* https://joinup.ec.europa.eu/software/page/eupl
*  
* Salvo cuando lo exija la legislación aplicable o se acuerde
* por escrito, el programa distribuido con arreglo a la
* Licencia se distribuye «TAL CUAL», SIN GARANTÍAS NI CONDICIONES
* DE NINGÚN TIPO, ni expresasni implícitas.
*
* Véase la Licencia en el idioma concreto que rige los permisos y 
* limitaciones que establece la Licencia.
*/ 

package gestor;

import gestor.utiles.*;
import javax.swing.*;

public final class DlgAsesores extends javax.swing.JDialog {

   boolean finalizar = false;
   public javax.swing.Timer timerCierraAviso;
   JFrame padre;

   public DlgAsesores(JFrame padre) {
      super(padre, true);
      this.padre = padre;
      initComponents();
      setLocationRelativeTo(null);
      this.setSize(600, 350);
      getRootPane().setDefaultButton(botonSi);
      preparaTimerAviso();
      timerCierraAviso.start();
      if (!Configuracion.instanciaUnica().cursorVisible) {
         setCursor(gestor.utiles.Global.mainForm.cursorTransparente);
      }
   }

   public void ajustar() {
      int anchoPadre = padre.getContentPane().getWidth();
      int altoPadre = padre.getContentPane().getWidth();
      int ancho = (int) (anchoPadre / 1.5);
      int alto = altoPadre / 3;
      setSize(ancho, alto);
      setLocationRelativeTo(padre);
   }

   public void ocultarBoton() {
      botonNo.setVisible(false);
      getRootPane().setDefaultButton(botonSi);
   }

   void cerrarCon(boolean valor) {
      // poner aviso sonoro...
      finalizar = valor;
      timerCierraAviso.stop();
      setVisible(false);
   }

   void preparaTimerAviso() {
      timerCierraAviso = new javax.swing.Timer(Configuracion.instanciaUnica().segundosCierreVentanas  * 1000, new java.awt.event.ActionListener() {

         public void actionPerformed(java.awt.event.ActionEvent evt) {
            cerrarCon(false);
         }
      });
   }

   /** 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.
    */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new MiPanel();
        botonSi = new gestor.utiles.MiBoton();
        botonNo = new gestor.utiles.MiBoton();
        jLabel1 = new gestor.utiles.SmoothLabel();
        jLabel2 = new gestor.utiles.SmoothLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setBackground(java.awt.Color.white);
        setUndecorated(true);
        jPanel1.setLayout(new java.awt.GridBagLayout());

        jPanel1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), javax.swing.BorderFactory.createMatteBorder(4, 4, 4, 4, new java.awt.Color(153, 153, 153))));
        botonSi.setFont(new java.awt.Font("Arial", 3, 28));
        botonSi.setForeground(new java.awt.Color(255, 0, 0));
        botonSi.setText(Global.trad.valor("Continuar"));
        botonSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSiActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.weighty = 100.0;
        gridBagConstraints.insets = new java.awt.Insets(18, 10, 18, 10);
        jPanel1.add(botonSi, gridBagConstraints);

        botonNo.setFont(new java.awt.Font("Arial", 3, 28));
        botonNo.setForeground(new java.awt.Color(255, 0, 0));
        botonNo.setText(Global.trad.valor("Salir"));
        botonNo.setFocusable(false);
        botonNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonNoActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.weighty = 100.0;
        gridBagConstraints.insets = new java.awt.Insets(18, 10, 18, 10);
        jPanel1.add(botonNo, gridBagConstraints);

        jLabel1.setFont(new java.awt.Font("Arial", 3, 26));
        jLabel1.setForeground(new java.awt.Color(51, 153, 255));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Opcion reservada para profesionales tributarios");
        jLabel1.setFocusable(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.weighty = 100.0;
        jPanel1.add(jLabel1, gridBagConstraints);

        jLabel2.setFont(new java.awt.Font("Arial", 3, 24));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("  sdfsfdsdfs");
        jLabel2.setFocusable(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.weightx = 100.0;
        gridBagConstraints.weighty = 100.0;
        jPanel1.add(jLabel2, gridBagConstraints);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void botonNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonNoActionPerformed
       cerrarCon(false);
    }//GEN-LAST:event_botonNoActionPerformed

    private void botonSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSiActionPerformed
       cerrarCon(true);
    }//GEN-LAST:event_botonSiActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonNo;
    private javax.swing.JButton botonSi;
    public javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
