1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
| package vue;
import ...
public class dossier_unique extends JPanel {
// Panels
public static JPanel panel_gauche = new JPanel();
public static JPanel panel_droit = new JPanel();
public static JPanel association = new JPanel();
public static JPanel contact = new JPanel();
public static JPanel panel_dynamique = new JPanel();
// Activités
private static String[] activites = new String[] {"Cinéma", "Musique", "Danse", "Peinture", "Sport", "Quartier", "Sculpture", "Informatique", "Littérature"};
// Checkbox
public static Checkbox check_cinema = new Checkbox();
public static Checkbox check_musique = new Checkbox();
public static Checkbox check_danse = new Checkbox();
public static Checkbox check_peinture = new Checkbox();
public static Checkbox check_sport = new Checkbox();
public static Checkbox check_quartier = new Checkbox();
public static Checkbox check_sculpture = new Checkbox();
public static Checkbox check_informatique = new Checkbox();
public static Checkbox check_litterature = new Checkbox();
// Valeurs des Checkbox
public static String val_cinema;
public static String val_musique;
public static String val_danse;
public static String val_peinture;
public static String val_sport;
public static String val_quartier;
public static String val_sculpture;
public static String val_informatique;
public static String val_litterature;
// Libellés des checkbox
public static JLabel lab_check_cinema = new JLabel("Cinéma");
public static JLabel lab_check_musique = new JLabel("Musique");
public static JLabel lab_check_danse = new JLabel("Danse");
public static JLabel lab_check_peinture = new JLabel("Peinture");
public static JLabel lab_check_sport = new JLabel("Sport");
public static JLabel lab_check_quartier = new JLabel("Quartier");
public static JLabel lab_check_sculpture = new JLabel("Sculpture");
public static JLabel lab_check_informatique = new JLabel("Informatique");
public static JLabel lab_check_litterature = new JLabel("Littérature");
// Liste déroulante
public static JComboBox liste_contacts = new JComboBox(new String[] {"siege_social", "president", "tresorier", "representant1", "representant2"});
// Libellés de association
public static JLabel lab_vide = new JLabel(" ");
public static JLabel lab_association = new JLabel("Association");
public static JLabel lab_numero = new JLabel("Numéro");
public static JLabel lab_sigle = new JLabel("Sigle");
public static JLabel lab_nom_complet = new JLabel("Nom complet");
public static JLabel lab_date_jo = new JLabel("Parution au JO");
public static JLabel lab_date_modif = new JLabel("Dernière modification");
public static JLabel lab_banque = new JLabel("Banque");
public static JLabel lab_act_principale = new JLabel("Activité pricipale");
public static JLabel lab_act_secondaires = new JLabel("Activités secondaires");
// Champs textes de Association
public static JTextField champ_num_asso = new JTextField(10);
public static JTextField champ_sigle = new JTextField(10);
public static JTextArea champ_nom_complet = new JTextArea(2,30);
public static JTextField champ_date_jo = new JTextField(10);
public static JTextField champ_date_modif = new JTextField(10);
public static JTextArea champ_buts = new JTextArea(10,40);
public static JTextField champ_banque = new JTextField(30);
// Variables
public static ResultSet resultat;
public static String num_asso;
private static final long serialVersionUID = 1L;
// Polices
Font titre1 = new Font("Arial", Font.BOLD, 14);
Font alerte = new Font("Arial", Font.BOLD, 14);
public dossier_unique(String num){
num_asso=num;
// MISE EN PAGE
setLayout(new MigLayout("","left","top"));
setOpaque(true);
setVisible(true);
// CONNEXION A LA BDD
try {
Class.forName(controleur.connexion.pilote);
Connection con = DriverManager.getConnection(controleur.connexion.url, controleur.connexion.user, controleur.connexion.password);
Statement instruction = con.createStatement();
ResultSet resultat = instruction.executeQuery("SELECT * FROM asso WHERE num_asso="+num);
resultat.next();
// INITIALISATION DES CHAMPS
// Association
champ_num_asso.setText(resultat.getString("num_asso"));
champ_sigle.setText(resultat.getString("sigle"));
champ_nom_complet.setText(resultat.getString("nom_complet"));
champ_date_jo.setText(resultat.getString("date_jo"));
champ_date_modif.setText(resultat.getString("date_modif"));
champ_buts.setText(resultat.getString("buts"));
champ_banque.setText(resultat.getString("banque"));
// Activités secondaire
val_cinema=resultat.getString("act_cinema");
val_musique=resultat.getString("act_musique");
val_danse=resultat.getString("act_danse");
val_peinture=resultat.getString("act_peinture");
val_sport=resultat.getString("act_sport");
val_quartier=resultat.getString("act_quartier");
val_sculpture=resultat.getString("act_sculpture");
val_informatique=resultat.getString("act_informatique");
val_litterature=resultat.getString("act_litterature");
if (val_cinema.equals("2")) {check_cinema.setState(true);}
if (val_musique.equals("2")) {check_musique.setState(true);}
if (val_danse.equals("2")) {check_danse.setState(true);}
if (val_peinture.equals("2")) {check_peinture.setState(true);}
if (val_sport.equals("2")) {check_sport.setState(true);}
if (val_quartier.equals("2")) {check_quartier.setState(true);}
if (val_sculpture.equals("2")) {check_sculpture.setState(true);}
if (val_informatique.equals("2")) {check_informatique.setState(true);}
if (val_litterature.equals("2")) {check_litterature.setState(true);}
// Siège Social
siege_social.champ_ss_adresse.setText(resultat.getString("ss_adresse"));
siege_social.champ_ss_cp.setText(resultat.getString("ss_cp"));
siege_social.champ_ss_ville.setText(resultat.getString("ss_ville"));
siege_social.champ_ss_tel1.setText(resultat.getString("ss_tel1"));
siege_social.champ_ss_tel2.setText(resultat.getString("ss_tel2"));
siege_social.champ_ss_fax.setText(resultat.getString("ss_fax"));
siege_social.champ_ss_courriel.setText(resultat.getString("ss_courriel"));
siege_social.champ_ss_site.setText(resultat.getString("ss_site"));
// Président
president.champ_pr_titre.setText(resultat.getString("pr_titre"));
president.champ_pr_nom.setText(resultat.getString("pr_nom"));
president.champ_pr_adresse.setText(resultat.getString("pr_adresse"));
president.champ_pr_cp.setText(resultat.getString("pr_cp"));
president.champ_pr_ville.setText(resultat.getString("pr_ville"));
president.champ_pr_tel1.setText(resultat.getString("pr_tel1"));
president.champ_pr_tel2.setText(resultat.getString("pr_tel2"));
president.champ_pr_fax.setText(resultat.getString("pr_fax"));
president.champ_pr_courriel.setText(resultat.getString("pr_courriel"));
president.champ_pr_site.setText(resultat.getString("pr_site"));
// Trésorier
tresorier.champ_tr_titre.setText(resultat.getString("tr_titre"));
tresorier.champ_tr_nom.setText(resultat.getString("tr_nom"));
tresorier.champ_tr_adresse.setText(resultat.getString("tr_adresse"));
tresorier.champ_tr_cp.setText(resultat.getString("tr_cp"));
tresorier.champ_tr_ville.setText(resultat.getString("tr_ville"));
tresorier.champ_tr_tel1.setText(resultat.getString("tr_tel1"));
tresorier.champ_tr_tel2.setText(resultat.getString("tr_tel2"));
tresorier.champ_tr_fax.setText(resultat.getString("tr_fax"));
tresorier.champ_tr_courriel.setText(resultat.getString("tr_courriel"));
tresorier.champ_tr_site.setText(resultat.getString("tr_site"));
// Représentant 1
representant1.champ_rp1_titre.setText(resultat.getString("rp1_titre"));
representant1.champ_rp1_nom.setText(resultat.getString("rp1_nom"));
representant1.champ_rp1_adresse.setText(resultat.getString("rp1_adresse"));
representant1.champ_rp1_cp.setText(resultat.getString("rp1_cp"));
representant1.champ_rp1_ville.setText(resultat.getString("rp1_ville"));
representant1.champ_rp1_tel1.setText(resultat.getString("rp1_tel1"));
representant1.champ_rp1_tel2.setText(resultat.getString("rp1_tel2"));
representant1.champ_rp1_fax.setText(resultat.getString("rp1_fax"));
representant1.champ_rp1_courriel.setText(resultat.getString("rp1_courriel"));
representant1.champ_rp1_site.setText(resultat.getString("rp1_site"));
// Représentant 2
representant2.champ_rp2_titre.setText(resultat.getString("rp2_titre"));
representant2.champ_rp2_nom.setText(resultat.getString("rp2_nom"));
representant2.champ_rp2_adresse.setText(resultat.getString("rp2_adresse"));
representant2.champ_rp2_cp.setText(resultat.getString("rp2_cp"));
representant2.champ_rp2_ville.setText(resultat.getString("rp2_ville"));
representant2.champ_rp2_tel1.setText(resultat.getString("rp2_tel1"));
representant2.champ_rp2_tel2.setText(resultat.getString("rp2_tel2"));
representant2.champ_rp2_fax.setText(resultat.getString("rp2_fax"));
representant2.champ_rp2_courriel.setText(resultat.getString("rp2_courriel"));
representant2.champ_rp2_site.setText(resultat.getString("rp2_site"));
/////////////////
//PANEL GAUCHE //
/////////////////
panel_gauche.setLayout(new MigLayout());
// PANEL ASSOCIATION (HAUT GAUCHE)
association.setBorder(BorderFactory.createLineBorder(Color.black));
association.setLayout(new MigLayout());
// Affichage de "Association"
lab_association.setFont(titre1);
association.add(lab_association, "span, wrap");
// Numéro de l'association
association.add(lab_numero, "align right");
association.add(champ_num_asso);
// Sigle de l'association
association.add(lab_sigle);
association.add(champ_sigle,"wrap");
// Nom de l'association
association.add(lab_nom_complet, "align right");
champ_nom_complet.setLineWrap(true);
champ_nom_complet.setWrapStyleWord(true);
champ_nom_complet.setBorder(BorderFactory.createLineBorder(Color.gray));
association.add(champ_nom_complet, "span, wrap");
// Date de parution au JO
association.add(lab_date_jo, "align right");
association.add(champ_date_jo, "wrap, span");
// Date de dernière modification
association.add(lab_date_modif, "align right");
JTextField date_modif = new JTextField(10);
association.add(date_modif, "wrap, span");
// PANEL CONTACT (BAS GAUCHE)
contact.setBorder(BorderFactory.createLineBorder(Color.black));
contact.setLayout(new MigLayout());
// Liste déroulante
liste_contacts.addActionListener(new but_dossier_unique_liste_contacts());
contact.add(liste_contacts, "wrap");
// PANEL DYNAMIQUE (BAS GAUCHE)
panel_dynamique.setLayout(new CardLayout());
// Siege social
siege_social siege_social = new siege_social();
siege_social.setBorder(BorderFactory.createLineBorder(Color.gray));
panel_dynamique.add(siege_social, "siege_social");
// President
president president = new president();
president.setBorder(BorderFactory.createLineBorder(Color.gray));
panel_dynamique.add(president, "president");
// Tresorier
tresorier tresorier = new tresorier();
tresorier.setBorder(BorderFactory.createLineBorder(Color.gray));
panel_dynamique.add(tresorier, "tresorier");
// Representant1
representant1 representant1 = new representant1();
representant1.setBorder(BorderFactory.createLineBorder(Color.gray));
panel_dynamique.add(representant1, "representant1");
// Representant2
representant2 representant2 = new representant2();
representant2.setBorder(BorderFactory.createLineBorder(Color.gray));
panel_dynamique.add(representant2, "representant2");
contact.add(panel_dynamique);
// AJOUT DES PANELS
panel_gauche.add(association, "wrap");
panel_gauche.add(contact);
/////////////////
// PANEL DROIT //
/////////////////
panel_droit.setBorder(BorderFactory.createLineBorder(Color.black));
panel_droit.setLayout(new MigLayout());
// Buts
panel_droit.add(new JLabel("Buts"), "align left, span 2, wrap");
champ_buts.setLineWrap(true);
champ_buts.setWrapStyleWord(true);
JScrollPane scroll_buts = new JScrollPane();
scroll_buts.setBorder(BorderFactory.createLineBorder(Color.gray));
scroll_buts.getViewport().add(champ_buts);
panel_droit.add(scroll_buts, "span 2, wrap");
// Passage d'une ligne
panel_droit.add(lab_vide, "span, wrap");
// Activité principale
panel_droit.add(lab_act_principale, "align right");
JComboBox activite_principale = new JComboBox(activites);
panel_droit.add(activite_principale, "wrap");
// Activités secondaires
panel_droit.add(lab_act_secondaires, "align right");
JPanel panel_activites_2nd = new JPanel();
panel_activites_2nd.setLayout(new MigLayout());
// Checkbox
panel_activites_2nd.add(check_cinema);
panel_activites_2nd.add(lab_check_cinema);
panel_activites_2nd.add(check_musique);
panel_activites_2nd.add(lab_check_musique);
panel_activites_2nd.add(check_danse);
panel_activites_2nd.add(lab_check_danse, "wrap");
panel_activites_2nd.add(check_peinture);
panel_activites_2nd.add(lab_check_peinture);
panel_activites_2nd.add(check_sport);
panel_activites_2nd.add(lab_check_sport);
panel_activites_2nd.add(check_quartier);
panel_activites_2nd.add(lab_check_quartier, "wrap");
panel_activites_2nd.add(check_sculpture);
panel_activites_2nd.add(lab_check_sculpture);
panel_activites_2nd.add(check_informatique);
panel_activites_2nd.add(lab_check_informatique);
panel_activites_2nd.add(check_litterature);
panel_activites_2nd.add(lab_check_litterature);
panel_droit.add(panel_activites_2nd, "wrap");
// Passage d'une ligne
panel_droit.add(new JLabel(" "), "span, wrap");
// Banque
panel_droit.add(lab_banque, "align right");
panel_droit.add(champ_banque);
/////////////////////////////////////////////////////////////////////////////////
add(panel_gauche);
add(panel_droit, "wrap");
// Bouton de sauvegarde
JButton sauvegarde_dossier_unique = new JButton("Sauvegarder");
sauvegarde_dossier_unique.addActionListener(new but_dossier_unique_sauvegarde());
add(sauvegarde_dossier_unique, "align right, span 2");
} // Try
catch (SQLException ex)
{
add(new JLabel("Connexion à la base de données impossible"));
}
catch(ClassNotFoundException ex)
{
add(new JLabel("Pilote de connexion introuvable"));
}
}// constructeur
} //class dossier_unique |
Partager