1 24 25 26 30 31 32 package org.objectweb.clif.analyser; 33 34 import java.io.*; 35 import java.util.*; 36 import javax.swing.*; 37 import java.awt.*; 38 import org.objectweb.clif.analyser.lib.gui.GuiPanelAnalyser; 39 40 41 public class Analyser 42 { 43 44 private static String [][] vuesdisponibles = new String [100][100]; 45 private static View[] existingviews = new View[100]; 46 private static int index; 47 private static int i=0; 48 49 private static GuiPanelAnalyser guipanelanalyser; 50 51 public Analyser() 52 { 53 } 54 55 public Analyser(GuiPanelAnalyser guiPanelAnalyser) 56 { 57 this.guipanelanalyser = guiPanelAnalyser; 58 } 59 60 public void update() 61 { 62 index=0; 63 listerFichier(); 64 fileToView(); 65 guipanelanalyser.updateViewTree(vuesdisponibles); 66 } 67 68 71 public static void start(){ 72 73 index=0; 74 listerFichier(); 75 fileToView(); 76 guipanelanalyser.updateViewTree(vuesdisponibles); 77 78 79 } 80 83 public static View creer(String name, String testId, String blade,int thread,String paramX,String paramY, String interval, int option){ 84 85 StringTokenizer st; 86 st = new StringTokenizer(interval,"-") ; 87 int tempdatedebut = (new Integer (st.nextToken())).intValue() ; 88 int tempdatefin = (new Integer (st.nextToken())).intValue() ; 89 90 View vue = new View(name,testId,blade,thread,paramX,paramY,tempdatedebut,tempdatefin,option); 91 return vue; 92 } 93 94 95 96 97 public static View wichViewNamed(String nodeparent,String node) 98 { 99 for(int i=0; i < index ;i++) 100 { 101 String temp; 102 String temp2; 103 if(node.endsWith(".view")) temp = existingviews[i].getName() + ".view" ; 104 else temp = existingviews[i].getName(); 105 if(nodeparent.endsWith("_rapport")) temp2 = existingviews[i].getTestId() + "_rapport" ; 106 else temp2 = existingviews[i].getTestId(); 107 108 if (node.equalsIgnoreCase(temp) && nodeparent.equalsIgnoreCase(temp2) ) return existingviews[i]; 109 } 110 return null; 111 } 112 113 114 115 116 117 118 119 122 public static void max(String testname,String vuename){ 123 View selectedView = wichViewNamed(testname,vuename); 124 if(selectedView != null){ 125 Fonction.fonctionMax(selectedView); 126 } 127 else System.out.println("vue non valide"); 128 guipanelanalyser.setView(selectedView); 129 } 130 131 public static void min(String testname,String vuename){ 132 View selectedView = wichViewNamed(testname,vuename); 133 if(selectedView != null){ 134 Fonction.fonctionMin(selectedView); 135 } 136 else System.out.println("vue non valide"); 137 guipanelanalyser.setView(selectedView); 138 } 139 140 141 public static void moyenne(String testname,String vuename){ 142 View selectedView = wichViewNamed(testname,vuename); 143 if(selectedView != null){ 144 Fonction.fonctionMoyenne(selectedView); 145 } 146 else System.out.println("vue non valide"); 147 guipanelanalyser.setView(selectedView); 148 } 149 150 public static void ecart(String testname,String vuename){ 151 View selectedView = wichViewNamed(testname,vuename); 152 if(selectedView != null){ 153 Fonction.fonctionEcart(selectedView); 154 } 155 else System.out.println("vue non valide"); 156 guipanelanalyser.setView(selectedView); 157 } 158 159 public static void pente(String testname,String vuename){ 160 View selectedView = wichViewNamed(testname,vuename); 161 if(selectedView != null){ 162 Fonction.fonctionPente(selectedView); 163 } 164 else System.out.println("vue non valide"); 165 guipanelanalyser.setView(selectedView); 166 } 167 168 169 public static void augmentreg(String testname,String vuename,int indice){ 170 View selectedView = wichViewNamed(testname,vuename); 171 if(selectedView != null){ 172 selectedView.setResult(Fonction.fonctionAugmentReg(selectedView,indice)); 173 } 174 else System.out.println("vue non valide"); 175 guipanelanalyser.setView(selectedView); 176 } 177 178 179 public static void diminreg(String testname,String vuename,int indice){ 180 View selectedView = wichViewNamed(testname,vuename); 181 if(selectedView != null){ 182 selectedView.setResult(Fonction.fonctionDiminReg(selectedView,indice)); 183 } 184 else System.out.println("vue non valide"); 185 guipanelanalyser.setView(selectedView); 186 } 187 188 public static void stationreg(String testname,String vuename,int indice){ 189 View selectedView = wichViewNamed(testname,vuename); 190 if(selectedView != null){ 191 selectedView.setResult(Fonction.fonctionStationReg(selectedView, indice)); 192 } 193 else System.out.println("vue non valide"); 194 guipanelanalyser.setView(selectedView); 195 } 196 197 198 199 200 201 202 public static void listerFichier() 203 { 204 File homeDir = new File("report/"); 205 if(homeDir.exists()) 206 { 207 String [] contient = homeDir.list(); 208 int i; 209 for (i=0; i < contient.length ;i++) 210 { 211 try { 212 (new File("report/" + contient[i] + "/vues")).mkdir(); 213 }catch (Exception e) { 214 e.printStackTrace() ; 215 System.exit(0) ; 216 } 217 String archive = new String ("report/" + contient[i] + "/archive.clif"); 218 if((new File(archive)).exists()) 219 { 220 int k=0; 221 vuesdisponibles[i][k] = contient[i]; 222 guipanelanalyser.addTest(contient[i]); 223 File vueDir = new File("report/" + contient[i] + "/vues"); 224 if(vueDir.exists()) 225 { 226 String [] contient2 = new String [100]; 227 contient2 = vueDir.list(); 228 k++; 229 for (int z=0;z<contient2.length ; z++) 230 { 231 if(contient2[z].endsWith(".view")) vuesdisponibles[i][k++] = contient2[z]; 232 } 233 vuesdisponibles[i][k] = null; 234 } 235 } 236 } 237 vuesdisponibles[i+1][0] = null; 238 } 239 } 240 241 public static void fileToView() 242 { 243 String line = null ; 244 BufferedReader file ; 245 FileInputStream fileInput; 246 StringTokenizer st; 247 248 try { 249 for(int i = 0 ; vuesdisponibles[i][0] != null ; i++) 250 for(int j = 1 ; vuesdisponibles[i][j] != null ; j++) 251 { 252 253 fileInput = new FileInputStream("report/" +vuesdisponibles[i][0] + "/vues/" + vuesdisponibles[i][j] ); 254 file = new BufferedReader(new InputStreamReader(fileInput)); 255 line = file.readLine() ; 256 st = new StringTokenizer(line,"|") ; 257 if(!st.nextToken().equalsIgnoreCase("#")) System.out.println("le fichier " + vuesdisponibles[i][0] + "/" + vuesdisponibles[i][j] + " est erroné !"); 258 else 259 { 260 View vue = new View(); 261 vue.setName(st.nextToken()); 262 vue.setTestId(st.nextToken()); 263 vue.setParamX(st.nextToken()); 264 vue.setParamY(st.nextToken()); 265 vue.setNommachine(st.nextToken()); 266 vue.setNumthread((new Integer (st.nextToken())).intValue()); 267 vue.setDatedebut((new Long (st.nextToken())).longValue()); 268 vue.setDatefin((new Long (st.nextToken())).longValue()); 269 existingviews[index++] = vue; 270 271 } 272 273 } 274 } 275 catch (Exception e) { 276 e.printStackTrace() ; 277 System.exit(0) ; 278 } 279 280 } 281 282 public static String parseArchive(String archive) 283 { 284 String result = ""; 285 try { 286 String line = null; 287 BufferedReader file = new BufferedReader(new InputStreamReader(new FileInputStream(archive))); 288 String [] bladeList = new String [100]; 289 int indexblade=0; 290 String [] paramList = new String [100]; 291 int indexparam=0; 292 long maxTime=0; 293 294 line = file.readLine() ; 295 while(line != null) 296 { 297 StringTokenizer st = new StringTokenizer(line,";") ; 298 long temp = (new Long (st.nextToken())).longValue(); 299 if(temp > maxTime) maxTime = temp; 300 st.nextToken(); 301 String tempblade = st.nextToken(); 302 if(!exists(tempblade,bladeList)) bladeList[indexblade++] = tempblade; 303 st.nextToken();st.nextToken();st.nextToken();st.nextToken();st.nextToken(); 304 String tempparam = st.nextToken(); 305 if(!exists(tempparam,paramList)) paramList[indexparam++] = tempparam; 306 line = file.readLine() ; 307 } 308 result = result + maxTime + ";"; 309 for(int i=0; bladeList[i] != null ;i++) result = result + bladeList[i] + "|" ; 310 result = result + ";" ; 311 for(int i=0; paramList[i] != null ;i++) result = result + paramList[i] + "|" ; 312 } 313 catch (Exception e) { 314 e.printStackTrace() ; 315 System.exit(0) ; 316 } 317 return result; 318 } 319 320 public static boolean exists(String instance, String [] list) 321 { 322 for(int i=0; list[i] != null ;i++) 323 if(list[i].equals(instance)) return true; 324 return false; 325 } 326 327 } 328 | Popular Tags |