/*
* FormOpcoes.java
*
* Created on 27 de Setembro de 2008, 20:03
*/
package view;
import controller.operating.GerenciadorConfiguracoesDoSistemaXml;
import controller.operating.GerenciadorConfiguracoesDriverXml;
import controller.operating.GerenciadorDeConfiguracoesDoSistema;
import controller.operating.GerenciadorOperacional;
import controller.operating.Strings;
import dao.Dao;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import util.DriverConexao;
/**
*
* @author Consult
*/
public class FormOpcoes extends javax.swing.JInternalFrame {
private DriverConexao drive;
private DriverConexao driveAnterior;
private File file;
/** Creates new form FormOpcoes */
public FormOpcoes() {
initComponents();
GerenciadorConfiguracoesDriverXml configuracoes = new GerenciadorConfiguracoesDriverXml();
driveAnterior = configuracoes.getConfigureConnection();
jTextFieldDriver.setText(driveAnterior.getName());
jTextFieldServer.setText(driveAnterior.getServerName());
jTextFieldSchema.setText(driveAnterior.getDataBase());
jTextFieldUserName.setText(driveAnterior.getUserName());
jTextFieldPassword.setText(driveAnterior.getPassword());
if (GerenciadorDeConfiguracoesDoSistema.getFazerSplash()) {
jCheckBoxSplash.setSelected(true);
} else {
jCheckBoxSplash.setSelected(false);
}
if (GerenciadorDeConfiguracoesDoSistema.getUsarConexao()) {
jCheckBoxConexao.setSelected(true);
} else {
jCheckBoxConexao.setSelected(false);
}
if (GerenciadorDeConfiguracoesDoSistema.getUsarConfirmarSaida()) {
jCheckBoxConfirmaSaida.setSelected(true);
} else {
jCheckBoxConfirmaSaida.setSelected(false);
}
if (GerenciadorDeConfiguracoesDoSistema.isIniciarMaximizado()) {
jCheckBoxIniciarMaximizado.setSelected(true);
} else {
jCheckBoxIniciarMaximizado.setSelected(false);
}
if (GerenciadorDeConfiguracoesDoSistema.isIniciarProtecao()) {
jCheckBoxLogin.setSelected(true);
} else {
jCheckBoxLogin.setSelected(false);
}
if (GerenciadorDeConfiguracoesDoSistema.isMinimizarTray()) {
jCheckBoxTray.setSelected(true);
} else {
jCheckBoxTray.setSelected(false);
}
}
private void salvar() {
drive = new DriverConexao(
jTextFieldDriver.getText(),
jTextFieldServer.getText(),
jTextFieldSchema.getText(),
jTextFieldUserName.getText(),
new String(jTextFieldPassword.getPassword()));
GerenciadorConfiguracoesDriverXml newDriverConfig = new GerenciadorConfiguracoesDriverXml();
newDriverConfig.setConfigureConnection(drive);
GerenciadorConfiguracoesDoSistemaXml systemConfig = new GerenciadorConfiguracoesDoSistemaXml();
systemConfig.setConfiguracoes();
}
private void close() {
GerenciadorOperacional.removeFrame();
}
public void closeAsk() {
Object[] options = {"Sim", "Não"};
int option = 0;
option = JOptionPane.showOptionDialog(null, Strings.operacaoSucesso + "\n" + Strings.confirmaFechamento, Strings.tituloProcesso, JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
if (option == JOptionPane.YES_OPTION) {
this.close();
}
}
/** 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() {
jTabbedPane = new javax.swing.JTabbedPane();
jPanelGeral = new javax.swing.JPanel();
jCheckBoxSplash = new javax.swing.JCheckBox();
jCheckBoxConexao = new javax.swing.JCheckBox();
jCheckBoxConfirmaSaida = new javax.swing.JCheckBox();
jCheckBoxIniciarMaximizado = new javax.swing.JCheckBox();
jCheckBoxLogin = new javax.swing.JCheckBox();
jCheckBoxTray = new javax.swing.JCheckBox();
jPanelConexao = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextFieldDriver = new javax.swing.JFormattedTextField();
jTextFieldServer = new javax.swing.JFormattedTextField();
jTextFieldSchema = new javax.swing.JFormattedTextField();
jTextFieldUserName = new javax.swing.JFormattedTextField();
jTextFieldPassword = new javax.swing.JPasswordField();
jLabel8 = new javax.swing.JLabel();
jPanelEstrutura = new javax.swing.JPanel();
jButtonProcurarBackup = new javax.swing.JButton();
jButtonProcurarRestore = new javax.swing.JButton();
jTextFieldBackup = new javax.swing.JTextField();
jTextFieldRestore = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jButtonExecutaBackup = new javax.swing.JButton();
jButtonExecutaRestore = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jButtonSalvarGeral = new javax.swing.JButton();
jButtonCancelar1 = new javax.swing.JButton();
setClosable(true);
setIconifiable(true);
setResizable(true);
setTitle("Opções");
jTabbedPane.setBackground(java.awt.Color.white);
jPanelGeral.setBackground(java.awt.Color.white);
jPanelGeral.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções Gerais"));
jCheckBoxSplash.setBackground(java.awt.Color.white);
jCheckBoxSplash.setText("Iniciar com Splash");
jCheckBoxSplash.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxSplashActionPerformed(evt);
}
});
jCheckBoxConexao.setBackground(java.awt.Color.white);
jCheckBoxConexao.setText("Efetuar conexão com banco de dados (Modo Teste)");
jCheckBoxConexao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxConexaoActionPerformed(evt);
}
});
jCheckBoxConfirmaSaida.setBackground(java.awt.Color.white);
jCheckBoxConfirmaSaida.setText("Confirmar antes de fechar");
jCheckBoxConfirmaSaida.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxConfirmaSaidaActionPerformed(evt);
}
});
jCheckBoxIniciarMaximizado.setBackground(java.awt.Color.white);
jCheckBoxIniciarMaximizado.setText("Iniciar maximizado");
jCheckBoxIniciarMaximizado.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxIniciarMaximizadoActionPerformed(evt);
}
});
jCheckBoxLogin.setBackground(java.awt.Color.white);
jCheckBoxLogin.setText("Solicitar Login do usuário");
jCheckBoxLogin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxLoginActionPerformed(evt);
}
});
jCheckBoxTray.setBackground(java.awt.Color.white);
jCheckBoxTray.setText("Minimizar para o Tray");
jCheckBoxTray.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxTrayActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanelGeralLayout = new javax.swing.GroupLayout(jPanelGeral);
jPanelGeral.setLayout(jPanelGeralLayout);
jPanelGeralLayout.setHorizontalGroup(
jPanelGeralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelGeralLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelGeralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelGeralLayout.createSequentialGroup()
.addGroup(jPanelGeralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jCheckBoxSplash, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCheckBoxConfirmaSaida)
.addComponent(jCheckBoxIniciarMaximizado, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCheckBoxLogin)
.addComponent(jCheckBoxConexao, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(41, Short.MAX_VALUE))
.addGroup(jPanelGeralLayout.createSequentialGroup()
.addComponent(jCheckBoxTray, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(202, 202, 202))))
);
jPanelGeralLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jCheckBoxConfirmaSaida, jCheckBoxIniciarMaximizado, jCheckBoxSplash});
jPanelGeralLayout.setVerticalGroup(
jPanelGeralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelGeralLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jCheckBoxSplash)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBoxConexao)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBoxConfirmaSaida)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBoxIniciarMaximizado)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBoxLogin)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jCheckBoxTray)
.addGap(27, 27, 27))
);
jTabbedPane.addTab("Geral", jPanelGeral);
jPanelConexao.setBackground(java.awt.Color.white);
jPanelConexao.setBorder(javax.swing.BorderFactory.createTitledBorder("Configurações da Conexão"));
jLabel1.setText("Driver");
jLabel2.setText("Server Host");
jLabel3.setText("Schema");
jLabel4.setText("UserName");
jLabel5.setText("Password");
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel8.setText("Conexão com MySql");
javax.swing.GroupLayout jPanelConexaoLayout = new javax.swing.GroupLayout(jPanelConexao);
jPanelConexao.setLayout(jPanelConexaoLayout);
jPanelConexaoLayout.setHorizontalGroup(
jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelConexaoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelConexaoLayout.createSequentialGroup()
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextFieldSchema, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addComponent(jTextFieldServer, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addComponent(jTextFieldUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addComponent(jTextFieldDriver, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addComponent(jTextFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 243, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelConexaoLayout.createSequentialGroup()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(55, 55, 55))))
);
jPanelConexaoLayout.setVerticalGroup(
jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelConexaoLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldDriver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(7, 7, 7)
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelConexaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextFieldPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addComponent(jLabel8)
.addContainerGap())
);
jTabbedPane.addTab("Conexão", jPanelConexao);
jPanelEstrutura.setBackground(java.awt.Color.white);
jPanelEstrutura.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções de Estrutura"));
jButtonProcurarBackup.setText("Selecionar");
jButtonProcurarBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonProcurarBackupActionPerformed(evt);
}
});
jButtonProcurarRestore.setText("Selecionar");
jButtonProcurarRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonProcurarRestoreActionPerformed(evt);
}
});
jTextFieldBackup.setText("Selecionar pasta e nomear arquivo para backup");
jTextFieldRestore.setText("Importar arquivo SQL para restaurar a estrutura");
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel6.setText("Backup");
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel7.setText("Restore");
jButtonExecutaBackup.setText("Ok");
jButtonExecutaBackup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonExecutaBackupActionPerformed(evt);
}
});
jButtonExecutaRestore.setText("Ok");
jButtonExecutaRestore.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonExecutaRestoreActionPerformed(evt);
}
});
jLabel9.setText("Ações dependentes de configurações locais");
javax.swing.GroupLayout jPanelEstruturaLayout = new javax.swing.GroupLayout(jPanelEstrutura);
jPanelEstrutura.setLayout(jPanelEstruturaLayout);
jPanelEstruturaLayout.setHorizontalGroup(
jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jButtonProcurarRestore)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jButtonProcurarBackup)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(111, 111, 111))
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jLabel9)
.addContainerGap(116, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jTextFieldBackup, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonExecutaBackup)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jTextFieldRestore, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonExecutaRestore)
.addContainerGap())))
);
jPanelEstruturaLayout.setVerticalGroup(
jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jButtonProcurarBackup)
.addGap(5, 5, 5))
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonExecutaBackup)
.addComponent(jTextFieldBackup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17)
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelEstruturaLayout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jButtonProcurarRestore))
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelEstruturaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonExecutaRestore)
.addComponent(jTextFieldRestore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21, 21, 21))
);
jTabbedPane.addTab("Dados", jPanelEstrutura);
jButtonSalvarGeral.setText("Salvar");
jButtonSalvarGeral.setMaximumSize(new java.awt.Dimension(75, 23));
jButtonSalvarGeral.setMinimumSize(new java.awt.Dimension(75, 23));
jButtonSalvarGeral.setPreferredSize(new java.awt.Dimension(75, 23));
jButtonSalvarGeral.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSalvarGeralActionPerformed(evt);
}
});
jButtonCancelar1.setText("Cancelar");
jButtonCancelar1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCancelar1ActionPerformed(evt);
}
});
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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jButtonSalvarGeral, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonCancelar1))
.addComponent(jTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonCancelar1)
.addComponent(jButtonSalvarGeral, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-380)/2, (screenSize.height-320)/2, 380, 320);
}// </editor-fold>//GEN-END:initComponents
private void jButtonSalvarGeralActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarGeralActionPerformed
// TODO add your handling code here:
this.salvar();
this.close();
}//GEN-LAST:event_jButtonSalvarGeralActionPerformed
private void jButtonCancelar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelar1ActionPerformed
// TODO add your handling code here:
this.close();
}//GEN-LAST:event_jButtonCancelar1ActionPerformed
private void jCheckBoxSplashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxSplashActionPerformed
// TODO add your handling code here:
if (jCheckBoxSplash.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setFazerSplash(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setFazerSplash(false);
}
}//GEN-LAST:event_jCheckBoxSplashActionPerformed
private void jCheckBoxConexaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxConexaoActionPerformed
// TODO add your handling code here:
if (jCheckBoxConexao.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setUsarConexao(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setUsarConexao(false);
}
}//GEN-LAST:event_jCheckBoxConexaoActionPerformed
private void jCheckBoxConfirmaSaidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxConfirmaSaidaActionPerformed
// TODO add your handling code here:
if (jCheckBoxConfirmaSaida.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setUsarConfirmarSaida(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setUsarConfirmarSaida(false);
}
}//GEN-LAST:event_jCheckBoxConfirmaSaidaActionPerformed
private void jCheckBoxIniciarMaximizadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxIniciarMaximizadoActionPerformed
// TODO add your handling code here:
if (jCheckBoxIniciarMaximizado.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setIniciarMaximizado(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setIniciarMaximizado(false);
}
}//GEN-LAST:event_jCheckBoxIniciarMaximizadoActionPerformed
private void jButtonProcurarBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonProcurarBackupActionPerformed
// TODO add your handling code here:
JFileChooser arquivo = new JFileChooser();
arquivo.setDialogTitle("Abrir");
int res = arquivo.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
file = arquivo.getSelectedFile();
try {
jTextFieldBackup.setText(file.getAbsolutePath());
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Não foi possível abrir o arquivo" + file.getPath() + "!", Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_jButtonProcurarBackupActionPerformed
private void jButtonProcurarRestoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonProcurarRestoreActionPerformed
// TODO add your handling code here:
JFileChooser arquivo = new JFileChooser();
arquivo.setDialogTitle("Abrir");
int res = arquivo.showOpenDialog(null);
if (res == JFileChooser.APPROVE_OPTION) {
file = arquivo.getSelectedFile();
try {
jTextFieldRestore.setText(file.getAbsolutePath());
FileChannel srcChannel = new FileInputStream(file.getAbsolutePath()).getChannel();
FileChannel dstChannel = new FileOutputStream(file.getName()).getChannel();
// Copia o arquivo de um lado pro outro
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
// Fecha os canais
srcChannel.close();
dstChannel.close();
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Não foi possível abrir o arquivo" + file.getPath() + "!", Strings.tituloMessageErro, JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_jButtonProcurarRestoreActionPerformed
private void jButtonExecutaBackupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExecutaBackupActionPerformed
// TODO add your handling code here:
String user = driveAnterior.getUserName();
String schema = driveAnterior.getDataBase();
String password = driveAnterior.getPassword();
String arquivoLocal = file.getName();
try {
Runtime.getRuntime().exec("cmd /c mysqldump -u" + user + " -p" + password + " " + schema + " > " + arquivoLocal);
Thread.sleep(3000);
//exec("cmd /c mysqldump -uroot -proot modulorelacionamento > backupfile.sql");//[backupfile.sql] < [restorefile.sql]");
String arquivo = jTextFieldBackup.getText();
FileChannel srcChannel = new FileInputStream(arquivoLocal).getChannel();
FileChannel dstChannel = new FileOutputStream(arquivo).getChannel();
// Copia o arquivo de um lado pro outro
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
// Fecha os canais
srcChannel.close();
dstChannel.close();
} catch (InterruptedException ex) {
Logger.getLogger(FormOpcoes.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
//new File(arquivoLocal).delete();
jTextFieldBackup.setText("");
this.closeAsk();
}//GEN-LAST:event_jButtonExecutaBackupActionPerformed
private void jButtonExecutaRestoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExecutaRestoreActionPerformed
// TODO add your handling code here:
try {
Dao dao = new Dao();
String user = driveAnterior.getUserName();
String schema = driveAnterior.getDataBase();
String host = driveAnterior.getServerName();
String password = driveAnterior.getPassword();
String arquivoLocal = file.getName();
dao.getNewSchema(schema);
//System.out.println("cmd /c mysql -h" + host + " -u" + user + " -p" + password + " " + schema + " < " + arquivoLocal);
Runtime.getRuntime().exec("cmd /c mysql -h" + host + " -u" + user + " -p" + password + " " + schema + " < " + arquivoLocal);
//exec("cmd /c mysqldump -uroot -proot modulorelacionamento > backupfile.sql");//[backupfile.sql] < [restorefile.sql]");
//pra poder apagar o arquivo tem que fazer essa gambiarra
Thread.sleep(3000);
//new File(file.getName()).delete();
} catch (InterruptedException ex) {
Logger.getLogger(FormOpcoes.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
}
jTextFieldRestore.setText("");
this.closeAsk();
}//GEN-LAST:event_jButtonExecutaRestoreActionPerformed
private void jCheckBoxLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxLoginActionPerformed
// TODO add your handling code here:
if (jCheckBoxLogin.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setIniciarProtecao(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setIniciarProtecao(false);
}
}//GEN-LAST:event_jCheckBoxLoginActionPerformed
private void jCheckBoxTrayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxTrayActionPerformed
// TODO add your handling code here:
if (jCheckBoxTray.isSelected()) {
GerenciadorDeConfiguracoesDoSistema.setMinimizarTray(true);
} else {
GerenciadorDeConfiguracoesDoSistema.setMinimizarTray(false);
}
}//GEN-LAST:event_jCheckBoxTrayActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButtonCancelar1;
private javax.swing.JButton jButtonExecutaBackup;
private javax.swing.JButton jButtonExecutaRestore;
private javax.swing.JButton jButtonProcurarBackup;
private javax.swing.JButton jButtonProcurarRestore;
private javax.swing.JButton jButtonSalvarGeral;
private javax.swing.JCheckBox jCheckBoxConexao;
private javax.swing.JCheckBox jCheckBoxConfirmaSaida;
private javax.swing.JCheckBox jCheckBoxIniciarMaximizado;
private javax.swing.JCheckBox jCheckBoxLogin;
private javax.swing.JCheckBox jCheckBoxSplash;
private javax.swing.JCheckBox jCheckBoxTray;
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.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanelConexao;
private javax.swing.JPanel jPanelEstrutura;
private javax.swing.JPanel jPanelGeral;
private javax.swing.JTabbedPane jTabbedPane;
private javax.swing.JTextField jTextFieldBackup;
private javax.swing.JFormattedTextField jTextFieldDriver;
private javax.swing.JPasswordField jTextFieldPassword;
private javax.swing.JTextField jTextFieldRestore;
private javax.swing.JFormattedTextField jTextFieldSchema;
private javax.swing.JFormattedTextField jTextFieldServer;
private javax.swing.JFormattedTextField jTextFieldUserName;
// End of variables declaration//GEN-END:variables
}