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
|
// main :
public static void main(String[] args) {
// declaration
String msgForEventWindows = "";
// lancement du serveurTCP
Connecteur cnxTCP = new Connecteur();
// instanciation ihm
Gui ihm = new Gui(cnxTCP);
ihm.compMere.pack();
ihm.myShell.pack();
ihm.myShell.open();
// instanciation d'1 Hashmap
hashForEventWindows = new HashMap<String, String>();
while (!ihm.myShell.isDisposed()) {
if (!ihm.display.readAndDispatch()) {
ihm.display.sleep();
}
if (Connecteur.isReady){
// lecture d'1 HashMap dans la file de message.
hashForEventWindows = Connecteur.ReadMqIn(Connecteur.mqIn);
// lecture de la HashMap et on stocke son contenu ds 1 String
msgForEventWindows = dumpMap("", hashForEventWindows);
// si la string n'est pas vide
if (msgForEventWindows!= null && msgForEventWindows.length() != 0) { // affichage de la String dans 1 TextArea de l'IHM
ihm.afficheEvents(msgForEventWindows);
// détection de la suite de caracteres "[err]" dans la String
int compteur = 0;
int error = msgForEventWindows.indexOf("[err]");
// si caracteres present alors on affiche un label en rouge
// + le nombre d'erreur retrouvées
if (error != -1){
compteur ++;
ihm.afficherCouleurKO(ihm.resTest);
ihm.textError.setText(Integer.toString(compteur));
}
else {
// sinon on affiche label en vert signifiant que tout est OK.
ihm.afficherCouleurOK(ihm.resTest);
ihm.textError.setText(Integer.toString(compteur));
}
msgForEventWindows = "";
Connecteur.isReady = false;
}
}
}
ihm.display.dispose();
}
} |
Partager