diff --git a/.gitignore b/.gitignore index e6a9875..c870d49 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,16 @@ bin/ /dist/ /nbdist/ /.nb-gradle/ + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar diff --git a/MANIFEST.MF b/MANIFEST.MF deleted file mode 100644 index 146db33..0000000 --- a/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Implementation-Title: Sistema_Banco_TADS_UFPR -Implementation-Version: 1.0 -Implementation-Vendor: br.ufpr -Main-Class: main.br.ufpr.controllers.Sistema -Class-Path: assets/ diff --git a/README.md b/README.md index e35f241..5d01206 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ Trabalho prático final de Linguagem de Programação Orientada a Objetos do cur - [Alunos](#alunos) - [Sistema](#sistema) - [Documentação](#documentação) - - [Javadoc](#javadoc) - - [Diagrama de classes](#diagrama-de-classes) ## Alunos - Alisson Gabriel Santos [@Alisson](https://github.com/AlissonGabrielSantos) @@ -30,14 +28,11 @@ Desenvolvimento do sistema bancário do **`Banco TADS-UFPR`** [Download latest release](https://github.com/Salgado2004/Trabalho-Final-LPOO-UFPR/releases/latest) - - ## Documentação -### Javadoc -Veja [Documentação Javadoc](https://salgado2004.github.io/Trabalho-Final-LPOO-UFPR/) +[Confira a documentação na nossa Wiki!](https://github.com/Salgado2004/Trabalho-Final-LPOO-UFPR/wiki) -### Diagrama de classes -![image](src/assets/diagrama.png) + +### © Tads UFPR 2024 diff --git a/docs/main/br/ufpr/controllers/Imagens.html b/docs/main/br/ufpr/controllers/Imagens.html index 2a11480..458fd71 100644 --- a/docs/main/br/ufpr/controllers/Imagens.html +++ b/docs/main/br/ufpr/controllers/Imagens.html @@ -63,7 +63,7 @@

Enum Class Imagens

java.lang.Object
java.lang.Enum<Imagens> -
main.br.ufpr.controllers.Imagens
+
br.ufpr.controllers.Imagens
diff --git a/docs/main/br/ufpr/controllers/Mensagens.html b/docs/main/br/ufpr/controllers/Mensagens.html index 54c81dd..d979c81 100644 --- a/docs/main/br/ufpr/controllers/Mensagens.html +++ b/docs/main/br/ufpr/controllers/Mensagens.html @@ -62,7 +62,7 @@

Class Mensagens

java.lang.Object -
main.br.ufpr.controllers.Mensagens
+
br.ufpr.controllers.Mensagens

diff --git a/docs/main/br/ufpr/controllers/Sistema.html b/docs/main/br/ufpr/controllers/Sistema.html index 2fa0a16..05d9ee6 100644 --- a/docs/main/br/ufpr/controllers/Sistema.html +++ b/docs/main/br/ufpr/controllers/Sistema.html @@ -62,7 +62,7 @@

Class Sistema

java.lang.Object -
main.br.ufpr.controllers.Sistema
+
br.ufpr.controllers.Sistema

diff --git a/docs/main/br/ufpr/models/Cliente.html b/docs/main/br/ufpr/models/Cliente.html index 5ed60dc..bcac3e0 100644 --- a/docs/main/br/ufpr/models/Cliente.html +++ b/docs/main/br/ufpr/models/Cliente.html @@ -62,7 +62,7 @@

Class Cliente

java.lang.Object -
main.br.ufpr.models.Cliente
+
br.ufpr.models.Cliente

diff --git a/docs/main/br/ufpr/models/Conta.html b/docs/main/br/ufpr/models/Conta.html index 3795589..cc13dbe 100644 --- a/docs/main/br/ufpr/models/Conta.html +++ b/docs/main/br/ufpr/models/Conta.html @@ -62,7 +62,7 @@

Class Conta

java.lang.Object -
main.br.ufpr.models.Conta
+
br.ufpr.models.Conta
diff --git a/docs/main/br/ufpr/models/ContaCorrente.html b/docs/main/br/ufpr/models/ContaCorrente.html index 21e70b3..e705fcb 100644 --- a/docs/main/br/ufpr/models/ContaCorrente.html +++ b/docs/main/br/ufpr/models/ContaCorrente.html @@ -62,8 +62,8 @@

Class ContaCorrente

java.lang.Object -
main.br.ufpr.models.Conta -
main.br.ufpr.models.ContaCorrente
+
br.ufpr.models.Conta +
br.ufpr.models.ContaCorrente
diff --git a/docs/main/br/ufpr/models/ContaInvestimento.html b/docs/main/br/ufpr/models/ContaInvestimento.html index 644371c..4b23cfa 100644 --- a/docs/main/br/ufpr/models/ContaInvestimento.html +++ b/docs/main/br/ufpr/models/ContaInvestimento.html @@ -62,8 +62,8 @@

Class ContaInvestimento

java.lang.Object -
main.br.ufpr.models.Conta -
main.br.ufpr.models.ContaInvestimento
+
br.ufpr.models.Conta +
br.ufpr.models.ContaInvestimento
diff --git a/docs/main/br/ufpr/models/Endereco.html b/docs/main/br/ufpr/models/Endereco.html index cb5f0dd..1d6fa81 100644 --- a/docs/main/br/ufpr/models/Endereco.html +++ b/docs/main/br/ufpr/models/Endereco.html @@ -62,7 +62,7 @@

Class Endereco

java.lang.Object -
main.br.ufpr.models.Endereco
+
br.ufpr.models.Endereco

diff --git a/docs/main/br/ufpr/models/comparables/NomeComparator.html b/docs/main/br/ufpr/models/comparables/NomeComparator.html index ad83111..3cec26e 100644 --- a/docs/main/br/ufpr/models/comparables/NomeComparator.html +++ b/docs/main/br/ufpr/models/comparables/NomeComparator.html @@ -62,7 +62,7 @@

Class NomeComparator

java.lang.Object -
main.br.ufpr.models.comparables.NomeComparator
+
br.ufpr.models.comparables.NomeComparator
diff --git a/docs/main/br/ufpr/models/comparables/SobrenomeComparator.html b/docs/main/br/ufpr/models/comparables/SobrenomeComparator.html index 3f57b50..6dde3e5 100644 --- a/docs/main/br/ufpr/models/comparables/SobrenomeComparator.html +++ b/docs/main/br/ufpr/models/comparables/SobrenomeComparator.html @@ -62,7 +62,7 @@

Class SobrenomeComparator

java.lang.Object -
main.br.ufpr.models.comparables.SobrenomeComparator
+
br.ufpr.models.comparables.SobrenomeComparator
diff --git a/docs/main/br/ufpr/services/FactoryConta.html b/docs/main/br/ufpr/services/FactoryConta.html index f83e3c6..b27ddf6 100644 --- a/docs/main/br/ufpr/services/FactoryConta.html +++ b/docs/main/br/ufpr/services/FactoryConta.html @@ -62,7 +62,7 @@

Class FactoryConta

java.lang.Object -
main.br.ufpr.services.FactoryConta
+
br.ufpr.services.FactoryConta

diff --git a/docs/main/br/ufpr/views/Home.html b/docs/main/br/ufpr/views/Home.html index 00912a7..4e43b97 100644 --- a/docs/main/br/ufpr/views/Home.html +++ b/docs/main/br/ufpr/views/Home.html @@ -62,7 +62,7 @@

Class Home

java.lang.Object -
main.br.ufpr.views.Home
+
br.ufpr.views.Home
diff --git a/docs/main/br/ufpr/views/ManipularConta.html b/docs/main/br/ufpr/views/ManipularConta.html index 062e910..a4125ba 100644 --- a/docs/main/br/ufpr/views/ManipularConta.html +++ b/docs/main/br/ufpr/views/ManipularConta.html @@ -62,7 +62,7 @@

Class ManipularConta

java.lang.Object -
main.br.ufpr.views.ManipularConta
+
br.ufpr.views.ManipularConta
diff --git a/docs/main/br/ufpr/views/ManterCliente.html b/docs/main/br/ufpr/views/ManterCliente.html index 0dfbda4..777143c 100644 --- a/docs/main/br/ufpr/views/ManterCliente.html +++ b/docs/main/br/ufpr/views/ManterCliente.html @@ -62,7 +62,7 @@

Class ManterCliente

java.lang.Object -
main.br.ufpr.views.ManterCliente
+
br.ufpr.views.ManterCliente
diff --git a/docs/main/br/ufpr/views/ManterClienteTableModel.html b/docs/main/br/ufpr/views/ManterClienteTableModel.html index 703544f..e692e88 100644 --- a/docs/main/br/ufpr/views/ManterClienteTableModel.html +++ b/docs/main/br/ufpr/views/ManterClienteTableModel.html @@ -63,7 +63,7 @@

Class ManterClienteTable
java.lang.Object
javax.swing.table.AbstractTableModel -
main.br.ufpr.views.ManterClienteTableModel
+
br.ufpr.views.ManterClienteTableModel
diff --git a/docs/main/br/ufpr/views/VincularCliente.html b/docs/main/br/ufpr/views/VincularCliente.html index 7fc011d..06a0fe6 100644 --- a/docs/main/br/ufpr/views/VincularCliente.html +++ b/docs/main/br/ufpr/views/VincularCliente.html @@ -62,7 +62,7 @@

Class VincularCliente

java.lang.Object -
main.br.ufpr.views.VincularCliente
+
br.ufpr.views.VincularCliente
diff --git a/docs/main/br/ufpr/views/VincularTableModel.html b/docs/main/br/ufpr/views/VincularTableModel.html index f77535e..8c257f9 100644 --- a/docs/main/br/ufpr/views/VincularTableModel.html +++ b/docs/main/br/ufpr/views/VincularTableModel.html @@ -63,7 +63,7 @@

Class VincularTableModel

java.lang.Object
javax.swing.table.AbstractTableModel -
main.br.ufpr.views.VincularTableModel
+
br.ufpr.views.VincularTableModel
diff --git a/docs/serialized-form.html b/docs/serialized-form.html index 2e39309..48ea40f 100644 --- a/docs/serialized-form.html +++ b/docs/serialized-form.html @@ -45,7 +45,7 @@

Package 
  • -

    Class main.br.ufpr.views.ManterClienteTableModel

    +

    Class br.ufpr.views.ManterClienteTableModel

    class ManterClienteTableModel extends AbstractTableModel implements Serializable
    • @@ -68,7 +68,7 @@
      columns
    • -

      Class main.br.ufpr.views.VincularTableModel

      +

      Class br.ufpr.views.VincularTableModel

      class VincularTableModel extends AbstractTableModel implements Serializable
      • diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b51a6fd --- /dev/null +++ b/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + br.ufpr.lpoo + banco-tads + 1.1.0 + + + 17 + 17 + 233.14475.28 + UTF-8 + + + + + jetbrains.releases + https://www.jetbrains.com/intellij-repository/releases + + + jetbrains.3rdparty + https://cache-redirector.jetbrains.com/intellij-dependencies + + + + + + junit + junit + 4.12 + test + + + com.jetbrains.intellij.java + java-gui-forms-rt + ${intellij.version} + + + + + + + + src/main/resources + + **/* + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + br.ufpr.lpoo.controllers.Sistema + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + jar-with-dependencies + + + + true + br.ufpr.lpoo.controllers.Sistema + + + false + + + + make-assembly + package + + single + + + + + + + \ No newline at end of file diff --git a/src/assets/diagrama.png b/src/assets/diagrama.png deleted file mode 100644 index 2c87e25..0000000 Binary files a/src/assets/diagrama.png and /dev/null differ diff --git a/src/main/br/ufpr/views/Home.java b/src/main/br/ufpr/views/Home.java deleted file mode 100644 index 8e8183e..0000000 --- a/src/main/br/ufpr/views/Home.java +++ /dev/null @@ -1,81 +0,0 @@ -package main.br.ufpr.views; - -import main.br.ufpr.controllers.Imagens; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.Tela; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - * Esta classe representa a tela inicial do sistema. - * Ela implementa a interface Tela e define os botões e ações da tela inicial. - */ -public class Home implements Tela { - private JPanel frame; - private JButton clientesButton; - private JButton contasButton; - private JButton transactionsButton; - private JLabel logo; - - /** - * Construtor para a classe Home. - * Define os valores iniciais para as variáveis de instância e adiciona os ouvintes de ação aos botões. - */ - public Home() { - logo.setIcon(Imagens.LOGO.icon(300, 300)); - contasButton.setIcon(Imagens.CONTAS.icon()); - clientesButton.setIcon(Imagens.CLIENTES.icon()); - transactionsButton.setIcon(Imagens.TRANSACTIONS.icon()); - - clientesButton.addActionListener(new ActionListener() { - /** - * Este método é chamado quando o botão Clientes é clicado. - * Ele navega para a tela ManterCliente. - * - * @param e O evento de ação. - */ - @Override - public void actionPerformed(ActionEvent e) { - ManterCliente frame = new ManterCliente(); - Sistema.navigate(frame); - } - }); - contasButton.addActionListener(new ActionListener() { - /** - * Este método é chamado quando o botão Contas é clicado. - * Ele navega para a tela VincularCliente. - * - * @param e O evento de ação. - */ - @Override - public void actionPerformed(ActionEvent e) { - VincularCliente frame = new VincularCliente(); - Sistema.navigate(frame); - } - }); - transactionsButton.addActionListener(new ActionListener() { - /** - * Este método é chamado quando o botão Transações é clicado. - * Ele navega para a tela ManipularConta. - * - * @param e O evento de ação. - */ - @Override - public void actionPerformed(ActionEvent e) { - ManipularConta frame = new ManipularConta(); - Sistema.navigate(frame); - } - }); - } - - /** - * Este método retorna o frame da tela. - * - * @return O frame da tela. - */ - public JPanel getFrame() { - return frame; - } -} \ No newline at end of file diff --git a/src/main/br/ufpr/views/ManipularConta.java b/src/main/br/ufpr/views/ManipularConta.java deleted file mode 100644 index 004c3b1..0000000 --- a/src/main/br/ufpr/views/ManipularConta.java +++ /dev/null @@ -1,193 +0,0 @@ -package main.br.ufpr.views; - -import main.br.ufpr.controllers.Imagens; -import main.br.ufpr.controllers.Mensagens; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.Cliente; -import main.br.ufpr.models.Conta; -import main.br.ufpr.models.ContaCorrente; -import main.br.ufpr.models.Tela; -import main.br.ufpr.services.Observer; - -import javax.swing.*; -import java.awt.event.*; -import java.beans.PropertyChangeEvent; - -/** - * Classe que representa a tela de manipulação de conta - * Realiza transações como saque, depósito e investimento - * @see Tela - */ -public class ManipularConta implements Tela, Observer { - private Conta conta; - private JPanel frame; - private JButton voltarButton; - private JTextField cpfCliente; - private JPanel dadosConta; - private JButton buscarButton; - private JPanel boxSaldo; - private JLabel saldo; - private JCheckBox mostrarSaldo; - private JTabbedPane tabbedPane1; - private JPanel sacar; - private JPanel depositar; - private JPanel investir; - private JTextField valorSaque; - private JButton saqueButton; - private JTextField valorDeposito; - private JButton depositoButton; - private JButton investirButton; - private JLabel tipoConta; - private JLabel rendimento; - private JLabel numeroConta; - private JLabel warningLimite; - - /** - * Construtor da classe ManipularConta - * Adiciona os ícones aos botões e painéis - * Adiciona os listeners aos botões - */ - public ManipularConta() { - buscarButton.setIcon(Imagens.SEARCH.icon()); - mostrarSaldo.setIcon(Imagens.EYE_OPEN.icon()); - mostrarSaldo.setSelectedIcon(Imagens.EYE_CLOSED.icon()); - tabbedPane1.setIconAt(0, Imagens.SAQUE.icon()); - tabbedPane1.setIconAt(1, Imagens.DEPOSITO.icon()); - tabbedPane1.setIconAt(2, Imagens.REMUNERA.icon()); - investirButton.setIcon(Imagens.INVESTIMENTO.icon()); - - voltarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Sistema.goBack(); - } - }); - mostrarSaldo.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - saldo.setVisible(mostrarSaldo.isSelected()); - } - }); - buscarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if(!cpfCliente.getText().isEmpty()) { - String cpf = cpfCliente.getText(); - conta = pesquisaContaPorCliente(cpf); - if(conta != null) { - loadConta(); - dadosConta.setVisible(true); - } - } - } - }); - saqueButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - try{ - double valor = Double.parseDouble(valorSaque.getText()); - if(conta.saca(valor)){ - Mensagens.sucesso(dadosConta, "Saque realizado com sucesso"); - } else { - Mensagens.aviso(dadosConta, conta.getClass() == ContaCorrente.class ? "Saldo/limite insuficiente" : "O valor restante é inferior ao montante mínimo"); - } - } catch (NumberFormatException ex){ - Mensagens.erro(dadosConta, "Valor inserido inválido"); - - } - } - }); - depositoButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - try{ - double valor = Double.parseDouble(valorDeposito.getText()); - if(conta.deposita(valor)) { - Mensagens.sucesso(dadosConta, "Depósito realizado com sucesso"); - } else { - Mensagens.aviso(dadosConta, "Depósito mínimo não atingido"); - } - } catch (NumberFormatException ex){ - Mensagens.erro(dadosConta, "Valor inserido inválido"); - } - } - }); - investirButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if(conta.getSaldo() > 0){ - conta.remunera(); - Mensagens.sucesso(dadosConta, "Investimento realizado com sucesso"); - } else { - Mensagens.aviso(dadosConta, "Saldo insuficiente para investir"); - } - } - }); - } - - /** - * Construtor da classe ManipularConta - * Serve para instanciar a classe e carregar os dados da conta de um cliente - * @param cliente Cliente que será manipulado - */ - public ManipularConta(Cliente cliente){ - this(); - conta = cliente.getConta(); - cpfCliente.setText(cliente.getCpf()); - loadConta(); - dadosConta.setVisible(true); - } - - private Conta pesquisaContaPorCliente(String cpfCliente){ - cpfCliente = cpfCliente.replaceAll("[^0-9]", ""); - for(Cliente c : Sistema.getClientes()){ - if(c.getCpf().equals(cpfCliente)){ - if (c.getConta() != null) { - return c.getConta(); - } else{ - Mensagens.aviso(dadosConta, "O cliente pesquisado não possui uma conta"); - return null; - } - } - } - Mensagens.aviso(dadosConta, "Esse cliente não foi encontrado"); - return null; - } - - private void loadConta(){ - Mensagens.carregando(dadosConta, "Carregando dados da conta..."); - saldo.setText("R$ " + String.format("%.2f", conta.getSaldo()).replace(".", ",") ); - numeroConta.setText("Conta Nº: "+ String.format("%6d", conta.getNumero())); - warningLimite.setVisible(conta.getSaldo() < 0); - if(conta.getClass() == ContaCorrente.class){ - tipoConta.setText("Sua conta é do tipo: Conta Corrente"); - rendimento.setText("Seu rendimento é de: 1% do montante total"); - } else { - tipoConta.setText("Sua conta é do tipo: Conta de Investimento"); - rendimento.setText("Seu rendimento é de: 2% do montante total"); - } - conta.addObserver(this); - } - - /** - * Retorna o painel principal da tela - * @return JPanel - * @see Tela - */ - public JPanel getFrame() { - return frame; - } - - /** - * Método que atualiza o saldo da conta - * @param evt Evento de mudança de propriedade - * @see Observer - */ - @Override - public void propertyChange(PropertyChangeEvent evt) { - if(evt.getPropertyName().equals("saldo")){ - saldo.setText("R$ " + String.format("%.2f", conta.getSaldo()).replace(".", ",") ); - warningLimite.setVisible(conta.getSaldo() < 0); - } - } -} diff --git a/src/main/br/ufpr/views/ManterCliente.java b/src/main/br/ufpr/views/ManterCliente.java deleted file mode 100644 index 97c3d58..0000000 --- a/src/main/br/ufpr/views/ManterCliente.java +++ /dev/null @@ -1,363 +0,0 @@ -package main.br.ufpr.views; - -import main.br.ufpr.controllers.Imagens; -import main.br.ufpr.controllers.Mensagens; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.Cliente; -import main.br.ufpr.models.Endereco; -import main.br.ufpr.models.Tela; -import main.br.ufpr.models.comparables.NomeComparator; -import main.br.ufpr.models.comparables.SobrenomeComparator; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; -import java.util.Comparator; - -/** - * Esta classe representa a tela de manutenção do cliente. - * Ela implementa a interface Tela e define os campos de entrada e botões para inserir, editar, excluir e buscar clientes. - */ -public class ManterCliente implements Tela { - private JPanel frame; - private JButton voltarButton; - private JTextField textFieldNome; - private JTextField textFieldSobrenome; - private JTextField textFieldLogradouro; - private JTextField textFieldBairro; - private JTextField textFieldCidade; - private JTextField textFieldCPF; - private JTextField textFieldRG; - private JButton buscarButton; - private JTable tabelaClientes; - private JTextField textFieldNumero; - private JButton inserirButton; - private JButton editarButton; - private JButton excluirButton; - private JScrollPane scrollPanel; - private JComboBox comboOrdem; - private Comparator comparator; - private ManterClienteTableModel tabelaModel = new ManterClienteTableModel(Sistema.getClientes()); - - - /** - * Construtor para a classe ManterCliente. - * Define os valores iniciais para as variáveis de instância e adiciona os ouvintes de ação aos botões. - */ - public ManterCliente() { - tabelaClientes.setModel(tabelaModel); - tabelaClientes.setColumnModel(tabelaClientes.getColumnModel()); - - excluirButton.setIcon(Imagens.DELETE.icon()); - editarButton.setIcon(Imagens.EDIT.icon()); - buscarButton.setIcon(Imagens.SEARCH.icon()); - inserirButton.setIcon(Imagens.ADD.icon()); - - scrollPanel.getViewport().setBackground(new Color(5,28,59)); - tabelaClientes.getTableHeader().setBackground(new Color(225,248,255)); - - comparator = new NomeComparator(); - tabelaModel.sortClientes(comparator); - - voltarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Sistema.goBack(); - } - }); - inserirButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String nome = textFieldNome.getText(); - String sobreNome = textFieldSobrenome.getText(); - String logradouro = textFieldLogradouro.getText(); - String bairro = textFieldBairro.getText(); - String cidade = textFieldCidade.getText(); - String numero = textFieldNumero.getText(); - String cpf = textFieldCPF.getText(); - String rg = textFieldRG.getText(); - - areTextFieldsFilled(textFieldNome, "nome"); - areTextFieldsFilled(textFieldSobrenome, "sobrenome"); - areTextFieldsFilled(textFieldLogradouro, "logradouro"); - areTextFieldsFilled(textFieldBairro, "bairro"); - areTextFieldsFilled(textFieldCidade, "cidade"); - areTextFieldsFilled(textFieldNumero, "numero"); - areTextFieldsFilled(textFieldCPF, "CPF"); - areTextFieldsFilled(textFieldRG, "RG"); - - cpf = cpf.replaceAll("[^0-9]", ""); - - if (isInteger(numero)) { - Mensagens.erro(null, "Número Inválido\n"); - return; - } - - if (cpf.equals("")) { - Mensagens.erro(null, "Campo CPF não pode estar vazio\n"); - return; - } - if (isCpfExistente(cpf)) { - Mensagens.erro(null, "CPF já cadastrado\n"); - return; - } - - if (!validaCpf(cpf)) { - Mensagens.erro(null, "CPF inválido\n"); - return; - } - - Endereco endereco = new Endereco(logradouro, bairro, numero, cidade); - Cliente c = new Cliente(nome, sobreNome, endereco, cpf, rg); - - Sistema.cadastrarCliente(c); - - textFieldNome.setText(""); - textFieldSobrenome.setText(""); - textFieldLogradouro.setText(""); - textFieldBairro.setText(""); - textFieldCidade.setText(""); - textFieldNumero.setText(""); - textFieldCPF.setText(""); - textFieldRG.setText(""); - - tabelaModel.fireTableDataChanged(); - } - }); - - - buscarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - - String cpf = textFieldCPF.getText(); - - cpf = cpf.replaceAll("[^0-9]", ""); - - if (cpf.equals("")) { - Mensagens.aviso(null, "Insira um CPF para buscar\n"); - return; - } - - if (!isCpfExistente(cpf)) { - Mensagens.erro(null, "CPF não cadastrado\n"); - return; - } - - - for (Cliente cliente : Sistema.getClientes()) { - if (cliente.getCpf().equalsIgnoreCase(cpf)) { - textFieldNome.setText(cliente.getNome()); - textFieldSobrenome.setText(cliente.getSobrenome()); - textFieldLogradouro.setText(cliente.getEndereco().getLogradouro()); - textFieldBairro.setText(cliente.getEndereco().getBairro()); - textFieldCidade.setText(cliente.getEndereco().getCidade()); - textFieldNumero.setText(Integer.toString(cliente.getEndereco().getNumero())); - textFieldRG.setText(cliente.getRg()); - } - } - - } - }); - - editarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - - String nome = textFieldNome.getText(); - String sobreNome = textFieldSobrenome.getText(); - String logradouro = textFieldLogradouro.getText(); - String bairro = textFieldBairro.getText(); - String cidade = textFieldCidade.getText(); - String numero = textFieldNumero.getText(); - String cpf = textFieldCPF.getText(); - String rg = textFieldRG.getText(); - - - areTextFieldsFilled(textFieldNome, "nome"); - areTextFieldsFilled(textFieldSobrenome, "sobrenome"); - areTextFieldsFilled(textFieldLogradouro, "logradouro"); - areTextFieldsFilled(textFieldBairro, "bairro"); - areTextFieldsFilled(textFieldCidade, "cidade"); - areTextFieldsFilled(textFieldNumero, "numero"); - areTextFieldsFilled(textFieldCPF, "CPF"); - areTextFieldsFilled(textFieldRG, "RG"); - - if (isInteger(numero)) { - Mensagens.erro(null, "Número Inválido\n"); - return; - } - - if (cpf.equals("")) { - Mensagens.aviso(null, "CPF não pode ser vazio\n"); - return; - } - - if (!validaCpf(cpf)) { - Mensagens.erro(null, "CPF Inválido\n"); - return; - } - - cpf = cpf.replaceAll("[^0-9]", ""); - - for (Cliente cliente : Sistema.getClientes()) { - if (cliente.getCpf().equalsIgnoreCase(cpf)) { - cliente.setNome(nome); - cliente.setSobrenome(sobreNome); - Endereco endereco = new Endereco(logradouro, bairro, numero, cidade); - cliente.setEndereco(endereco); - cliente.setRg(rg); - } - } - - Mensagens.sucesso(null, "Informações editadas\n"); - - textFieldNome.setText(""); - textFieldSobrenome.setText(""); - textFieldLogradouro.setText(""); - textFieldBairro.setText(""); - textFieldCidade.setText(""); - textFieldNumero.setText(""); - textFieldCPF.setText(""); - textFieldRG.setText(""); - - tabelaModel.fireTableDataChanged(); - } - }); - - excluirButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String cpf = textFieldCPF.getText(); - - cpf = cpf.replaceAll("[^0-9]", ""); - - String finalCpf = cpf; - - Sistema.getClientes().removeIf(cliente -> cliente.getCpf().equalsIgnoreCase(finalCpf)); - - Mensagens.sucesso(null, "CPF "+cpf+" removido\n"); - - textFieldNome.setText(""); - textFieldSobrenome.setText(""); - textFieldLogradouro.setText(""); - textFieldBairro.setText(""); - textFieldCidade.setText(""); - textFieldNumero.setText(""); - textFieldCPF.setText(""); - textFieldRG.setText(""); - - tabelaModel.fireTableDataChanged(); - } - }); - comboOrdem.addComponentListener(new ComponentAdapter() { - }); - comboOrdem.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (comboOrdem.getSelectedIndex() == 1) { - comparator = new SobrenomeComparator(); - } else { - comparator = new NomeComparator(); - } - tabelaModel.sortClientes(comparator); - } - }); - } - /** - * Verifica se um CPF já existe na lista de clientes. - * - * @param cpf O CPF a ser verificado. - * @return Verdadeiro se o CPF já existe, falso caso contrário. - */ - private boolean isCpfExistente(String cpf) { - for (Cliente cliente : Sistema.getClientes()) { - if (cliente.getCpf().equalsIgnoreCase(cpf)) { - return true; - } - } - return false; - } - /** - * Verifica se uma string pode ser convertida para um número inteiro. - * - * @param str A string a ser verificada. - * @return Verdadeiro se a string pode ser convertida para um número inteiro, falso caso contrário. - */ - public static boolean isInteger(String str) { - if (str == null) { - return true; - } - try { - Integer.parseInt(str); - } catch (NumberFormatException e) { - return true; - } - return false; - } - /** - * Verifica se um campo de texto está preenchido. - * - * @param textField O campo de texto a ser verificado. - * @param campo O nome do campo a ser verificado. - * @return Verdadeiro se o campo de texto está preenchido, falso caso contrário. - */ - public static boolean areTextFieldsFilled(JTextField textField, String campo) { - if (textField.getText().trim().isEmpty()) { - Mensagens.aviso(null, "Campo "+campo+" está vazio\n"); - return false; - } - return true; - } - /** - * Valida um CPF. - * - * @param cpf O CPF a ser validado. - * @return Verdadeiro se o CPF é válido, falso caso contrário. - */ - public static boolean validaCpf(String cpf) { - int soma = 0, resto = 0; - - cpf = cpf.replaceAll("[^0-9]", ""); - - if (cpf.matches("[0-9]{11}") && !cpf.matches("^(\\d)\\1{10}")) { - for (int i = 0; i < 9; i++) { - soma += Integer.parseInt(cpf.substring(i, i + 1)) * (10 - i); - } - resto = 11 - (soma % 11); - if (resto == 10 || resto == 11) { - resto = 0; - } - if (resto != Integer.parseInt(cpf.substring(9, 10))) { - return false; - } - - soma = 0; - for (int i = 0; i < 10; i++) { - soma += Integer.parseInt(cpf.substring(i, i + 1)) * (11 - i); - } - resto = 11 - (soma % 11); - if (resto == 10 || resto == 11) { - resto = 0; - } - if (resto != Integer.parseInt(cpf.substring(10, 11))) { - return false; - } - - return true; - } - return false; - } - /** - * Este método retorna o frame da tela. - * - * @return O frame da tela. - */ - public JPanel getFrame() { - return frame; - } - - private void createUIComponents() { - // TODO: place custom component creation code here - } -} diff --git a/src/main/br/ufpr/views/VincularCliente.java b/src/main/br/ufpr/views/VincularCliente.java deleted file mode 100644 index 0808f40..0000000 --- a/src/main/br/ufpr/views/VincularCliente.java +++ /dev/null @@ -1,205 +0,0 @@ -package main.br.ufpr.views; - -import main.br.ufpr.controllers.Mensagens; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.controllers.Imagens; -import main.br.ufpr.models.Cliente; -import main.br.ufpr.models.ContaCorrente; -import main.br.ufpr.models.ContaInvestimento; -import main.br.ufpr.models.Tela; -import main.br.ufpr.services.FactoryConta; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.*; - -/** - * Classe responsável por vincular um cliente a uma conta. - * Implementa a interface Tela. - */ -public class VincularCliente implements Tela { - private JPanel frame; - private JButton voltarButton; - private JComboBox tipoConta; - private JTextField depositoInicial; - private JTextField textField2; - private JTextField textField3; - private JButton salvarButton; - private JLabel label1; - private JLabel label2; - private JLabel label3; - private JTable tabela; - private JPanel formulario; - private JButton gerenciarContaButton; - private JButton excluirButton; - private VincularTableModel tabelaModel = new VincularTableModel(Sistema.getClientes()); - private Cliente clienteSelecionado; - private ContaCorrente corrente; - private ContaInvestimento investimento; - private JScrollPane scrollPanel; - - /** - * Construtor da classe VincularCliente. - * Inicializa os componentes da interface e define os listeners dos botões. - */ - public VincularCliente() { - - excluirButton.setIcon(Imagens.DELETE.icon()); - gerenciarContaButton.setIcon(Imagens.DEPOSITO.icon()); - - tabela.setModel(tabelaModel); - tabela.setColumnModel(tabela.getColumnModel()); - - scrollPanel.getViewport().setBackground(new Color(5,28,59)); - tabela.getTableHeader().setBackground(new Color(225,248,255)); - - voltarButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Sistema.goBack(); - } - }); - - tipoConta.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent actionEvent) { - label1.setText("Depósito Inicial:"); - - switch (Objects.requireNonNull(tipoConta.getSelectedItem()).toString()) { - case "Conta Corrente": - formulario.setVisible(true); - label2.setText("Limite:"); - label3.setVisible(false); - textField3.setVisible(false); - break; - case "Conta Investimento": - formulario.setVisible(true); - label3.setVisible(true); - textField3.setVisible(true); - label2.setText("Montante Mínimo:"); - label3.setText("Depósito Mínimo:"); - break; - default: - formulario.setVisible(false); - break; - } - } - }); - - - - tabela.getSelectionModel().addListSelectionListener(e -> { - if (tabela.getSelectedRow() != -1) { - clienteSelecionado = Sistema.getClientes().get(tabela.getSelectedRow()); - tipoConta.setEnabled(false); - excluirButton.setVisible(true); - gerenciarContaButton.setVisible(true); - salvarButton.setVisible(false); - switch (clienteSelecionado.getConta() != null? clienteSelecionado.getConta().getClass().getSimpleName() : "") { - case "ContaCorrente": - tipoConta.setSelectedItem("Conta Corrente"); - corrente = (ContaCorrente) clienteSelecionado.getConta(); - depositoInicial.setText(String.valueOf(corrente.getDepositoInicial())); - textField2.setText(String.valueOf(corrente.getLimite())); - break; - case "ContaInvestimento": - tipoConta.setSelectedItem("Conta Investimento"); - investimento = (ContaInvestimento) clienteSelecionado.getConta(); - depositoInicial.setText(String.valueOf(investimento.getDepositoInicial())); - textField2.setText(String.valueOf(investimento.getMontanteMinimo())); - textField3.setText(String.valueOf(investimento.getDepositoMinimo())); - break; - default: - tipoConta.setSelectedItem(""); - depositoInicial.setText(""); - textField2.setText(""); - textField3.setText(""); - excluirButton.setVisible(false); - gerenciarContaButton.setVisible(false); - salvarButton.setVisible(true); - tipoConta.setEnabled(true); - break; - } - } - }); - - - salvarButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - - FactoryConta factory = new FactoryConta(); - ArrayList campos = new ArrayList<>(Arrays.asList(depositoInicial, textField2, textField3)); - - try { - factory.abrirConta(tipoConta.getSelectedItem().toString(), clienteSelecionado, validaCampos(campos)); - Mensagens.sucesso(frame, "Conta cadastrada com sucesso!"); - formulario.setVisible(false); - tipoConta.setEnabled(false); - tabelaModel.fireTableDataChanged(); - - } catch (NumberFormatException ex){ - Mensagens.erro(frame, ex.getMessage()); - } catch (IllegalArgumentException ex){ - Mensagens.aviso(frame, ex.getMessage()); - } - } - }); - - gerenciarContaButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Sistema.navigate(new ManipularConta(clienteSelecionado)); - } - }); - - excluirButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - - if(!Mensagens.confirmar(frame, "Tem certeza que deseja excluir a conta?")) return; - Sistema.getContas().remove(clienteSelecionado.getConta()); - clienteSelecionado.setConta(null); - tabelaModel.fireTableDataChanged(); - Mensagens.sucesso(frame, "Conta excluída com sucesso"); - tipoConta.setSelectedIndex(0); - - } - }); - } - /** - * Retorna o painel principal da tela. - * - * @return O painel principal da tela. - */ - public JPanel getFrame() { - return frame; - } - - /** - * Valida se todos os campos necessários estão preenchidos corretamente e, se estiver, retorna um array com os valores dos campos. - * - * @param campos ArrayList de campos de texto a serem verificados. - * @return ArrayList com os valores dos campos. - * @throws NumberFormatException Se um dos campos não for um número válido. - * @throws IllegalArgumentException Se um dos campos estiver vazio. - */ - private ArrayList validaCampos(ArrayList campos){ - ArrayList valores = new ArrayList<>(); - for (JTextField campo : campos){ - if (!campo.isVisible()) continue; - if (campo.getText().isEmpty()){ - throw new IllegalArgumentException("Preencha todos os campos"); - } - try { - valores.add(Double.parseDouble(campo.getText())); - } catch (NumberFormatException e) { - throw new NumberFormatException("Valor '" + campo.getText() + "' inválido"); - } - } - return valores; - } -} diff --git a/src/main/br/ufpr/controllers/Imagens.java b/src/main/java/br/ufpr/lpoo/controllers/Imagens.java similarity index 91% rename from src/main/br/ufpr/controllers/Imagens.java rename to src/main/java/br/ufpr/lpoo/controllers/Imagens.java index 0bb4145..81f2886 100644 --- a/src/main/br/ufpr/controllers/Imagens.java +++ b/src/main/java/br/ufpr/lpoo/controllers/Imagens.java @@ -1,4 +1,4 @@ -package main.br.ufpr.controllers; +package br.ufpr.lpoo.controllers; import javax.imageio.ImageIO; import javax.swing.ImageIcon; @@ -52,7 +52,7 @@ public enum Imagens { */ public ImageIcon icon() { try{ - InputStream is = getClass().getResourceAsStream("/assets/"+path); + InputStream is = getClass().getClassLoader().getResourceAsStream("assets/"+path); Image image = ImageIO.read(is); return new ImageIcon(image); } catch (IOException e) { @@ -74,7 +74,7 @@ public ImageIcon icon() { */ public ImageIcon icon(int width, int height) { try{ - InputStream is = getClass().getResourceAsStream("/assets/"+path); + InputStream is = getClass().getClassLoader().getResourceAsStream("assets/"+path); Image image = ImageIO.read(is); return new ImageIcon(image.getScaledInstance(width, height, Image.SCALE_SMOOTH)); } catch (IOException e) { @@ -94,7 +94,7 @@ public ImageIcon icon(int width, int height) { */ public Image image() { try{ - InputStream is = getClass().getResourceAsStream("/assets/"+path); + InputStream is = getClass().getClassLoader().getResourceAsStream("assets/"+path); return ImageIO.read(is); } catch (IOException e) { System.out.println("Erro ao carregar imagem "+ path); diff --git a/src/main/br/ufpr/controllers/Mensagens.java b/src/main/java/br/ufpr/lpoo/controllers/Mensagens.java similarity index 98% rename from src/main/br/ufpr/controllers/Mensagens.java rename to src/main/java/br/ufpr/lpoo/controllers/Mensagens.java index 5649a32..c5e47e9 100644 --- a/src/main/br/ufpr/controllers/Mensagens.java +++ b/src/main/java/br/ufpr/lpoo/controllers/Mensagens.java @@ -1,4 +1,4 @@ -package main.br.ufpr.controllers; +package br.ufpr.lpoo.controllers; import javax.swing.*; import java.awt.*; diff --git a/src/main/br/ufpr/controllers/Sistema.java b/src/main/java/br/ufpr/lpoo/controllers/Sistema.java similarity index 97% rename from src/main/br/ufpr/controllers/Sistema.java rename to src/main/java/br/ufpr/lpoo/controllers/Sistema.java index f4e7b29..b54944f 100644 --- a/src/main/br/ufpr/controllers/Sistema.java +++ b/src/main/java/br/ufpr/lpoo/controllers/Sistema.java @@ -1,6 +1,7 @@ -package main.br.ufpr.controllers; -import main.br.ufpr.models.*; -import main.br.ufpr.views.Home; +package br.ufpr.lpoo.controllers; + +import br.ufpr.lpoo.models.*; +import br.ufpr.lpoo.views.Home; import javax.swing.*; import java.awt.*; diff --git a/src/main/br/ufpr/models/Cliente.java b/src/main/java/br/ufpr/lpoo/models/Cliente.java similarity index 98% rename from src/main/br/ufpr/models/Cliente.java rename to src/main/java/br/ufpr/lpoo/models/Cliente.java index 9aed550..15d11c4 100644 --- a/src/main/br/ufpr/models/Cliente.java +++ b/src/main/java/br/ufpr/lpoo/models/Cliente.java @@ -1,5 +1,4 @@ -package main.br.ufpr.models; -import java.text.Normalizer; +package br.ufpr.lpoo.models; /** * Esta classe representa um cliente no sistema. diff --git a/src/main/br/ufpr/models/Conta.java b/src/main/java/br/ufpr/lpoo/models/Conta.java similarity index 97% rename from src/main/br/ufpr/models/Conta.java rename to src/main/java/br/ufpr/lpoo/models/Conta.java index d2bc34f..0e343b9 100644 --- a/src/main/br/ufpr/models/Conta.java +++ b/src/main/java/br/ufpr/lpoo/models/Conta.java @@ -1,6 +1,6 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; -import main.br.ufpr.services.Observer; +import br.ufpr.lpoo.services.Observer; import java.beans.PropertyChangeSupport; diff --git a/src/main/br/ufpr/models/ContaCorrente.java b/src/main/java/br/ufpr/lpoo/models/ContaCorrente.java similarity index 98% rename from src/main/br/ufpr/models/ContaCorrente.java rename to src/main/java/br/ufpr/lpoo/models/ContaCorrente.java index 15e6a75..9726d6c 100644 --- a/src/main/br/ufpr/models/ContaCorrente.java +++ b/src/main/java/br/ufpr/lpoo/models/ContaCorrente.java @@ -1,4 +1,4 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; /** * Esta classe representa uma Conta Corrente no sistema. diff --git a/src/main/br/ufpr/models/ContaI.java b/src/main/java/br/ufpr/lpoo/models/ContaI.java similarity index 97% rename from src/main/br/ufpr/models/ContaI.java rename to src/main/java/br/ufpr/lpoo/models/ContaI.java index 6333739..9b6bc88 100644 --- a/src/main/br/ufpr/models/ContaI.java +++ b/src/main/java/br/ufpr/lpoo/models/ContaI.java @@ -1,4 +1,4 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; /** * Esta é uma interface que define os métodos que uma conta deve implementar. diff --git a/src/main/br/ufpr/models/ContaInvestimento.java b/src/main/java/br/ufpr/lpoo/models/ContaInvestimento.java similarity index 99% rename from src/main/br/ufpr/models/ContaInvestimento.java rename to src/main/java/br/ufpr/lpoo/models/ContaInvestimento.java index 066c717..9ed7676 100644 --- a/src/main/br/ufpr/models/ContaInvestimento.java +++ b/src/main/java/br/ufpr/lpoo/models/ContaInvestimento.java @@ -1,4 +1,4 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; /** * Esta classe representa uma Conta de Investimento no sistema. diff --git a/src/main/br/ufpr/models/Endereco.java b/src/main/java/br/ufpr/lpoo/models/Endereco.java similarity index 98% rename from src/main/br/ufpr/models/Endereco.java rename to src/main/java/br/ufpr/lpoo/models/Endereco.java index 6633ff3..589dbe3 100644 --- a/src/main/br/ufpr/models/Endereco.java +++ b/src/main/java/br/ufpr/lpoo/models/Endereco.java @@ -1,4 +1,4 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; /** * Esta classe representa um Endereço no sistema. diff --git a/src/main/br/ufpr/models/Tela.java b/src/main/java/br/ufpr/lpoo/models/Tela.java similarity index 79% rename from src/main/br/ufpr/models/Tela.java rename to src/main/java/br/ufpr/lpoo/models/Tela.java index 303e1cc..d676bea 100644 --- a/src/main/br/ufpr/models/Tela.java +++ b/src/main/java/br/ufpr/lpoo/models/Tela.java @@ -1,4 +1,4 @@ -package main.br.ufpr.models; +package br.ufpr.lpoo.models; import javax.swing.JPanel; @@ -12,5 +12,6 @@ public interface Tela { * * @return O frame da tela. */ - public JPanel getFrame(); + JPanel getFrame(); + void initUIComponents(); } \ No newline at end of file diff --git a/src/main/br/ufpr/models/comparables/NomeComparator.java b/src/main/java/br/ufpr/lpoo/models/comparables/NomeComparator.java similarity index 83% rename from src/main/br/ufpr/models/comparables/NomeComparator.java rename to src/main/java/br/ufpr/lpoo/models/comparables/NomeComparator.java index 2a94077..8f2974f 100644 --- a/src/main/br/ufpr/models/comparables/NomeComparator.java +++ b/src/main/java/br/ufpr/lpoo/models/comparables/NomeComparator.java @@ -1,6 +1,6 @@ -package main.br.ufpr.models.comparables; +package br.ufpr.lpoo.models.comparables; -import main.br.ufpr.models.Cliente; +import br.ufpr.lpoo.models.Cliente; import java.util.Comparator; diff --git a/src/main/br/ufpr/models/comparables/SobrenomeComparator.java b/src/main/java/br/ufpr/lpoo/models/comparables/SobrenomeComparator.java similarity index 84% rename from src/main/br/ufpr/models/comparables/SobrenomeComparator.java rename to src/main/java/br/ufpr/lpoo/models/comparables/SobrenomeComparator.java index 412e8a3..b85de3d 100644 --- a/src/main/br/ufpr/models/comparables/SobrenomeComparator.java +++ b/src/main/java/br/ufpr/lpoo/models/comparables/SobrenomeComparator.java @@ -1,6 +1,6 @@ -package main.br.ufpr.models.comparables; +package br.ufpr.lpoo.models.comparables; -import main.br.ufpr.models.Cliente; +import br.ufpr.lpoo.models.Cliente; import java.util.Comparator; diff --git a/src/main/br/ufpr/services/FactoryConta.java b/src/main/java/br/ufpr/lpoo/services/FactoryConta.java similarity index 71% rename from src/main/br/ufpr/services/FactoryConta.java rename to src/main/java/br/ufpr/lpoo/services/FactoryConta.java index 1062749..12a0144 100644 --- a/src/main/br/ufpr/services/FactoryConta.java +++ b/src/main/java/br/ufpr/lpoo/services/FactoryConta.java @@ -1,10 +1,10 @@ -package main.br.ufpr.services; +package br.ufpr.lpoo.services; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.Cliente; -import main.br.ufpr.models.Conta; -import main.br.ufpr.models.ContaCorrente; -import main.br.ufpr.models.ContaInvestimento; +import br.ufpr.lpoo.controllers.Sistema; +import br.ufpr.lpoo.models.Cliente; +import br.ufpr.lpoo.models.Conta; +import br.ufpr.lpoo.models.ContaCorrente; +import br.ufpr.lpoo.models.ContaInvestimento; import java.util.ArrayList; diff --git a/src/main/br/ufpr/services/Observer.java b/src/main/java/br/ufpr/lpoo/services/Observer.java similarity index 86% rename from src/main/br/ufpr/services/Observer.java rename to src/main/java/br/ufpr/lpoo/services/Observer.java index 965a699..7c96550 100644 --- a/src/main/br/ufpr/services/Observer.java +++ b/src/main/java/br/ufpr/lpoo/services/Observer.java @@ -1,4 +1,4 @@ -package main.br.ufpr.services; +package br.ufpr.lpoo.services; import java.beans.PropertyChangeListener; diff --git a/src/main/br/ufpr/views/Home.form b/src/main/java/br/ufpr/lpoo/views/Home.form similarity index 88% rename from src/main/br/ufpr/views/Home.form rename to src/main/java/br/ufpr/lpoo/views/Home.form index e5f2903..525c7da 100644 --- a/src/main/br/ufpr/views/Home.form +++ b/src/main/java/br/ufpr/lpoo/views/Home.form @@ -1,9 +1,9 @@ -
        + - + @@ -51,9 +51,14 @@ - + + + + + + diff --git a/src/main/java/br/ufpr/lpoo/views/Home.java b/src/main/java/br/ufpr/lpoo/views/Home.java new file mode 100644 index 0000000..a6686fc --- /dev/null +++ b/src/main/java/br/ufpr/lpoo/views/Home.java @@ -0,0 +1,137 @@ +package br.ufpr.lpoo.views; + +import br.ufpr.lpoo.controllers.Imagens; +import br.ufpr.lpoo.controllers.Sistema; +import br.ufpr.lpoo.models.Tela; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * Esta classe representa a tela inicial do sistema. + * Ela implementa a interface Tela e define os botões e ações da tela inicial. + */ +public class Home implements Tela { + private JPanel frame; + private JButton clientesButton; + private JButton contasButton; + private JButton transactionsButton; + private JLabel logo; + + /** + * Construtor para a classe Home. + * Define os valores iniciais para as variáveis de instância e adiciona os ouvintes de ação aos botões. + */ + public Home() { + clientesButton.addActionListener(new ActionListener() { + /** + * Este método é chamado quando o botão Clientes é clicado. + * Ele navega para a tela ManterCliente. + * + * @param e O evento de ação. + */ + @Override + public void actionPerformed(ActionEvent e) { + ManterCliente frame = new ManterCliente(); + Sistema.navigate(frame); + } + }); + contasButton.addActionListener(new ActionListener() { + /** + * Este método é chamado quando o botão Contas é clicado. + * Ele navega para a tela VincularCliente. + * + * @param e O evento de ação. + */ + @Override + public void actionPerformed(ActionEvent e) { + VincularCliente frame = new VincularCliente(); + Sistema.navigate(frame); + } + }); + transactionsButton.addActionListener(new ActionListener() { + /** + * Este método é chamado quando o botão Transações é clicado. + * Ele navega para a tela ManipularConta. + * + * @param e O evento de ação. + */ + @Override + public void actionPerformed(ActionEvent e) { + ManipularConta frame = new ManipularConta(); + Sistema.navigate(frame); + } + }); + this.initUIComponents(); + } + + @Override + public void initUIComponents() { + this.logo.setIcon(Imagens.LOGO.icon(300, 300)); + this.contasButton.setIcon(Imagens.CONTAS.icon()); + this.clientesButton.setIcon(Imagens.CLIENTES.icon()); + this.transactionsButton.setIcon(Imagens.TRANSACTIONS.icon()); + } + + /** + * Este método retorna o frame da tela. + * + * @return O frame da tela. + */ + public JPanel getFrame() { + return frame; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + frame = new JPanel(); + frame.setLayout(new GridLayoutManager(3, 3, new Insets(8, 8, 8, 8), -1, -1)); + frame.setBackground(new Color(-16442309)); + frame.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-1967873)), "Home", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-1967873))); + clientesButton = new JButton(); + clientesButton.setBackground(new Color(-11487489)); + clientesButton.setText("Clientes"); + frame.add(clientesButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + contasButton = new JButton(); + contasButton.setBackground(new Color(-11487489)); + contasButton.setText("Contas"); + frame.add(contasButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false)); + transactionsButton = new JButton(); + transactionsButton.setBackground(new Color(-11487489)); + transactionsButton.setText("Transações"); + frame.add(transactionsButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setForeground(new Color(-1967873)); + label1.setText("© UFPR TADS 2024"); + frame.add(label1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_SOUTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + logo = new JLabel(); + logo.setIcon(new ImageIcon(getClass().getResource("/assets/logo.jpg"))); + logo.setText(""); + frame.add(logo, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(300, 300), new Dimension(300, 300), new Dimension(300, 300), 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return frame; + } +} \ No newline at end of file diff --git a/src/main/br/ufpr/views/ManipularConta.form b/src/main/java/br/ufpr/lpoo/views/ManipularConta.form similarity index 99% rename from src/main/br/ufpr/views/ManipularConta.form rename to src/main/java/br/ufpr/lpoo/views/ManipularConta.form index c175b38..2c26058 100644 --- a/src/main/br/ufpr/views/ManipularConta.form +++ b/src/main/java/br/ufpr/lpoo/views/ManipularConta.form @@ -1,5 +1,5 @@ - + diff --git a/src/main/java/br/ufpr/lpoo/views/ManipularConta.java b/src/main/java/br/ufpr/lpoo/views/ManipularConta.java new file mode 100644 index 0000000..21bf4b4 --- /dev/null +++ b/src/main/java/br/ufpr/lpoo/views/ManipularConta.java @@ -0,0 +1,358 @@ +package br.ufpr.lpoo.views; + +import br.ufpr.lpoo.controllers.*; +import br.ufpr.lpoo.models.*; +import br.ufpr.lpoo.services.Observer; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; + +/** + * Classe que representa a tela de manipulação de conta + * Realiza transações como saque, depósito e investimento + * + * @see Tela + */ +public class ManipularConta implements Tela, Observer { + private Conta conta; + private JPanel frame; + private JButton voltarButton; + private JTextField cpfCliente; + private JPanel dadosConta; + private JButton buscarButton; + private JPanel boxSaldo; + private JLabel saldo; + private JCheckBox mostrarSaldo; + private JTabbedPane tabbedPane1; + private JPanel sacar; + private JPanel depositar; + private JPanel investir; + private JTextField valorSaque; + private JButton saqueButton; + private JTextField valorDeposito; + private JButton depositoButton; + private JButton investirButton; + private JLabel tipoConta; + private JLabel rendimento; + private JLabel numeroConta; + private JLabel warningLimite; + + /** + * Construtor da classe ManipularConta + * Adiciona os ícones aos botões e painéis + * Adiciona os listeners aos botões + */ + public ManipularConta() { + this.initUIComponents(); + + voltarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Sistema.goBack(); + } + }); + mostrarSaldo.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + saldo.setVisible(mostrarSaldo.isSelected()); + } + }); + buscarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (!cpfCliente.getText().isEmpty()) { + String cpf = cpfCliente.getText(); + conta = pesquisaContaPorCliente(cpf); + if (conta != null) { + loadConta(); + dadosConta.setVisible(true); + } + } + } + }); + saqueButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + double valor = Double.parseDouble(valorSaque.getText()); + if (conta.saca(valor)) { + Mensagens.sucesso(dadosConta, "Saque realizado com sucesso"); + } else { + Mensagens.aviso(dadosConta, conta.getClass() == ContaCorrente.class ? "Saldo/limite insuficiente" : "O valor restante é inferior ao montante mínimo"); + } + } catch (NumberFormatException ex) { + Mensagens.erro(dadosConta, "Valor inserido inválido"); + + } + } + }); + depositoButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + double valor = Double.parseDouble(valorDeposito.getText()); + if (conta.deposita(valor)) { + Mensagens.sucesso(dadosConta, "Depósito realizado com sucesso"); + } else { + Mensagens.aviso(dadosConta, "Depósito mínimo não atingido"); + } + } catch (NumberFormatException ex) { + Mensagens.erro(dadosConta, "Valor inserido inválido"); + } + } + }); + investirButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (conta.getSaldo() > 0) { + conta.remunera(); + Mensagens.sucesso(dadosConta, "Investimento realizado com sucesso"); + } else { + Mensagens.aviso(dadosConta, "Saldo insuficiente para investir"); + } + } + }); + } + + /** + * Construtor da classe ManipularConta + * Serve para instanciar a classe e carregar os dados da conta de um cliente + * + * @param cliente Cliente que será manipulado + */ + public ManipularConta(Cliente cliente) { + this(); + conta = cliente.getConta(); + cpfCliente.setText(cliente.getCpf()); + loadConta(); + dadosConta.setVisible(true); + } + + private Conta pesquisaContaPorCliente(String cpfCliente) { + cpfCliente = cpfCliente.replaceAll("[^0-9]", ""); + for (Cliente c : Sistema.getClientes()) { + if (c.getCpf().equals(cpfCliente)) { + if (c.getConta() != null) { + return c.getConta(); + } else { + Mensagens.aviso(dadosConta, "O cliente pesquisado não possui uma conta"); + return null; + } + } + } + Mensagens.aviso(dadosConta, "Esse cliente não foi encontrado"); + return null; + } + + private void loadConta() { + Mensagens.carregando(dadosConta, "Carregando dados da conta..."); + saldo.setText("R$ " + String.format("%.2f", conta.getSaldo()).replace(".", ",")); + numeroConta.setText("Conta Nº: " + String.format("%6d", conta.getNumero())); + warningLimite.setVisible(conta.getSaldo() < 0); + if (conta.getClass() == ContaCorrente.class) { + tipoConta.setText("Sua conta é do tipo: Conta Corrente"); + rendimento.setText("Seu rendimento é de: 1% do montante total"); + } else { + tipoConta.setText("Sua conta é do tipo: Conta de Investimento"); + rendimento.setText("Seu rendimento é de: 2% do montante total"); + } + conta.addObserver(this); + } + + /** + * Retorna o painel principal da tela + * + * @return JPanel + * @see Tela + */ + public JPanel getFrame() { + return frame; + } + + @Override + public void initUIComponents() { + buscarButton.setIcon(Imagens.SEARCH.icon()); + mostrarSaldo.setIcon(Imagens.EYE_OPEN.icon()); + mostrarSaldo.setSelectedIcon(Imagens.EYE_CLOSED.icon()); + tabbedPane1.setIconAt(0, Imagens.SAQUE.icon()); + tabbedPane1.setIconAt(1, Imagens.DEPOSITO.icon()); + tabbedPane1.setIconAt(2, Imagens.REMUNERA.icon()); + investirButton.setIcon(Imagens.INVESTIMENTO.icon()); + } + + /** + * Método que atualiza o saldo da conta + * + * @param evt Evento de mudança de propriedade + * @see Observer + */ + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("saldo")) { + saldo.setText("R$ " + String.format("%.2f", conta.getSaldo()).replace(".", ",")); + warningLimite.setVisible(conta.getSaldo() < 0); + } + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + frame = new JPanel(); + frame.setLayout(new GridLayoutManager(3, 4, new Insets(8, 8, 8, 8), -1, -1)); + frame.setBackground(new Color(-16442309)); + frame.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-1967873)), "Transações", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-1967873))); + voltarButton = new JButton(); + voltarButton.setBackground(new Color(-11487489)); + voltarButton.setText("Voltar"); + frame.add(voltarButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + cpfCliente = new JTextField(); + cpfCliente.setBackground(new Color(-2500135)); + frame.add(cpfCliente, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label1 = new JLabel(); + label1.setForeground(new Color(-1967873)); + label1.setText("CPF do cliente:"); + frame.add(label1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setForeground(new Color(-1967873)); + label2.setText("Consultar conta"); + frame.add(label2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + dadosConta = new JPanel(); + dadosConta.setLayout(new GridLayoutManager(3, 4, new Insets(8, 8, 8, 8), -1, -1)); + dadosConta.setBackground(new Color(-14134075)); + dadosConta.setEnabled(false); + dadosConta.setOpaque(true); + dadosConta.setVisible(false); + frame.add(dadosConta, new GridConstraints(2, 1, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + dadosConta.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + numeroConta = new JLabel(); + numeroConta.setForeground(new Color(-1967873)); + numeroConta.setText("Conta Nº: 12345"); + dadosConta.add(numeroConta, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + boxSaldo = new JPanel(); + boxSaldo.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + boxSaldo.setBackground(new Color(-16442309)); + boxSaldo.setOpaque(true); + boxSaldo.setVisible(true); + dadosConta.add(boxSaldo, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_VERTICAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(85, 20), new Dimension(85, 20), 0, false)); + saldo = new JLabel(); + saldo.setEnabled(true); + saldo.setFocusable(true); + saldo.setForeground(new Color(-1967873)); + saldo.setHorizontalAlignment(0); + saldo.setHorizontalTextPosition(0); + saldo.setName(""); + saldo.setOpaque(false); + saldo.setText("R$8000,00"); + saldo.setVerifyInputWhenFocusTarget(true); + saldo.setVisible(false); + boxSaldo.add(saldo, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + mostrarSaldo = new JCheckBox(); + mostrarSaldo.setBackground(new Color(-14134075)); + mostrarSaldo.setText(""); + mostrarSaldo.setToolTipText("Ver saldo"); + dadosConta.add(mostrarSaldo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tabbedPane1 = new JTabbedPane(); + tabbedPane1.setBackground(new Color(-12611640)); + dadosConta.add(tabbedPane1, new GridConstraints(2, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, 200), null, 0, false)); + sacar = new JPanel(); + sacar.setLayout(new GridLayoutManager(3, 2, new Insets(4, 4, 4, 4), -1, -1)); + sacar.setBackground(new Color(-16442309)); + tabbedPane1.addTab("Sacar", sacar); + final JLabel label3 = new JLabel(); + label3.setForeground(new Color(-1967873)); + label3.setText("Informe o valor que você deseja sacar:"); + sacar.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + sacar.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + valorSaque = new JTextField(); + valorSaque.setBackground(new Color(-2500135)); + sacar.add(valorSaque, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + sacar.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + saqueButton = new JButton(); + saqueButton.setBackground(new Color(-11487489)); + saqueButton.setText("Realizar saque"); + sacar.add(saqueButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + depositar = new JPanel(); + depositar.setLayout(new GridLayoutManager(3, 2, new Insets(4, 4, 4, 4), -1, -1)); + depositar.setBackground(new Color(-16442309)); + tabbedPane1.addTab("Depositar", depositar); + final JLabel label4 = new JLabel(); + label4.setForeground(new Color(-1967873)); + label4.setText("Informe o valor que você deseja depositar:"); + depositar.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer3 = new Spacer(); + depositar.add(spacer3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + valorDeposito = new JTextField(); + valorDeposito.setBackground(new Color(-2500135)); + depositar.add(valorDeposito, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer4 = new Spacer(); + depositar.add(spacer4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + depositoButton = new JButton(); + depositoButton.setBackground(new Color(-11487489)); + depositoButton.setText("Realizar depósito"); + depositar.add(depositoButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + investir = new JPanel(); + investir.setLayout(new GridLayoutManager(5, 2, new Insets(4, 4, 4, 4), -1, -1)); + investir.setBackground(new Color(-16442309)); + tabbedPane1.addTab("Investir", investir); + tipoConta = new JLabel(); + tipoConta.setBackground(new Color(-1967873)); + tipoConta.setForeground(new Color(-1967873)); + tipoConta.setText("Sua conta é do tipo: Investimento"); + investir.add(tipoConta, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + investir.add(spacer5, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + rendimento = new JLabel(); + rendimento.setForeground(new Color(-1967873)); + rendimento.setText("Seu rendimento é de: 102%"); + investir.add(rendimento, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + investirButton = new JButton(); + investirButton.setBackground(new Color(-11487489)); + investirButton.setText("Investir agora"); + investir.add(investirButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer6 = new Spacer(); + investir.add(spacer6, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer7 = new Spacer(); + investir.add(spacer7, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer8 = new Spacer(); + dadosConta.add(spacer8, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + warningLimite = new JLabel(); + warningLimite.setForeground(new Color(-2752502)); + warningLimite.setText("Usando limite"); + warningLimite.setToolTipText("O saldo atual da sua conta é R$0,00. Estamos considerando seu limite"); + warningLimite.setVisible(false); + dadosConta.add(warningLimite, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + buscarButton = new JButton(); + buscarButton.setBackground(new Color(-11487489)); + buscarButton.setText("Buscar"); + frame.add(buscarButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer9 = new Spacer(); + frame.add(spacer9, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return frame; + } +} diff --git a/src/main/br/ufpr/views/ManterCliente.form b/src/main/java/br/ufpr/lpoo/views/ManterCliente.form similarity index 99% rename from src/main/br/ufpr/views/ManterCliente.form rename to src/main/java/br/ufpr/lpoo/views/ManterCliente.form index b09e6b7..879e10d 100644 --- a/src/main/br/ufpr/views/ManterCliente.form +++ b/src/main/java/br/ufpr/lpoo/views/ManterCliente.form @@ -1,5 +1,5 @@ - + diff --git a/src/main/java/br/ufpr/lpoo/views/ManterCliente.java b/src/main/java/br/ufpr/lpoo/views/ManterCliente.java new file mode 100644 index 0000000..5e1ed4a --- /dev/null +++ b/src/main/java/br/ufpr/lpoo/views/ManterCliente.java @@ -0,0 +1,548 @@ +package br.ufpr.lpoo.views; + +import br.ufpr.lpoo.controllers.*; +import br.ufpr.lpoo.models.Cliente; +import br.ufpr.lpoo.models.Endereco; +import br.ufpr.lpoo.models.Tela; +import br.ufpr.lpoo.models.comparables.*; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.FontUIResource; +import javax.swing.text.StyleContext; +import java.awt.*; +import java.awt.event.*; +import java.util.Comparator; +import java.util.Locale; + +/** + * Esta classe representa a tela de manutenção do cliente. + * Ela implementa a interface Tela e define os campos de entrada e botões para inserir, editar, excluir e buscar clientes. + */ +public class ManterCliente implements Tela { + private JPanel frame; + private JButton voltarButton; + private JTextField textFieldNome; + private JTextField textFieldSobrenome; + private JTextField textFieldLogradouro; + private JTextField textFieldBairro; + private JTextField textFieldCidade; + private JTextField textFieldCPF; + private JTextField textFieldRG; + private JButton buscarButton; + private JTable tabelaClientes; + private JTextField textFieldNumero; + private JButton inserirButton; + private JButton editarButton; + private JButton excluirButton; + private JScrollPane scrollPanel; + private JComboBox comboOrdem; + private Comparator comparator; + private ManterClienteTableModel tabelaModel = new ManterClienteTableModel(Sistema.getClientes()); + + + /** + * Construtor para a classe ManterCliente. + * Define os valores iniciais para as variáveis de instância e adiciona os ouvintes de ação aos botões. + */ + public ManterCliente() { + this.initUIComponents(); + tabelaClientes.setModel(tabelaModel); + tabelaClientes.setColumnModel(tabelaClientes.getColumnModel()); + + comparator = new NomeComparator(); + tabelaModel.sortClientes(comparator); + + voltarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Sistema.goBack(); + } + }); + inserirButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String nome = textFieldNome.getText(); + String sobreNome = textFieldSobrenome.getText(); + String logradouro = textFieldLogradouro.getText(); + String bairro = textFieldBairro.getText(); + String cidade = textFieldCidade.getText(); + String numero = textFieldNumero.getText(); + String cpf = textFieldCPF.getText(); + String rg = textFieldRG.getText(); + + areTextFieldsFilled(textFieldNome, "nome"); + areTextFieldsFilled(textFieldSobrenome, "sobrenome"); + areTextFieldsFilled(textFieldLogradouro, "logradouro"); + areTextFieldsFilled(textFieldBairro, "bairro"); + areTextFieldsFilled(textFieldCidade, "cidade"); + areTextFieldsFilled(textFieldNumero, "numero"); + areTextFieldsFilled(textFieldCPF, "CPF"); + areTextFieldsFilled(textFieldRG, "RG"); + + cpf = cpf.replaceAll("[^0-9]", ""); + + if (isInteger(numero)) { + Mensagens.erro(null, "Número Inválido\n"); + return; + } + + if (cpf.equals("")) { + Mensagens.erro(null, "Campo CPF não pode estar vazio\n"); + return; + } + if (isCpfExistente(cpf)) { + Mensagens.erro(null, "CPF já cadastrado\n"); + return; + } + + if (!validaCpf(cpf)) { + Mensagens.erro(null, "CPF inválido\n"); + return; + } + + Endereco endereco = new Endereco(logradouro, bairro, numero, cidade); + Cliente c = new Cliente(nome, sobreNome, endereco, cpf, rg); + + Sistema.cadastrarCliente(c); + + textFieldNome.setText(""); + textFieldSobrenome.setText(""); + textFieldLogradouro.setText(""); + textFieldBairro.setText(""); + textFieldCidade.setText(""); + textFieldNumero.setText(""); + textFieldCPF.setText(""); + textFieldRG.setText(""); + + tabelaModel.fireTableDataChanged(); + } + }); + + + buscarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + String cpf = textFieldCPF.getText(); + + cpf = cpf.replaceAll("[^0-9]", ""); + + if (cpf.equals("")) { + Mensagens.aviso(null, "Insira um CPF para buscar\n"); + return; + } + + if (!isCpfExistente(cpf)) { + Mensagens.erro(null, "CPF não cadastrado\n"); + return; + } + + + for (Cliente cliente : Sistema.getClientes()) { + if (cliente.getCpf().equalsIgnoreCase(cpf)) { + textFieldNome.setText(cliente.getNome()); + textFieldSobrenome.setText(cliente.getSobrenome()); + textFieldLogradouro.setText(cliente.getEndereco().getLogradouro()); + textFieldBairro.setText(cliente.getEndereco().getBairro()); + textFieldCidade.setText(cliente.getEndereco().getCidade()); + textFieldNumero.setText(Integer.toString(cliente.getEndereco().getNumero())); + textFieldRG.setText(cliente.getRg()); + } + } + + } + }); + + editarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + String nome = textFieldNome.getText(); + String sobreNome = textFieldSobrenome.getText(); + String logradouro = textFieldLogradouro.getText(); + String bairro = textFieldBairro.getText(); + String cidade = textFieldCidade.getText(); + String numero = textFieldNumero.getText(); + String cpf = textFieldCPF.getText(); + String rg = textFieldRG.getText(); + + + areTextFieldsFilled(textFieldNome, "nome"); + areTextFieldsFilled(textFieldSobrenome, "sobrenome"); + areTextFieldsFilled(textFieldLogradouro, "logradouro"); + areTextFieldsFilled(textFieldBairro, "bairro"); + areTextFieldsFilled(textFieldCidade, "cidade"); + areTextFieldsFilled(textFieldNumero, "numero"); + areTextFieldsFilled(textFieldCPF, "CPF"); + areTextFieldsFilled(textFieldRG, "RG"); + + if (isInteger(numero)) { + Mensagens.erro(null, "Número Inválido\n"); + return; + } + + if (cpf.equals("")) { + Mensagens.aviso(null, "CPF não pode ser vazio\n"); + return; + } + + if (!validaCpf(cpf)) { + Mensagens.erro(null, "CPF Inválido\n"); + return; + } + + cpf = cpf.replaceAll("[^0-9]", ""); + + for (Cliente cliente : Sistema.getClientes()) { + if (cliente.getCpf().equalsIgnoreCase(cpf)) { + cliente.setNome(nome); + cliente.setSobrenome(sobreNome); + Endereco endereco = new Endereco(logradouro, bairro, numero, cidade); + cliente.setEndereco(endereco); + cliente.setRg(rg); + } + } + + Mensagens.sucesso(null, "Informações editadas\n"); + + textFieldNome.setText(""); + textFieldSobrenome.setText(""); + textFieldLogradouro.setText(""); + textFieldBairro.setText(""); + textFieldCidade.setText(""); + textFieldNumero.setText(""); + textFieldCPF.setText(""); + textFieldRG.setText(""); + + tabelaModel.fireTableDataChanged(); + } + }); + + excluirButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String cpf = textFieldCPF.getText(); + + cpf = cpf.replaceAll("[^0-9]", ""); + + String finalCpf = cpf; + + Sistema.getClientes().removeIf(cliente -> cliente.getCpf().equalsIgnoreCase(finalCpf)); + + Mensagens.sucesso(null, "CPF " + cpf + " removido\n"); + + textFieldNome.setText(""); + textFieldSobrenome.setText(""); + textFieldLogradouro.setText(""); + textFieldBairro.setText(""); + textFieldCidade.setText(""); + textFieldNumero.setText(""); + textFieldCPF.setText(""); + textFieldRG.setText(""); + + tabelaModel.fireTableDataChanged(); + } + }); + comboOrdem.addComponentListener(new ComponentAdapter() { + }); + comboOrdem.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (comboOrdem.getSelectedIndex() == 1) { + comparator = new SobrenomeComparator(); + } else { + comparator = new NomeComparator(); + } + tabelaModel.sortClientes(comparator); + } + }); + } + + @Override + public void initUIComponents() { + this.excluirButton.setIcon(Imagens.DELETE.icon()); + this.editarButton.setIcon(Imagens.EDIT.icon()); + this.buscarButton.setIcon(Imagens.SEARCH.icon()); + this.inserirButton.setIcon(Imagens.ADD.icon()); + + this.scrollPanel.getViewport().setBackground(new Color(5, 28, 59)); + this.tabelaClientes.getTableHeader().setBackground(new Color(225, 248, 255)); + } + + /** + * Verifica se um CPF já existe na lista de clientes. + * + * @param cpf O CPF a ser verificado. + * @return Verdadeiro se o CPF já existe, falso caso contrário. + */ + private boolean isCpfExistente(String cpf) { + for (Cliente cliente : Sistema.getClientes()) { + if (cliente.getCpf().equalsIgnoreCase(cpf)) { + return true; + } + } + return false; + } + + /** + * Verifica se uma string pode ser convertida para um número inteiro. + * + * @param str A string a ser verificada. + * @return Verdadeiro se a string pode ser convertida para um número inteiro, falso caso contrário. + */ + public static boolean isInteger(String str) { + if (str == null) { + return true; + } + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + return true; + } + return false; + } + + /** + * Verifica se um campo de texto está preenchido. + * + * @param textField O campo de texto a ser verificado. + * @param campo O nome do campo a ser verificado. + * @return Verdadeiro se o campo de texto está preenchido, falso caso contrário. + */ + public static boolean areTextFieldsFilled(JTextField textField, String campo) { + if (textField.getText().trim().isEmpty()) { + Mensagens.aviso(null, "Campo " + campo + " está vazio\n"); + return false; + } + return true; + } + + /** + * Valida um CPF. + * + * @param cpf O CPF a ser validado. + * @return Verdadeiro se o CPF é válido, falso caso contrário. + */ + public static boolean validaCpf(String cpf) { + int soma = 0, resto = 0; + + cpf = cpf.replaceAll("[^0-9]", ""); + + if (cpf.matches("[0-9]{11}") && !cpf.matches("^(\\d)\\1{10}")) { + for (int i = 0; i < 9; i++) { + soma += Integer.parseInt(cpf.substring(i, i + 1)) * (10 - i); + } + resto = 11 - (soma % 11); + if (resto == 10 || resto == 11) { + resto = 0; + } + if (resto != Integer.parseInt(cpf.substring(9, 10))) { + return false; + } + + soma = 0; + for (int i = 0; i < 10; i++) { + soma += Integer.parseInt(cpf.substring(i, i + 1)) * (11 - i); + } + resto = 11 - (soma % 11); + if (resto == 10 || resto == 11) { + resto = 0; + } + if (resto != Integer.parseInt(cpf.substring(10, 11))) { + return false; + } + + return true; + } + return false; + } + + /** + * Este método retorna o frame da tela. + * + * @return O frame da tela. + */ + public JPanel getFrame() { + return frame; + } + + private void createUIComponents() { + // TODO: place custom component creation code here + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + frame = new JPanel(); + frame.setLayout(new GridLayoutManager(7, 4, new Insets(8, 8, 8, 8), -1, -1)); + frame.setBackground(new Color(-16442309)); + frame.setEnabled(false); + frame.setForeground(new Color(-1967873)); + frame.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-1967873)), "Clientes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-1967873))); + final JLabel label1 = new JLabel(); + label1.setForeground(new Color(-1967873)); + label1.setText("Nome:"); + frame.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setForeground(new Color(-1967873)); + label2.setText("Sobrenome:"); + frame.add(label2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textFieldNome = new JTextField(); + textFieldNome.setBackground(new Color(-2500135)); + textFieldNome.setForeground(new Color(-16777216)); + frame.add(textFieldNome, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + textFieldSobrenome = new JTextField(); + textFieldSobrenome.setBackground(new Color(-2500135)); + textFieldSobrenome.setForeground(new Color(-16777216)); + frame.add(textFieldSobrenome, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(2, 6, new Insets(0, 0, 0, 0), -1, -1)); + panel1.setBackground(new Color(-16442309)); + panel1.setEnabled(false); + panel1.setForeground(new Color(-1967873)); + frame.add(panel1, new GridConstraints(1, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-1967873)), "Endereço", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel1.getFont()), new Color(-1967873))); + final JLabel label3 = new JLabel(); + label3.setForeground(new Color(-1967873)); + label3.setText("Logradouro:"); + panel1.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, 17), null, 0, false)); + textFieldLogradouro = new JTextField(); + textFieldLogradouro.setBackground(new Color(-2500135)); + textFieldLogradouro.setForeground(new Color(-16777216)); + panel1.add(textFieldLogradouro, new GridConstraints(0, 1, 1, 5, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setForeground(new Color(-1967873)); + label4.setText("Número:"); + panel1.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(50, 17), null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setForeground(new Color(-1967873)); + label5.setText("Bairro:"); + panel1.add(label5, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textFieldBairro = new JTextField(); + textFieldBairro.setBackground(new Color(-2500135)); + textFieldBairro.setForeground(new Color(-16777216)); + panel1.add(textFieldBairro, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label6 = new JLabel(); + label6.setForeground(new Color(-1967873)); + label6.setText("Cidade:"); + panel1.add(label6, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textFieldCidade = new JTextField(); + textFieldCidade.setBackground(new Color(-2500135)); + textFieldCidade.setForeground(new Color(-16777216)); + panel1.add(textFieldCidade, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + textFieldNumero = new JTextField(); + textFieldNumero.setBackground(new Color(-2500135)); + textFieldNumero.setForeground(new Color(-16777216)); + panel1.add(textFieldNumero, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setForeground(new Color(-1967873)); + label7.setText("CPF:"); + frame.add(label7, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textFieldCPF = new JTextField(); + textFieldCPF.setBackground(new Color(-2500135)); + textFieldCPF.setForeground(new Color(-16777216)); + frame.add(textFieldCPF, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setForeground(new Color(-1967873)); + label8.setText("RG:"); + frame.add(label8, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textFieldRG = new JTextField(); + textFieldRG.setBackground(new Color(-2500135)); + textFieldRG.setForeground(new Color(-16777216)); + frame.add(textFieldRG, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + buscarButton = new JButton(); + buscarButton.setBackground(new Color(-11487489)); + buscarButton.setText("Buscar"); + frame.add(buscarButton, new GridConstraints(3, 2, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + scrollPanel = new JScrollPane(); + scrollPanel.setBackground(new Color(-14134075)); + scrollPanel.setEnabled(true); + frame.add(scrollPanel, new GridConstraints(5, 0, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-16442309)), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + tabelaClientes = new JTable(); + tabelaClientes.setBackground(new Color(-11487489)); + tabelaClientes.setEnabled(true); + tabelaClientes.setForeground(new Color(-16777216)); + tabelaClientes.setGridColor(new Color(-16442309)); + tabelaClientes.setSelectionForeground(new Color(-14134075)); + tabelaClientes.setShowVerticalLines(false); + tabelaClientes.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE); + tabelaClientes.putClientProperty("Table.isFileList", Boolean.FALSE); + scrollPanel.setViewportView(tabelaClientes); + inserirButton = new JButton(); + inserirButton.setBackground(new Color(-11487489)); + inserirButton.setText("Inserir"); + frame.add(inserirButton, new GridConstraints(3, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + voltarButton = new JButton(); + voltarButton.setBackground(new Color(-11487489)); + voltarButton.setText("Voltar"); + frame.add(voltarButton, new GridConstraints(6, 3, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label9 = new JLabel(); + label9.setForeground(new Color(-1967873)); + label9.setText("Clientes cadastrados"); + frame.add(label9, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + editarButton = new JButton(); + editarButton.setBackground(new Color(-11487489)); + editarButton.setText("Editar"); + frame.add(editarButton, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + excluirButton = new JButton(); + excluirButton.setBackground(new Color(-11487489)); + excluirButton.setText("Excluir"); + frame.add(excluirButton, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + comboOrdem = new JComboBox(); + comboOrdem.setBackground(new Color(-2500135)); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement("nome"); + defaultComboBoxModel1.addElement("sobrenome"); + comboOrdem.setModel(defaultComboBoxModel1); + frame.add(comboOrdem, new GridConstraints(4, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label10 = new JLabel(); + label10.setForeground(new Color(-1967873)); + label10.setText("Ordenar por"); + frame.add(label10, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { + if (currentFont == null) return null; + String resultName; + if (fontName == null) { + resultName = currentFont.getName(); + } else { + Font testFont = new Font(fontName, Font.PLAIN, 10); + if (testFont.canDisplay('a') && testFont.canDisplay('1')) { + resultName = fontName; + } else { + resultName = currentFont.getName(); + } + } + Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); + boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac"); + Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize()); + return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return frame; + } +} diff --git a/src/main/br/ufpr/views/ManterClienteTableModel.java b/src/main/java/br/ufpr/lpoo/views/ManterClienteTableModel.java similarity index 95% rename from src/main/br/ufpr/views/ManterClienteTableModel.java rename to src/main/java/br/ufpr/lpoo/views/ManterClienteTableModel.java index 3014269..da0d879 100644 --- a/src/main/br/ufpr/views/ManterClienteTableModel.java +++ b/src/main/java/br/ufpr/lpoo/views/ManterClienteTableModel.java @@ -1,9 +1,8 @@ -package main.br.ufpr.views; +package br.ufpr.lpoo.views; + +import br.ufpr.lpoo.models.Cliente; -import main.br.ufpr.models.Cliente; import javax.swing.table.AbstractTableModel; -import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; diff --git a/src/main/br/ufpr/views/VincularCliente.form b/src/main/java/br/ufpr/lpoo/views/VincularCliente.form similarity index 99% rename from src/main/br/ufpr/views/VincularCliente.form rename to src/main/java/br/ufpr/lpoo/views/VincularCliente.form index d40bb97..7b490e0 100644 --- a/src/main/br/ufpr/views/VincularCliente.form +++ b/src/main/java/br/ufpr/lpoo/views/VincularCliente.form @@ -1,5 +1,5 @@ - + diff --git a/src/main/java/br/ufpr/lpoo/views/VincularCliente.java b/src/main/java/br/ufpr/lpoo/views/VincularCliente.java new file mode 100644 index 0000000..f2c0e68 --- /dev/null +++ b/src/main/java/br/ufpr/lpoo/views/VincularCliente.java @@ -0,0 +1,307 @@ +package br.ufpr.lpoo.views; + +import br.ufpr.lpoo.controllers.*; +import br.ufpr.lpoo.models.Cliente; +import br.ufpr.lpoo.models.ContaCorrente; +import br.ufpr.lpoo.models.ContaInvestimento; +import br.ufpr.lpoo.models.Tela; +import br.ufpr.lpoo.services.FactoryConta; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.*; + +/** + * Classe responsável por vincular um cliente a uma conta. + * Implementa a interface Tela. + */ +public class VincularCliente implements Tela { + private JPanel frame; + private JButton voltarButton; + private JComboBox tipoConta; + private JTextField depositoInicial; + private JTextField textField2; + private JTextField textField3; + private JButton salvarButton; + private JLabel label1; + private JLabel label2; + private JLabel label3; + private JTable tabela; + private JPanel formulario; + private JButton gerenciarContaButton; + private JButton excluirButton; + private VincularTableModel tabelaModel = new VincularTableModel(Sistema.getClientes()); + private Cliente clienteSelecionado; + private ContaCorrente corrente; + private ContaInvestimento investimento; + private JScrollPane scrollPanel; + + /** + * Construtor da classe VincularCliente. + * Inicializa os componentes da interface e define os listeners dos botões. + */ + public VincularCliente() { + this.initUIComponents(); + + tabela.setModel(tabelaModel); + tabela.setColumnModel(tabela.getColumnModel()); + + voltarButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Sistema.goBack(); + } + }); + + tipoConta.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + label1.setText("Depósito Inicial:"); + + switch (Objects.requireNonNull(tipoConta.getSelectedItem()).toString()) { + case "Conta Corrente": + formulario.setVisible(true); + label2.setText("Limite:"); + label3.setVisible(false); + textField3.setVisible(false); + break; + case "Conta Investimento": + formulario.setVisible(true); + label3.setVisible(true); + textField3.setVisible(true); + label2.setText("Montante Mínimo:"); + label3.setText("Depósito Mínimo:"); + break; + default: + formulario.setVisible(false); + break; + } + } + }); + + + tabela.getSelectionModel().addListSelectionListener(e -> { + if (tabela.getSelectedRow() != -1) { + clienteSelecionado = Sistema.getClientes().get(tabela.getSelectedRow()); + tipoConta.setEnabled(false); + excluirButton.setVisible(true); + gerenciarContaButton.setVisible(true); + salvarButton.setVisible(false); + switch (clienteSelecionado.getConta() != null ? clienteSelecionado.getConta().getClass().getSimpleName() : "") { + case "ContaCorrente": + tipoConta.setSelectedItem("Conta Corrente"); + corrente = (ContaCorrente) clienteSelecionado.getConta(); + depositoInicial.setText(String.valueOf(corrente.getDepositoInicial())); + textField2.setText(String.valueOf(corrente.getLimite())); + break; + case "ContaInvestimento": + tipoConta.setSelectedItem("Conta Investimento"); + investimento = (ContaInvestimento) clienteSelecionado.getConta(); + depositoInicial.setText(String.valueOf(investimento.getDepositoInicial())); + textField2.setText(String.valueOf(investimento.getMontanteMinimo())); + textField3.setText(String.valueOf(investimento.getDepositoMinimo())); + break; + default: + tipoConta.setSelectedItem(""); + depositoInicial.setText(""); + textField2.setText(""); + textField3.setText(""); + excluirButton.setVisible(false); + gerenciarContaButton.setVisible(false); + salvarButton.setVisible(true); + tipoConta.setEnabled(true); + break; + } + } + }); + + + salvarButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + FactoryConta factory = new FactoryConta(); + ArrayList campos = new ArrayList<>(Arrays.asList(depositoInicial, textField2, textField3)); + + try { + factory.abrirConta(tipoConta.getSelectedItem().toString(), clienteSelecionado, validaCampos(campos)); + Mensagens.sucesso(frame, "Conta cadastrada com sucesso!"); + formulario.setVisible(false); + tipoConta.setEnabled(false); + tabelaModel.fireTableDataChanged(); + + } catch (NumberFormatException ex) { + Mensagens.erro(frame, ex.getMessage()); + } catch (IllegalArgumentException ex) { + Mensagens.aviso(frame, ex.getMessage()); + } + } + }); + + gerenciarContaButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Sistema.navigate(new ManipularConta(clienteSelecionado)); + } + }); + + excluirButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + + if (!Mensagens.confirmar(frame, "Tem certeza que deseja excluir a conta?")) return; + Sistema.getContas().remove(clienteSelecionado.getConta()); + clienteSelecionado.setConta(null); + tabelaModel.fireTableDataChanged(); + Mensagens.sucesso(frame, "Conta excluída com sucesso"); + tipoConta.setSelectedIndex(0); + + } + }); + } + + /** + * Retorna o painel principal da tela. + * + * @return O painel principal da tela. + */ + public JPanel getFrame() { + return frame; + } + + @Override + public void initUIComponents() { + excluirButton.setIcon(Imagens.DELETE.icon()); + gerenciarContaButton.setIcon(Imagens.DEPOSITO.icon()); + scrollPanel.getViewport().setBackground(new Color(5, 28, 59)); + tabela.getTableHeader().setBackground(new Color(225, 248, 255)); + } + + /** + * Valida se todos os campos necessários estão preenchidos corretamente e, se estiver, retorna um array com os valores dos campos. + * + * @param campos ArrayList de campos de texto a serem verificados. + * @return ArrayList com os valores dos campos. + * @throws NumberFormatException Se um dos campos não for um número válido. + * @throws IllegalArgumentException Se um dos campos estiver vazio. + */ + private ArrayList validaCampos(ArrayList campos) { + ArrayList valores = new ArrayList<>(); + for (JTextField campo : campos) { + if (!campo.isVisible()) continue; + if (campo.getText().isEmpty()) { + throw new IllegalArgumentException("Preencha todos os campos"); + } + try { + valores.add(Double.parseDouble(campo.getText())); + } catch (NumberFormatException e) { + throw new NumberFormatException("Valor '" + campo.getText() + "' inválido"); + } + } + return valores; + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + frame = new JPanel(); + frame.setLayout(new GridLayoutManager(5, 3, new Insets(8, 8, 8, 8), -1, -1)); + frame.setBackground(new Color(-16442309)); + frame.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-1967873)), "Contas", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(-1967873))); + final JLabel label4 = new JLabel(); + label4.setBackground(new Color(-1967873)); + label4.setForeground(new Color(-1967873)); + label4.setText("Tipo de conta:"); + frame.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + tipoConta = new JComboBox(); + tipoConta.setBackground(new Color(-2500135)); + tipoConta.setEnabled(false); + final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); + defaultComboBoxModel1.addElement(""); + defaultComboBoxModel1.addElement("Conta Corrente"); + defaultComboBoxModel1.addElement("Conta Investimento"); + tipoConta.setModel(defaultComboBoxModel1); + tipoConta.setToolTipText("Você deve selecionar um cliente."); + frame.add(tipoConta, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(189, 34), null, 0, false)); + scrollPanel = new JScrollPane(); + scrollPanel.setBackground(new Color(-12611640)); + frame.add(scrollPanel, new GridConstraints(1, 0, 3, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + scrollPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(-16442309)), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + tabela = new JTable(); + tabela.setBackground(new Color(-11487489)); + tabela.setForeground(new Color(-16777216)); + tabela.setGridColor(new Color(-16442309)); + tabela.setVisible(true); + scrollPanel.setViewportView(tabela); + formulario = new JPanel(); + formulario.setLayout(new GridLayoutManager(5, 3, new Insets(5, 5, 5, 5), -1, -1)); + formulario.setBackground(new Color(-16442309)); + formulario.setVisible(false); + frame.add(formulario, new GridConstraints(4, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + excluirButton = new JButton(); + excluirButton.setBackground(new Color(-11487489)); + excluirButton.setText("Excluir"); + formulario.add(excluirButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + salvarButton = new JButton(); + salvarButton.setBackground(new Color(-11487489)); + salvarButton.setText("Salvar"); + formulario.add(salvarButton, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gerenciarContaButton = new JButton(); + gerenciarContaButton.setBackground(new Color(-11487489)); + gerenciarContaButton.setText("Gerenciar conta"); + formulario.add(gerenciarContaButton, new GridConstraints(4, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label3 = new JLabel(); + label3.setForeground(new Color(-1967873)); + label3.setText("Label"); + label3.setVisible(true); + formulario.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label2 = new JLabel(); + label2.setForeground(new Color(-1967873)); + label2.setText("Limite:"); + label2.setVisible(true); + formulario.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + label1 = new JLabel(); + label1.setForeground(new Color(-1967873)); + label1.setText("Depósito Inicial:"); + formulario.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + textField3 = new JTextField(); + textField3.setBackground(new Color(-2500135)); + textField3.setVisible(true); + formulario.add(textField3, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + textField2 = new JTextField(); + textField2.setBackground(new Color(-2500135)); + formulario.add(textField2, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + depositoInicial = new JTextField(); + depositoInicial.setBackground(new Color(-2500135)); + formulario.add(depositoInicial, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + voltarButton = new JButton(); + voltarButton.setBackground(new Color(-11487489)); + voltarButton.setText("Voltar"); + frame.add(voltarButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return frame; + } +} diff --git a/src/main/br/ufpr/views/VincularTableModel.java b/src/main/java/br/ufpr/lpoo/views/VincularTableModel.java similarity index 97% rename from src/main/br/ufpr/views/VincularTableModel.java rename to src/main/java/br/ufpr/lpoo/views/VincularTableModel.java index f328547..541b944 100644 --- a/src/main/br/ufpr/views/VincularTableModel.java +++ b/src/main/java/br/ufpr/lpoo/views/VincularTableModel.java @@ -1,6 +1,6 @@ -package main.br.ufpr.views; +package br.ufpr.lpoo.views; -import main.br.ufpr.models.Cliente; +import br.ufpr.lpoo.models.Cliente; import javax.swing.table.AbstractTableModel; import java.util.List; diff --git a/src/assets/add.png b/src/main/resources/assets/add.png similarity index 100% rename from src/assets/add.png rename to src/main/resources/assets/add.png diff --git a/src/assets/clientes.png b/src/main/resources/assets/clientes.png similarity index 100% rename from src/assets/clientes.png rename to src/main/resources/assets/clientes.png diff --git a/src/assets/contas.png b/src/main/resources/assets/contas.png similarity index 100% rename from src/assets/contas.png rename to src/main/resources/assets/contas.png diff --git a/src/assets/delete.png b/src/main/resources/assets/delete.png similarity index 100% rename from src/assets/delete.png rename to src/main/resources/assets/delete.png diff --git a/src/assets/deposito.png b/src/main/resources/assets/deposito.png similarity index 100% rename from src/assets/deposito.png rename to src/main/resources/assets/deposito.png diff --git a/src/assets/edit.png b/src/main/resources/assets/edit.png similarity index 100% rename from src/assets/edit.png rename to src/main/resources/assets/edit.png diff --git a/src/assets/error.png b/src/main/resources/assets/error.png similarity index 100% rename from src/assets/error.png rename to src/main/resources/assets/error.png diff --git a/src/assets/eye_closed.png b/src/main/resources/assets/eye_closed.png similarity index 100% rename from src/assets/eye_closed.png rename to src/main/resources/assets/eye_closed.png diff --git a/src/assets/eye_open.png b/src/main/resources/assets/eye_open.png similarity index 100% rename from src/assets/eye_open.png rename to src/main/resources/assets/eye_open.png diff --git a/src/assets/icon.png b/src/main/resources/assets/icon.png similarity index 100% rename from src/assets/icon.png rename to src/main/resources/assets/icon.png diff --git a/src/assets/investir.png b/src/main/resources/assets/investir.png similarity index 100% rename from src/assets/investir.png rename to src/main/resources/assets/investir.png diff --git a/src/assets/load.png b/src/main/resources/assets/load.png similarity index 100% rename from src/assets/load.png rename to src/main/resources/assets/load.png diff --git a/src/assets/logo.jpg b/src/main/resources/assets/logo.jpg similarity index 100% rename from src/assets/logo.jpg rename to src/main/resources/assets/logo.jpg diff --git a/src/assets/remunera.png b/src/main/resources/assets/remunera.png similarity index 100% rename from src/assets/remunera.png rename to src/main/resources/assets/remunera.png diff --git a/src/assets/saque.png b/src/main/resources/assets/saque.png similarity index 100% rename from src/assets/saque.png rename to src/main/resources/assets/saque.png diff --git a/src/assets/search.png b/src/main/resources/assets/search.png similarity index 100% rename from src/assets/search.png rename to src/main/resources/assets/search.png diff --git a/src/assets/sucess.png b/src/main/resources/assets/sucess.png similarity index 100% rename from src/assets/sucess.png rename to src/main/resources/assets/sucess.png diff --git a/src/assets/transactions.png b/src/main/resources/assets/transactions.png similarity index 100% rename from src/assets/transactions.png rename to src/main/resources/assets/transactions.png diff --git a/src/assets/warning.png b/src/main/resources/assets/warning.png similarity index 100% rename from src/assets/warning.png rename to src/main/resources/assets/warning.png diff --git a/src/test/br/ufpr/controllers/TesteSistema.java b/src/test/java/br/ufpr/lpoo/controllers/TesteSistema.java similarity index 77% rename from src/test/br/ufpr/controllers/TesteSistema.java rename to src/test/java/br/ufpr/lpoo/controllers/TesteSistema.java index f4e0de7..f9158f7 100644 --- a/src/test/br/ufpr/controllers/TesteSistema.java +++ b/src/test/java/br/ufpr/lpoo/controllers/TesteSistema.java @@ -1,7 +1,6 @@ -package test.br.ufpr.controllers; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.Cliente; -import main.br.ufpr.models.Endereco; +package br.ufpr.lpoo.controllers; +import br.ufpr.lpoo.models.Cliente; +import br.ufpr.lpoo.models.Endereco; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/src/test/br/ufpr/models/TesteCliente.java b/src/test/java/br/ufpr/lpoo/models/TesteCliente.java similarity index 93% rename from src/test/br/ufpr/models/TesteCliente.java rename to src/test/java/br/ufpr/lpoo/models/TesteCliente.java index d26104d..75abae5 100644 --- a/src/test/br/ufpr/models/TesteCliente.java +++ b/src/test/java/br/ufpr/lpoo/models/TesteCliente.java @@ -1,7 +1,4 @@ -package test.br.ufpr.models; -import main.br.ufpr.models.*; -import main.br.ufpr.models.Endereco; -import java.util.ArrayList; +package br.ufpr.lpoo.models; import org.junit.Test; import static org.junit.Assert.*; diff --git a/src/test/br/ufpr/models/TesteConta.java b/src/test/java/br/ufpr/lpoo/models/TesteConta.java similarity index 96% rename from src/test/br/ufpr/models/TesteConta.java rename to src/test/java/br/ufpr/lpoo/models/TesteConta.java index 6894261..94062dd 100644 --- a/src/test/br/ufpr/models/TesteConta.java +++ b/src/test/java/br/ufpr/lpoo/models/TesteConta.java @@ -1,10 +1,7 @@ -package test.br.ufpr.models; +package br.ufpr.lpoo.models; -import main.br.ufpr.models.*; import org.junit.Test; -import static org.junit.Assert.*; - public class TesteConta { private Endereco criarEndereco() { diff --git a/src/test/br/ufpr/models/TesteEndereco.java b/src/test/java/br/ufpr/lpoo/models/TesteEndereco.java similarity index 92% rename from src/test/br/ufpr/models/TesteEndereco.java rename to src/test/java/br/ufpr/lpoo/models/TesteEndereco.java index 5b77e4d..f071ace 100644 --- a/src/test/br/ufpr/models/TesteEndereco.java +++ b/src/test/java/br/ufpr/lpoo/models/TesteEndereco.java @@ -1,5 +1,5 @@ -package test.br.ufpr.models; -import main.br.ufpr.models.*; +package br.ufpr.lpoo.models; + import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/src/test/br/ufpr/views/TesteManipularConta.java b/src/test/java/br/ufpr/lpoo/views/TesteManipularConta.java similarity index 97% rename from src/test/br/ufpr/views/TesteManipularConta.java rename to src/test/java/br/ufpr/lpoo/views/TesteManipularConta.java index cf02278..0129f5b 100644 --- a/src/test/br/ufpr/views/TesteManipularConta.java +++ b/src/test/java/br/ufpr/lpoo/views/TesteManipularConta.java @@ -1,8 +1,7 @@ -package test.br.ufpr.views; +package br.ufpr.lpoo.views; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.*; -import main.br.ufpr.views.ManipularConta; +import br.ufpr.lpoo.controllers.Sistema; +import br.ufpr.lpoo.models.*; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/br/ufpr/views/TesteVincularCliente.java b/src/test/java/br/ufpr/lpoo/views/TesteVincularCliente.java similarity index 97% rename from src/test/br/ufpr/views/TesteVincularCliente.java rename to src/test/java/br/ufpr/lpoo/views/TesteVincularCliente.java index 7b6d016..11f5ad8 100644 --- a/src/test/br/ufpr/views/TesteVincularCliente.java +++ b/src/test/java/br/ufpr/lpoo/views/TesteVincularCliente.java @@ -1,8 +1,7 @@ -package test.br.ufpr.views; +package br.ufpr.lpoo.views; -import main.br.ufpr.controllers.Sistema; -import main.br.ufpr.models.*; -import main.br.ufpr.views.VincularCliente; +import br.ufpr.lpoo.controllers.Sistema; +import br.ufpr.lpoo.models.*; import org.junit.After; import org.junit.Before; import org.junit.Test;