1 24 25 26 30 31 package org.objectweb.clif.analyser.lib.gui; 32 33 import java.awt.GridBagConstraints ; 34 import java.awt.GridBagLayout ; 35 import java.awt.GridLayout ; 36 import java.awt.event.ActionEvent ; 37 import java.awt.event.ActionListener ; 38 import java.awt.Dimension ; 39 40 import javax.swing.JButton ; 41 import javax.swing.JComboBox ; 42 import javax.swing.JLabel ; 43 import javax.swing.JPanel ; 44 import javax.swing.JScrollPane ; 45 import javax.swing.JSplitPane ; 46 import javax.swing.JTable ; 47 import javax.swing.JTree ; 48 import javax.swing.tree.DefaultMutableTreeNode ; 49 import javax.swing.event.*; 50 51 import javax.swing.tree.*; 52 import javax.swing.JTextField ; 53 import javax.swing.Timer ; 54 import javax.swing.event.TableModelEvent ; 55 import javax.swing.event.TableModelListener ; 56 import org.objectweb.clif.analyser.Analyser; 57 import org.objectweb.clif.analyser.Hypothesis; 58 import org.objectweb.clif.analyser.AutomaticAnalyser; 59 import org.objectweb.clif.analyser.lib.gui.GuiPanelOutput; 60 61 62 63 public class GuiPanelAutomaticAnalyser extends JPanel implements ActionListener , TreeSelectionListener{ 64 65 private AutomaticAnalyser aa; 66 67 private JTextField ruleField = new JTextField ("premiere regle"); 68 private JTextField hypField = new JTextField ("premiere hypothese"); 69 private JTextField testIdField = new JTextField ("test#0"); 70 private JTextField machineField = new JTextField ("g-ladale"); 71 private JTextField threadField = new JTextField ("-1"); 72 private JComboBox paramXCombo = null; 73 private JComboBox paramYCombo = null; 74 private JTextField intervalField = new JTextField ("0-50000"); 75 private JComboBox fonctionCombo = null;; 76 private JTextField fresultField = new JTextField ("98"); 77 78 private JButton eraseButton = new JButton ("Erase"); 79 private JButton validButton = new JButton ("Valid"); 80 81 private JLabel ruleLabel = new JLabel ("Rule name: "); 82 private JLabel hypLabel = new JLabel ("Hypothesis name: "); 83 private JLabel caracLabel = new JLabel ("Caracteristics..."); 84 private JLabel testIdLabel = new JLabel ("Test param : "); 85 private JLabel machineLabel = new JLabel ("Injector param : "); 86 private JLabel threadLabel = new JLabel ("Thread param : "); 87 private JLabel paramXLabel = new JLabel ("X axis param : "); 88 private JLabel paramYLabel = new JLabel ("Y axis param : "); 89 private JLabel intervalLabel = new JLabel ("Interval param: "); 90 private JLabel fonctionLabel = new JLabel ("Fonction param: "); 91 private JLabel fresultLabel = new JLabel ("Fonction result param: "); 92 93 private JPanel panelDroite = new JPanel (); 94 private JPanel panelGauche = new JPanel (); 95 private JPanel panelHaut = new JPanel (); 96 private JPanel panelBas = new JPanel (); 97 private JPanel panelResult = new JPanel (); 99 100 101 private JTree tree ; 102 private DefaultMutableTreeNode top; 103 private String [][] rules = new String [100][100]; 104 private GridBagConstraints cTree = new GridBagConstraints (); 105 private GridBagConstraints c = new GridBagConstraints (); 106 107 private JScrollPane treePane; 108 private JScrollPane graphPane; 109 110 private JSplitPane splitPane = null; 111 private JSplitPane splitPaneGauche = null; 112 private JSplitPane splitPaneResult = null; 114 115 116 private GuiPanelOutput message = new GuiPanelOutput(); 117 private static GuiPanelOutput resultat = new GuiPanelOutput(); 118 119 121 122 126 public GuiPanelAutomaticAnalyser() { 127 128 GridBagLayout gbg = new GridBagLayout (); 129 GridBagConstraints cg = new GridBagConstraints (); 130 131 this.setLayout(new GridLayout (1, 1)); 132 panelBas.setLayout(gbg); 133 cg.gridx = 0; 134 cg.gridy = 0; 135 cg.gridheight = 1; 136 cg.gridwidth = 1; 137 cg.weightx = 300; 138 cg.weighty = 300; 139 cg.fill = GridBagConstraints.BOTH; 140 cg.anchor = GridBagConstraints.SOUTH; 141 message.setSize(200, 200); 142 message.setOutputText("commentaire sur l'hypothese selectionnée\n--------------------------\n"); 143 panelBas.add(message, cg); 144 145 GridBagLayout gb = new GridBagLayout (); 146 147 String [] comboElementsdeX = new String [10]; 148 String [] comboElementsdeY = new String [10]; 149 String [] comboElementsdeFonction = new String [6]; 150 151 comboElementsdeY[0] = comboElementsdeX[0] = "testing time"; 152 comboElementsdeY[1] = comboElementsdeX[1] = "response time"; 153 comboElementsdeY[2] = comboElementsdeX[2] = "number of users"; 154 comboElementsdeY[3] = comboElementsdeX[3] = "hits per second"; 155 comboElementsdeY[4] = comboElementsdeX[4] = "processor"; 156 comboElementsdeY[5] = comboElementsdeX[5] = "memory"; 157 comboElementsdeY[6] = comboElementsdeX[6] = "Java virtuel machine"; 158 comboElementsdeY[7] = comboElementsdeX[7] = "network"; 159 comboElementsdeY[8] = comboElementsdeX[8] = "disk"; 160 comboElementsdeY[9] = comboElementsdeX[9] = "activity control"; 161 paramXCombo = new JComboBox (comboElementsdeX); 162 paramYCombo = new JComboBox (comboElementsdeY); 163 comboElementsdeFonction[0] = "Maximum"; 164 comboElementsdeFonction[1] = "Minimum"; 165 comboElementsdeFonction[2] = "Mean"; 166 comboElementsdeFonction[3] = "Standard deviation"; 167 comboElementsdeFonction[4] = "Linar regression"; 168 comboElementsdeFonction[5] = "Regular increase"; 169 fonctionCombo = new JComboBox (comboElementsdeFonction); 170 171 172 173 174 treePane = initTree(); 175 176 this.setLayout(new GridLayout (1, 1)); 177 panelHaut.setLayout(gb); 178 179 panelDroite.setLayout(gb); 180 cTree.gridx = 0; 181 cTree.gridy = 0; 182 cTree.gridheight = 1; 183 cTree.gridwidth = 1; 184 cTree.weightx = 100; 185 cTree.weighty = 100; 186 cTree.fill = GridBagConstraints.BOTH; 187 cTree.anchor = GridBagConstraints.NORTH; 188 treePane.setSize(100, 50); 189 panelDroite.add(treePane, cTree); 191 c.gridx = 0; 192 c.gridy = 11; 193 c.gridheight = 1; 194 c.gridwidth = 1; 195 c.weightx = 0; 196 c.weighty = 0; 197 c.fill = GridBagConstraints.NONE; 198 c.anchor = GridBagConstraints.WEST; 199 validButton.setActionCommand("VALID"); 200 validButton.addActionListener(this); 201 panelHaut.add(validButton, c); 202 c.gridx = 1; 203 c.gridy = 11; 204 c.gridheight = 1; 205 c.gridwidth = 1; 206 c.weightx = 0; 207 c.weighty = 0; 208 c.fill = GridBagConstraints.NONE; 209 c.anchor = GridBagConstraints.EAST; 210 eraseButton.setActionCommand("ERASE"); 211 eraseButton.addActionListener(this); 212 panelHaut.add(eraseButton, c); 213 214 c.gridx = 0; 215 c.gridy = 1; 216 c.gridheight = 1; 217 c.gridwidth = 1; 218 c.weightx = 0; 219 c.weighty = 0; 220 c.fill = GridBagConstraints.NONE; 221 c.anchor = GridBagConstraints.WEST; 222 panelHaut.add(ruleLabel, c); 223 c.gridx = 1; 224 c.gridy = 1; 225 c.gridheight = 1; 226 c.gridwidth = 1; 227 c.weightx = 0; 228 c.weighty = 0; 229 c.fill = GridBagConstraints.NONE; 230 c.anchor = GridBagConstraints.WEST; 231 ruleField.setSize(ruleField.getPreferredSize()); 233 ruleField.setMinimumSize(ruleField.getPreferredSize()); 234 ruleField.setMaximumSize(ruleField.getPreferredSize()); 235 panelHaut.add(ruleField, c); 236 237 c.gridx = 0; 238 c.gridy = 2; 239 c.gridheight = 1; 240 c.gridwidth = 1; 241 c.weightx = 0; 242 c.weighty = 0; 243 c.fill = GridBagConstraints.NONE; 244 c.anchor = GridBagConstraints.WEST; 245 panelHaut.add(hypLabel, c); 246 c.gridx = 1; 247 c.gridy = 2; 248 c.gridheight = 1; 249 c.gridwidth = 1; 250 c.weightx = 0; 251 c.weighty = 0; 252 c.fill = GridBagConstraints.NONE; 253 c.anchor = GridBagConstraints.WEST; 254 hypField.setSize(hypField.getPreferredSize()); 256 hypField.setMinimumSize(hypField.getPreferredSize()); 257 hypField.setMaximumSize(hypField.getPreferredSize()); 258 panelHaut.add(hypField, c); 259 260 261 c.gridx = 0; 262 c.gridy = 3; 263 c.gridheight = 1; 264 c.gridwidth = 1; 265 c.weightx = 0; 266 c.weighty = 0; 267 c.fill = GridBagConstraints.NONE; 268 c.anchor = GridBagConstraints.WEST; 269 panelHaut.add(testIdLabel, c); 270 c.gridx = 1; 271 c.gridy = 3; 272 c.gridheight = 1; 273 c.gridwidth = 1; 274 c.weightx = 0; 275 c.weighty = 0; 276 c.fill = GridBagConstraints.NONE; 277 c.anchor = GridBagConstraints.WEST; 278 testIdField.setSize(testIdField.getPreferredSize()); 280 testIdField.setMinimumSize(testIdField.getPreferredSize()); 281 testIdField.setMaximumSize(testIdField.getPreferredSize()); 282 panelHaut.add(testIdField, c); 283 284 c.gridx = 0; 285 c.gridy = 6; 286 c.gridheight = 1; 287 c.gridwidth = 1; 288 c.weightx = 0; 289 c.weighty = 0; 290 c.fill = GridBagConstraints.NONE; 291 c.anchor = GridBagConstraints.WEST; 292 panelHaut.add(paramXLabel, c); 293 c.gridx = 1; 294 c.gridy = 6; 295 c.gridheight = 1; 296 c.gridwidth = 1; 297 c.weightx = 0; 298 c.weighty = 0; 299 c.fill = GridBagConstraints.NONE; 300 c.anchor = GridBagConstraints.WEST; 301 panelHaut.add(paramXCombo, c); 302 303 c.gridx = 0; 304 c.gridy = 7; 305 c.gridheight = 1; 306 c.gridwidth = 1; 307 c.weightx = 0; 308 c.weighty = 0; 309 c.fill = GridBagConstraints.NONE; 310 c.anchor = GridBagConstraints.WEST; 311 panelHaut.add(paramYLabel, c); 312 c.gridx = 1; 313 c.gridy = 7; 314 c.gridheight = 1; 315 c.gridwidth = 1; 316 c.weightx = 0; 317 c.weighty = 0; 318 c.fill = GridBagConstraints.NONE; 319 c.anchor = GridBagConstraints.WEST; 320 panelHaut.add(paramYCombo, c); 321 322 c.gridx = 0; 323 c.gridy = 4; 324 c.gridheight = 1; 325 c.gridwidth = 1; 326 c.weightx = 0; 327 c.weighty = 0; 328 c.fill = GridBagConstraints.NONE; 329 c.anchor = GridBagConstraints.WEST; 330 panelHaut.add(machineLabel, c); 331 c.gridx = 1; 332 c.gridy = 4; 333 c.gridheight = 1; 334 c.gridwidth = 1; 335 c.weightx = 0; 336 c.weighty = 0; 337 c.fill = GridBagConstraints.NONE; 338 c.anchor = GridBagConstraints.WEST; 339 machineField.setSize(machineField.getPreferredSize()); 341 machineField.setMinimumSize(machineField.getPreferredSize()); 342 machineField.setMaximumSize(machineField.getPreferredSize()); 343 panelHaut.add(machineField, c); 344 345 c.gridx = 0; 346 c.gridy = 5; 347 c.gridheight = 1; 348 c.gridwidth = 1; 349 c.weightx = 0; 350 c.weighty = 0; 351 c.fill = GridBagConstraints.NONE; 352 c.anchor = GridBagConstraints.WEST; 353 panelHaut.add(threadLabel, c); 354 c.gridx = 1; 355 c.gridy = 5; 356 c.gridheight = 1; 357 c.gridwidth = 1; 358 c.weightx = 0; 359 c.weighty = 0; 360 c.fill = GridBagConstraints.NONE; 361 c.anchor = GridBagConstraints.WEST; 362 threadField.setSize(threadField.getPreferredSize()); 364 threadField.setMinimumSize(threadField.getPreferredSize()); 365 threadField.setMaximumSize(threadField.getPreferredSize()); 366 panelHaut.add(threadField, c); 367 368 c.gridx = 0; 369 c.gridy = 8; 370 c.gridheight = 1; 371 c.gridwidth = 1; 372 c.weightx = 0; 373 c.weighty = 0; 374 c.fill = GridBagConstraints.NONE; 375 c.anchor = GridBagConstraints.WEST; 376 panelHaut.add(intervalLabel, c); 377 c.gridx = 1; 378 c.gridy = 8; 379 c.gridheight = 1; 380 c.gridwidth = 1; 381 c.weightx = 0; 382 c.weighty = 0; 383 c.fill = GridBagConstraints.NONE; 384 c.anchor = GridBagConstraints.WEST; 385 intervalField.setSize(intervalField.getPreferredSize()); 387 intervalField.setMinimumSize(intervalField.getPreferredSize()); 388 intervalField.setMaximumSize(intervalField.getPreferredSize()); 389 panelHaut.add(intervalField, c); 390 391 c.gridx = 0; 392 c.gridy = 9; 393 c.gridheight = 1; 394 c.gridwidth = 1; 395 c.weightx = 0; 396 c.weighty = 0; 397 c.fill = GridBagConstraints.NONE; 398 c.anchor = GridBagConstraints.WEST; 399 panelHaut.add(fonctionLabel, c); 400 c.gridx = 1; 401 c.gridy = 9; 402 c.gridheight = 1; 403 c.gridwidth = 1; 404 c.weightx = 0; 405 c.weighty = 0; 406 c.fill = GridBagConstraints.NONE; 407 c.anchor = GridBagConstraints.WEST; 408 panelHaut.add(fonctionCombo, c); 409 410 c.gridx = 0; 411 c.gridy = 10; 412 c.gridheight = 1; 413 c.gridwidth = 1; 414 c.weightx = 0; 415 c.weighty = 0; 416 c.fill = GridBagConstraints.NONE; 417 c.anchor = GridBagConstraints.WEST; 418 panelHaut.add(fresultLabel, c); 419 c.gridx = 1; 420 c.gridy = 10; 421 c.gridheight = 1; 422 c.gridwidth = 1; 423 c.weightx = 0; 424 c.weighty = 0; 425 c.fill = GridBagConstraints.NONE; 426 c.anchor = GridBagConstraints.WEST; 427 fresultField.setSize(fresultField.getPreferredSize()); 429 fresultField.setMinimumSize(fresultField.getPreferredSize()); 430 fresultField.setMaximumSize(fresultField.getPreferredSize()); 431 panelHaut.add(fresultField, c); 432 433 434 435 436 splitPaneGauche = new JSplitPane (JSplitPane.VERTICAL_SPLIT, panelHaut,panelBas); 437 splitPaneGauche.setOneTouchExpandable(true); 438 panelGauche.add(splitPaneGauche); 439 440 panelResult.setLayout(gbg); 441 resultat.setSize(200, 200); 442 resultat.setOutputText("résultats des recherches en cours\n--------------------------\n"); 443 panelResult.add(resultat,cg); 444 445 splitPaneResult = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, panelResult,panelGauche); 446 splitPaneResult.setDividerLocation(280); 447 splitPaneResult.setOneTouchExpandable(true); 448 449 450 splitPane = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, splitPaneResult,panelDroite); 451 splitPane.setDividerLocation(600); 452 splitPane.setOneTouchExpandable(true); 453 455 456 460 461 465 add(splitPane); 466 467 468 469 } 470 471 472 477 480 481 482 487 public void actionPerformed(ActionEvent e) { 488 489 String command = e.getActionCommand(); 490 491 if (command.equals("VALID")) { 492 rules = aa.newrule(ruleField.getText(),hypField.getText(),testIdField.getText(),machineField.getText(),threadField.getText(),paramXCombo.getSelectedIndex(),paramYCombo.getSelectedIndex(),intervalField.getText(),fonctionCombo.getSelectedIndex(),fresultField.getText()); 493 updateViewTree(); 495 makeComment(ruleField.getText(),hypField.getText(),testIdField.getText(),machineField.getText(),threadField.getText(),paramXCombo.getSelectedIndex(),paramYCombo.getSelectedIndex(),intervalField.getText(),fonctionCombo.getSelectedIndex(),fresultField.getText()); 496 497 }else if (command.equals("ERASE")) { 498 rules = aa.erase(ruleField.getText(),hypField.getText()); 499 updateViewTree(); 501 } 502 503 } 504 505 506 public void valueChanged(TreeSelectionEvent e) { 507 DefaultMutableTreeNode node = (DefaultMutableTreeNode ) tree.getLastSelectedPathComponent(); 508 if (node == null) return; 509 if (node.isLeaf()) { 510 Hypothesis hyp = aa.wichHypNamed(node.getParent().toString(),node.toString()); 511 if(hyp != null) 512 { 513 ruleField.setText(node.getParent().toString()); 514 setHypothesis(hyp); 515 } 516 517 } else { 518 System.out.println("ceci est une regle"); 519 } 520 } 521 522 public void setHypothesis(Hypothesis hyp) 523 { 524 hypField.setText(hyp.getName()); 525 testIdField.setText(hyp.getTest()); 526 machineField.setText(hyp.getMachine()); 527 threadField.setText(hyp.getThread()); 528 intervalField.setText(hyp.getInterval()) ; 529 paramYCombo.setSelectedIndex(hyp.getY()); 530 paramXCombo.setSelectedIndex(hyp.getX()); 531 fonctionCombo.setSelectedIndex(hyp.getFonction()); 532 fresultField.setText(hyp.getFresult()); 533 534 535 } 536 537 public JScrollPane initTree() 538 { 539 top = new DefaultMutableTreeNode ("Existing rules"); 540 createNodes(top); 541 tree = new JTree (top); 542 tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 543 tree.addTreeSelectionListener(this); 544 return (new JScrollPane (tree)); 545 546 } 547 548 549 private void createNodes(DefaultMutableTreeNode top) { 550 551 DefaultMutableTreeNode rep = null; 552 DefaultMutableTreeNode file = null; 553 554 555 for(int i = 0 ; rules[i][0] != null ; i++) 556 { 557 rep = new DefaultMutableTreeNode ((String ) (rules[i][0])); 558 top.add(rep); 559 for(int j = 1 ; rules[i][j] != null ; j++) 560 { 561 file = new DefaultMutableTreeNode ((String ) (rules[i][j])); 562 rep.add(file); 563 } 564 } 565 } 566 567 568 public static void updateResult(String comment) 569 { 570 resultat.clearText(); 571 resultat.setOutputText(comment); 572 } 573 574 575 public void updateViewTree() 576 { 577 panelDroite.remove(treePane); 578 treePane = initTree(); 579 panelDroite.add(treePane,cTree); 580 panelDroite.validate(); 581 } 582 583 public void makeComment(String rule,String hyp,String test,String machine,String thread,int X,int Y,String interval,int fonction,String fresult) 584 { 585 String comment = null; 586 String result = null; 587 String [] VAR = new String [5]; 588 String [] NONVAR = new String [5]; 589 590 int i=0; 591 int j=0; 592 String stringX = null; 593 String stringY = null; 594 String stringFonction =null; 595 596 if(Y==0) stringY = "du temps de test"; 597 if(Y==1) stringY = "du temps de reponse "; 598 if(Y==2) stringY = "du nombre d'utilisateurs connectés "; 599 if(Y==3) stringY = "du nombre de hits par seconde "; 600 if(Y==4) stringY = "du CPU "; 601 if(Y==5) stringY = "de la mémoire "; 602 if(Y==6) stringY = "de la jvm "; 603 if(Y==7) stringY = "du reseau "; 604 if(Y==8) stringY = "des acces disques "; 605 606 if(X==0) stringX = "en fonction du temps de test "; 607 if(X==1) stringX = "en fonction du temps de reponse "; 608 if(X==2) stringX = "en fonction du nombre d'utilisateurs connectés "; 609 if(X==3) stringX = "en fonction du nombre de hits par seconde "; 610 if(X==4) stringX = "en fonction du CPU "; 611 if(X==5) stringX = "en fonction de la mémoire "; 612 if(X==6) stringX = "en fonction de la jvm "; 613 if(X==7) stringX = "en fonction du reseau "; 614 if(X==7) stringX = "en fonction des acces disques "; 615 616 if(fonction==0) stringFonction = "maximum "; 617 if(fonction==1) stringFonction = "minimum "; 618 if(fonction==2) stringFonction = "moyenne "; 619 if(fonction==3) stringFonction = "ecart type "; 620 if(fonction==4) stringFonction = " regression lineaire "; 621 if(fonction==5) stringFonction = "augmentation reg "; 622 623 624 625 result = " Le moteur de recherche va \nrechercher"; 626 if(test.startsWith("VAR")) VAR[i++] = "tous les tests "; 627 else NONVAR[j++] = "pour le test "+test+" "; 628 if(machine.startsWith("VAR")) VAR[i++] = "toutes les machines "; 629 else NONVAR[j++] = "pour la machine "+machine+" "; 630 if(thread.startsWith("VAR")) VAR[i++] = "tous les threads "; 631 else NONVAR[j++] = "pour le thread "+thread+" "; 632 if(interval.startsWith("VAR")) VAR[i++] = "tous les intervales "; 633 else NONVAR[j++] = "pour l'interval "+interval+" "; 634 635 comment = "Nous cherchons des "+i+"-uplets : \n"; 636 637 for(i=0; VAR[i] != null;i++) result = result + ", " + VAR[i] ; 638 result = result + "\npour lesquels la courbe "+stringY +"\n"+ stringX+"\n" ; 639 for(i=0; NONVAR[i] != null;i++) result = result + ", " + NONVAR[i] ; 640 641 result = result + ", \nobtient le résultat : " + fresult+ " lorsqu'on lui \napplique la fonction "+stringFonction+"."; 642 comment = comment +result; 643 644 message.clearText(); 645 message.setOutputText(comment); 646 } 647 648 } 649 | Popular Tags |