-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from kaua-pt/Vista
Vista
- Loading branch information
Showing
55 changed files
with
4,109 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
SistemaDeAcademia/src/Controladores/ControladorConsultaTreino.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package Controladores; | ||
|
||
import javax.swing.DefaultListModel; | ||
|
||
import Modelo.BancoDeDados; | ||
import Modelo.Treino; | ||
import Visao.PanelConsultaTreino; | ||
import Visao.PanelVerTreino; | ||
|
||
public class ControladorConsultaTreino { | ||
|
||
private PanelConsultaTreino tela; | ||
private Treino treino; | ||
|
||
public ControladorConsultaTreino(PanelConsultaTreino tela) { | ||
this.tela = tela; | ||
} | ||
|
||
public void acaoPerformada(Object e) { | ||
if (e == tela.getBtnVoltar()) { | ||
ControladorRedirecionar.caminho(1); | ||
} else if (e == tela.getBtnDeletar()) { | ||
treino = Treino.getUmTreino((String) tela.getListTreinos().getSelectedValue()); | ||
treino.deletar(); | ||
ControladorRedirecionar.caminho(1); | ||
|
||
} else if (e == tela.getBtnVer()) { | ||
treino = Treino.getUmTreino((String) tela.getListTreinos().getSelectedValue()); | ||
PanelVerTreino verTreino = new PanelVerTreino(treino); | ||
tela.add(verTreino); | ||
tela.getPanelGeral().setVisible(false); | ||
} | ||
} | ||
|
||
public void inicializar() { | ||
DefaultListModel<Object> retorno = new DefaultListModel<Object>(); | ||
for (Treino treino : BancoDeDados.treinos) { | ||
retorno.addElement(treino.getNome()); | ||
} | ||
tela.getListTreinos().setModel(retorno); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
SistemaDeAcademia/src/Controladores/ControladorListarExercicios.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package Controladores; | ||
|
||
import javax.swing.DefaultListModel; | ||
|
||
import Modelo.BancoDeDados; | ||
import Modelo.Exercicio; | ||
import Modelo.TipoDeGrupamento; | ||
import Visao.PanelEditarExercicio; | ||
import Visao.PanelListarExercicios; | ||
|
||
public class ControladorListarExercicios { | ||
|
||
private PanelListarExercicios panel; | ||
private Exercicio exercicio; | ||
|
||
public ControladorListarExercicios(PanelListarExercicios panel) { | ||
this.panel = panel; | ||
} | ||
|
||
public void acaoPerformada(Object e) { | ||
if (e == panel.getBtnBuscar()) { | ||
DefaultListModel<Object> retorno = new DefaultListModel<Object>(); | ||
for (Exercicio exercicio : BancoDeDados.exercicios) { | ||
if (exercicio.getTipo() | ||
.equals(TipoDeGrupamento.pegarTipo(panel.getComboGrupamento().getSelectedIndex() + 1))) { | ||
retorno.addElement(exercicio.getNome() + "-" + exercicio.getDescricao()); | ||
} | ||
} | ||
|
||
panel.getListExercicios().setModel(retorno); | ||
|
||
} else if (e == panel.getBtnDeletar()) { | ||
exercicio = Exercicio.getUmExercicio((String) panel.getListExercicios().getSelectedValue()); | ||
exercicio.deletar(); | ||
ControladorRedirecionar.caminho(1); | ||
} else if (e == panel.getBtnEditar()) { | ||
|
||
String nome = panel.getListExercicios().getSelectedValue().toString(); | ||
int pos = nome.indexOf("-"); | ||
nome.substring(0, pos); | ||
PanelEditarExercicio panelExercicio = new PanelEditarExercicio( | ||
Exercicio.getUmExercicio(nome.substring(0, pos))); | ||
panel.add(panelExercicio); | ||
panel.getPanelmain().setVisible(false); | ||
|
||
} else if (e == panel.getBtnVoltar()) { | ||
ControladorRedirecionar.caminho(1); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
SistemaDeAcademia/src/Controladores/ControladorMainLabel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* | ||
*/ | ||
package Controladores; | ||
|
||
import javax.swing.JPanel; | ||
|
||
import Visao.PanelInicio; | ||
import Visao.PanelMenu; | ||
import Visao.PanelRedirecionar; | ||
|
||
/** | ||
* @author Kauã Vinícius | ||
* | ||
* | ||
* @see PanelMenu | ||
*/ | ||
public class ControladorMainLabel { | ||
|
||
private PanelMenu tela; | ||
private JPanel[] telas = new JPanel[12]; | ||
|
||
public ControladorMainLabel(PanelMenu painelMenu) { | ||
this.tela = painelMenu; | ||
} | ||
|
||
public void caminho(int id) { | ||
esconderTelas(); | ||
|
||
if (id == 1) { | ||
PanelInicio inicio = new PanelInicio(); | ||
operarTela(id, inicio); | ||
|
||
} else if (id == 2) { | ||
PanelRedirecionar redirecionarAluno = new PanelRedirecionar("Alunos", "Consultar "); | ||
operarTela(id, redirecionarAluno); | ||
|
||
} else if (id == 3) { | ||
PanelRedirecionar redirecionarExercicio = new PanelRedirecionar("Exercicios", "Listar "); | ||
operarTela(id, redirecionarExercicio); | ||
|
||
} else if (id == 4) { | ||
PanelRedirecionar redirecionarTreino = new PanelRedirecionar("Treinos", "Consultar "); | ||
operarTela(id, redirecionarTreino); | ||
} else if (id == 5) { | ||
tela.dispose(); | ||
} | ||
} | ||
|
||
public void operarTela(int id, JPanel elemento) { | ||
telas[id - 1] = elemento; | ||
this.tela.getPanelMainMenu().add(elemento); | ||
elemento.setVisible(true); | ||
} | ||
|
||
public void esconderTelas() { | ||
for (JPanel telaCriada : telas) { | ||
if (telaCriada != null) { | ||
telaCriada.setVisible(false); | ||
} | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
SistemaDeAcademia/src/Controladores/ControladorRedirecionar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package Controladores; | ||
|
||
import javax.swing.JPanel; | ||
|
||
import Visao.PanelBuscaAluno; | ||
import Visao.PanelCadastroAluno; | ||
import Visao.PanelCadastroExercicio; | ||
import Visao.PanelCadastroTreino; | ||
import Visao.PanelConsultaTreino; | ||
import Visao.PanelListarExercicios; | ||
|
||
public class ControladorRedirecionar { | ||
|
||
private static JPanel tela; | ||
private static JPanel padrao; | ||
private static JPanel[] telas = new JPanel[20]; | ||
|
||
public static void receptacao(String operacao, int id) { | ||
if (operacao == "Alunos") { | ||
caminho(id); | ||
} else if (operacao == "Exercicios") { | ||
caminho(id + 1); | ||
} else if (operacao == "Treinos") { | ||
caminho(id + 2); | ||
} | ||
} | ||
|
||
public static void caminho(int id) { | ||
ControladorRedirecionar.padrao.setVisible(false); | ||
esconderTelas(); | ||
|
||
if (id == 1) { | ||
operarTela(id, ControladorRedirecionar.padrao); | ||
} else if (id == 2) { | ||
PanelCadastroAluno cadastroA = new PanelCadastroAluno(); | ||
operarTela(id, cadastroA); | ||
} else if (id == 3) { | ||
PanelCadastroExercicio cadastroE = new PanelCadastroExercicio(); | ||
operarTela(id, cadastroE); | ||
} else if (id == 4) { | ||
PanelCadastroTreino cadastroT = new PanelCadastroTreino(); | ||
operarTela(id, cadastroT); | ||
} else if (id == 5) { | ||
PanelBuscaAluno buscaA = new PanelBuscaAluno(); | ||
operarTela(id, buscaA); | ||
} else if (id == 6) { | ||
PanelListarExercicios listarE = new PanelListarExercicios(); | ||
operarTela(id, listarE); | ||
} else if (id == 7) { | ||
PanelConsultaTreino consultaT = new PanelConsultaTreino(); | ||
operarTela(id, consultaT); | ||
} | ||
|
||
} | ||
|
||
public static void operarTela(int id, JPanel elemento) { | ||
telas[id - 1] = elemento; | ||
ControladorRedirecionar.tela.add(elemento); | ||
elemento.setVisible(true); | ||
} | ||
|
||
public static void esconderTelas() { | ||
for (JPanel telaCriada : telas) { | ||
if (telaCriada != null) { | ||
telaCriada.setVisible(false); | ||
} | ||
} | ||
} | ||
|
||
public static JPanel getTela() { | ||
return tela; | ||
} | ||
|
||
public static void setTela(JPanel tela) { | ||
ControladorRedirecionar.tela = tela; | ||
} | ||
|
||
public static JPanel getPadrao() { | ||
return padrao; | ||
} | ||
|
||
public static void setPadrao(JPanel padrao) { | ||
ControladorRedirecionar.padrao = padrao; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
SistemaDeAcademia/src/Controladores/ControladorTelaBuscaAluno.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package Controladores; | ||
|
||
import java.awt.Image; | ||
import java.awt.Toolkit; | ||
|
||
import javax.swing.ImageIcon; | ||
|
||
import Modelo.Aluno; | ||
import Visao.PanelBuscaAluno; | ||
import Visao.PanelEditarAluno; | ||
import Visao.PanelMenu; | ||
|
||
public class ControladorTelaBuscaAluno { | ||
|
||
private PanelBuscaAluno tela; | ||
private Aluno aluno; | ||
|
||
public ControladorTelaBuscaAluno(PanelBuscaAluno tela) { | ||
this.tela = tela; | ||
} | ||
|
||
public void acaoPerformada(Object e) { | ||
if (e == tela.getBtnBuscar()) { | ||
|
||
aluno = Aluno.getUmAluno(tela.getTextField().getText()); | ||
if (aluno == null) { | ||
tela.getPanelNaoEncontrado().setVisible(true); | ||
tela.getPanelInfo().setVisible(false); | ||
} else { | ||
tela.getPanelNaoEncontrado().setVisible(false); | ||
alterarInformacoes(); | ||
tela.getPanelInfo().setVisible(true); | ||
} | ||
|
||
} else if (e == tela.getBtnDeletar()) { | ||
|
||
if (aluno != null) { | ||
aluno.deletar(); | ||
ControladorRedirecionar.caminho(1); | ||
} | ||
|
||
} else if (e == tela.getBtnEditar()) { | ||
PanelEditarAluno panelEditarA = new PanelEditarAluno(aluno); | ||
tela.add(panelEditarA); | ||
panelEditarA.setVisible(true); | ||
tela.getPanelbase().setVisible(false); | ||
|
||
} else if (e == tela.getBtnVoltar()) { | ||
ControladorRedirecionar.caminho(1); | ||
} | ||
} | ||
|
||
public void alterarInformacoes() { | ||
|
||
tela.getLblIMCPessoa() | ||
.setIcon(new ImageIcon(Toolkit.getDefaultToolkit() | ||
.getImage(PanelMenu.class | ||
.getResource("/Imagens/" + aluno.calcularParametro().replaceAll(" ", "_") + ".png")) | ||
.getScaledInstance(160, 160, Image.SCALE_SMOOTH))); | ||
tela.getLblTreinos().setText("Treinos"); | ||
tela.getLblNome().setText("Nome:" + aluno.getPrimeiroNome()); | ||
tela.getLblAltura().setText("Altura:\r" + aluno.getAltura()); | ||
tela.getLblIMC().setText(String.format("IMC:%.2f", aluno.calcularImc())); | ||
tela.getLblPeso().setText("Peso:\r" + aluno.getPeso()); | ||
tela.getLblTreinos(); | ||
tela.getLblIdade().setText("Idade:\r" + aluno.getIdade()); | ||
tela.getSituacao().setText(aluno.calcularParametro()); | ||
tela.getListTreinos().setModel(aluno.pegarNomesTreino()); | ||
tela.getLblIMCPessoa().setVisible(true); | ||
tela.getListTreinos().setVisible(true); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
SistemaDeAcademia/src/Controladores/ControladorTelaCadastroAluno.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package Controladores; | ||
|
||
import Modelo.Aluno; | ||
import Visao.PanelCadastroAluno; | ||
|
||
public class ControladorTelaCadastroAluno { | ||
|
||
private PanelCadastroAluno tela; | ||
|
||
public ControladorTelaCadastroAluno(PanelCadastroAluno tela) { | ||
this.tela = tela; | ||
} | ||
|
||
public void acaoPerformada(Object e) { | ||
if (e == tela.getBtnCadastrar()) { | ||
if (((tela.getTextNomeAluno().getText().isEmpty() == false) | ||
&& (tela.getTextNomeAluno().getText().isBlank() == false) | ||
&& (Aluno.getUmAluno(tela.getTextNomeAluno().getText())) == null)) { | ||
|
||
cadastrarAluno(tela.getTextNomeAluno().getText(), (int) tela.getSpinIdade().getValue(), | ||
(double) tela.getSpinAltura().getValue(), (double) tela.getSpinPeso().getValue()); | ||
ControladorRedirecionar.caminho(1); | ||
} | ||
} else if (e == tela.getBtnVoltar()) { | ||
ControladorRedirecionar.caminho(1); | ||
} | ||
} | ||
|
||
public void cadastrarAluno(String nome, int idade, double altura, double peso) { | ||
Aluno aluno = new Aluno(nome, idade, altura, peso); | ||
aluno.cadastro(); | ||
} | ||
} |
Oops, something went wrong.
0138286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like