maj V1.0.1 (JRE 1.7 with JDK 1.8)
This commit is contained in:
parent
955364ae50
commit
6894c2e51f
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_261">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
@ -19,5 +19,6 @@
|
|||||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/xmlbeans-3.0.1.jar"/>
|
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.poi.ooxml with dependances/xmlbeans-3.0.1.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.tika with dependances/commons-io-2.11.0.jar"/>
|
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/apache.tika with dependances/commons-io-2.11.0.jar"/>
|
||||||
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/juniversalchardet-2.4.0.jar"/>
|
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/juniversalchardet-2.4.0.jar"/>
|
||||||
|
<classpathentry kind="lib" path="C:/Users/pabr6/Library jar/xml-apis-1.4.01.wso2v1.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -21,9 +21,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
|||||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
@ -126,6 +126,6 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
|||||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||||
org.eclipse.jdt.core.compiler.release=enabled
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
|
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
|
||||||
org.eclipse.jdt.core.incompleteClasspath=error
|
org.eclipse.jdt.core.incompleteClasspath=error
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,10 +8,13 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class base {
|
public class base {
|
||||||
|
|
||||||
@ -30,9 +33,25 @@ public class base {
|
|||||||
String defaultValue = "2022-2023";
|
String defaultValue = "2022-2023";
|
||||||
String userInput = JOptionPane.showInputDialog("Quelle est l'année universitaire ? ",defaultValue);
|
String userInput = JOptionPane.showInputDialog("Quelle est l'année universitaire ? ",defaultValue);
|
||||||
|
|
||||||
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String regex = "(\\d{4})-(\\d{4})";
|
||||||
|
|
||||||
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
Matcher matcher = pattern.matcher(userInput);
|
||||||
|
|
||||||
|
if (matcher.matches()) {
|
||||||
|
int firstNumber = Integer.parseInt(matcher.group(1));
|
||||||
|
int secondNumber = Integer.parseInt(matcher.group(2));
|
||||||
|
|
||||||
|
if (firstNumber < secondNumber) {
|
||||||
|
|
||||||
if(!userInput.isEmpty()) {
|
if(!userInput.isEmpty()) {
|
||||||
|
userInput = "Years_" + supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(userInput);
|
||||||
nBase.addChild(new noeud(userInput));
|
nBase.addChild(new noeud(userInput));
|
||||||
nBase.setAttribut("defaut_Year", userInput);
|
nBase.setAttribut("defaut_Year", userInput);
|
||||||
|
|
||||||
@ -54,7 +73,29 @@ public class base {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, "Erreur détectée !", "Erreur", JOptionPane.ERROR_MESSAGE);
|
|
||||||
|
} else {
|
||||||
|
System.out.println("Le format est valide, mais le premier nombre n'est pas inférieur au second nombre.");
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel message = new JLabel("<html><p>Le format est valide, la première année n'est pas inférieure à la seconde année.</p>"
|
||||||
|
+ "<p>Exemple de format : 2023-2024</p></html>");
|
||||||
|
panel.add(message);
|
||||||
|
JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Le format est invalide.");
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel message = new JLabel("<html><p>Le format est invalide.</p>"
|
||||||
|
+ "<p>Exemple de format : 2023-2024</p></html>");
|
||||||
|
panel.add(message);
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
8
src/baseUFRHG/commandes.java
Normal file
8
src/baseUFRHG/commandes.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package baseUFRHG;
|
||||||
|
|
||||||
|
public class commandes {
|
||||||
|
|
||||||
|
public static noeud nBase = null;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -9,6 +9,8 @@ import javax.swing.ImageIcon;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
public class demarre extends JFrame {
|
public class demarre extends JFrame {
|
||||||
@ -60,9 +62,11 @@ public class demarre extends JFrame {
|
|||||||
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")));
|
btnCreate.setIcon(new ImageIcon(demarre.class.getResource("/resources/exportbasetoexcel.png")));
|
||||||
btnCreate.addActionListener(new ActionListener() {
|
btnCreate.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
noeud nBase = recupeBases.recupeLaBase();
|
if(commandes.nBase==null) {
|
||||||
|
commandes.nBase = recupeBases.recupeLaBase();
|
||||||
|
}
|
||||||
//Exporte la base dans un classeur Excel.
|
//Exporte la base dans un classeur Excel.
|
||||||
exportBaseToExcel.export(nBase);
|
exportBaseToExcel.export();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnCreate.setHorizontalAlignment(SwingConstants.LEFT);
|
btnCreate.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
@ -114,7 +118,10 @@ public class demarre extends JFrame {
|
|||||||
btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/gestionnaire.png")));
|
btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/gestionnaire.png")));
|
||||||
btnTutoriels.addActionListener(new ActionListener() {
|
btnTutoriels.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
new gestionnaire();
|
if(commandes.nBase==null) {
|
||||||
|
commandes.nBase = recupeBases.recupeLaBase();
|
||||||
|
}
|
||||||
|
afficheGestionnaire();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/tutoriel.png")));
|
// btnTutoriels.setIcon(new ImageIcon(demarre.class.getResource("/resources/tutoriel.png")));
|
||||||
@ -163,4 +170,36 @@ public class demarre extends JFrame {
|
|||||||
btnNewButton_1.setBounds(10, 378, 356, 30);
|
btnNewButton_1.setBounds(10, 378, 356, 30);
|
||||||
frmEvalwriter.getContentPane().add(btnNewButton_1);
|
frmEvalwriter.getContentPane().add(btnNewButton_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void afficheGestionnaire() {
|
||||||
|
if(commandes.nBase.getNumberChildren()>0) {
|
||||||
|
if(commandes.nBase.getAttributes("defaut_Year")!=null) {
|
||||||
|
String defautYear = commandes.nBase.getAttributes("defaut_Year");
|
||||||
|
if(commandes.nBase.getChild(defautYear)!=null) {
|
||||||
|
if(commandes.nBase.getChild(defautYear).getNumberChildren()>0) {
|
||||||
|
new gestionnaire();
|
||||||
|
}else {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel message = new JLabel("<html><p>Dans la base de données, il n'y a pas de donnée"
|
||||||
|
+ "<br>pour l'année universitaire " + defautYear +"</p></html>");
|
||||||
|
panel.add(message);
|
||||||
|
JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel message = new JLabel("<html><p>Dans la base de données, il n'y a pas d'année universitaire par défaut.</p></html>");
|
||||||
|
panel.add(message);
|
||||||
|
JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
JLabel message = new JLabel("<html><p>Dans la base de données est vide.</p></html>");
|
||||||
|
panel.add(message);
|
||||||
|
JOptionPane.showMessageDialog(null, panel, "Erreur", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
package baseUFRHG;
|
package baseUFRHG;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class exportBaseToExcel {
|
public class exportBaseToExcel {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void export(noeud nBase) {
|
public static void export() {
|
||||||
|
|
||||||
// Données
|
// Données
|
||||||
Object[][] data = new Object[nBase.getChild(nBase.getAttributes("defaut_Year")).getNumberChildren()][29];
|
Object[][] data = new Object[commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getNumberChildren()][29];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int indexFormation = 0 ;
|
int indexFormation = 0 ;
|
||||||
for(noeud formation : nBase.getChild(nBase.getAttributes("defaut_Year")).getChildren()) {
|
for(noeud formation : commandes.nBase.getChild(commandes.nBase.getAttributes("defaut_Year")).getChildren()) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +89,15 @@ public class exportBaseToExcel {
|
|||||||
indexFormation++;
|
indexFormation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data.length>0) {
|
||||||
new CreateCalcWorkbook(data);
|
new CreateCalcWorkbook(data);
|
||||||
|
}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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ import java.util.Map;
|
|||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
@ -29,7 +32,6 @@ public class gestionnaire extends JFrame {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
noeud nBase = null;
|
|
||||||
|
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
@ -40,23 +42,28 @@ public class gestionnaire extends JFrame {
|
|||||||
private JTable table;
|
private JTable table;
|
||||||
private JScrollPane scrollPane_1;
|
private JScrollPane scrollPane_1;
|
||||||
private JLabel lblNewLabel;
|
private JLabel lblNewLabel;
|
||||||
|
private String defautYear = null;
|
||||||
|
private JPanel panelNorth;
|
||||||
|
private JMenu mnNewMenu;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
*/
|
*/
|
||||||
public gestionnaire() {
|
public gestionnaire() {
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
getContentPane().setLayout(null);
|
getContentPane().setLayout(null);
|
||||||
|
if(commandes.nBase==null) {
|
||||||
|
commandes.nBase = recupeBases.recupeLaBase();
|
||||||
|
}
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
frame = new JFrame();
|
frame = new JFrame();
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setBounds(100, 100, 1200, 651);
|
frame.setBounds(100, 100, 1200, 651);
|
||||||
frame.setTitle("Gestionnaire Base des inscriptions des étudiants");
|
frame.setTitle("Gestionnaire Base des inscriptions des étudiants");
|
||||||
frame.setLocationRelativeTo(null); // Centre la fenêtre à l'écran
|
frame.setLocationRelativeTo(null); // Centre la fenêtre à l'écran
|
||||||
@ -67,8 +74,6 @@ public class gestionnaire extends JFrame {
|
|||||||
frame.setContentPane(contentPane);
|
frame.setContentPane(contentPane);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nBase = recupeBases.recupeLaBase();
|
|
||||||
cYears = new JComboBox<String>();
|
cYears = new JComboBox<String>();
|
||||||
cYears.setLocation(10, 25);
|
cYears.setLocation(10, 25);
|
||||||
cYears.setSize(168, 32);
|
cYears.setSize(168, 32);
|
||||||
@ -84,25 +89,39 @@ public class gestionnaire extends JFrame {
|
|||||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
List<String> lGroupeTD = new ArrayList<String>();
|
List<String> lGroupeTD = new ArrayList<String>();
|
||||||
for(noeud nChild : nBase.getChildren()) {
|
lGroupeTD.add(" - ");
|
||||||
|
for(noeud nChild : commandes.nBase.getChildren()) {
|
||||||
cYears.addItem(nChild.getName());
|
cYears.addItem(nChild.getName());
|
||||||
for(noeud nFormation : nChild.getChildren()) {
|
for(noeud nFormation : nChild.getChildren()) {
|
||||||
cFormations.addItem(nFormation.getName());
|
cFormations.addItem(nFormation.getName());
|
||||||
String GroupeTD = nFormation.getAttributes().get("Groupe_TD");
|
|
||||||
if(GroupeTD!=null) if(!GroupeTD.isEmpty()) {
|
|
||||||
if(!lGroupeTD.contains(GroupeTD))lGroupeTD.add(GroupeTD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defautYear = commandes.nBase.getAttributes("defaut_Year");
|
||||||
|
cYears.setSelectedItem(defautYear);
|
||||||
|
cFormations.setSelectedIndex(0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cYears.setVisible(true);
|
cYears.setVisible(true);
|
||||||
cFormations.setVisible(true);
|
cFormations.setVisible(true);
|
||||||
|
cGroupeTD.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
// Ajout d'un ActionListener à la JComboBox
|
// Ajout d'un ActionListener à la JComboBox
|
||||||
cFormations.addActionListener(new ActionListener() {
|
cFormations.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
majTable();
|
majTableFormation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Ajout d'un ActionListener à la JComboBox
|
||||||
|
cGroupeTD.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
majTableGroupes();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,50 +132,80 @@ public class gestionnaire extends JFrame {
|
|||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
contentPane.setLayout(new BorderLayout(0, 0));
|
contentPane.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scrollPane_1 = new JScrollPane();
|
scrollPane_1 = new JScrollPane();
|
||||||
scrollPane_1.setViewportBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
scrollPane_1.setViewportBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
|
||||||
|
|
||||||
contentPane.add(scrollPane_1);
|
contentPane.add(scrollPane_1, BorderLayout.CENTER);
|
||||||
scrollPane_1.setViewportView(table);
|
scrollPane_1.setViewportView(table);
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
JPanel panelFiltre = new JPanel();
|
||||||
contentPane.add(panel, BorderLayout.NORTH);
|
// contentPane.add(panelFiltre, BorderLayout.CENTER);
|
||||||
panel.setLayout(null);
|
panelFiltre.setLayout(null);
|
||||||
panel.setPreferredSize(new Dimension(400, 80));
|
panelFiltre.setPreferredSize(new Dimension(400, 80));
|
||||||
panel.setBackground(Color.gray);
|
panelFiltre.setBackground(Color.gray);
|
||||||
panel.add(cYears);
|
panelFiltre.add(cYears);
|
||||||
panel.add(cFormations);
|
panelFiltre.add(cFormations);
|
||||||
|
|
||||||
JLabel lblYears = new JLabel("Année");
|
JLabel lblYears = new JLabel("Année");
|
||||||
lblYears.setFont(new Font("Tahoma", Font.BOLD, 12));
|
lblYears.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||||
lblYears.setHorizontalAlignment(SwingConstants.LEFT);
|
lblYears.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
lblYears.setBounds(10, 11, 72, 14);
|
lblYears.setBounds(10, 11, 72, 14);
|
||||||
panel.add(lblYears);
|
panelFiltre.add(lblYears);
|
||||||
|
|
||||||
JLabel lblFormation = new JLabel("Formation");
|
JLabel lblFormation = new JLabel("Formation");
|
||||||
lblFormation.setFont(new Font("Tahoma", Font.BOLD, 12));
|
lblFormation.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||||
lblFormation.setHorizontalAlignment(SwingConstants.LEFT);
|
lblFormation.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
lblFormation.setBounds(188, 11, 101, 14);
|
lblFormation.setBounds(188, 11, 101, 14);
|
||||||
panel.add(lblFormation);
|
panelFiltre.add(lblFormation);
|
||||||
|
|
||||||
lblNewLabel = new JLabel("Groupe TD");
|
lblNewLabel = new JLabel("Groupe TD");
|
||||||
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
|
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||||
lblNewLabel.setBounds(489, 11, 121, 14);
|
lblNewLabel.setBounds(489, 11, 121, 14);
|
||||||
panel.add(lblNewLabel);
|
panelFiltre.add(lblNewLabel);
|
||||||
|
|
||||||
|
|
||||||
panel.add(cGroupeTD);
|
panelFiltre.add(cGroupeTD);
|
||||||
|
|
||||||
majTable();
|
panelNorth = new JPanel();
|
||||||
|
contentPane.add(panelNorth, BorderLayout.NORTH);
|
||||||
|
panelNorth.setLayout(new BorderLayout(0, 0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
|
||||||
|
JMenu fileMenu = new JMenu("Fichier");
|
||||||
|
JMenuItem openItem = new JMenuItem("Ouvrir");
|
||||||
|
JMenuItem saveItem = new JMenuItem("Enregistrer");
|
||||||
|
JMenuItem exitItem = new JMenuItem("Quitter");
|
||||||
|
|
||||||
|
fileMenu.add(openItem);
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
panelNorth.add(panelFiltre);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
majTableFormation();
|
||||||
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void majTable() {
|
private void majTableFormation() {
|
||||||
noeud nYears = nBase.getChild(cYears.getSelectedItem().toString());
|
noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString());
|
||||||
|
|
||||||
if(nYears!=null) {
|
if(nYears!=null) {
|
||||||
noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString());
|
noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString());
|
||||||
@ -172,12 +221,8 @@ public class gestionnaire extends JFrame {
|
|||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
head[indexCol] = key;
|
head[indexCol] = key;
|
||||||
}else {
|
}else {
|
||||||
String key = entry.getKey();
|
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
data[indexRow-1][indexCol] = value;
|
data[indexRow-1][indexCol] = value;
|
||||||
if(key.equals("Groupe_TD")) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
indexCol++;
|
indexCol++;
|
||||||
}
|
}
|
||||||
@ -185,11 +230,37 @@ public class gestionnaire extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cGroupeTD.removeAllItems();
|
||||||
|
|
||||||
|
List<String> lGroupeTD = new ArrayList<String>();
|
||||||
|
lGroupeTD.add(" - ");
|
||||||
|
if(nFormation!=null) {
|
||||||
|
for(noeud nStudent : nFormation.getChildren()) {
|
||||||
|
if(nStudent.getAttributes("Groupe_TD")!=null) {
|
||||||
|
String GroupeTD = nStudent.getAttributes("Groupe_TD");
|
||||||
|
if(GroupeTD!=null) {
|
||||||
|
if(supprimeCaracatresSpeciaux.TousLesCaracatresSpeciaux(GroupeTD).length()>0) {
|
||||||
|
if(!lGroupeTD.contains(GroupeTD)) {
|
||||||
|
lGroupeTD.add(GroupeTD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String option : lGroupeTD) {
|
||||||
|
cGroupeTD.addItem(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table.setModel(new DefaultTableModel(data, head));
|
table.setModel(new DefaultTableModel(data, head));
|
||||||
|
|
||||||
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
|
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
|
||||||
// Obtention de la colonne à l'index donné
|
// Obtention de la colonne à l'index donné
|
||||||
table.getColumnModel().getColumn(columnIndex).setWidth(getMaxColumnWidth(table, columnIndex));
|
table.getColumnModel().getColumn(columnIndex).setPreferredWidth(getMaxColumnWidth(table, columnIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
table.revalidate();
|
table.revalidate();
|
||||||
@ -201,6 +272,61 @@ public class gestionnaire extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void majTableGroupes() {
|
||||||
|
String GroupeTD = (String) cGroupeTD.getSelectedItem();
|
||||||
|
if(GroupeTD!=null) {
|
||||||
|
noeud nYears = commandes.nBase.getChild(cYears.getSelectedItem().toString());
|
||||||
|
if(nYears!=null) {
|
||||||
|
noeud nFormation = nYears.getChild(cFormations.getSelectedItem().toString());
|
||||||
|
|
||||||
|
|
||||||
|
String[] head = new String[31] ;
|
||||||
|
String[][] data = new String[nFormation.getChildren().size()-1][31] ;
|
||||||
|
|
||||||
|
|
||||||
|
int indexRow = 0;
|
||||||
|
for(noeud nStudent : nFormation.getChildren()) {
|
||||||
|
int indexCol = 0;
|
||||||
|
boolean trouve = false;
|
||||||
|
for (Map.Entry<String, String> entry : nStudent.getAttributes().entrySet()) {
|
||||||
|
if(indexRow==0) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
head[indexCol] = key;
|
||||||
|
indexCol++;
|
||||||
|
trouve=true;
|
||||||
|
}else {
|
||||||
|
String value = entry.getValue();
|
||||||
|
if(nStudent.getAttributes("Groupe_TD").equals(GroupeTD)) {
|
||||||
|
data[indexRow-1][indexCol] = value;
|
||||||
|
indexCol++;
|
||||||
|
trouve=true;
|
||||||
|
}
|
||||||
|
if(GroupeTD.equals(" - ")) {
|
||||||
|
data[indexRow-1][indexCol] = value;
|
||||||
|
indexCol++;
|
||||||
|
trouve=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(trouve)indexRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.setModel(new DefaultTableModel(data, head));
|
||||||
|
|
||||||
|
for (int columnIndex = 0; columnIndex < table.getColumnCount(); columnIndex++) {
|
||||||
|
// Obtention de la colonne à l'index donné
|
||||||
|
table.getColumnModel().getColumn(columnIndex).setPreferredWidth(getMaxColumnWidth(table, columnIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
table.revalidate();
|
||||||
|
table.repaint();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Détermine la largeur de la colonne max pour ajustement.
|
* Détermine la largeur de la colonne max pour ajustement.
|
||||||
* @param table
|
* @param table
|
||||||
@ -208,7 +334,7 @@ public class gestionnaire extends JFrame {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static int getMaxColumnWidth(JTable table, int columnIndex) {
|
private static int getMaxColumnWidth(JTable table, int columnIndex) {
|
||||||
int maxWidth = 40;
|
int maxWidth = 36;
|
||||||
|
|
||||||
DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
|
DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
|
||||||
|
|
||||||
@ -223,6 +349,11 @@ public class gestionnaire extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return maxWidth;
|
return maxWidth+4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,17 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|||||||
public class importAllBaseToExcel {
|
public class importAllBaseToExcel {
|
||||||
|
|
||||||
public static void lecture(File file) {
|
public static void lecture(File file) {
|
||||||
|
if(commandes.nBase==null) {
|
||||||
|
commandes.nBase = recupeBases.recupeLaBase();
|
||||||
|
}
|
||||||
|
|
||||||
noeud nBase = recupeBases.recupeLaBase();
|
int compteur = 0 ;
|
||||||
|
|
||||||
try (FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath());
|
try (FileInputStream fileInputStream = new FileInputStream(file.getAbsolutePath());
|
||||||
Workbook workbook = new XSSFWorkbook(fileInputStream)) {
|
Workbook workbook = new XSSFWorkbook(fileInputStream)) {
|
||||||
|
|
||||||
int numSheets = workbook.getNumberOfSheets();
|
int numSheets = workbook.getNumberOfSheets();
|
||||||
int compteur = 0 ;
|
|
||||||
|
|
||||||
|
|
||||||
for (int sheetIndex = 0; sheetIndex < numSheets; sheetIndex++) {
|
for (int sheetIndex = 0; sheetIndex < numSheets; sheetIndex++) {
|
||||||
@ -41,7 +44,7 @@ public class importAllBaseToExcel {
|
|||||||
|
|
||||||
if(indexCol==0) { // Colonne formation
|
if(indexCol==0) { // Colonne formation
|
||||||
if(cell.getCellType() == CellType.STRING) {
|
if(cell.getCellType() == CellType.STRING) {
|
||||||
nBF = nBase.getChild(cell.getStringCellValue());
|
nBF = commandes.nBase.getChild(cell.getStringCellValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,12 +110,10 @@ public class importAllBaseToExcel {
|
|||||||
System.out.println(); // Nouvelle ligne entre les feuilles
|
System.out.println(); // Nouvelle ligne entre les feuilles
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showInternalMessageDialog(null, "Nombre de modification : " +String.valueOf(compteur));
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class importAllBaseToExcel", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la class importAllBaseToExcel", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
sauvegardeXMLBase.save(nBase);
|
sauvegardeXMLBase.saveModif(commandes.nBase, compteur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@ package baseUFRHG;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
public class lecture {
|
public class lecture {
|
||||||
|
|
||||||
|
|
||||||
@ -13,7 +17,7 @@ public class lecture {
|
|||||||
noeud nBase = recupeBases.recupeLaBase();
|
noeud nBase = recupeBases.recupeLaBase();
|
||||||
|
|
||||||
|
|
||||||
|
if(nBase!=null) {
|
||||||
// lecture et création d'un noeud à partir d'un fichier CSV
|
// lecture et création d'un noeud à partir d'un fichier CSV
|
||||||
try {
|
try {
|
||||||
File fileData = FileChooserCSV.retourneFileCSV();
|
File fileData = FileChooserCSV.retourneFileCSV();
|
||||||
@ -30,6 +34,13 @@ public class lecture {
|
|||||||
|
|
||||||
// ajoute les étudiants qui n'existent pas, dans la base.
|
// ajoute les étudiants qui n'existent pas, dans la base.
|
||||||
nBase = majBase.addStudents(nBase,noeudCSV);
|
nBase = majBase.addStudents(nBase,noeudCSV);
|
||||||
|
}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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,10 +18,24 @@ public class sauvegardeXMLBase {
|
|||||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
||||||
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
new FileOutputStream(directoryName), StandardCharsets.UTF_8))) {
|
||||||
writer.write(nBase.toWrite());
|
writer.write(nBase.toWrite());
|
||||||
|
JOptionPane.showMessageDialog(null, "La base a été sauvegardée.", "Sauvegarde", JOptionPane.INFORMATION_MESSAGE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void saveModif(noeud nBase,Integer nbreModif) {
|
||||||
|
// Sauvegarde de la base
|
||||||
|
String directoryName = Paths.get("").toAbsolutePath().toString()+ "/base.xml";
|
||||||
|
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);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
JOptionPane.showMessageDialog(null, e.toString(), "Erreur dans la méthode save", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user