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
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.lang.*;
import java.util.Vector;
import javax.swing.table.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader.*;
import javax.swing.JFrame;
import javax.swing.JTable;
import java.lang.Object;
public class FmtGestionPalette
extends FmtMere {
private GridLayout gridLayout1 = new GridLayout();
private Panel panel1 = new Panel();
private Label label1 = new Label();
private Label label2 = new Label();
private Label label3 = new Label();
private Button btnafficher = new Button();
private Button btnquitter = new Button();
private Button btnraffrechir = new Button();
private Button btnsupprimer = new Button();
private Button btnnouveau = new Button();
private int choixliste = 0;
private int choixliste2 = 0;
private int lignes = 0;
private int colonnes = 0;
private int taille = 0;
private String nomZone = "";
private String nomSzone = "";
private String nomColonnes = "";
private String st;
private String[] nomColonnePalette = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
private DefaultTableModel tablemodelPalette;
private JScrollPane jScrollPanePalette = new JScrollPane();
private JTable tablePalette = new JTable();
private Frame maframe = this;
private int suppOk = 0, rep = -1;
private int A = 1;
private int B = 2;
private int C = 3;
private int D = 4;
private int E = 5;
private int F = 6;
private int G = 7;
private int H = 8;
private int I = 9;
private int J = 10;
private int K = 11;
private int L = 12;
private int M = 13;
private int N = 14;
private int O = 15;
private int P = 16;
private int Q = 17;
private int R = 18;
private int S = 19;
private int T = 20;
private int U = 21;
private int V = 22;
private int W = 23;
private int X = 24;
private int Y = 25;
private int Z = 26;
public FmtGestionPalette(Connection dbConnect, String zone, String szone,
int nbLignes, int nbColonnes) {
super(dbConnect, zone, szone, nbLignes, nbColonnes);
this.dbConnect = dbConnect;
this.zone = zone;
this.szone = szone;
this.nbLignes = nbLignes;
this.nbColonnes = nbColonnes;
try {
jbInit(zone, szone, nbLignes, nbColonnes);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void jbInit(String zone, String szone, int nbLignes, int nbColonnes) throws
Exception {
lignes = nbLignes;
colonnes = nbColonnes;
nomZone = zone;
nomSzone = szone;
pleinEcran();
this.setLayout(gridLayout1);
this.setBackground(new Color(212, 208, 255));
panel1.setLayout(null);
label1.setFont(new java.awt.Font("Dialog", 0, 18));
label1.setForeground(SystemColor.textHighlight);
label1.setText("Controle de la zone :");
label1.setBounds(new Rectangle(50, 11, 200, 40));
label2.setFont(new java.awt.Font("Dialog", 0, 18));
label2.setForeground(SystemColor.textHighlight);
label2.setText(nomZone);
label2.setBounds(new Rectangle(255, 11, 70, 40));
label3.setFont(new java.awt.Font("Dialog", 0, 18));
label3.setForeground(SystemColor.textHighlight);
label3.setText(nomSzone);
label3.setBounds(new Rectangle(350, 11, 50, 40));
this.setTitle("Gestion des Palettes d'une Zone");
btnsupprimer.setLabel("Supprimer");
btnsupprimer.setBounds(new Rectangle(28, screenheight - 150, 116, 30));
btnnouveau.setLabel("Créer");
btnnouveau.setBounds(new Rectangle(184, screenheight - 150, 116, 30));
btnafficher.setLabel("Afficher");
btnafficher.setBounds(new Rectangle(338, screenheight - 150, 116, 30));
btnquitter.setLabel("Fermer");
btnquitter.setBounds(new Rectangle(492, screenheight - 150, 116, 30));
btnraffrechir.setLabel("Actualiser");
btnraffrechir.setBounds(new Rectangle(646, screenheight - 150, 116, 30));
nomColonneTablePalette(lignes, colonnes);
jScrollPanePalette.setBounds(new Rectangle(20, 100, screenwidth - 50, 500));
jScrollPanePalette.setVisible(true);
remplirlalisteLigne(zone, szone, colonnes, lignes);
panel1.add(label1, null);
panel1.add(label2, null);
panel1.add(label3, null);
panel1.add(btnsupprimer, null);
panel1.add(btnnouveau, null);
panel1.add(btnafficher, null);
panel1.add(btnquitter, null);
panel1.add(btnraffrechir, null);
panel1.add(jScrollPanePalette, null);
jScrollPanePalette.getViewport().add(tablePalette, null);
this.add(panel1, null);
this.setVisible(true);
btnsupprimer.addActionListener(supprimer);
btnnouveau.addActionListener(nouveau);
btnafficher.addActionListener(afficher);
btnquitter.addActionListener(quitter);
btnraffrechir.addActionListener(raffrechir);
maframe.setResizable(false);
}
// Le bouton afficher doit lancer l'ouverture de la fenetre FmtPalette.
ActionListener afficher = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("afficher boutton");
// choixliste = tablePalette.getSelectedRow();
// choixliste2 = tablePalette.getSelectedColumn();
// String ligne = (String)tablePalette.getValueAt(choixliste,1);
// String col = (String)tablePalette.getValueAt(choixliste,2);
// int aa = Integer.parseInt(ligne);
// int colonne = Integer.parseInt(col);
// String c = (String)tablePalette.getValueAt(choixliste,choixliste2);
try {
//FP.jbInit(nomZone,nomSzone,ligne,bb);
// System.out.println(nomZone+"zone");
// System.out.println(nomSzone+"szone");
// System.out.println(ligne+"ligne");
// System.out.println(colonne+"colonne");
// FmtPalette FP = new FmtPalette(dbConnect, nomZone, nomSzone, ligne, colonne);
FmtPalette FP = new FmtPalette(dbConnect, "HALL1", "A", "4", 1);
}
catch (java.lang.Exception exception) {
System.out.println(exception);
exception.printStackTrace();
}
}
};
private void BoxErreur(String texte) {
JOptionPane.showMessageDialog(this, texte);
}
private void erreur() {
BoxErreur("Impossible de supprimer la Palette");
}
private void messageSelection() {
BoxErreur("Vous devez sélectionner un élément de la table");
}
// Affichage ligne par ligne de la table des palettes ... on sort un vecteur de palette par ligne.
// puis on travaille ce vecteur pour que l'on puisse inserer les palettes au bon endroit. pour le moment on fera que mettre
// une croix dans la cellule pour voir si tout fonctionne convenablement.
public void remplirlalisteLigne(String zone, String szone, int nbColonnes, int nbLignes) {
for (int i = 0; i <= nbLignes; i++) {
affLstPaletteLigne(zone, szone, nbColonnes, i);
}
}
private void affLstPaletteLigne(String zone, String szone, int nbColonnes, int numLigne) {
Vector v = new Vector();
SqlPalette sqlp = new SqlPalette(dbConnect);
v = sqlp.listePaletteLigne(zone, szone, numLigne);
ajoutTabPaletteLigne(v, nbColonnes);
}
private void ajoutTabPaletteLigne(Vector v, int nbColonnes) {
Palette p;
for (int i = 0; i < v.size(); i++) {
p = (Palette) v.elementAt(i);
ajoutTabPaletteLigne(p, nbColonnes);
}
}
private void ajoutTabPaletteLigne(Palette p, int nbColonnes) {
String[] data = new String[nbColonnes];
for (int i = 0; i < nbColonnes; i++) {
if (i != Integer.parseInt(p.getPerang().trim())) {
data[i] = "";
} else {
int j = (i-1);
data[j] = "X";
}
}
System.out.println("addRow TableModel");
tablemodelPalette.addRow(data);
}
protected void nomColonneTablePalette(int lignes, int colonnes) {
tablemodelPalette = new DefaultTableModel(lignes, colonnes) {
public boolean isCellEditable(int row, int column) {
return false;
}
};
tablePalette = new JTable(tablemodelPalette);
for (int col = 0; col < colonnes; col++) {
tablemodelPalette.addColumn(nomColonnePalette[col]);
}
}
ActionListener quitter = new ActionListener() {
public void actionPerformed(ActionEvent e) {
maframe.dispose();
}
};
ActionListener raffrechir = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
jbInit(nomZone, nomSzone, lignes, colonnes);
}
catch (java.lang.Exception exception) {
System.out.println(exception);
exception.printStackTrace();
}
}
};
ActionListener nouveau = new ActionListener() {
public void actionPerformed(ActionEvent e) {
int numMaximum = 0;
SqlPalette nouvellePalette = new SqlPalette(dbConnect);
try {
numMaximum = nouvellePalette.maxNumPal();
}
catch (Exception exception) {
exception.printStackTrace();
}
try {
FmtPaletteNew FMW = new FmtPaletteNew(dbConnect, nomZone, nomSzone,
numMaximum);
}
catch (java.lang.Exception exception) {
System.out.println(exception);
exception.printStackTrace();
}
}
};
ActionListener supprimer = new ActionListener() {
public void actionPerformed(ActionEvent e) {
choixliste = tablePalette.getSelectedRow();
choixliste2 = tablePalette.getSelectedColumn();
String ligne = (String) tablePalette.getValueAt(choixliste, 1);
String col = (String) tablePalette.getValueAt(choixliste, 2);
int aa = Integer.parseInt(ligne);
int colonne = Integer.parseInt(col);
try {
System.out.println(nomZone + "zone");
System.out.println(nomSzone + "szone");
System.out.println(ligne + "ligne");
System.out.println(colonne + "colonne");
FmtPaletteSupp FPS = new FmtPaletteSupp(dbConnect, nomZone, nomSzone,
ligne, colonne);
}
catch (java.lang.Exception exception) {
System.out.println(exception);
exception.printStackTrace();
}
}
};
} |
Partager