00001 package edu.ksu.cis.bandera.bui;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import edu.ksu.cis.bandera.jjjc.*;
00036 import edu.ksu.cis.bandera.annotation.*;
00037 import edu.ksu.cis.bandera.specification.predicate.datastructure.*;
00038 import java.awt.*;
00039 import java.util.*;
00040 import javax.swing.*;
00041 import javax.swing.tree.*;
00042 public class PredicateBrowser extends JFrame {
00043 private JLabel ivjConstraintLabel = null;
00044 private JTextField ivjConstraintTextField = null;
00045 private JLabel ivjDescriptionLabel = null;
00046 private JScrollPane ivjDescriptionScrollPane = null;
00047 private JTextArea ivjDescriptionTextArea = null;
00048 private JButton ivjGotoButton = null;
00049 private JLabel ivjNameLabel = null;
00050 private JTextField ivjNameTextField = null;
00051 private JButton ivjOkButton = null;
00052 private JPanel ivjPredicateBrowserContentPane = null;
00053 private JSplitPane ivjPredicateBrowserSplitPane = null;
00054 private JPanel ivjPredicatePanel = null;
00055 private JScrollPane ivjPredicateScrollPane = null;
00056 private JTree ivjPredicateTree = null;
00057 private JLabel ivjTypeLabel = null;
00058 private JTextField ivjTypeTextField = null;
00059 private JButton ivjErrorMessageButton = null;
00060 IvjEventHandler ivjEventHandler = new IvjEventHandler();
00061 private JButton ivjAddButton = null;
00062
00063 class IvjEventHandler implements java.awt.event.ActionListener, javax.swing.event.TreeSelectionListener {
00064 public void actionPerformed(java.awt.event.ActionEvent e) {
00065 if (e.getSource() == PredicateBrowser.this.getOkButton())
00066 connEtoM1(e);
00067 if (e.getSource() == PredicateBrowser.this.getErrorMessageButton())
00068 connEtoC2();
00069 if (e.getSource() == PredicateBrowser.this.getGotoButton())
00070 connEtoC3();
00071 if (e.getSource() == PredicateBrowser.this.getAddButton())
00072 connEtoC4();
00073 };
00074 public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
00075 if (e.getSource() == PredicateBrowser.this.getPredicateTree())
00076 connEtoC1();
00077 };
00078 };
00079
00080
00081
00082 public PredicateBrowser() {
00083 super();
00084 initialize();
00085 }
00086
00087
00088
00089
00090 public PredicateBrowser(String title) {
00091 super(title);
00092 }
00093
00094
00095
00096 public void addButton_ActionEvents() {
00097 Object o = ((DefaultMutableTreeNode) getPredicateTree().getLastSelectedPathComponent()).getUserObject();
00098 if (o instanceof Predicate) {
00099 Predicate p = (Predicate) o;
00100 BUI.propertyManager.getPropositionTextField().setText(BUI.propertyManager.getPropositionTextField().getText() + p.getName());
00101 BUI.propertyManager.propositionTextField_KeyEvents();
00102 BUI.propertyManager.setVisible(true);
00103 BUI.propertyManager.requestFocus();
00104 BUI.propertyManager.getPropertyManagerTabbedPane().setSelectedIndex(1);
00105 }
00106 }
00107
00108
00109
00110
00111
00112
00113 private DefaultMutableTreeNode buildTree(DefaultMutableTreeNode root, Object object) {
00114 if (object instanceof Hashtable) {
00115 Hashtable table = (Hashtable) object;
00116 TreeSet ts = new TreeSet();
00117 for (Enumeration e = table.keys(); e.hasMoreElements();) {
00118 ts.add(e.nextElement());
00119 }
00120
00121 for (Iterator i = ts.iterator(); i.hasNext();) {
00122 Object key = i.next();
00123 Object value = table.get(key);
00124 root.add(buildTree(new DefaultMutableTreeNode(key.toString()), value));
00125 }
00126 } else if (object instanceof PredicateSet) {
00127 PredicateSet set = (PredicateSet) object;
00128 Hashtable table = set.getPredicateTable();
00129 TreeSet ts = new TreeSet();
00130 for (Enumeration e = table.keys(); e.hasMoreElements();) {
00131 ts.add(e.nextElement());
00132 }
00133 for (Iterator i = ts.iterator(); i.hasNext();) {
00134 root.add(new DefaultMutableTreeNode(table.get(i.next())));
00135 }
00136 }
00137 return root;
00138 }
00139
00140
00141
00142
00143 private void connEtoC1() {
00144 try {
00145
00146
00147 this.predicateTree_TreeSelectionEvents();
00148
00149
00150 } catch (java.lang.Throwable ivjExc) {
00151
00152
00153 handleException(ivjExc);
00154 }
00155 }
00156
00157
00158
00159
00160 private void connEtoC2() {
00161 try {
00162
00163
00164 this.errorMessageButton_ActionEvents();
00165
00166
00167 } catch (java.lang.Throwable ivjExc) {
00168
00169
00170 handleException(ivjExc);
00171 }
00172 }
00173
00174
00175
00176
00177 private void connEtoC3() {
00178 try {
00179
00180
00181 this.gotoButton_ActionEvents();
00182
00183
00184 } catch (java.lang.Throwable ivjExc) {
00185
00186
00187 handleException(ivjExc);
00188 }
00189 }
00190
00191
00192
00193
00194 private void connEtoC4() {
00195 try {
00196
00197
00198 this.addButton_ActionEvents();
00199
00200
00201 } catch (java.lang.Throwable ivjExc) {
00202
00203
00204 handleException(ivjExc);
00205 }
00206 }
00207
00208
00209
00210
00211
00212 private void connEtoM1(java.awt.event.ActionEvent arg1) {
00213 try {
00214
00215
00216 this.setVisible(false);
00217
00218
00219 } catch (java.lang.Throwable ivjExc) {
00220
00221
00222 handleException(ivjExc);
00223 }
00224 }
00225
00226
00227
00228 public void errorMessageButton_ActionEvents() {
00229 StringBuffer buffer = new StringBuffer();
00230 Predicate p = (Predicate) ((DefaultMutableTreeNode) getPredicateTree().getLastSelectedPathComponent()).getUserObject();
00231 for (Enumeration e = p.getExceptions().elements(); e.hasMoreElements();) {
00232 Exception ex = (Exception) e.nextElement();
00233 buffer.append(ex.getMessage() + "\n");
00234 }
00235 JOptionPane.showMessageDialog(this, buffer.toString(), "Information", JOptionPane.INFORMATION_MESSAGE);
00236 }
00237
00238
00239
00240
00241
00242 private javax.swing.JButton getAddButton() {
00243 if (ivjAddButton == null) {
00244 try {
00245 ivjAddButton = new javax.swing.JButton();
00246 ivjAddButton.setName("AddButton");
00247 ivjAddButton.setMnemonic('a');
00248 ivjAddButton.setText("Add to property");
00249 ivjAddButton.setBackground(new java.awt.Color(204,204,255));
00250 ivjAddButton.setEnabled(false);
00251
00252
00253 } catch (java.lang.Throwable ivjExc) {
00254
00255
00256 handleException(ivjExc);
00257 }
00258 }
00259 return ivjAddButton;
00260 }
00261
00262
00263
00264
00265 private static void getBuilderData() {
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 }
00314
00315
00316
00317
00318
00319 private javax.swing.JLabel getConstraintLabel() {
00320 if (ivjConstraintLabel == null) {
00321 try {
00322 ivjConstraintLabel = new javax.swing.JLabel();
00323 ivjConstraintLabel.setName("ConstraintLabel");
00324 ivjConstraintLabel.setText("Constraint:");
00325 ivjConstraintLabel.setForeground(java.awt.Color.black);
00326
00327
00328 } catch (java.lang.Throwable ivjExc) {
00329
00330
00331 handleException(ivjExc);
00332 }
00333 }
00334 return ivjConstraintLabel;
00335 }
00336
00337
00338
00339
00340
00341 private javax.swing.JTextField getConstraintTextField() {
00342 if (ivjConstraintTextField == null) {
00343 try {
00344 ivjConstraintTextField = new javax.swing.JTextField();
00345 ivjConstraintTextField.setName("ConstraintTextField");
00346 ivjConstraintTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00347 ivjConstraintTextField.setEditable(false);
00348
00349
00350 } catch (java.lang.Throwable ivjExc) {
00351
00352
00353 handleException(ivjExc);
00354 }
00355 }
00356 return ivjConstraintTextField;
00357 }
00358
00359
00360
00361
00362
00363 private javax.swing.JLabel getDescriptionLabel() {
00364 if (ivjDescriptionLabel == null) {
00365 try {
00366 ivjDescriptionLabel = new javax.swing.JLabel();
00367 ivjDescriptionLabel.setName("DescriptionLabel");
00368 ivjDescriptionLabel.setText("Description:");
00369 ivjDescriptionLabel.setForeground(java.awt.Color.black);
00370
00371
00372 } catch (java.lang.Throwable ivjExc) {
00373
00374
00375 handleException(ivjExc);
00376 }
00377 }
00378 return ivjDescriptionLabel;
00379 }
00380
00381
00382
00383
00384
00385 private javax.swing.JScrollPane getDescriptionScrollPane() {
00386 if (ivjDescriptionScrollPane == null) {
00387 try {
00388 ivjDescriptionScrollPane = new javax.swing.JScrollPane();
00389 ivjDescriptionScrollPane.setName("DescriptionScrollPane");
00390 getDescriptionScrollPane().setViewportView(getDescriptionTextArea());
00391
00392
00393 } catch (java.lang.Throwable ivjExc) {
00394
00395
00396 handleException(ivjExc);
00397 }
00398 }
00399 return ivjDescriptionScrollPane;
00400 }
00401
00402
00403
00404
00405
00406 private javax.swing.JTextArea getDescriptionTextArea() {
00407 if (ivjDescriptionTextArea == null) {
00408 try {
00409 ivjDescriptionTextArea = new javax.swing.JTextArea();
00410 ivjDescriptionTextArea.setName("DescriptionTextArea");
00411 ivjDescriptionTextArea.setBorder(BorderFactory.createLoweredBevelBorder());
00412 ivjDescriptionTextArea.setBackground(new java.awt.Color(204,204,204));
00413 ivjDescriptionTextArea.setBounds(0, 0, 160, 120);
00414 ivjDescriptionTextArea.setEditable(false);
00415
00416
00417 } catch (java.lang.Throwable ivjExc) {
00418
00419
00420 handleException(ivjExc);
00421 }
00422 }
00423 return ivjDescriptionTextArea;
00424 }
00425
00426
00427
00428
00429
00430 private javax.swing.JButton getErrorMessageButton() {
00431 if (ivjErrorMessageButton == null) {
00432 try {
00433 ivjErrorMessageButton = new javax.swing.JButton();
00434 ivjErrorMessageButton.setName("ErrorMessageButton");
00435 ivjErrorMessageButton.setMnemonic('e');
00436 ivjErrorMessageButton.setText("Show Error Message(s)");
00437 ivjErrorMessageButton.setBackground(new java.awt.Color(204,204,255));
00438 ivjErrorMessageButton.setEnabled(false);
00439
00440
00441 } catch (java.lang.Throwable ivjExc) {
00442
00443
00444 handleException(ivjExc);
00445 }
00446 }
00447 return ivjErrorMessageButton;
00448 }
00449
00450
00451
00452
00453
00454 private javax.swing.JButton getGotoButton() {
00455 if (ivjGotoButton == null) {
00456 try {
00457 ivjGotoButton = new javax.swing.JButton();
00458 ivjGotoButton.setName("GotoButton");
00459 ivjGotoButton.setMnemonic('g');
00460 ivjGotoButton.setText("Goto Definition");
00461 ivjGotoButton.setBackground(new java.awt.Color(204,204,255));
00462 ivjGotoButton.setEnabled(false);
00463
00464
00465 } catch (java.lang.Throwable ivjExc) {
00466
00467
00468 handleException(ivjExc);
00469 }
00470 }
00471 return ivjGotoButton;
00472 }
00473
00474
00475
00476
00477
00478 private javax.swing.JLabel getNameLabel() {
00479 if (ivjNameLabel == null) {
00480 try {
00481 ivjNameLabel = new javax.swing.JLabel();
00482 ivjNameLabel.setName("NameLabel");
00483 ivjNameLabel.setText("Name:");
00484 ivjNameLabel.setForeground(java.awt.Color.black);
00485
00486
00487 } catch (java.lang.Throwable ivjExc) {
00488
00489
00490 handleException(ivjExc);
00491 }
00492 }
00493 return ivjNameLabel;
00494 }
00495
00496
00497
00498
00499
00500 private javax.swing.JTextField getNameTextField() {
00501 if (ivjNameTextField == null) {
00502 try {
00503 ivjNameTextField = new javax.swing.JTextField();
00504 ivjNameTextField.setName("NameTextField");
00505 ivjNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00506 ivjNameTextField.setEditable(false);
00507
00508
00509 } catch (java.lang.Throwable ivjExc) {
00510
00511
00512 handleException(ivjExc);
00513 }
00514 }
00515 return ivjNameTextField;
00516 }
00517
00518
00519
00520
00521
00522 private javax.swing.JButton getOkButton() {
00523 if (ivjOkButton == null) {
00524 try {
00525 ivjOkButton = new javax.swing.JButton();
00526 ivjOkButton.setName("OkButton");
00527 ivjOkButton.setMnemonic('o');
00528 ivjOkButton.setText("Ok");
00529 ivjOkButton.setBackground(new java.awt.Color(204,204,255));
00530
00531
00532 } catch (java.lang.Throwable ivjExc) {
00533
00534
00535 handleException(ivjExc);
00536 }
00537 }
00538 return ivjOkButton;
00539 }
00540
00541
00542
00543
00544
00545 private javax.swing.JPanel getPredicateBrowserContentPane() {
00546 if (ivjPredicateBrowserContentPane == null) {
00547 try {
00548 ivjPredicateBrowserContentPane = new javax.swing.JPanel();
00549 ivjPredicateBrowserContentPane.setName("PredicateBrowserContentPane");
00550 ivjPredicateBrowserContentPane.setBorder(new javax.swing.border.EtchedBorder());
00551 ivjPredicateBrowserContentPane.setLayout(new java.awt.BorderLayout());
00552 ivjPredicateBrowserContentPane.setBackground(new java.awt.Color(204,204,255));
00553 getPredicateBrowserContentPane().add(getOkButton(), "South");
00554 getPredicateBrowserContentPane().add(getPredicateBrowserSplitPane(), "Center");
00555
00556
00557 } catch (java.lang.Throwable ivjExc) {
00558
00559
00560 handleException(ivjExc);
00561 }
00562 }
00563 return ivjPredicateBrowserContentPane;
00564 }
00565
00566
00567
00568
00569
00570 private javax.swing.JSplitPane getPredicateBrowserSplitPane() {
00571 if (ivjPredicateBrowserSplitPane == null) {
00572 try {
00573 ivjPredicateBrowserSplitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
00574 ivjPredicateBrowserSplitPane.setName("PredicateBrowserSplitPane");
00575 getPredicateBrowserSplitPane().add(getPredicateScrollPane(), "left");
00576 getPredicateBrowserSplitPane().add(getPredicatePanel(), "right");
00577
00578
00579 } catch (java.lang.Throwable ivjExc) {
00580
00581
00582 handleException(ivjExc);
00583 }
00584 }
00585 return ivjPredicateBrowserSplitPane;
00586 }
00587
00588
00589
00590
00591
00592 private javax.swing.JPanel getPredicatePanel() {
00593 if (ivjPredicatePanel == null) {
00594 try {
00595 ivjPredicatePanel = new javax.swing.JPanel();
00596 ivjPredicatePanel.setName("PredicatePanel");
00597 ivjPredicatePanel.setBorder(new javax.swing.border.EtchedBorder());
00598 ivjPredicatePanel.setLayout(new java.awt.GridBagLayout());
00599 ivjPredicatePanel.setBackground(new java.awt.Color(204,204,255));
00600
00601 java.awt.GridBagConstraints constraintsNameLabel = new java.awt.GridBagConstraints();
00602 constraintsNameLabel.gridx = 0; constraintsNameLabel.gridy = 0;
00603 constraintsNameLabel.fill = java.awt.GridBagConstraints.BOTH;
00604 constraintsNameLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00605 getPredicatePanel().add(getNameLabel(), constraintsNameLabel);
00606
00607 java.awt.GridBagConstraints constraintsNameTextField = new java.awt.GridBagConstraints();
00608 constraintsNameTextField.gridx = 1; constraintsNameTextField.gridy = 0;
00609 constraintsNameTextField.gridwidth = 4;
00610 constraintsNameTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00611 constraintsNameTextField.weightx = 1.0;
00612 constraintsNameTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00613 getPredicatePanel().add(getNameTextField(), constraintsNameTextField);
00614
00615 java.awt.GridBagConstraints constraintsTypeLabel = new java.awt.GridBagConstraints();
00616 constraintsTypeLabel.gridx = 0; constraintsTypeLabel.gridy = 1;
00617 constraintsTypeLabel.fill = java.awt.GridBagConstraints.BOTH;
00618 constraintsTypeLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00619 getPredicatePanel().add(getTypeLabel(), constraintsTypeLabel);
00620
00621 java.awt.GridBagConstraints constraintsTypeTextField = new java.awt.GridBagConstraints();
00622 constraintsTypeTextField.gridx = 1; constraintsTypeTextField.gridy = 1;
00623 constraintsTypeTextField.gridwidth = 4;
00624 constraintsTypeTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00625 constraintsTypeTextField.weightx = 1.0;
00626 constraintsTypeTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00627 getPredicatePanel().add(getTypeTextField(), constraintsTypeTextField);
00628
00629 java.awt.GridBagConstraints constraintsConstraintLabel = new java.awt.GridBagConstraints();
00630 constraintsConstraintLabel.gridx = 0; constraintsConstraintLabel.gridy = 2;
00631 constraintsConstraintLabel.fill = java.awt.GridBagConstraints.BOTH;
00632 constraintsConstraintLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00633 getPredicatePanel().add(getConstraintLabel(), constraintsConstraintLabel);
00634
00635 java.awt.GridBagConstraints constraintsConstraintTextField = new java.awt.GridBagConstraints();
00636 constraintsConstraintTextField.gridx = 1; constraintsConstraintTextField.gridy = 2;
00637 constraintsConstraintTextField.gridwidth = 4;
00638 constraintsConstraintTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00639 constraintsConstraintTextField.weightx = 1.0;
00640 constraintsConstraintTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00641 getPredicatePanel().add(getConstraintTextField(), constraintsConstraintTextField);
00642
00643 java.awt.GridBagConstraints constraintsDescriptionLabel = new java.awt.GridBagConstraints();
00644 constraintsDescriptionLabel.gridx = 0; constraintsDescriptionLabel.gridy = 3;
00645 constraintsDescriptionLabel.gridwidth = 5;
00646 constraintsDescriptionLabel.fill = java.awt.GridBagConstraints.BOTH;
00647 constraintsDescriptionLabel.insets = new java.awt.Insets(15, 10, 0, 10);
00648 getPredicatePanel().add(getDescriptionLabel(), constraintsDescriptionLabel);
00649
00650 java.awt.GridBagConstraints constraintsDescriptionScrollPane = new java.awt.GridBagConstraints();
00651 constraintsDescriptionScrollPane.gridx = 0; constraintsDescriptionScrollPane.gridy = 4;
00652 constraintsDescriptionScrollPane.gridwidth = 5;
00653 constraintsDescriptionScrollPane.fill = java.awt.GridBagConstraints.BOTH;
00654 constraintsDescriptionScrollPane.weightx = 1.0;
00655 constraintsDescriptionScrollPane.weighty = 1.0;
00656 constraintsDescriptionScrollPane.insets = new java.awt.Insets(5, 10, 0, 10);
00657 getPredicatePanel().add(getDescriptionScrollPane(), constraintsDescriptionScrollPane);
00658
00659 java.awt.GridBagConstraints constraintsGotoButton = new java.awt.GridBagConstraints();
00660 constraintsGotoButton.gridx = 2; constraintsGotoButton.gridy = 5;
00661 constraintsGotoButton.gridwidth = 2;
00662 constraintsGotoButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
00663 constraintsGotoButton.weightx = 1.0;
00664 constraintsGotoButton.insets = new java.awt.Insets(15, 10, 10, 10);
00665 getPredicatePanel().add(getGotoButton(), constraintsGotoButton);
00666
00667 java.awt.GridBagConstraints constraintsErrorMessageButton = new java.awt.GridBagConstraints();
00668 constraintsErrorMessageButton.gridx = 4; constraintsErrorMessageButton.gridy = 5;
00669 constraintsErrorMessageButton.fill = java.awt.GridBagConstraints.BOTH;
00670 constraintsErrorMessageButton.weightx = 1.0;
00671 constraintsErrorMessageButton.insets = new java.awt.Insets(15, 0, 10, 10);
00672 getPredicatePanel().add(getErrorMessageButton(), constraintsErrorMessageButton);
00673
00674 java.awt.GridBagConstraints constraintsAddButton = new java.awt.GridBagConstraints();
00675 constraintsAddButton.gridx = 0; constraintsAddButton.gridy = 5;
00676 constraintsAddButton.gridwidth = 2;
00677 constraintsAddButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
00678 constraintsAddButton.weightx = 1.0;
00679 constraintsAddButton.insets = new java.awt.Insets(15, 10, 10, 0);
00680 getPredicatePanel().add(getAddButton(), constraintsAddButton);
00681
00682
00683 } catch (java.lang.Throwable ivjExc) {
00684
00685
00686 handleException(ivjExc);
00687 }
00688 }
00689 return ivjPredicatePanel;
00690 }
00691
00692
00693
00694
00695
00696 private javax.swing.JScrollPane getPredicateScrollPane() {
00697 if (ivjPredicateScrollPane == null) {
00698 try {
00699 ivjPredicateScrollPane = new javax.swing.JScrollPane();
00700 ivjPredicateScrollPane.setName("PredicateScrollPane");
00701 ivjPredicateScrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
00702 getPredicateScrollPane().setViewportView(getPredicateTree());
00703
00704
00705 } catch (java.lang.Throwable ivjExc) {
00706
00707
00708 handleException(ivjExc);
00709 }
00710 }
00711 return ivjPredicateScrollPane;
00712 }
00713
00714
00715
00716
00717
00718 private javax.swing.JTree getPredicateTree() {
00719 if (ivjPredicateTree == null) {
00720 try {
00721 ivjPredicateTree = new javax.swing.JTree();
00722 ivjPredicateTree.setName("PredicateTree");
00723 ivjPredicateTree.setBackground(new java.awt.Color(204,204,204));
00724 ivjPredicateTree.setBounds(0, 0, 526, 299);
00725
00726 ivjPredicateTree.setUI(new javax.swing.plaf.metal.MetalTreeUI() {
00727 public javax.swing.plaf.metal.MetalTreeUI setAngledColor() {
00728 setHashColor(Color.black);
00729 return this;
00730 }
00731 }.setAngledColor());
00732 ivjPredicateTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
00733 ivjPredicateTree.setCellRenderer(new DefaultTreeCellRenderer() {
00734 public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
00735 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
00736 setIcon(null);
00737 Object o = ((DefaultMutableTreeNode) value).getUserObject();
00738 if (o instanceof PredicateSet) {
00739 setText(((PredicateSet) o).getName().toString());
00740 } else if (o instanceof Predicate) {
00741 Predicate p = (Predicate) o;
00742 setText(p.getName().getLastIdentifier());
00743 if (!p.isValid())
00744 setIcon(IconLibrary.errorIcon);
00745 }
00746 return this;
00747 }
00748 });
00749 ((DefaultTreeCellRenderer) ivjPredicateTree.getCellRenderer()).setBackgroundNonSelectionColor(new Color(204, 204, 204));
00750 ivjPredicateTree.putClientProperty("JTree.lineStyle", "Angled");
00751
00752 } catch (java.lang.Throwable ivjExc) {
00753
00754
00755 handleException(ivjExc);
00756 }
00757 }
00758 return ivjPredicateTree;
00759 }
00760
00761
00762
00763
00764
00765 private javax.swing.JLabel getTypeLabel() {
00766 if (ivjTypeLabel == null) {
00767 try {
00768 ivjTypeLabel = new javax.swing.JLabel();
00769 ivjTypeLabel.setName("TypeLabel");
00770 ivjTypeLabel.setText("Type:");
00771 ivjTypeLabel.setForeground(java.awt.Color.black);
00772
00773
00774 } catch (java.lang.Throwable ivjExc) {
00775
00776
00777 handleException(ivjExc);
00778 }
00779 }
00780 return ivjTypeLabel;
00781 }
00782
00783
00784
00785
00786
00787 private javax.swing.JTextField getTypeTextField() {
00788 if (ivjTypeTextField == null) {
00789 try {
00790 ivjTypeTextField = new javax.swing.JTextField();
00791 ivjTypeTextField.setName("TypeTextField");
00792 ivjTypeTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00793 ivjTypeTextField.setEditable(false);
00794
00795
00796 } catch (java.lang.Throwable ivjExc) {
00797
00798
00799 handleException(ivjExc);
00800 }
00801 }
00802 return ivjTypeTextField;
00803 }
00804
00805
00806
00807 public void gotoButton_ActionEvents() {
00808 Predicate p = (Predicate) ((DefaultMutableTreeNode) getPredicateTree().getLastSelectedPathComponent()).getUserObject();
00809 if (p instanceof ExpressionPredicate) {
00810 BUI.sessionPane.select(CompilationManager.getCompiledClasses().get(p.getType().getName().toString()) , p);
00811 BUI.bui.requestFocus();
00812 } else {
00813 Annotation a = p.getAnnotation();
00814 if (a instanceof LabeledStmtAnnotation) {
00815 a = CompilationManager.getAnnotationManager().getMethodAnnotationContainingAnnotation(a);
00816 }
00817 BUI.sessionPane.select(a, p);
00818 }
00819 }
00820
00821
00822
00823
00824 private void handleException(java.lang.Throwable exception) {
00825
00826
00827
00828
00829 }
00830
00831
00832
00833
00834
00835 private void initConnections() throws java.lang.Exception {
00836
00837
00838 getOkButton().addActionListener(ivjEventHandler);
00839 getPredicateTree().addTreeSelectionListener(ivjEventHandler);
00840 getErrorMessageButton().addActionListener(ivjEventHandler);
00841 getGotoButton().addActionListener(ivjEventHandler);
00842 getAddButton().addActionListener(ivjEventHandler);
00843 }
00844
00845
00846
00847
00848 private void initialize() {
00849 try {
00850
00851
00852 setName("PredicateBrowser");
00853 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
00854 setSize(529, 335);
00855 setTitle("Predicate Browser");
00856 setContentPane(getPredicateBrowserContentPane());
00857 initConnections();
00858 } catch (java.lang.Throwable ivjExc) {
00859 handleException(ivjExc);
00860 }
00861
00862 updateTree();
00863
00864 }
00865
00866
00867
00868
00869 public static void main(java.lang.String[] args) {
00870 try {
00871 PredicateBrowser aPredicateBrowser;
00872 aPredicateBrowser = new PredicateBrowser();
00873 aPredicateBrowser.addWindowListener(new java.awt.event.WindowAdapter() {
00874 public void windowClosing(java.awt.event.WindowEvent e) {
00875 System.exit(0);
00876 };
00877 });
00878 aPredicateBrowser.setVisible(true);
00879 } catch (Throwable exception) {
00880 System.err.println("Exception occurred in main() of javax.swing.JFrame");
00881 exception.printStackTrace(System.out);
00882 }
00883 }
00884
00885
00886
00887 public void predicateTree_TreeSelectionEvents() {
00888 Object o = ((DefaultMutableTreeNode) getPredicateTree().getLastSelectedPathComponent()).getUserObject();
00889 if (o instanceof Predicate) {
00890 Predicate p = (Predicate) o;
00891 getNameTextField().setText(p.getName().toString());
00892 String si = p.isStatic() ? "Static " : "Instance ";
00893 if (p instanceof LocationPredicate) {
00894 getTypeTextField().setText(si + "Location Predicate on label '" + ((LocationPredicate) p).getLabel() + "'");
00895 } else if (p instanceof ExpressionPredicate) {
00896 getTypeTextField().setText(si + "Expression Predicate");
00897 } else if (p instanceof ReturnPredicate) {
00898 getTypeTextField().setText(si + "Return Predicate");
00899 } else if (p instanceof InvokePredicate) {
00900 getTypeTextField().setText(si + "Invoke Predicate");
00901 }
00902 getConstraintTextField().setText(p.getConstraint() == null ? "none" : p.getConstraint().toString().trim());
00903 getDescriptionTextArea().setText(p.getDescription() == null ? "none" : p.getDescription());
00904 getErrorMessageButton().setEnabled(!p.isValid());
00905 getGotoButton().setEnabled(true);
00906 getAddButton().setEnabled(p.isValid() && (BUI.property.getActivatedTemporalLogicProperty() != null));
00907 } else {
00908 getErrorMessageButton().setEnabled(false);
00909 getGotoButton().setEnabled(false);
00910 getAddButton().setEnabled(false);
00911 getNameTextField().setText("");
00912 getTypeTextField().setText("");
00913 getConstraintTextField().setText("");
00914 getDescriptionTextArea().setText("");
00915 }
00916 }
00917
00918
00919
00920 public void updateTree() {
00921 getPredicateTree().setModel(new DefaultTreeModel(buildTree(new DefaultMutableTreeNode("Predicate"), PredicateSet.getPredicateSetTable())));
00922 getPredicateScrollPane().validate();
00923 getPredicateScrollPane().repaint();
00924
00925 }
00926 }