Skip to content

Commit

Permalink
Limitando número de mensagens de feedback, adicionando mensagem para …
Browse files Browse the repository at this point in the history
…erro do conexão ao BD
  • Loading branch information
IgorFonck committed Oct 29, 2019
1 parent 31de789 commit 507604f
Show file tree
Hide file tree
Showing 7 changed files with 1,479 additions and 18 deletions.
4 changes: 2 additions & 2 deletions build/built-jar.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Mon, 28 Oct 2019 21:10:29 -0300
#Tue, 29 Oct 2019 13:46:56 -0300


C\:\\Users\\Igor\\Documents\\NetBeansProjects\\logicits=
C\:\\Users\\igorfonseca\\Documents\\NetBeansProjects\\logicits=
Binary file modified h2/bdlogicits.mv.db
Binary file not shown.
1,458 changes: 1,458 additions & 0 deletions h2/bdlogicits.trace.db

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nbproject/private/private.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ do.depend=false
do.jar=true
javac.debug=true
javadoc.preview=true
user.properties.file=C:\\Users\\Igor\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
user.properties.file=C:\\Users\\igorfonseca\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
21 changes: 7 additions & 14 deletions src/model/ConexaoDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ public ConexaoDAO() {
* Retorna a conexão.
* Cria a conexão, caso ela ainda não exista. Então, retorna a conexão.
* @return a conexão
* @throws java.sql.SQLException
*/
public static Connection getConexao() {
public static Connection getConexao() throws SQLException {
if (conn == null) {
try {
conn = DriverManager.getConnection(banco, usuario, senha);
System.out.println("Conexão com o BD realizada com sucesso!");
} catch (SQLException ex) {
System.out.println("Erro na conexão: " + ex.getMessage());
}
conn = DriverManager.getConnection(banco, usuario, senha);
System.out.println("Conexão com o BD realizada com sucesso!");
}
return conn;
}
Expand All @@ -45,17 +42,13 @@ public static Connection getConexao() {
* Cria um PreparedStatement a partir do SQL informado.
* @param sql a query
* @return PreparedStatement
* @throws java.sql.SQLException
*/
public static PreparedStatement getPreparedStatement(String sql) {
public static PreparedStatement getPreparedStatement(String sql) throws SQLException {
if (conn == null) {
conn = getConexao();
}
try {
return conn.prepareStatement(sql);
} catch (SQLException ex) {
System.out.println("Erro de SQL: " + ex.getMessage());
}
return null;
return conn.prepareStatement(sql);
}

}
1 change: 1 addition & 0 deletions src/view/jfInicial.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import mdlaf.MaterialLookAndFeel;
Expand Down
11 changes: 10 additions & 1 deletion src/view/jfPrincipal.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import control.Tutor;
import java.awt.CardLayout;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BoxLayout;
Expand Down Expand Up @@ -41,6 +43,7 @@ public class jfPrincipal extends javax.swing.JFrame {
* Creates new form jfPrincipal
*/
public jfPrincipal() {
//this.pilhaFeedback;

initComponents();
setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
Expand Down Expand Up @@ -842,7 +845,7 @@ private void jbHipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:e
if(isHipoteseValida(hip))
novaLinha(hip, "Hipótese");
else
System.out.println("Hipótese inválida.");
novoFeedback("O valor informado para a hipótese não é válido.");
}

}//GEN-LAST:event_jbHipActionPerformed
Expand Down Expand Up @@ -1014,6 +1017,7 @@ private void jbGravarSolucaoActionPerformed(java.awt.event.ActionEvent evt) {//G
private int hipLevel = 0; // Contador de níveis de hipóteses
private Regra regraAtual; // Registra qual regra foi selecionada
private String respostaFinal; // Armazena a conclusão
Queue<JLabel> filaFeedback = new LinkedList<>();

enum Regra {
INTRO_CONJ,
Expand Down Expand Up @@ -1060,8 +1064,13 @@ private void novoFeedback(String mensagem) {
jpListaFeedback.add(novaMensagem);
jpListaFeedback.revalidate();
jpListaFeedback.repaint();
filaFeedback.add(novaMensagem);
if(filaFeedback.size() > 10)
jpListaFeedback.remove(filaFeedback.poll());
}



private void selecionarFormulas(final int numFormulas) {
// Configura texto das linhas selecionadas
textoLinhas = "<html>";
Expand Down

0 comments on commit 507604f

Please sign in to comment.