/*
* Copyright (C) 2015 Allsoft
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package br.com.allsoft.avros.interfaces;
import br.com.allsoft.avros.backup.RecuperaBackup;
import br.com.allsoft.avros.backup.SalvaBackup;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author Luana
*/
public class IfrmBackup extends javax.swing.JInternalFrame {
//Métodos
Runnable salvar = new SalvaBackup();
Runnable recupera = new RecuperaBackup();
/**
* Cria a ProgressBar
*/
/**
* Creates new form ifrmSenha
*/
public IfrmBackup() {
initComponents();
}
/**
* 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() {
jLabel1 = new javax.swing.JLabel();
jProgressBar1 = new javax.swing.JProgressBar();
jLabel2 = new javax.swing.JLabel();
btnBackup = new javax.swing.JButton();
lblLogo = new javax.swing.JLabel();
btnRecuperar = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
lblCarregando = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
setClosable(true);
setIconifiable(true);
setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/allsoft/avros/img/Keychain.png"))); // NOI18N
addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameClosed(evt);
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
formInternalFrameOpened(evt);
}
});
jLabel2.setFont(ClsEstilo.tituloFonte);
jLabel2.setForeground(ClsEstilo.tituloCor);
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Backup");
jLabel2.setFocusable(false);
btnBackup.setFont(ClsEstilo.botaoFonte);
btnBackup.setForeground(ClsEstilo.botaoCor);
btnBackup.setText("Fazer backup");
btnBackup.setFocusCycleRoot(true);
btnBackup.setNextFocusableComponent(btnRecuperar);
btnBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackupActionPerformed(evt);
}
});
btnBackup.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
btnBackupKeyPressed(evt);
}
});
lblLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/allsoft/avros/img/logopequeno.png"))); // NOI18N
lblLogo.setFocusable(false);
btnRecuperar.setFont(ClsEstilo.botaoFonte);
btnRecuperar.setForeground(ClsEstilo.botaoCor);
btnRecuperar.setText("Recuperar dados do backup");
btnRecuperar.setNextFocusableComponent(btnBackup);
btnRecuperar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRecuperarActionPerformed(evt);
}
});
btnRecuperar.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
btnRecuperarKeyPressed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Verdana", 0, 24)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0, 51, 51));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel3.setText("pretende fazer?");
jLabel3.setFocusable(false);
jLabel6.setFont(new java.awt.Font("Verdana", 0, 24)); // NOI18N
jLabel6.setForeground(new java.awt.Color(0, 51, 51));
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel6.setText("O que você");
jLabel6.setFocusable(false);
lblCarregando.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblCarregando.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/allsoft/avros/img/loading.gif"))); // NOI18N
lblCarregando.setText("Carregando");
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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(57, 57, 57)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(btnBackup)
.addComponent(btnRecuperar)
.addComponent(lblCarregando, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblCarregando, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnBackup)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnRecuperar)
.addGap(23, 23, 23))))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
Container a = this.getContentPane();
a.setBackground(ClsEstilo.formbg);
Dimension dim = this.getParent().getSize();
this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2 + 50);
lblCarregando.setVisible(false);
}//GEN-LAST:event_formInternalFrameOpened
private void btnBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackupActionPerformed
try {
new Thread(salvar).start();
} catch (Exception ex) {
Logger.getLogger(IfrmBackup.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(this, "ERRO: " + ex, "Erro", JOptionPane.ERROR_MESSAGE);
return;
}
}//GEN-LAST:event_btnBackupActionPerformed
private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
FrmPrincipal.bBackup = false;
}//GEN-LAST:event_formInternalFrameClosed
private void btnRecuperarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRecuperarActionPerformed
int j = JOptionPane.showConfirmDialog(this, "Tem certeza que deseja recuperar os dados do último backup? Ao fazer isso os dados atuais serão perdidos.", "Recuperar backup", JOptionPane.YES_NO_OPTION);
if (j == JOptionPane.YES_OPTION) {
try {
Thread backup = new Thread(recupera);
backup.start();
} catch (Exception ex) {
Logger.getLogger(IfrmBackup.class.getName()).log(Level.SEVERE, null, ex);
}
}
}//GEN-LAST:event_btnRecuperarActionPerformed
private void btnBackupKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnBackupKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
btnBackup.doClick();
}
}//GEN-LAST:event_btnBackupKeyPressed
private void btnRecuperarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnRecuperarKeyPressed
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
btnRecuperar.doClick();
}
}//GEN-LAST:event_btnRecuperarKeyPressed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnBackup;
private javax.swing.JButton btnRecuperar;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel6;
private javax.swing.JProgressBar jProgressBar1;
public static javax.swing.JLabel lblCarregando;
private javax.swing.JLabel lblLogo;
// End of variables declaration//GEN-END:variables
}