MAJ V1.0.1 (JRE 1.8 with JDK 1.8.0_271)

This commit is contained in:
pablo rodriguez 2023-07-02 11:46:31 +02:00
parent fcb98675d9
commit e3edd431d4
16 changed files with 403 additions and 50 deletions

BIN
Base.xlsx

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

1
base_sauvegarde.xml Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,46 @@
package baseUFRHG;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
public class ExempleMAJ extends JFrame{
private JFrame frame;
public ExempleMAJ() {
init();
}
/**
*
*/
private static final long serialVersionUID = 1L;
public void init() {
frame = new JFrame();
frame.setTitle("Gestion des inscriptions et des groupes - langues - informatique - stage - rentrée");
frame.setBounds(100, 100, 1000, 600);
int screenWidth = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getWidth();
int screenHeight = (int) java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getHeight();
frame.setLocation(( (screenWidth) - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setIcon(new ImageIcon(ExempleMAJ.class.getResource("/resources/Exemple de mise à jour.png")));
frame.getContentPane().add(lblNewLabel, BorderLayout.CENTER);
ImageIcon img = new ImageIcon(demarre.class.getResource("/resources/logo.png"));
frame.setIconImage(img.getImage());
frame.setResizable(false);
frame.setVisible(true);
}
}

View File

@ -156,16 +156,16 @@ public class createEmargement extends JFrame{
Row row4 = sheet.createRow(4);
Cell cell4 = row4.createCell(1);
cell4.setCellValue("Numéro");
cell4.setCellValue("NUMÉRO");
cell4.setCellStyle(blueCellStyle);
Cell cell5 = row4.createCell(2);
cell5.setCellValue("Nom");
cell5.setCellValue("NOM");
cell5.setCellStyle(blueCellStyle);
Cell cell6 = row4.createCell(3);
cell6.setCellValue("Prénom");
cell6.setCellValue("PRÉNOM");
cell6.setCellStyle(blueCellStyle);
Cell cell7 = row4.createCell(4);
@ -188,11 +188,11 @@ public class createEmargement extends JFrame{
cell.setCellStyle(cellStyle);
cell = row.createCell(2);
cell.setCellValue(String.valueOf(rowData[3]));
cell.setCellValue(String.valueOf(rowData[3]).toUpperCase());
cell.setCellStyle(cellStyle);
cell = row.createCell(3);
cell.setCellValue(String.valueOf(rowData[2]));
cell.setCellValue(String.valueOf(rowData[2]).toUpperCase());
cell.setCellStyle(cellStyle);
cell = row.createCell(4);
@ -208,8 +208,8 @@ public class createEmargement extends JFrame{
int widthInCharsB = (int) (2 * 256 / 0.146);
sheet.setColumnWidth(1, widthInCharsB);
// Définir la largeur de la colonne E (5 cm)
int widthInCharsE = (int) (5 * 256 / 0.146);
// Définir la largeur de la colonne E (6 cm)
int widthInCharsE = (int) (6 * 256 / 0.146);
sheet.setColumnWidth(4, widthInCharsE);
sheet.autoSizeColumn(0);

View File

@ -1,9 +1,14 @@
package baseUFRHG;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JButton;
@ -30,6 +35,22 @@ public class demarre extends JFrame {
try {
demarre window = new demarre();
window.frmEvalwriter.setVisible(true);
// Créez un Timer
Timer timer = new Timer();
// Créez une tâche de sauvegarde automatique
TimerTask autoSaveTask = new TimerTask() {
@Override
public void run() {
// Appeler la méthode de sauvegarde ici
sauvegardeXMLBase.saveSauvegarde(commandes.nBase);
}
};
// Planifiez la tâche de sauvegarde automatique à exécuter toutes les 5 minutes 5 * 60 * 1000
timer.schedule(autoSaveTask, 0, 300000);
} catch (Exception e) {
e.printStackTrace();
}
@ -37,9 +58,6 @@ public class demarre extends JFrame {
public demarre() {
commandes.nBase = recupeBases.recupeLaBase();
initialize();
}
@ -62,6 +80,8 @@ public class demarre extends JFrame {
ImageIcon img = new ImageIcon(demarre.class.getResource("/resources/logo.png"));
frmEvalwriter.setIconImage(img.getImage());
frmEvalwriter.setResizable(false);
btnCreate = new JButton("Exporter toute la base dans un classeur MS Excel (base.xlsx)");
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")));
btnCreate.addActionListener(new ActionListener() {
@ -175,12 +195,28 @@ public class demarre extends JFrame {
JButton btnNAideMiseAJour = new JButton("Aide à la mise en jour");
btnNAideMiseAJour.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new ExempleMAJ();
}
});
btnNAideMiseAJour.setFont(new Font("Tahoma", Font.BOLD, 12));
btnNAideMiseAJour.setBounds(10, 378, 356, 30);
frmEvalwriter.getContentPane().add(btnNAideMiseAJour);
// Ajoutez un WindowListener à la fenêtre principale
frmEvalwriter.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// Parcourez tous les secondaryFrame existants et fermez-les
for (Window window : Window.getWindows()) {
if (window instanceof JFrame && window != demarre.this) {
window.dispose();
}
}
System.exit(0);
}
});
}

View File

@ -1,6 +1,8 @@
package baseUFRHG;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@ -199,8 +201,9 @@ public class exportBaseToExcel {
data[0][28] = data1;
indexStudent++;
}
// Trier le data1 par ordre aphabétique de la troisième colonne (les noms)
Arrays.sort(data1, Comparator.comparing(row -> row[3]));
if(data.length>0) {

View File

@ -19,6 +19,7 @@ import java.util.Map;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JFrame;
@ -30,6 +31,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
@ -39,16 +41,17 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import baseUFRHG.sauvegardeXMLBase.saveType;
import baseUFRHG.actions.exportEmargement;
import baseUFRHG.actions.exportTable;
import baseUFRHG.actions.saveTable;
import javax.swing.JButton;
import javax.swing.JTextPane;
public class gestionnaire extends JFrame {
@ -90,6 +93,8 @@ public class gestionnaire extends JFrame {
private String defautYear = null;
public noeud nTable = null;
String oldValue = null;
List<String> prefereAffichage = new ArrayList<>();
@ -135,8 +140,10 @@ public class gestionnaire extends JFrame {
table = new JTable();
table.setFont(new Font("Arial", Font.PLAIN, 16));
table.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setRowHeight(20);
for(noeud nChild : commandes.nBase.getChildren()) {
cYears.addItem(nChild.getName());
@ -246,8 +253,6 @@ public class gestionnaire extends JFrame {
}
});
menuAffichage.addSeparator();
@ -329,8 +334,8 @@ public class gestionnaire extends JFrame {
JMenuItem exportItem = menuExport.add(new exportTable(this));
menuExport.add(exportItem);
menuExport.addSeparator();
JMenuItem saveItem = menuExport.add(new exportEmargement(this));
menuExport.add(saveItem);
JMenuItem emargement = menuExport.add(new exportEmargement(this));
menuExport.add(emargement);
menuBar.add(menuExport);
@ -477,7 +482,7 @@ public class gestionnaire extends JFrame {
panelSouth.add(lblInformation);
lblInformationStudent.setForeground(new Color(255, 255, 128));
lblInformationStudent.setFont(new Font("Tahoma", Font.PLAIN, 12));
lblInformationStudent.setFont(new Font("Tahoma", Font.BOLD, 20));
lblInformationStudent.setAlignmentY(1.0f);
panelSouth.add(lblInformationStudent);
@ -562,40 +567,60 @@ public class gestionnaire extends JFrame {
});
// Ajout d'un ListSelectionListener pour détecter la sélection de la ligne
// Ajout d'un ListSelectionListener pour détecter la sélection de la ligne et de la colonne
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
int selectedRow = table.getSelectedRow();
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
if (selectedRow != -1 && selectedColumn != -1) {
if(table.getValueAt(selectedRow, selectedColumn)!=null) {
oldValue = table.getValueAt(selectedRow, selectedColumn).toString();
}else {
oldValue=null;
}
}
if (selectedRow != -1) {
// Récupération des données de la ligne sélectionnée
Object[] rowData = new Object[table.getColumnCount()];
Map<String,Integer> head = getMapNamesColumnsIndexColumns();
for (int i = 0; i < table.getColumnCount(); i++) {
rowData[i] = table.getValueAt(selectedRow, i);
}
// Concaténation des valeurs de la ligne dans une chaîne de caractères
// StringBuilder sb = new StringBuilder();
// for (Object value : rowData) {
// sb.append(value).append(", ");
// }
// sb.delete(sb.length() - 2, sb.length()); // Suppression de la virgule finale
// String rowDataString = sb.toString();
// Mise à jour de la JLabel avec les données de la ligne sélectionnée
// lblInformationStudent.setText("<html><p>Ligne : " + selectedRow + "<br> " + table.getValueAt(selectedRow, 16) + " " + table.getValueAt(selectedRow, 15)
// + " - - Groupe TD : " + table.getValueAt(selectedRow, 10)
// + " - - Groupe Langue : "+ table.getValueAt(selectedRow, 7)
// + " - - Groupe Informatique : " + table.getValueAt(selectedRow, 6) +"</p></html>");
int indexCode = head.get("Individu_-_Code_Etudiant");
int indexNom = head.get("Individu_-_Nom");
int indexPrenom = head.get("Individu_-_Prenom");
if(rowData[indexPrenom]!=null && rowData[indexNom]!=null && rowData[indexCode]!=null) {
lblInformationStudent.setText(rowData[indexPrenom].toString() + " " + rowData[indexNom].toString() + " - " + rowData[indexCode].toString() );
}else {
lblInformationStudent.setText("");
}
}
}
}
});
// Ajout d'un écouteur de modification de cellule
table.getModel().addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.UPDATE) {
int row = e.getFirstRow();
int column = e.getColumn();
Object newValue = table.getValueAt(row, column);
System.out.println("Valeur avant modification : " + oldValue);
System.out.println("Valeur après modification : " + newValue);
}
}
});
majTableFormation();
majTableGroupes();
@ -817,6 +842,8 @@ public class gestionnaire extends JFrame {
*/
public void majTableGroupes() {
lblInformationStudent.setText("");
String pasChoisi = " - ";
String GroupeTD = (String) cGroupeTD.getSelectedItem();
String LV1 = (String) cLV1.getSelectedItem();
@ -1070,7 +1097,20 @@ public class gestionnaire extends JFrame {
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
// Obtention de la colonne à l'index donné
table.getColumnModel().getColumn(columnIndex).setPreferredWidth(getMaxColumnWidth(table, columnIndex));
}
}
// for (int row = 0; row < table.getRowCount(); row++) {
// int rowHeight = table.getRowHeight(); // Hauteur par défaut
// for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
// TableCellRenderer cellRenderer = table.getCellRenderer(row, columnIndex);
// Component comp = table.prepareRenderer(cellRenderer, row, columnIndex);
// int cellHeight = comp.getPreferredSize().height;
// rowHeight = Math.max(rowHeight, cellHeight);
// table.getColumnModel().getColumn(columnIndex).setPreferredWidth(getMaxColumnWidth(table, columnIndex));
// }
// table.setRowHeight(row, rowHeight);
// }
// Ajouter un écouteur de modification de cellule à la table
table.getModel().addTableModelListener(e -> {
@ -1078,6 +1118,14 @@ public class gestionnaire extends JFrame {
int column = e.getColumn();
if (row != -1 && column != -1) {
String key = getColumnsName()[column];
if(key.equals("IAE_-_Etape_lib.") || key.equals("Individu_-_Code_Etudiant")
|| key.equals("Individu_-_Email")) {
JOptionPane.showMessageDialog(null, "<html>Impossible de modifier ce contenu.<br>"
+ "Actualisez la table pour ne plus voir votre saisie.</html>", "Erreur", JOptionPane.ERROR_MESSAGE);
return;
}
String value = (String) table.getValueAt(row, column);
// Obtenir l'indice de la colonne "Individu_-_Code_Etudiant"
@ -1099,7 +1147,7 @@ public class gestionnaire extends JFrame {
}
}else {
JOptionPane.showMessageDialog(null, "Le contenu ne doit pas être composé d'espace.", "Erreur", JOptionPane.ERROR_MESSAGE);
table.setValueAt("", row, column);
table.setValueAt(oldValue, row, column);
}
majTableFormation();
@ -1168,4 +1216,21 @@ public class gestionnaire extends JFrame {
}
return columnNames;
}
private Map<String, Integer> getMapNamesColumnsIndexColumns(){
// Obtenir le modèle de la table
TableModel model = table.getModel();
// Obtenir le nombre de colonnes dans le modèle
int columnCount = model.getColumnCount();
// Créer un tableau pour stocker les en-têtes de colonne
Map<String,Integer> MapColumnNames = new HashMap<String,Integer>();
// Récupérer les en-têtes de colonne à partir du modèle
for (int i = 0; i < columnCount; i++) {
MapColumnNames.put(model.getColumnName(i), i);
}
return MapColumnNames;
}
}

View File

@ -79,28 +79,34 @@ public class importAllBaseToExcel {
if (cellType == CellType.STRING) {
String cellValue = cell.getStringCellValue();
String value = nStudent.getAttributes(sheet.getRow(0).getCell(indexCol).getStringCellValue());
boolean isOnlySpaces = value.matches("\\s+");
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
if(value!=null) {
boolean isOnlySpaces = value.matches("\\s+");
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
}
}
System.out.print(cellValue + " ");
} else if (cellType == CellType.NUMERIC) {
String cellValue = String.valueOf( (int) cell.getNumericCellValue());
String value = nStudent.getAttributes(sheet.getRow(0).getCell(indexCol).getStringCellValue());
boolean isOnlySpaces = value.matches("\\s+");
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
if(value!=null) {
boolean isOnlySpaces = value.matches("\\s+");
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
}
}
System.out.print(cellValue + " ");
} else if (cellType == CellType.BOOLEAN) {
String cellValue = String.valueOf(cell.getBooleanCellValue());
String value = nStudent.getAttributes(sheet.getRow(0).getCell(indexCol).getStringCellValue());
boolean isOnlySpaces = value.matches("\\s+");
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
if(value!=null) {
if(!isOnlySpaces)if(!cellValue.equals(value)) {
nStudent.setAttribut(sheet.getRow(0).getCell(indexCol).getStringCellValue(), cellValue);
compteur++;
}
}
System.out.print(cellValue + " ");
} else {

View File

@ -32,6 +32,21 @@ public class sauvegardeXMLBase {
}
public static void saveSauvegarde(noeud nBase) {
// Sauvegarde de la base
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base_sauvegarde.xml";
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
writer.write(nBase.toWrite());
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode saveSauvegarde.", JOptionPane.ERROR_MESSAGE);
}
}
public static void saveModif(noeud nBase, Integer nbreModif) {
// Sauvegarde de la base
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB