Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Gheovgos authored Feb 14, 2022
1 parent 9dbb7ac commit 2bfbe21
Show file tree
Hide file tree
Showing 21 changed files with 1,627 additions and 152 deletions.
1 change: 1 addition & 0 deletions java/src/Database/ConnessioneDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ public static ConnessioneDatabase getInstance() throws SQLException {
}
return instance;
}

}
161 changes: 161 additions & 0 deletions java/src/GUI/CercaCorso.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package GUI;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.MatteBorder;

import controller.Controller;

public class CercaCorso {

private JFrame frame;
Controller controller;

public CercaCorso(Controller c) {
controller = c;
initialize();
frame.setVisible(true);
}


private void initialize() {
frame = new JFrame();
frame.setTitle("Manabi");
frame.setIconImage(Toolkit.getDefaultToolkit().getImage(VisualizzaTestDaCompilare.class.getResource("/Immagini/icona manabi.png")));
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 609, 599);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
String[] mat = controller.returnAllMat();
String[] rs = controller.returnAllTestName();

int max = rs.length;
controller.caricaTest(rs[0]);
controller.caricaInsegnante(controller.t.creatoreTest);


String tempo = controller.t.tempo.toString();
tempo = tempo.substring(11, 19);

JTextPane txtpnSelezionaCorso = new JTextPane();
txtpnSelezionaCorso.setText("Seleziona corso");
txtpnSelezionaCorso.setEditable(false);
txtpnSelezionaCorso.setBounds(284, 11, 122, 20);
frame.getContentPane().add(txtpnSelezionaCorso);

JComboBox comboMat = new JComboBox();
comboMat.setBounds(10, 32, 198, 22);
frame.getContentPane().add(comboMat);
comboMat.setMaximumRowCount(mat.length);
comboMat.setModel(new DefaultComboBoxModel(mat));


JComboBox comboBox = new JComboBox();

comboBox.setMaximumRowCount(max);
comboBox.setModel(new DefaultComboBoxModel(rs));
comboBox.setBounds(284, 32, 299, 22);
frame.getContentPane().add(comboBox);

JTextPane txtpnElencoDeiTest = new JTextPane();
txtpnElencoDeiTest.setText("Seleziona materia:");
txtpnElencoDeiTest.setEditable(false);
txtpnElencoDeiTest.setBounds(10, 11, 299, 20);
frame.getContentPane().add(txtpnElencoDeiTest);

JTextPane textNomeTest = new JTextPane();
textNomeTest.setEditable(false);
textNomeTest.setBorder(null);
textNomeTest.setText("Nome test: "+controller.t.nomeTest);
textNomeTest.setBounds(10, 84, 198, 43);
frame.getContentPane().add(textNomeTest);

JTextPane txtpnTempo = new JTextPane();
txtpnTempo.setText("Tempo: "+tempo);
txtpnTempo.setEditable(false);
txtpnTempo.setBounds(383, 84, 200, 20);
frame.getContentPane().add(txtpnTempo);

JEditorPane editorDescrizione = new JEditorPane();
editorDescrizione.setEditable(false);
editorDescrizione.setText(controller.t.descrizione);
editorDescrizione.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
editorDescrizione.setBounds(10, 181, 573, 292);
frame.getContentPane().add(editorDescrizione);

JTextPane textDesc = new JTextPane();
textDesc.setText("Descrizione:");
textDesc.setEditable(false);
textDesc.setBounds(10, 150, 82, 20);
frame.getContentPane().add(textDesc);

JTextPane editorMateria = new JTextPane();
editorMateria.setEditable(false);
editorMateria.setBorder(null);
editorMateria.setText("Autore: "+controller.i.cognome+" "+controller.i.nome);
editorMateria.setBounds(218, 84, 149, 43);
frame.getContentPane().add(editorMateria);

JButton btnNewButton = new JButton("Indietro");
btnNewButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
frame.setVisible(false);
}
});
btnNewButton.setBounds(10, 526, 89, 23);
frame.getContentPane().add(btnNewButton);


JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon(VisualizzaTestInsegnante.class.getResource("/Immagini/SFONDO TUTTO.png")));
lblNewLabel.setBounds(102, 0, 823, 602);
frame.getContentPane().add(lblNewLabel);

comboBox.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
int selected = 0;
selected = comboBox.getSelectedIndex();
controller.caricaTest(rs[selected]);

String tempo = controller.t.tempo.toString();
tempo = tempo.substring(11, 19); textNomeTest.setText("Nome Test: "+controller.t.nomeTest); editorDescrizione.setText(controller.t.descrizione);
txtpnTempo.setText("Tempo: "+tempo); editorMateria.setText("Autore: "+controller.i.cognome+" "+controller.i.nome); }
});

comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {

int selected = 0;
selected = comboBox.getSelectedIndex();
controller.caricaTest(rs[selected]);

String tempo = controller.t.tempo.toString();
tempo = tempo.substring(11, 19);
textNomeTest.setText("Nome Test: "+controller.t.nomeTest); editorDescrizione.setText(controller.t.descrizione);
txtpnTempo.setText("Tempo: "+tempo); editorMateria.setText("Autore: "+controller.i.cognome+" "+controller.i.nome);


}
});

}
}

3 changes: 3 additions & 0 deletions java/src/GUI/CompilaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private void initialize() {

Ttempo = new JTextField();
Ttempo.setText("Tempo rimanente: "+controller.t.tempo.getTime());
Ttempo.setVisible(false);
Ttempo.setEditable(false);
Ttempo.setBounds(603, 11, 186, 20);
frame.getContentPane().add(Ttempo);
Expand Down Expand Up @@ -184,6 +185,7 @@ public void mouseClicked(MouseEvent e) {
progresso--;
frame.setVisible(false);
TestCompletato next = new TestCompletato(controller);
return;
}

textDomanda.setText(controller.t.quesiti[progresso].domanda);
Expand Down Expand Up @@ -237,6 +239,7 @@ public void mouseClicked(MouseEvent e) {
progresso--;
frame.setVisible(false);
TestCompletato next = new TestCompletato(controller);
return;
}
textDomanda.setText(controller.t.quesiti[progresso].domanda);

Expand Down
52 changes: 35 additions & 17 deletions java/src/GUI/DBSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
import java.sql.SQLException;

import javax.swing.SwingConstants;
import java.awt.Toolkit;
import javax.swing.border.LineBorder;

public class DBSettings {

JFrame frame;
private JTextField textOutput;
private JTextPane textOutput;
Controller controller;
private JTextField getUrl;
private JTextField getPass;

public DBSettings(Controller c) {
controller = c;
Expand All @@ -28,6 +32,8 @@ public DBSettings(Controller c) {

private void initialize() {
frame = new JFrame();
frame.setIconImage(Toolkit.getDefaultToolkit().getImage(DBSettings.class.getResource("/Immagini/icona manabi.png")));
frame.setTitle("Manabi");
frame.getContentPane().setBackground(Color.WHITE);
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Expand All @@ -50,33 +56,28 @@ public void mouseClicked(MouseEvent e) {
btnBack.setBounds(10, 227, 89, 23);
frame.getContentPane().add(btnBack);

textOutput = new JTextField();
textOutput = new JTextPane();
textOutput.setBorder(new LineBorder(new Color(0, 0, 0)));
textOutput.setToolTipText("Console di Output");
textOutput.setHorizontalAlignment(SwingConstants.LEFT);


textOutput.setEditable(false);
textOutput.setBounds(10, 73, 414, 130);
frame.getContentPane().add(textOutput);
textOutput.setColumns(10);

JButton nuovoDB = new JButton("Crea DB");
nuovoDB.setToolTipText("Se la verifica fallisce, premere qui per la creazione di un nuovo Database.");
nuovoDB.setEnabled(false);
nuovoDB.setBounds(335, 227, 89, 23);
frame.getContentPane().add(nuovoDB);

JButton btnNewButton = new JButton("Test connessione");
btnNewButton.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {


try {
if(controller.checkConnection()) {

textOutput.setText("Connessione effettuata con successo.\nNome: "+controller.connessione.nome+"\nConnessione: "+controller.connessione.url+"\nDriver: "+controller.connessione.driver);
textOutput.setText("Connessione effettuata con successo.\r\nNome: "+controller.connessione.nome+"\r\nConnessione: "+controller.connessione.url+"\r\nDriver: "+controller.connessione.driver);

}
else {textOutput.setText("Connessione al Database fallita. Clicca su 'Crea nuovo database' per creare un nuovo DB."); nuovoDB.setEnabled(false);}
else {textOutput.setText("Connessione al Database fallita.");}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Expand All @@ -88,12 +89,29 @@ public void mouseClicked(MouseEvent e) {
btnNewButton.setBounds(20, 42, 138, 23);
frame.getContentPane().add(btnNewButton);

getUrl = new JTextField();
getUrl.setText("jdbc:postgresql://localhost:5432/Manabi");
getUrl.setBounds(286, 11, 138, 20);
frame.getContentPane().add(getUrl);
getUrl.setColumns(10);

nuovoDB.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
}
});
getPass = new JTextField();
getPass.setText("admin");
getPass.setColumns(10);
getPass.setBounds(286, 43, 138, 20);
frame.getContentPane().add(getPass);

JTextPane txtpnInserisciUrl = new JTextPane();
txtpnInserisciUrl.setEditable(false);
txtpnInserisciUrl.setText("Inserisci URL:");
txtpnInserisciUrl.setBounds(181, 11, 77, 20);
frame.getContentPane().add(txtpnInserisciUrl);

JTextPane txtpnInserisciPassword = new JTextPane();
txtpnInserisciPassword.setEditable(false);
txtpnInserisciPassword.setText("Inserisci password:");
txtpnInserisciPassword.setBounds(181, 42, 99, 20);
frame.getContentPane().add(txtpnInserisciPassword);


}
Expand Down
47 changes: 20 additions & 27 deletions java/src/GUI/MenuInsegnante.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package GUI;

import java.awt.EventQueue;

import controller.*;
import modelli.Quesiti;
import modelli.Test;

import javax.swing.JFrame;
import javax.swing.JTextField;
Expand All @@ -19,6 +17,7 @@
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.EmptyBorder;

public class MenuInsegnante {

Expand All @@ -29,8 +28,6 @@ public class MenuInsegnante {
private JTextField txtCreaQuesito;
private JTextField txtVisualizzaTest;
private JTextField txtCorreggiTest;
private JTextField txtNonHaiCreato;
private JTextField txtNonHaiCreato_1;

public MenuInsegnante(Controller c) {
controller = c;
Expand Down Expand Up @@ -65,6 +62,7 @@ private void initialize() {
frame.getContentPane().add(txtCreaTest);

txtBenvenuto = new JTextField();
txtBenvenuto.setBorder(new EmptyBorder(0, 0, 0, 0));
txtBenvenuto.setBackground(Color.WHITE);
txtBenvenuto.setEditable(false);
txtBenvenuto.setText("Benvenuto, "+controller.i.username);
Expand Down Expand Up @@ -92,6 +90,15 @@ public void mouseClicked(MouseEvent e) {
frame.getContentPane().add(creaTest);

JButton vediTest = new JButton("");
vediTest.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
frame.setVisible(false);
@SuppressWarnings("unused")
VisualizzaTestInsegnante next = new VisualizzaTestInsegnante(controller);


}
});
vediTest.setBackground(new Color(255, 255, 102));
vediTest.setBorderPainted(false);
vediTest.setIcon(new ImageIcon(MenuInsegnante.class.getResource("/Immagini/photo5778473851175418934.jpg")));
Expand Down Expand Up @@ -145,6 +152,14 @@ public void mouseClicked(MouseEvent e) {
frame.getContentPane().add(logout);

JButton apriSettings = new JButton("");
apriSettings.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@SuppressWarnings("unused")
UserSettings next = new UserSettings(controller, true);
}
});
apriSettings.setBorder(new EmptyBorder(0, 0, 0, 0));
apriSettings.setContentAreaFilled(false);
apriSettings.setBorderPainted(false);
apriSettings.setIcon(new ImageIcon(MenuInsegnante.class.getResource("/Immagini/settings.png")));
Expand Down Expand Up @@ -183,27 +198,5 @@ public void mouseClicked(MouseEvent e) {
txtCorreggiTest.setColumns(10);
txtCorreggiTest.setBounds(473, 495, 149, 20);
frame.getContentPane().add(txtCorreggiTest);

txtNonHaiCreato = new JTextField();
txtNonHaiCreato.setForeground(new Color(255, 99, 71));
txtNonHaiCreato.setFont(new Font("Tahoma", Font.BOLD, 11));
txtNonHaiCreato.setOpaque(false);
txtNonHaiCreato.setBorder(null);
txtNonHaiCreato.setEditable(false);
txtNonHaiCreato.setText("Non hai creato ancora nessun test! Prima di poterlo visualizzare devi crearne uno.");
txtNonHaiCreato.setBounds(139, 526, 471, 20);
frame.getContentPane().add(txtNonHaiCreato);
txtNonHaiCreato.setColumns(10);

txtNonHaiCreato_1 = new JTextField();
txtNonHaiCreato_1.setText("Non hai creato ancora nessun test! Prima di poter aggiungere quesiti devi crearlo.");
txtNonHaiCreato_1.setOpaque(false);
txtNonHaiCreato_1.setForeground(new Color(255, 99, 71));
txtNonHaiCreato_1.setFont(new Font("Tahoma", Font.BOLD, 11));
txtNonHaiCreato_1.setEditable(false);
txtNonHaiCreato_1.setColumns(10);
txtNonHaiCreato_1.setBorder(null);
txtNonHaiCreato_1.setBounds(139, 540, 471, 20);
frame.getContentPane().add(txtNonHaiCreato_1);
}
}
Loading

0 comments on commit 2bfbe21

Please sign in to comment.