Maj V1.0.1 (JRE 1.7 with JDK 1.8)

This commit is contained in:
pablo rodriguez 2023-06-29 11:10:32 +02:00
parent 6d51df2a36
commit 11690632e2
18 changed files with 238 additions and 33 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
L2 Histoire.xlsx Normal file

Binary file not shown.

Binary file not shown.

BIN
base.xlsx

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -34,34 +34,38 @@ public class CreateCalcWorkbook extends JFrame{
private ProcessTask processTask;
private JFrame fr;
JPanel panel;
String nameFile;
public CreateCalcWorkbook(Object[][] data){
fr = new JFrame();
fr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
public CreateCalcWorkbook(Object[][] data, String nameFile){
this.nameFile = nameFile;
this.fr = new JFrame();
this.fr.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
fr.setTitle("Création du classeur");
fr.getContentPane().setLayout(new BorderLayout());
this.fr.setTitle("Création du classeur");
this.fr.getContentPane().setLayout(new BorderLayout());
panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setPreferredSize(new Dimension(300, 50));
this.panel = new JPanel();
this.panel.setLayout(new BorderLayout());
this.panel.setPreferredSize(new Dimension(300, 50));
JLabel titleLabel = new JLabel("Processus");
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(titleLabel, BorderLayout.NORTH);
this.panel.add(titleLabel, BorderLayout.NORTH);
progressBar = new JProgressBar(0, data.length);
progressBar.setStringPainted(true);
panel.add(progressBar, BorderLayout.CENTER);
this.progressBar = new JProgressBar(0, data.length);
this.progressBar.setStringPainted(true);
this.panel.add(progressBar, BorderLayout.CENTER);
fr.getContentPane().add(panel, BorderLayout.CENTER);
this.fr.getContentPane().add(panel, BorderLayout.CENTER);
fr.pack();
this.fr.pack();
fr.setLocationRelativeTo(null); // Centre la fenêtre à l'écran
fr.setVisible(true);
this.fr.setLocationRelativeTo(null); // Centre la fenêtre à l'écran
this.fr.setVisible(true);
fr.setVisible(true);
this.fr.setVisible(true);
processTask = new ProcessTask(data);
processTask.execute();
@ -81,7 +85,7 @@ public class CreateCalcWorkbook extends JFrame{
@Override
protected Void doInBackground() throws Exception {
String filePath = Paths.get("").toAbsolutePath().toString()+ "/base.xlsx";
String filePath = Paths.get("").toAbsolutePath().toString()+ "/"+ nameFile +".xlsx";
try (Workbook workbook = new XSSFWorkbook()) {
int rows = data.length; // Nombre de lignes

View File

@ -0,0 +1,47 @@
package baseUFRHG.actions;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import baseUFRHG.demarre;
import baseUFRHG.exportBaseToExcel;
import baseUFRHG.gestionnaire;
import baseUFRHG.noeud;
public class exportTable extends AbstractAction{
private noeud nTable = null;
private gestionnaire instance;
public exportTable(gestionnaire instance) {
this.instance = instance;
putValue( Action.NAME, "Exporter table Ms Excel" );
putValue( Action.SMALL_ICON, new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")) );
putValue( Action.LARGE_ICON_KEY, new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")) );
putValue( Action.SHORT_DESCRIPTION, "Exporter la table dans un classeur Ms Excel." );
}
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
instance.majTableGroupes();
this.nTable = instance.nTable;
if(nTable!=null) {
System.out.println(nTable.toWrite());
exportBaseToExcel.exportTable(nTable);
}else {
System.out.println("nTable = null");
}
}
}

View File

@ -3,6 +3,6 @@ package baseUFRHG;
public class commandes {
public static noeud nBase = null;
}

View File

@ -66,7 +66,7 @@ public class demarre extends JFrame {
commandes.nBase = recupeBases.recupeLaBase();
}
//Exporte la base dans un classeur Excel.
exportBaseToExcel.export();
exportBaseToExcel.exportBase();
}
});
btnCreate.setHorizontalAlignment(SwingConstants.LEFT);

View File

@ -8,7 +8,7 @@ public class exportBaseToExcel {
public static void export() {
public static void exportBase() {
// Données
Object[][] data = new Object[commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getNumberChildren()][29];
@ -90,7 +90,7 @@ public class exportBaseToExcel {
}
if(data.length>0) {
new CreateCalcWorkbook(data);
new CreateCalcWorkbook(data,"Base");
}else {
JPanel panel = new JPanel();
JLabel message = new JLabel("<html><p>La base de données est nulle.</p></html>");
@ -105,7 +105,90 @@ public class exportBaseToExcel {
public static void exportTable(noeud nTable) {
// Données
Object[][] data = new Object[1][29];
String formation = nTable.getFirstChild().getAttributes("IAE_-_Etape_lib.");
data[0][0] = nTable.getFirstChild().getAttributes("IAE_-_Etape_lib.");
data[0][1] = "Formation";
data[0][2] = "Individu_-_Code_Etudiant";
data[0][3] = "Individu_-_Prenom";
data[0][4] = "Individu_-_Nom";
data[0][5] = "Profil_etudiant_lib.";
data[0][6] = "Individu_-_Tel._portable";
data[0][7] = "Individu_-_Email_personnel";
data[0][8] = "Individu_-_Email";
data[0][9] = "Groupe";
data[0][10] = "Groupe_Principal";
data[0][11] = "Groupe_TD";
data[0][12] = "Groupe_Langue";
data[0][13] = "LV1";
data[0][14] = "LV2";
data[0][15] = "Groupe_Informatique";
data[0][16] = "Atelier-rentree_horaire";
data[0][17] = "Atelier_pre-rentree_enseignant";
data[0][18] = "Atelier_pre-rentree_salle";
data[0][19] = "UE_Libre";
data[0][20] = "Covoiturage";
data[0][21] = "Etudiant_Covoiturage";
data[0][22] = "Stage_1";
data[0][23] = "Num_convention_1";
data[0][24] = "Periode_1";
data[0][25] = "Stage_2";
data[0][26] = "Num_convention_2";
data[0][27] = "Periode_2";
String[][] data1 = new String[nTable.getChildren().size()][27];
int indexStudent = 0;
for(noeud nStudent : nTable.getChildren()) {
data1[indexStudent][0] = nStudent.getAttributes("IAE_-_Etape_lib.");;
data1[indexStudent][1] = nStudent.getAttributes("Individu_-_Code_Etudiant");
data1[indexStudent][2] = nStudent.getAttributes("Individu_-_Prenom");
data1[indexStudent][3] = nStudent.getAttributes("Individu_-_Nom");
data1[indexStudent][4] = nStudent.getAttributes("Profil_etudiant_lib.");
data1[indexStudent][5] = nStudent.getAttributes("Individu_-_Tel._portable");
data1[indexStudent][6] = nStudent.getAttributes("Individu_-_Email_personnel");
data1[indexStudent][7] = nStudent.getAttributes("Individu_-_Email");
data1[indexStudent][8] = nStudent.getAttributes("Groupe");
data1[indexStudent][9] = nStudent.getAttributes("Groupe_Principal");
data1[indexStudent][10] = nStudent.getAttributes("Groupe_TD");
data1[indexStudent][11] = nStudent.getAttributes("Groupe_Langue");
data1[indexStudent][12] = nStudent.getAttributes("LV1");
data1[indexStudent][13] = nStudent.getAttributes("LV2");
data1[indexStudent][14] = nStudent.getAttributes("Groupe_Informatique");
data1[indexStudent][15] = nStudent.getAttributes("Atelier-rentree_horaire");
data1[indexStudent][16] = nStudent.getAttributes("Atelier_pre-rentree_enseignant");
data1[indexStudent][17] = nStudent.getAttributes("Atelier_pre-rentree_salle");
data1[indexStudent][18] = nStudent.getAttributes("UE_Libre");
data1[indexStudent][19] = nStudent.getAttributes("Covoiturage");
data1[indexStudent][20] = nStudent.getAttributes("Etudiant_Covoiturage");
data1[indexStudent][21] = nStudent.getAttributes("Stage_1");
data1[indexStudent][22] = nStudent.getAttributes("Num_convention_1");
data1[indexStudent][23] = nStudent.getAttributes("Periode_1");
data1[indexStudent][24] = nStudent.getAttributes("Stage_2");
data1[indexStudent][25] = nStudent.getAttributes("Num_convention_2");
data1[indexStudent][26] = nStudent.getAttributes("Periode_2");
data[0][28] = data1;
indexStudent++;
}
if(data.length>0) {
new CreateCalcWorkbook(data,formation);
}else {
JPanel panel = new JPanel();
JLabel message = new JLabel("<html><p>La base de données est nulle.</p></html>");
panel.add(message);
JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE);
}
}
}

View File

@ -26,6 +26,8 @@ import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import baseUFRHG.actions.exportTable;
public class gestionnaire extends JFrame {
/**
@ -44,7 +46,7 @@ public class gestionnaire extends JFrame {
private JLabel lblNewLabel;
private String defautYear = null;
private JPanel panelNorth;
private JMenu mnNewMenu;
public noeud nTable = null;
@ -58,6 +60,7 @@ public class gestionnaire extends JFrame {
commandes.nBase = recupeBases.recupeLaBase();
}
initialize();
}
@ -176,17 +179,20 @@ public class gestionnaire extends JFrame {
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("Fichier");
JMenuItem openItem = new JMenuItem("Ouvrir");
JMenuItem saveItem = new JMenuItem("Enregistrer");
JMenuItem exportItem = fileMenu.add(new exportTable(this));
JMenuItem saveItem = new JMenuItem("Enregistrer les modifications");
JMenuItem exitItem = new JMenuItem("Quitter");
fileMenu.add(openItem);
fileMenu.add(exportItem);
fileMenu.add(saveItem);
fileMenu.addSeparator(); // Ajouter une séparation entre les éléments du menu
fileMenu.add(exitItem);
menuBar.add(fileMenu);
panelNorth.add(menuBar, BorderLayout.NORTH);
@ -207,8 +213,13 @@ public class gestionnaire extends JFrame {
private void majTableFormation() {
noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString());
nTable = new noeud("Table");
nTable.setAttribut("defaut_Year", defautYear);
if(nYears!=null) {
noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString());
nTable.setAttribut("Formation", cFormations.getSelectedItem().toString());
nTable.setAttribut("GroupeTD", " - ");
String[] head = new String[31] ;
String[][] data = new String[nFormation.getChildren().size()-1][31] ;
@ -227,6 +238,11 @@ public class gestionnaire extends JFrame {
indexCol++;
}
indexRow++;
try {
nTable.addChild(nStudent.clone());
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
@ -274,10 +290,23 @@ public class gestionnaire extends JFrame {
private void majTableGroupes() {
public void majTableGroupes() {
String GroupeTD = (String) cGroupeTD.getSelectedItem();
nTable = new noeud("Table");
nTable.setAttribut("defaut_Year", defautYear);
if(cGroupeTD.getSelectedItem()!=null) {
nTable.setAttribut("GroupeTD", cGroupeTD.getSelectedItem().toString());
}else {
nTable.setAttribut("GroupeTD", " - ");
}
if(GroupeTD!=null) {
noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString());
nTable.setAttribut("Formation", cFormations.getSelectedItem().toString());
if(nYears!=null) {
noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString());
@ -310,7 +339,15 @@ public class gestionnaire extends JFrame {
}
}
}
if(trouve)indexRow++;
if(trouve) {
indexRow++;
try {
nTable.addChild(nStudent.clone());
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
table.setModel(new DefaultTableModel(data, head));
@ -322,6 +359,7 @@ public class gestionnaire extends JFrame {
table.revalidate();
table.repaint();
}
}

View File

@ -44,7 +44,7 @@ public class importAllBaseToExcel {
if(indexCol==0) { // Colonne formation
if(cell.getCellType() == CellType.STRING) {
nBF = commandes.nBase.getChild(cell.getStringCellValue());
nBF = commandes.nBase.getChild(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(cell.getStringCellValue()));
}
}

View File

@ -14,7 +14,7 @@ import java.util.regex.Pattern;
* @author pabr6
*
*/
public class noeud {
public class noeud implements Cloneable{
private String name;
private String content;
private SortedMap<String, String> attributes = new TreeMap<>();
@ -92,6 +92,15 @@ public class noeud {
}
return sb.toString();
}
/**
* Retourne le premier enfant ou retourne un null.
* @return
*/
public noeud getFirstChild() {
if(this.children.size()>0) return this.children.get(0);
return null;
}
/**
* Place le contenu textuel content à ce noeud.<br>
@ -204,6 +213,24 @@ public class noeud {
return false;
}
/**
* Clone de l'objet.
*/
public noeud clone() throws CloneNotSupportedException {
noeud cloned = (noeud) super.clone();
// Copie profonde des objets privés si nécessaire
if(this.name!=null) cloned.name = new String(this.name);
if(this.content!=null) cloned.content = new String(this.content);
cloned.attributes = new TreeMap<String,String>(this.attributes);
cloned.children = new ArrayList<noeud>(this.children);
// if(this.Parent!=null) cloned.Parent = this.Parent.clone();
return cloned;
}
/**
* Retourne le premier enfant ou enfant d'enfant qui contient un attribut nameAttribut.<br>
* Sinon retourne un null.

View File

@ -32,7 +32,13 @@ public class sauvegardeXMLBase {
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
writer.write(nBase.toWrite());
JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
if(nbreModif>0) {
JOptionPane.showMessageDialog(null, "Les " + nbreModif +" modifications ont été enregistrées dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
}else {
JOptionPane.showMessageDialog(null, "Il n'y a pas eu de modification dans la base.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
}
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE);