1 24 25 26 31 32 package org.objectweb.clif.analyser.lib.gui; 33 34 import java.awt.GridBagConstraints ; 35 import java.awt.GridBagLayout ; 36 import java.awt.GridLayout ; 37 import java.awt.event.ActionEvent ; 38 import java.awt.event.ActionListener ; 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.JFrame ; 54 import ptolemy.plot.Plot; 55 import javax.swing.Timer ; 56 import javax.swing.event.TableModelEvent ; 57 import javax.swing.event.TableModelListener ; 58 import org.objectweb.clif.analyser.Analyser; 59 import org.objectweb.clif.analyser.View; 60 import org.objectweb.clif.analyser.lib.gui.GuiPanelOutput; 61 import java.util.StringTokenizer ; 62 63 64 public class GuiPanelAnalyser extends JPanel implements ActionListener , TreeSelectionListener{ 65 66 private Analyser a; 67 private JFrame frame = new JFrame (); 68 69 private JTextField nameField = new JTextField (20); 70 private JTextField testIdField = new JTextField (20); 71 private JComboBox testCombo = null; 72 private JComboBox paramXCombo = null; 73 private JComboBox paramYCombo = null; 74 private JComboBox bladeCombo = null; 75 private JComboBox fonctionCombo = null; 76 77 78 private JTextField machineField = new JTextField (20); 79 private JTextField threadField = new JTextField (20); 80 private JTextField intervalField = new JTextField (20); 81 82 private JButton creerButton = new JButton ("Create view"); 83 private JButton updateButton = new JButton ("Update Test Tree"); 84 private JButton optionButton = new JButton ("Options"); 85 86 87 private JLabel nameLabel = new JLabel ("View name"); 88 private JLabel testIdLabel = new JLabel ("Test name"); 89 private JLabel paramXLabel = new JLabel ("X axis param"); 90 private JLabel paramYLabel = new JLabel ("Y axis param"); 91 private JLabel machineLabel = new JLabel ("Blade name"); 92 private JLabel threadLabel = new JLabel ("V. client number"); 93 private JLabel intervalLabel = new JLabel ("Time interval"); 94 95 private JPanel panelDroite = new JPanel (); 96 private JPanel panelGauche = new JPanel (); 97 private JPanel panelHaut = new JPanel (); 98 private JPanel panelBas = new JPanel (); 99 100 101 private JTree tree ; 102 private DefaultMutableTreeNode top; 103 private String [][] vues = new String [100][100]; 104 GridBagConstraints cTree = new GridBagConstraints (); 105 106 private JScrollPane treePane; 107 private JScrollPane graphPane; 108 109 private JSplitPane splitPane = null; 110 private JSplitPane splitPaneGauche = null; 111 private GuiPanelOutput message = new GuiPanelOutput(); 112 113 114 118 public GuiPanelAnalyser() { 119 120 a = new Analyser(this); 121 GridBagLayout gbg = new GridBagLayout (); 122 GridBagConstraints cg = new GridBagConstraints (); 123 124 this.setLayout(new GridLayout (1, 1)); 125 panelBas.setLayout(gbg); 126 cg.gridx = 0; 127 cg.gridy = 0; 128 cg.gridheight = 1; 129 cg.gridwidth = 1; 130 cg.weightx = 300; 131 cg.weighty = 300; 132 cg.fill = GridBagConstraints.BOTH; 133 cg.anchor = GridBagConstraints.SOUTH; 134 message.setSize(200, 200); 135 message.setOutputText(" "); 136 panelBas.add(message, cg); 138 139 GraphAnalyser graphpane = new GraphAnalyser(); 140 graphPane = new JScrollPane (graphpane.init()); 141 panelHaut.add(graphPane); 142 143 splitPaneGauche = new JSplitPane (JSplitPane.VERTICAL_SPLIT, panelHaut,panelBas); 144 splitPaneGauche.setOneTouchExpandable(true); 145 panelGauche.add(splitPaneGauche); 146 147 148 GridBagLayout gb = new GridBagLayout (); 149 GridBagConstraints c = new GridBagConstraints (); 150 151 testCombo = new JComboBox (); 152 paramXCombo = new JComboBox (); 153 paramYCombo = new JComboBox (); 154 bladeCombo = new JComboBox (); 155 fonctionCombo = new JComboBox (); 156 fonctionCombo.addItem("Maximum"); 157 fonctionCombo.addItem("Minimum"); 158 fonctionCombo.addItem("Mean"); 159 fonctionCombo.addItem("Standard deviation"); 160 161 bladeCombo.setEditable(true); 162 paramYCombo.setEditable(true); 163 paramXCombo.setEditable(true); 164 paramYCombo.setActionCommand("PARAMY"); 165 paramYCombo.addActionListener(this); 166 testCombo.setActionCommand("TEST"); 167 testCombo.addActionListener(this); 168 paramXCombo.setActionCommand("PARAMX"); 169 paramXCombo.addActionListener(this); 170 171 172 173 treePane = initTree(); 174 175 this.setLayout(new GridLayout (1, 1)); 176 panelDroite.setLayout(gb); 177 178 179 c.gridx = 0; 180 c.gridy = 0; 181 updateButton.setActionCommand("UPDATE"); 182 updateButton.addActionListener(this); 183 panelDroite.add(updateButton, c); 184 c.gridx = 1; 185 c.gridy = 0; 186 fonctionCombo.setActionCommand("FONCTION"); 187 fonctionCombo.addActionListener(this); 188 panelDroite.add(fonctionCombo, c); 189 190 cTree.gridx = 0; 191 cTree.gridy = 1; 192 cTree.gridheight = 1; 193 cTree.gridwidth = 2; 194 cTree.weightx = 1; 195 cTree.weighty = 2; 196 cTree.fill = GridBagConstraints.BOTH; 197 cTree.anchor = GridBagConstraints.NORTH; 198 panelDroite.add(treePane, cTree); 200 201 202 c.gridx = 0; 203 c.gridy = 3; 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.WEST; 210 panelDroite.add(nameLabel, c); 211 c.gridx = 1; 212 c.gridy = 3; 213 c.gridheight = 1; 214 c.gridwidth = 1; 215 c.weightx = 0; 216 c.weighty = 0; 217 c.fill = GridBagConstraints.NONE; 218 c.anchor = GridBagConstraints.WEST; 219 nameField.setSize(nameField.getPreferredSize()); 221 nameField.setMinimumSize(nameField.getPreferredSize()); 222 nameField.setMaximumSize(nameField.getPreferredSize()); 223 panelDroite.add(nameField, c); 224 225 c.gridx = 0; 226 c.gridy = 4; 227 c.gridheight = 1; 228 c.gridwidth = 1; 229 c.weightx = 0; 230 c.weighty = 0; 231 c.fill = GridBagConstraints.NONE; 232 c.anchor = GridBagConstraints.WEST; 233 panelDroite.add(testIdLabel, c); 234 c.gridx = 1; 235 c.gridy = 4; 236 c.gridheight = 1; 237 c.gridwidth = 1; 238 c.weightx = 0; 239 c.weighty = 0; 240 c.fill = GridBagConstraints.NONE; 241 c.anchor = GridBagConstraints.WEST; 242 panelDroite.add(testCombo, c); 243 244 c.gridx = 0; 245 c.gridy = 5; 246 c.gridheight = 1; 247 c.gridwidth = 1; 248 c.weightx = 0; 249 c.weighty = 0; 250 c.fill = GridBagConstraints.NONE; 251 c.anchor = GridBagConstraints.WEST; 252 panelDroite.add(paramXLabel, c); 253 c.gridx = 1; 254 c.gridy = 5; 255 c.gridheight = 1; 256 c.gridwidth = 1; 257 c.weightx = 0; 258 c.weighty = 0; 259 c.fill = GridBagConstraints.NONE; 260 c.anchor = GridBagConstraints.WEST; 261 panelDroite.add(paramXCombo, c); 262 263 c.gridx = 0; 264 c.gridy = 6; 265 c.gridheight = 1; 266 c.gridwidth = 1; 267 c.weightx = 0; 268 c.weighty = 0; 269 c.fill = GridBagConstraints.NONE; 270 c.anchor = GridBagConstraints.WEST; 271 panelDroite.add(paramYLabel, c); 272 c.gridx = 1; 273 c.gridy = 6; 274 c.gridheight = 1; 275 c.gridwidth = 1; 276 c.weightx = 0; 277 c.weighty = 0; 278 c.fill = GridBagConstraints.NONE; 279 c.anchor = GridBagConstraints.WEST; 280 panelDroite.add(paramYCombo, c); 281 282 c.gridx = 0; 283 c.gridy = 7; 284 c.gridheight = 1; 285 c.gridwidth = 1; 286 c.weightx = 0; 287 c.weighty = 0; 288 c.fill = GridBagConstraints.NONE; 289 c.anchor = GridBagConstraints.WEST; 290 panelDroite.add(machineLabel, c); 291 c.gridx = 1; 292 c.gridy = 7; 293 c.gridheight = 1; 294 c.gridwidth = 1; 295 c.weightx = 0; 296 c.weighty = 0; 297 c.fill = GridBagConstraints.NONE; 298 c.anchor = GridBagConstraints.WEST; 299 panelDroite.add(bladeCombo, c); 300 301 c.gridx = 0; 302 c.gridy = 8; 303 c.gridheight = 1; 304 c.gridwidth = 1; 305 c.weightx = 0; 306 c.weighty = 0; 307 c.fill = GridBagConstraints.NONE; 308 c.anchor = GridBagConstraints.WEST; 309 panelDroite.add(threadLabel, c); 310 c.gridx = 1; 311 c.gridy = 8; 312 c.gridheight = 1; 313 c.gridwidth = 1; 314 c.weightx = 0; 315 c.weighty = 0; 316 c.fill = GridBagConstraints.NONE; 317 c.anchor = GridBagConstraints.WEST; 318 threadField.setSize(threadField.getPreferredSize()); 320 threadField.setMinimumSize(threadField.getPreferredSize()); 321 threadField.setMaximumSize(threadField.getPreferredSize()); 322 panelDroite.add(threadField, c); 323 324 c.gridx = 0; 325 c.gridy = 9; 326 c.gridheight = 1; 327 c.gridwidth = 1; 328 c.weightx = 0; 329 c.weighty = 0; 330 c.fill = GridBagConstraints.NONE; 331 c.anchor = GridBagConstraints.WEST; 332 panelDroite.add(intervalLabel, c); 333 c.gridx = 1; 334 c.gridy = 9; 335 c.gridheight = 1; 336 c.gridwidth = 1; 337 c.weightx = 0; 338 c.weighty = 0; 339 c.fill = GridBagConstraints.NONE; 340 c.anchor = GridBagConstraints.WEST; 341 intervalField.setSize(intervalField.getPreferredSize()); 343 intervalField.setMinimumSize(intervalField.getPreferredSize()); 344 intervalField.setMaximumSize(intervalField.getPreferredSize()); 345 panelDroite.add(intervalField, c); 346 347 348 c.gridx = 0; 349 c.gridy = 10; 350 optionButton.setActionCommand("OPTION"); 351 optionButton.addActionListener(this); 352 panelDroite.add(optionButton, c); 353 c.gridx = 1; 354 c.gridy = 10; 355 creerButton.setActionCommand("CREER"); 356 creerButton.addActionListener(this); 357 panelDroite.add(creerButton, c); 358 359 360 361 362 363 364 365 splitPane = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT, panelGauche,panelDroite); 366 splitPane.setDividerLocation(600); 367 splitPane.setOneTouchExpandable(true); 368 add(splitPane); 369 370 } 371 372 377 public void actionPerformed(ActionEvent e) { 378 379 String command = e.getActionCommand(); 380 381 if (command.equals("CREER")) 382 { 383 GuiInitDialog dlg = new GuiInitDialog(frame,"option"); 384 int option = (new Integer (dlg.ask())).intValue(); 385 View createView = a.creer(nameField.getText(), testCombo.getSelectedItem().toString(), bladeCombo.getSelectedItem().toString(),new Integer (threadField.getText()).intValue(), paramXCombo.getSelectedItem().toString(), paramYCombo.getSelectedItem().toString(),intervalField.getText(),option); 386 if(createView != null) tracer(createView); 387 else System.out.println("View corrupted..."); 388 } 389 390 391 else if (command.equals("UPDATE")) 392 { 393 a.update(); 395 } 396 else if (command.equals("OPTION")) 397 { 398 399 } 400 else if (command.equals("FONCTION")) 401 { 402 if(fonctionCombo.getSelectedIndex()==0) Analyser.max(testCombo.getSelectedItem().toString(),nameField.getText()); 403 else if(fonctionCombo.getSelectedIndex()==1) Analyser.min(testCombo.getSelectedItem().toString(),nameField.getText()); 404 else if(fonctionCombo.getSelectedIndex()==2) Analyser.moyenne(testCombo.getSelectedItem().toString(),nameField.getText()); 405 else if(fonctionCombo.getSelectedIndex()==3) Analyser.ecart(testCombo.getSelectedItem().toString(),nameField.getText()); 406 } 407 else if (command.equals("PARAMY")) 408 { 409 410 } 411 else if (command.equals("PARAMX")) 412 { 413 414 } 415 else if (command.equals("TEST")) 416 { 417 String testId = testCombo.getSelectedItem().toString(); 418 String archive = "report/" + testId + "/archive.clif"; 419 String parsingResult = org.objectweb.clif.analyser.Analyser.parseArchive(archive); 420 updateTestData(parsingResult); 421 } 422 423 } 424 425 public void updateTestData(String parsingResult) 426 { 427 428 paramXCombo.removeAllItems(); 429 paramYCombo.removeAllItems(); 430 bladeCombo.removeAllItems(); 431 paramXCombo.addItem("Testing time"); 432 StringTokenizer st = new StringTokenizer (parsingResult,";"); 433 intervalField.setText("0-"+ st.nextToken()); 434 threadField.setText("-1"); 435 StringTokenizer stblade = new StringTokenizer (st.nextToken(),"|"); 436 while(stblade.hasMoreElements()) bladeCombo.addItem(stblade.nextToken()); 437 StringTokenizer stparam = new StringTokenizer (st.nextToken(),"|"); 438 while(stparam.hasMoreElements()) paramYCombo.addItem(stparam.nextToken()); 439 } 440 441 public void addTest(String testId) 442 { 443 testCombo.addItem(testId); 444 } 445 446 447 448 public void tracer(View vue) 449 { 450 panelHaut.remove(graphPane); 451 GraphAnalyser graphpane = new GraphAnalyser(); 452 graphPane = new JScrollPane (graphpane.update(vue)); 453 panelHaut.add(graphPane); 454 panelHaut.validate(); 455 456 } 457 458 459 460 461 public void setView(View vue) 462 { 463 testIdField.setText(vue.getTestId()); 464 nameField.setText(vue.getName()); 465 machineField.setText(vue.getNommachine()); 466 threadField.setText((String ) ("" + vue.getNumthread()+ "")); 467 intervalField.setText((String ) (vue.getDatedebut() + "-" + vue.getDatefin())) ; 468 message.clearText(); 471 message.setOutputText(vue.getResult()); 472 } 473 474 475 public String getView() 476 { 477 return nameField.getText(); 478 } 479 480 public String getTest() 481 { 482 return testCombo.getSelectedItem().toString(); 483 } 484 485 public void valueChanged(TreeSelectionEvent e) { 486 DefaultMutableTreeNode node = (DefaultMutableTreeNode ) tree.getLastSelectedPathComponent(); 487 if (node == null) return; 488 if (node.isLeaf()) { 489 View selectedView = a.wichViewNamed(node.getParent().toString(),node.toString()); 490 if(selectedView != null) 491 { 492 setView(selectedView); 493 tracer(selectedView); 494 } 495 } 496 } 497 498 499 public JScrollPane initTree() 500 { 501 top = new DefaultMutableTreeNode ("Existing views"); 502 createNodes(top); 503 tree = new JTree (top); 504 tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); 505 tree.setShowsRootHandles(true); 506 tree.addTreeSelectionListener(this); 507 return (new JScrollPane (tree)); 508 509 } 510 511 private void createNodes(DefaultMutableTreeNode top) { 512 513 DefaultMutableTreeNode rep = null; 514 DefaultMutableTreeNode file = null; 515 516 517 for(int i = 0 ; vues[i][0] != null ; i++) 518 { 519 rep = new DefaultMutableTreeNode ((String ) vues[i][0]); 520 top.add(rep); 521 for(int j = 1 ; vues[i][j] != null ; j++) 522 { 523 file = new DefaultMutableTreeNode ((String ) vues[i][j]); 524 rep.add(file); 525 } 526 } 527 } 528 529 530 531 public void updateViewTree(String [][] existingviews) 532 { 533 534 for(int i = 0 ; existingviews[i][0] != null ; i++) 535 for(int j = 0 ; existingviews[i][j] != null ; j++) 536 { 537 vues[i][j] = existingviews[i][j] ; 538 } 539 540 panelDroite.remove(treePane); 541 542 treePane = initTree(); 543 panelDroite.add(treePane,cTree); panelDroite.validate(); 546 547 548 549 } 550 551 552 553 554 } 555 | Popular Tags |