Transférer les fichiers vers 'src/Test'
This commit is contained in:
parent
848b195beb
commit
b9bb272720
@ -4,6 +4,9 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* La fenêtre principale contenant les vues
|
||||||
|
*/
|
||||||
public class MainMenu extends JFrame {
|
public class MainMenu extends JFrame {
|
||||||
public static final int MENU = 0, ADMIN = 1, PROF = 2, STUDENT = 3;
|
public static final int MENU = 0, ADMIN = 1, PROF = 2, STUDENT = 3;
|
||||||
private static final int FULL = 4, WINDOW = 5;
|
private static final int FULL = 4, WINDOW = 5;
|
||||||
@ -29,7 +32,10 @@ public class MainMenu extends JFrame {
|
|||||||
new CustomJButton(viewName[2])
|
new CustomJButton(viewName[2])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur de base
|
||||||
|
* @param listener controller initialisé dans le main
|
||||||
|
*/
|
||||||
public MainMenu(Controller listener) {
|
public MainMenu(Controller listener) {
|
||||||
super();
|
super();
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
@ -39,6 +45,12 @@ public class MainMenu extends JFrame {
|
|||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construit un objet MainMenu sur la vue sélectionnée et le mode d'affichage choisi
|
||||||
|
* @param listener controller initialisé dans le main
|
||||||
|
* @param selectedView vue à afficher
|
||||||
|
* @param screenStyle disposition d'affichage plein écran ou fenêtré
|
||||||
|
*/
|
||||||
public MainMenu(Controller listener, int selectedView, int screenStyle) {
|
public MainMenu(Controller listener, int selectedView, int screenStyle) {
|
||||||
super();
|
super();
|
||||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
@ -53,7 +65,10 @@ public class MainMenu extends JFrame {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change le mode d'affichage
|
||||||
|
* @param screenStyle
|
||||||
|
*/
|
||||||
private void setScreenStyle(int screenStyle) {
|
private void setScreenStyle(int screenStyle) {
|
||||||
if (screenStyle == FULL) {
|
if (screenStyle == FULL) {
|
||||||
this.setUndecorated(true);
|
this.setUndecorated(true);
|
||||||
@ -65,7 +80,10 @@ public class MainMenu extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise les paramètres de la fenêtre
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
private void init(Controller listener) {
|
private void init(Controller listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
@ -86,7 +104,9 @@ public class MainMenu extends JFrame {
|
|||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée le bar de menu
|
||||||
|
*/
|
||||||
private void createJMenuBar() {
|
private void createJMenuBar() {
|
||||||
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("Affichage");
|
JMenu menu = new JMenu("Menu"), file = new JMenu("File"), edit = new JMenu("Edit"), view = new JMenu("Affichage");
|
||||||
|
|
||||||
@ -131,7 +151,10 @@ public class MainMenu extends JFrame {
|
|||||||
this.setJMenuBar(menuBar);
|
this.setJMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passe la fenêtre en plein écran
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
private void setFullScreen(ActionEvent e) {
|
private void setFullScreen(ActionEvent e) {
|
||||||
if (screenStatus != FULL) {
|
if (screenStatus != FULL) {
|
||||||
this.dispose();
|
this.dispose();
|
||||||
@ -139,7 +162,10 @@ public class MainMenu extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passe la fenêtre en fenêtré
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
private void unsetFullScreen(ActionEvent e) {
|
private void unsetFullScreen(ActionEvent e) {
|
||||||
if (screenStatus != WINDOW) {
|
if (screenStatus != WINDOW) {
|
||||||
this.dispose();
|
this.dispose();
|
||||||
@ -147,13 +173,21 @@ public class MainMenu extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renvoie au menu principal
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
private void backtoMainMenu(ActionEvent e) {
|
private void backtoMainMenu(ActionEvent e) {
|
||||||
this.setJMenuBar(null);
|
this.setJMenuBar(null);
|
||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée une vue avec le résultat de la base de données à côté
|
||||||
|
* @param sidePanel actions relatives à l'utilisateur
|
||||||
|
* @param origin
|
||||||
|
* @return panel contenant les boutons et la table
|
||||||
|
*/
|
||||||
private JPanel cardWithTable(JPanel sidePanel, String origin) {
|
private JPanel cardWithTable(JPanel sidePanel, String origin) {
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
@ -181,7 +215,10 @@ public class MainMenu extends JFrame {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permet de naviguer entre les vues
|
||||||
|
* @param index index de la vue
|
||||||
|
*/
|
||||||
private void changeView(int index) {
|
private void changeView(int index) {
|
||||||
table = this.listener.initTable();
|
table = this.listener.initTable();
|
||||||
|
|
||||||
@ -216,7 +253,10 @@ public class MainMenu extends JFrame {
|
|||||||
travelThroughCards(index);
|
travelThroughCards(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Met à jour la table de cet objet
|
||||||
|
* @param table nouvelle table
|
||||||
|
*/
|
||||||
public void updateTable(JTable table) {
|
public void updateTable(JTable table) {
|
||||||
if (cardIndex == 1) {
|
if (cardIndex == 1) {
|
||||||
this.table = table;
|
this.table = table;
|
||||||
@ -233,7 +273,10 @@ public class MainMenu extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée le menu principal
|
||||||
|
* @return panel contenant le menu principal
|
||||||
|
*/
|
||||||
private JPanel firstCard() {
|
private JPanel firstCard() {
|
||||||
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
JPanel mainPanel = new JPanel(), centerPanel = new JPanel();
|
||||||
Dimension buttonDimension = new Dimension(300, 50);
|
Dimension buttonDimension = new Dimension(300, 50);
|
||||||
@ -259,7 +302,10 @@ public class MainMenu extends JFrame {
|
|||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée la vue administrateur
|
||||||
|
* @return panel contenant la vue admin
|
||||||
|
*/
|
||||||
private JPanel adminView() {
|
private JPanel adminView() {
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setLayout(new BorderLayout());
|
mainPanel.setLayout(new BorderLayout());
|
||||||
@ -267,7 +313,10 @@ public class MainMenu extends JFrame {
|
|||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée la vue professeur
|
||||||
|
* @return panel contenant la vue professeur
|
||||||
|
*/
|
||||||
private JPanel profView() {
|
private JPanel profView() {
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setLayout(new BorderLayout());
|
mainPanel.setLayout(new BorderLayout());
|
||||||
@ -275,7 +324,10 @@ public class MainMenu extends JFrame {
|
|||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée la vue étudiant
|
||||||
|
* @return panel contenant la vue étudiant
|
||||||
|
*/
|
||||||
private JPanel studentView() {
|
private JPanel studentView() {
|
||||||
JPanel mainPanel = new JPanel();
|
JPanel mainPanel = new JPanel();
|
||||||
mainPanel.setLayout(new BorderLayout());
|
mainPanel.setLayout(new BorderLayout());
|
||||||
@ -283,7 +335,10 @@ public class MainMenu extends JFrame {
|
|||||||
return mainPanel;
|
return mainPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action réalisée par les boutons du menu principal
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
private void action(ActionEvent e) {
|
private void action(ActionEvent e) {
|
||||||
JButton origin = (JButton) e.getSource();
|
JButton origin = (JButton) e.getSource();
|
||||||
|
|
||||||
@ -296,7 +351,10 @@ public class MainMenu extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise la vue sélectionnée
|
||||||
|
* @param index index de la vue choisie
|
||||||
|
*/
|
||||||
private void initView(int index) {
|
private void initView(int index) {
|
||||||
if (menuBar == null) {
|
if (menuBar == null) {
|
||||||
menuBar = new JMenuBar();
|
menuBar = new JMenuBar();
|
||||||
@ -336,7 +394,6 @@ public class MainMenu extends JFrame {
|
|||||||
travelThroughCards(cardIndex);
|
travelThroughCards(cardIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void travelThroughCards(int index) {
|
private void travelThroughCards(int index) {
|
||||||
cards.first(this.getContentPane());
|
cards.first(this.getContentPane());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user