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 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gelipanas_utilitaire;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.sql.*;
import java.text.ParseException;
import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.text.MaskFormatter;
import java.util.Timer;
import java.util.TimerTask;
/**
*
* @author er82467
*/
public class Gelipanas_traitement_aff extends JFrame{
public Timer horloge = new Timer();
private JMenuBar Menu;
private JMenu MFichier;
private JMenuItem Close;
private JMenu MAide;
private JMenuItem Manuel;
private JLabel Label_Rens;
private JLabel Tokens_pris;
private JLabel Tokens_lib;
private JLabel tokens;
private JLabel job_attent;
private JLabel job_encours;
private JLabel job_actuels;
private JLabel MAJ_0;
private JLabel MAJ_1;
private JLabel MAJ_2;
private JLabel MAJ_3;
private JButton supprim;
private JButton modification;
private JButton Kill;
private JButton BPatran;
private JFormattedTextField Toccup;//27
private JFormattedTextField Tlib;//28
public static int X3[]={0,0,1,2,1,2,0,0,0,0,0,0,3,2,3,1,3};
public static int Y3[]={0,1,1,1,2,2,3,4,8,13,16,17,8,16,16,24,2};
public static int largeur3[]={2,1,1,1,1,1,1,6,6,6,6,6,1,1,1,3,1};
public static int hauteur3[]={1,1,1,1,1,1,1,3,1,3,1,3,1,1,1,1,1};
public static boolean Option=false;
private JTable tab_ser1;
private JTable tab_ser2;
private JTable tab_ser3;
private Object col;
Methodetableserveur2 MDL_inf2 ;
Methodetableserveur1 MDL_inf1 ;
Methodetableserveur3 MDL_inf3 ;
public int Limite_max=1772;
public int total_utilise=0;
public int marge_nastran= 350;
public int marge_patran = 96;
public int marge_utilisable;
////////////////////////////////////////////////////////////////////////////
//// valeurs temporaires
////////////////////////////////////////////////////////////////////////////
public String totlic ;
public String occlic ;
public String[] LogIn = new String[60];
public String[] Date = new String[60];
public String[] Heure = new String[60];
public int[] Licence = new int[60];
public String[] tabnum = new String[60];
public String[] tabdat = new String[60];
public String[] machine = new String[60];
public String[] processus = new String[60];
public String[] Job = new String[60];
public String[] tab_type_log = new String[60];
public String[] tab_type_2 = new String[60];
public String[] tab_mac = new String[60];
public String[] tab_log_db = new String[60];
public String[] tab_date_db = new String[60];
public String[] tab_horaire_db = new String[60];
public int[] Licence_db = new int[60];
public String[] machine_db = new String[60];
public String[] processus_db = new String[60];
public String[] Job_db = new String[100];
//////////////////// valeur a supprimer ////////////////////////////////////
public String[] rien_1 = new String[60];
public String[] rien_2 = new String[60];
public String[] rien_3 = new String[60];
////////////////////////////////////////////////////////////////////////////
///// Propriétés affichage ecran
////////////////////////////////////////////////////////////////////////////
private int width;
private int height;
private Toolkit toolkit;
////////////////////////////////////////////////////////////////////////////
public class Gelipanas_traitement_Worker extends SwingWorker<Integer,Integer>{
Connection connexion = null;
Connection connexion2 = null;
public int val;
public Gelipanas_traitement_Worker(){
}
@Override
public Integer doInBackground(){
horloge.schedule(new TimerTask(){
public void run(){
try{
traitement trait = new traitement();
LBatch b1 = new LBatch();
batch_running run = new batch_running();
Jobs job = new Jobs();
// Toccup.setValue(trait.getTotLic());
// Tlib.setValue(trait.getOccLic());
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// ZONE DE TEST MYSQL ///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
try{
try{
Class.forName("com.mysql.jdbc.Driver");// sun.jdbc.odbc.JdbcOdbcDriver
}catch(ClassNotFoundException ex){
ex.printStackTrace();
System.out.println("NOT FOUND ");
}
try{
connexion = DriverManager.getConnection("jdbc:mysql://Oberon/gelipanas_db","root","oberon2012"); // connexion a oberon
Statement stmt = connexion.createStatement();
ResultSet nb_licence = stmt.executeQuery("SELECT nb_licence FROM etat_licence;");
nb_licence.next();
totlic=nb_licence.getString("nb_licence");
ResultSet seuil_licence = stmt.executeQuery("SELECT seuil_licence FROM etat_licence;");
seuil_licence.next();
occlic = seuil_licence.getString("seuil_licence");
Toccup.setValue(totlic);
Tlib.setValue(occlic);// a garder
connexion2 = DriverManager.getConnection("jdbc:mysql://Oberon/gelipanas_db","root","oberon2012"); // connexion a oberon
Statement stmtX = connexion2.createStatement();
ResultSet RsLog = stmtX.executeQuery("SELECT Login,date,horaire,nb_licence FROM etat_serveur;");
int itl=0;
while(RsLog.next()){
tab_log_db[itl]=RsLog.getString("Login");
tab_date_db[itl]=RsLog.getString("date");
tab_horaire_db[itl]=RsLog.getString("horaire");
Licence_db[itl] = RsLog.getInt("nb_licence");
// System.out.println(tab_log_db[itl] + " arrivant le :" + tab_date_db[itl] + " à " + tab_horaire_db[itl] + " et a pris :"+Licence_db[itl]);
itl++;
}
itl=0;
}catch(SQLException sqle){
System.out.println("ERROR SQL :");
sqle.printStackTrace();
}
catch(Exception e){
System.out.println("OTHER ERROR:");
e.printStackTrace();
}finally{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// FIN ZONE DE TEST MYSQL ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
MDL_inf2 = new Methodetableserveur2(tab_log_db,tab_date_db,tab_horaire_db,Licence_db ); MDL_inf1 = new Methodetableserveur1(job.getmachine(),job.getprocessus(),"Utilisateur",job.getjob());
MDL_inf3 = new Methodetableserveur3(b1.gettabnum(),b1.gettabdat(),b1.gettab_type_2(),b1.gettab_type_log(),b1.gettab_mac());
// application des model sur les tableaux
tab_ser1.setModel(MDL_inf2);
tab_ser2.setModel(MDL_inf1);
tab_ser3.setModel(MDL_inf3);
// dimensions des cellules du tableau tab_ser3
tab_ser1.getColumnModel().getColumn(0).setPreferredWidth(50); // colonne 1 / numéro
tab_ser1.getColumnModel().getColumn(1).setPreferredWidth(50);//colonne 2 / fichier
tab_ser1.getColumnModel().getColumn(2).setPreferredWidth(50);//colonne 3 / utilisateur
tab_ser1.getColumnModel().getColumn(3).setPreferredWidth(50);//colonne 4 / type
tab_ser1.getColumnModel().getColumn(4).setPreferredWidth(50);//colonne 5 / machine
tab_ser2.getColumnModel().getColumn(0).setPreferredWidth(50); // colonne 1 / numéro
tab_ser2.getColumnModel().getColumn(1).setPreferredWidth(50);//colonne 2 / fichier
tab_ser2.getColumnModel().getColumn(2).setPreferredWidth(50);//colonne 3 / utilisateur
tab_ser2.getColumnModel().getColumn(3).setPreferredWidth(50);//colonne 4 / type
tab_ser3.getColumnModel().getColumn(0).setPreferredWidth(1); // colonne 1 / numéro
tab_ser3.getColumnModel().getColumn(1).setPreferredWidth(350);//colonne 2 / fichier
tab_ser3.getColumnModel().getColumn(2).setPreferredWidth(35);//colonne 3 / utilisateur
tab_ser3.getColumnModel().getColumn(3).setPreferredWidth(10);//colonne 4 / type
tab_ser3.getColumnModel().getColumn(4).setPreferredWidth(50);//colonne 5 / machine
if(occlic=="0"){
MAJ_0.setText("Mise a jour en cours. Patientez svp");
}else{
MAJ_0.setText(" ");
}
}catch(ArrayIndexOutOfBoundsException aiobe){
aiobe.printStackTrace();
System.out.println("ERREUR aiobe");
}
}catch(Exception exp){
exp.printStackTrace();
System.out.println(" ERREUR dans les modeles");
}
}
},0,7000);
return val;
}
@Override
protected void done(){
}
}
public Gelipanas_traitement_aff(){
super("Gelipanas_traitement_aff");
setTitle("GeLiPaNas Beta Version - Etat du Serveur");
setSize(750,650);
setResizable(false);
//setLocationRelativeTo(null);
////////////////////////////////////////////////////////////////////////
//// Information affichage unité informatique
////////////////////////////////////////////////////////////////////////
toolkit = Toolkit.getDefaultToolkit();
// On récupère la taille de l'écran par défaut :
width = toolkit.getScreenSize().width/2;
height = toolkit.getScreenSize().height/4;
// On récupère la configuration par défaut de l'écran par défaut :
GraphicsConfiguration gconf = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice().getDefaultConfiguration();
////////////////////////////////////////////////////////////////////////
setLocation(0,height);
Container PServ = getContentPane();
PServ.setLayout(new FlowLayout());
Label_Rens = new JLabel("Renseignement serveur");
tokens = new JLabel("Disponibilité Licences ");
Tokens_pris = new JLabel(" Maximal");
Tokens_lib = new JLabel(" En cours d'utilisation");
Toccup = new JFormattedTextField();
Toccup.setEditable(false);
Tlib = new JFormattedTextField();
Tlib.setEditable(false);
job_actuels = new JLabel("les jobs actuels sur serveur: ");
job_attent = new JLabel("Jobs en cours sur le serveur: ");
job_encours = new JLabel("Jobs en attentes: ");
MAJ_0 = new JLabel();
supprim = new JButton("Suppression Job en attente");
modification = new JButton("Modification Job en attente");
Kill = new JButton("Suppression Job en cours");
BPatran = new JButton();
BPatran.setToolTipText("Attendez la mise à jour avant de lancer l'application");
// on place une grille
GridBagLayout grille5 = new GridBagLayout();
PServ.setLayout(grille5);
// contraintes graphique REns
GridBagConstraints co1 = new GridBagConstraints();
co1.fill = GridBagConstraints.BOTH; /// ajustement vertical et horizontal
co1.gridx=X3[0];
co1.gridy=Y3[0];
co1.insets = new Insets(5,5,5,5);//marge de 5 en ht,bs,gh,dt
co1.gridwidth=largeur3[0];
co1.gridheight=hauteur3[0];
....
// ajout renseignement
PServ.add(Label_Rens,co1);
PServ.add(tokens,co2);
PServ.add(Tokens_pris,co3);
PServ.add(Tokens_lib,co4);
PServ.add(MAJ_0,co14);
PServ.add(Toccup,co5);
PServ.add(Tlib,co6);
PServ.add(job_actuels,co7);
PServ.add(job_attent,co8);
PServ.add(job_encours,co9);
tab_ser1 = new JTable(MDL_inf2);
PServ.add(new JScrollPane(tab_ser1),co72);
tab_ser2 = new JTable(MDL_inf1);
PServ.add((new JScrollPane(tab_ser2)),co82);
tab_ser3 = new JTable(MDL_inf3);
PServ.add(new JScrollPane(tab_ser3),co92);
setVisible(true);
PServ.add(modification,co12);
modification.setEnabled(false); }
} |
Partager