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 javax.swing.table.*;
00036 import java.io.*;
00037 import java.util.*;
00038 import java.awt.*;
00039 import javax.swing.*;
00040 import javax.swing.tree.*;
00041 import edu.ksu.cis.bandera.specification.pattern.*;
00042 import edu.ksu.cis.bandera.specification.pattern.datastructure.*;
00043 public class PatternManager extends JFrame {
00044 private static String[] columnNames = { "Temporal Logic", "Patterned Formula" };
00045 private JScrollPane ivjLeftScrollPane = null;
00046 private JButton ivjOkButton = null;
00047 private JPanel ivjPatternManagerContentPane = null;
00048 private JSplitPane ivjPatternManagerSplitPane = null;
00049 private JPanel ivjPatternPanel = null;
00050 private JLabel ivjDescriptionLabel = null;
00051 private JScrollPane ivjDescriptionScrollPane = null;
00052 private JTextArea ivjDescriptionTextArea = null;
00053 private JLabel ivjMappingLabel = null;
00054 private JLabel ivjNameLabel = null;
00055 private JTextField ivjNameTextField = null;
00056 private JLabel ivjParametersLabel = null;
00057 private JTextField ivjParametersTextField = null;
00058 private JLabel ivjScopeLabel = null;
00059 private JTextField ivjScopeTextField = null;
00060 private JTree ivjPatternTree = null;
00061 private JLabel ivjFormatLabel = null;
00062 private JTextField ivjFormatTextField = null;
00063 private JTable ivjMappingTable = null;
00064 private JScrollPane ivjMappingScrollPane = null;
00065 private java.awt.Color bg = new Color(204, 204, 204);
00066 private JPanel ivjButtonsPanel = null;
00067 private JButton ivjLoadButton = null;
00068 private JButton ivjSaveButton = null;
00069 private JButton ivjErrorMessagesButton = null;
00070 private JPanel ivjPatternButtonsPanel = null;
00071 private JButton ivjAddMappingButton = null;
00072 private JButton ivjRemoveMappingButton = null;
00073 IvjEventHandler ivjEventHandler = new IvjEventHandler();
00074
00075 class IvjEventHandler implements java.awt.event.ActionListener, javax.swing.event.TreeSelectionListener {
00076 public void actionPerformed(java.awt.event.ActionEvent e) {
00077 if (e.getSource() == PatternManager.this.getOkButton())
00078 connEtoM1(e);
00079 if (e.getSource() == PatternManager.this.getErrorMessagesButton())
00080 connEtoC2();
00081 if (e.getSource() == PatternManager.this.getLoadButton())
00082 connEtoC3();
00083 };
00084 public void valueChanged(javax.swing.event.TreeSelectionEvent e) {
00085 if (e.getSource() == PatternManager.this.getPatternTree())
00086 connEtoC1();
00087 };
00088 };
00089
00090
00091
00092 public PatternManager() {
00093 super();
00094 initialize();
00095 }
00096
00097
00098
00099
00100 public PatternManager(String title) {
00101 super(title);
00102 }
00103
00104
00105
00106
00107
00108
00109 private DefaultMutableTreeNode buildPatternTree(DefaultMutableTreeNode root, Object object) {
00110 if (object instanceof Hashtable) {
00111 Hashtable table = (Hashtable) object;
00112 TreeSet ts = new TreeSet();
00113 for (Enumeration e = table.keys(); e.hasMoreElements();) {
00114 ts.add(e.nextElement());
00115 }
00116 for (Iterator i = ts.iterator(); i.hasNext();) {
00117 Object key = i.next();
00118 Object value = table.get(key);
00119 if (value instanceof Hashtable) {
00120 root.add(buildPatternTree(new DefaultMutableTreeNode(key), value));
00121 } else {
00122 root.add(new DefaultMutableTreeNode(value));
00123 }
00124 }
00125 }
00126 return root;
00127 }
00128
00129
00130
00131
00132 private void connEtoC1() {
00133 try {
00134
00135
00136 this.patternTree_TreeSelectionEvents();
00137
00138
00139 } catch (java.lang.Throwable ivjExc) {
00140
00141
00142 handleException(ivjExc);
00143 }
00144 }
00145
00146
00147
00148
00149 private void connEtoC2() {
00150 try {
00151
00152
00153 this.errorMessagesButton_ActionEvents();
00154
00155
00156 } catch (java.lang.Throwable ivjExc) {
00157
00158
00159 handleException(ivjExc);
00160 }
00161 }
00162
00163
00164
00165
00166 private void connEtoC3() {
00167 try {
00168
00169
00170 this.loadButton_ActionEvents();
00171
00172
00173 } catch (java.lang.Throwable ivjExc) {
00174
00175
00176 handleException(ivjExc);
00177 }
00178 }
00179
00180
00181
00182
00183
00184 private void connEtoM1(java.awt.event.ActionEvent arg1) {
00185 try {
00186
00187
00188 this.setVisible(false);
00189
00190
00191 } catch (java.lang.Throwable ivjExc) {
00192
00193
00194 handleException(ivjExc);
00195 }
00196 }
00197
00198
00199
00200 public void errorMessagesButton_ActionEvents() {
00201 StringBuffer buffer = new StringBuffer();
00202 Pattern p = (Pattern) ((DefaultMutableTreeNode) getPatternTree().getLastSelectedPathComponent()).getUserObject();
00203 for (Enumeration e = p.getExceptions().elements(); e.hasMoreElements();) {
00204 Object o = e.nextElement();
00205 if (o instanceof Exception) {
00206 Exception ex = (Exception) o;
00207 buffer.append(ex.getMessage() + "\n");
00208 } else {
00209 buffer.append(o + "\n");
00210 }
00211 }
00212 JOptionPane.showMessageDialog(this, buffer.toString(), "Information", JOptionPane.INFORMATION_MESSAGE);
00213 }
00214
00215
00216
00217
00218
00219 private javax.swing.JButton getAddMappingButton() {
00220 if (ivjAddMappingButton == null) {
00221 try {
00222 ivjAddMappingButton = new javax.swing.JButton();
00223 ivjAddMappingButton.setName("AddMappingButton");
00224 ivjAddMappingButton.setMnemonic('a');
00225 ivjAddMappingButton.setText("Add Mapping");
00226 ivjAddMappingButton.setBackground(new java.awt.Color(204,204,255));
00227 ivjAddMappingButton.setEnabled(false);
00228
00229
00230 } catch (java.lang.Throwable ivjExc) {
00231
00232
00233 handleException(ivjExc);
00234 }
00235 }
00236 return ivjAddMappingButton;
00237 }
00238
00239
00240
00241
00242 private static void getBuilderData() {
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
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 private javax.swing.JPanel getButtonsPanel() {
00311 if (ivjButtonsPanel == null) {
00312 try {
00313 ivjButtonsPanel = new javax.swing.JPanel();
00314 ivjButtonsPanel.setName("ButtonsPanel");
00315 ivjButtonsPanel.setBorder(new javax.swing.border.EtchedBorder());
00316 ivjButtonsPanel.setLayout(new java.awt.GridBagLayout());
00317 ivjButtonsPanel.setBackground(new java.awt.Color(204,204,255));
00318
00319 java.awt.GridBagConstraints constraintsSaveButton = new java.awt.GridBagConstraints();
00320 constraintsSaveButton.gridx = 1; constraintsSaveButton.gridy = 1;
00321 constraintsSaveButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
00322 constraintsSaveButton.weightx = 1.0;
00323 constraintsSaveButton.weighty = 1.0;
00324 constraintsSaveButton.insets = new java.awt.Insets(10, 10, 10, 0);
00325 getButtonsPanel().add(getSaveButton(), constraintsSaveButton);
00326
00327 java.awt.GridBagConstraints constraintsLoadButton = new java.awt.GridBagConstraints();
00328 constraintsLoadButton.gridx = 2; constraintsLoadButton.gridy = 1;
00329 constraintsLoadButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
00330 constraintsLoadButton.weightx = 1.0;
00331 constraintsLoadButton.weighty = 1.0;
00332 constraintsLoadButton.insets = new java.awt.Insets(10, 10, 10, 0);
00333 getButtonsPanel().add(getLoadButton(), constraintsLoadButton);
00334
00335 java.awt.GridBagConstraints constraintsOkButton = new java.awt.GridBagConstraints();
00336 constraintsOkButton.gridx = 3; constraintsOkButton.gridy = 1;
00337 constraintsOkButton.fill = java.awt.GridBagConstraints.HORIZONTAL;
00338 constraintsOkButton.weightx = 1.0;
00339 constraintsOkButton.weighty = 1.0;
00340 constraintsOkButton.insets = new java.awt.Insets(10, 10, 10, 10);
00341 getButtonsPanel().add(getOkButton(), constraintsOkButton);
00342
00343
00344 } catch (java.lang.Throwable ivjExc) {
00345
00346
00347 handleException(ivjExc);
00348 }
00349 }
00350 return ivjButtonsPanel;
00351 }
00352
00353
00354
00355
00356
00357 private javax.swing.JLabel getDescriptionLabel() {
00358 if (ivjDescriptionLabel == null) {
00359 try {
00360 ivjDescriptionLabel = new javax.swing.JLabel();
00361 ivjDescriptionLabel.setName("DescriptionLabel");
00362 ivjDescriptionLabel.setDisplayedMnemonic('d');
00363 ivjDescriptionLabel.setText("Description:");
00364 ivjDescriptionLabel.setForeground(java.awt.Color.black);
00365
00366
00367 } catch (java.lang.Throwable ivjExc) {
00368
00369
00370 handleException(ivjExc);
00371 }
00372 }
00373 return ivjDescriptionLabel;
00374 }
00375
00376
00377
00378
00379
00380 private javax.swing.JScrollPane getDescriptionScrollPane() {
00381 if (ivjDescriptionScrollPane == null) {
00382 try {
00383 ivjDescriptionScrollPane = new javax.swing.JScrollPane();
00384 ivjDescriptionScrollPane.setName("DescriptionScrollPane");
00385 ivjDescriptionScrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
00386 ivjDescriptionScrollPane.setBackground(java.awt.Color.white);
00387 getDescriptionScrollPane().setViewportView(getDescriptionTextArea());
00388
00389
00390 } catch (java.lang.Throwable ivjExc) {
00391
00392
00393 handleException(ivjExc);
00394 }
00395 }
00396 return ivjDescriptionScrollPane;
00397 }
00398
00399
00400
00401
00402
00403 private javax.swing.JTextArea getDescriptionTextArea() {
00404 if (ivjDescriptionTextArea == null) {
00405 try {
00406 ivjDescriptionTextArea = new javax.swing.JTextArea();
00407 ivjDescriptionTextArea.setName("DescriptionTextArea");
00408 ivjDescriptionTextArea.setLineWrap(true);
00409 ivjDescriptionTextArea.setBounds(0, 0, 160, 120);
00410 ivjDescriptionTextArea.setFocusAccelerator('d');
00411
00412
00413 } catch (java.lang.Throwable ivjExc) {
00414
00415
00416 handleException(ivjExc);
00417 }
00418 }
00419 return ivjDescriptionTextArea;
00420 }
00421
00422
00423
00424
00425
00426 private javax.swing.JButton getErrorMessagesButton() {
00427 if (ivjErrorMessagesButton == null) {
00428 try {
00429 ivjErrorMessagesButton = new javax.swing.JButton();
00430 ivjErrorMessagesButton.setName("ErrorMessagesButton");
00431 ivjErrorMessagesButton.setMnemonic('e');
00432 ivjErrorMessagesButton.setText("Show Error Message(s)");
00433 ivjErrorMessagesButton.setBackground(new java.awt.Color(204,204,255));
00434 ivjErrorMessagesButton.setEnabled(false);
00435
00436
00437 } catch (java.lang.Throwable ivjExc) {
00438
00439
00440 handleException(ivjExc);
00441 }
00442 }
00443 return ivjErrorMessagesButton;
00444 }
00445
00446
00447
00448
00449
00450 private javax.swing.JLabel getFormatLabel() {
00451 if (ivjFormatLabel == null) {
00452 try {
00453 ivjFormatLabel = new javax.swing.JLabel();
00454 ivjFormatLabel.setName("FormatLabel");
00455 ivjFormatLabel.setDisplayedMnemonic('f');
00456 ivjFormatLabel.setText("Format:");
00457 ivjFormatLabel.setForeground(java.awt.Color.black);
00458
00459
00460 } catch (java.lang.Throwable ivjExc) {
00461
00462
00463 handleException(ivjExc);
00464 }
00465 }
00466 return ivjFormatLabel;
00467 }
00468
00469
00470
00471
00472
00473 private javax.swing.JTextField getFormatTextField() {
00474 if (ivjFormatTextField == null) {
00475 try {
00476 ivjFormatTextField = new javax.swing.JTextField();
00477 ivjFormatTextField.setName("FormatTextField");
00478 ivjFormatTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00479 ivjFormatTextField.setFocusAccelerator('f');
00480
00481
00482 } catch (java.lang.Throwable ivjExc) {
00483
00484
00485 handleException(ivjExc);
00486 }
00487 }
00488 return ivjFormatTextField;
00489 }
00490
00491
00492
00493
00494
00495 private javax.swing.JScrollPane getLeftScrollPane() {
00496 if (ivjLeftScrollPane == null) {
00497 try {
00498 ivjLeftScrollPane = new javax.swing.JScrollPane();
00499 ivjLeftScrollPane.setName("LeftScrollPane");
00500 ivjLeftScrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
00501 getLeftScrollPane().setViewportView(getPatternTree());
00502
00503
00504 } catch (java.lang.Throwable ivjExc) {
00505
00506
00507 handleException(ivjExc);
00508 }
00509 }
00510 return ivjLeftScrollPane;
00511 }
00512
00513
00514
00515
00516
00517 private javax.swing.JButton getLoadButton() {
00518 if (ivjLoadButton == null) {
00519 try {
00520 ivjLoadButton = new javax.swing.JButton();
00521 ivjLoadButton.setName("LoadButton");
00522 ivjLoadButton.setMnemonic('l');
00523 ivjLoadButton.setText("Load");
00524 ivjLoadButton.setBackground(new java.awt.Color(204,204,255));
00525 ivjLoadButton.setEnabled(true);
00526
00527
00528 } catch (java.lang.Throwable ivjExc) {
00529
00530
00531 handleException(ivjExc);
00532 }
00533 }
00534 return ivjLoadButton;
00535 }
00536
00537
00538
00539
00540
00541 private javax.swing.JLabel getMappingLabel() {
00542 if (ivjMappingLabel == null) {
00543 try {
00544 ivjMappingLabel = new javax.swing.JLabel();
00545 ivjMappingLabel.setName("MappingLabel");
00546 ivjMappingLabel.setText("Mapping:");
00547 ivjMappingLabel.setForeground(java.awt.Color.black);
00548
00549
00550 } catch (java.lang.Throwable ivjExc) {
00551
00552
00553 handleException(ivjExc);
00554 }
00555 }
00556 return ivjMappingLabel;
00557 }
00558
00559
00560
00561
00562
00563 private javax.swing.JScrollPane getMappingScrollPane() {
00564 if (ivjMappingScrollPane == null) {
00565 try {
00566 ivjMappingScrollPane = new javax.swing.JScrollPane();
00567 ivjMappingScrollPane.setName("MappingScrollPane");
00568 ivjMappingScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER);
00569 ivjMappingScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
00570 ivjMappingScrollPane.setBorder(new javax.swing.border.EtchedBorder());
00571 getMappingScrollPane().setViewportView(getMappingTable());
00572
00573
00574 } catch (java.lang.Throwable ivjExc) {
00575
00576
00577 handleException(ivjExc);
00578 }
00579 }
00580 return ivjMappingScrollPane;
00581 }
00582
00583
00584
00585
00586
00587 private javax.swing.JTable getMappingTable() {
00588 if (ivjMappingTable == null) {
00589 try {
00590 ivjMappingTable = new javax.swing.JTable();
00591 ivjMappingTable.setName("MappingTable");
00592 getMappingScrollPane().setColumnHeaderView(ivjMappingTable.getTableHeader());
00593 getMappingScrollPane().getViewport().setBackingStoreEnabled(true);
00594 ivjMappingTable.setBounds(0, 0, 200, 200);
00595
00596 ivjMappingTable.setModel(new DefaultTableModel(new Object[0][0], columnNames));
00597
00598 } catch (java.lang.Throwable ivjExc) {
00599
00600
00601 handleException(ivjExc);
00602 }
00603 }
00604 return ivjMappingTable;
00605 }
00606
00607
00608
00609
00610
00611 private javax.swing.JLabel getNameLabel() {
00612 if (ivjNameLabel == null) {
00613 try {
00614 ivjNameLabel = new javax.swing.JLabel();
00615 ivjNameLabel.setName("NameLabel");
00616 ivjNameLabel.setDisplayedMnemonic('n');
00617 ivjNameLabel.setText("Name:");
00618 ivjNameLabel.setForeground(java.awt.Color.black);
00619
00620
00621 } catch (java.lang.Throwable ivjExc) {
00622
00623
00624 handleException(ivjExc);
00625 }
00626 }
00627 return ivjNameLabel;
00628 }
00629
00630
00631
00632
00633
00634 private javax.swing.JTextField getNameTextField() {
00635 if (ivjNameTextField == null) {
00636 try {
00637 ivjNameTextField = new javax.swing.JTextField();
00638 ivjNameTextField.setName("NameTextField");
00639 ivjNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00640 ivjNameTextField.setFocusAccelerator('n');
00641 ivjNameTextField.setEditable(true);
00642
00643
00644 } catch (java.lang.Throwable ivjExc) {
00645
00646
00647 handleException(ivjExc);
00648 }
00649 }
00650 return ivjNameTextField;
00651 }
00652
00653
00654
00655
00656
00657 private javax.swing.JButton getOkButton() {
00658 if (ivjOkButton == null) {
00659 try {
00660 ivjOkButton = new javax.swing.JButton();
00661 ivjOkButton.setName("OkButton");
00662 ivjOkButton.setMnemonic('o');
00663 ivjOkButton.setText("Ok");
00664 ivjOkButton.setBackground(new java.awt.Color(204,204,245));
00665
00666
00667 } catch (java.lang.Throwable ivjExc) {
00668
00669
00670 handleException(ivjExc);
00671 }
00672 }
00673 return ivjOkButton;
00674 }
00675
00676
00677
00678
00679
00680 private javax.swing.JLabel getParametersLabel() {
00681 if (ivjParametersLabel == null) {
00682 try {
00683 ivjParametersLabel = new javax.swing.JLabel();
00684 ivjParametersLabel.setName("ParametersLabel");
00685 ivjParametersLabel.setDisplayedMnemonic('p');
00686 ivjParametersLabel.setText("Parameters:");
00687 ivjParametersLabel.setForeground(java.awt.Color.black);
00688
00689
00690 } catch (java.lang.Throwable ivjExc) {
00691
00692
00693 handleException(ivjExc);
00694 }
00695 }
00696 return ivjParametersLabel;
00697 }
00698
00699
00700
00701
00702
00703 private javax.swing.JTextField getParametersTextField() {
00704 if (ivjParametersTextField == null) {
00705 try {
00706 ivjParametersTextField = new javax.swing.JTextField();
00707 ivjParametersTextField.setName("ParametersTextField");
00708 ivjParametersTextField.setBorder(BorderFactory.createLoweredBevelBorder());
00709 ivjParametersTextField.setFocusAccelerator('p');
00710
00711
00712 } catch (java.lang.Throwable ivjExc) {
00713
00714
00715 handleException(ivjExc);
00716 }
00717 }
00718 return ivjParametersTextField;
00719 }
00720
00721
00722
00723
00724
00725 private javax.swing.JPanel getPatternButtonsPanel() {
00726 if (ivjPatternButtonsPanel == null) {
00727 try {
00728 ivjPatternButtonsPanel = new javax.swing.JPanel();
00729 ivjPatternButtonsPanel.setName("PatternButtonsPanel");
00730 ivjPatternButtonsPanel.setBorder(new javax.swing.border.CompoundBorder());
00731 ivjPatternButtonsPanel.setLayout(new java.awt.GridBagLayout());
00732 ivjPatternButtonsPanel.setBackground(new java.awt.Color(204,204,255));
00733
00734 java.awt.GridBagConstraints constraintsAddMappingButton = new java.awt.GridBagConstraints();
00735 constraintsAddMappingButton.gridx = 0; constraintsAddMappingButton.gridy = 0;
00736 constraintsAddMappingButton.fill = java.awt.GridBagConstraints.BOTH;
00737 constraintsAddMappingButton.weightx = 1.0;
00738 constraintsAddMappingButton.weighty = 1.0;
00739 constraintsAddMappingButton.insets = new java.awt.Insets(5, 6, 5, 0);
00740 getPatternButtonsPanel().add(getAddMappingButton(), constraintsAddMappingButton);
00741
00742 java.awt.GridBagConstraints constraintsRemoveMappingButton = new java.awt.GridBagConstraints();
00743 constraintsRemoveMappingButton.gridx = 1; constraintsRemoveMappingButton.gridy = 0;
00744 constraintsRemoveMappingButton.fill = java.awt.GridBagConstraints.BOTH;
00745 constraintsRemoveMappingButton.weightx = 1.0;
00746 constraintsRemoveMappingButton.weighty = 1.0;
00747 constraintsRemoveMappingButton.insets = new java.awt.Insets(5, 10, 5, 0);
00748 getPatternButtonsPanel().add(getRemoveMappingButton(), constraintsRemoveMappingButton);
00749
00750 java.awt.GridBagConstraints constraintsErrorMessagesButton = new java.awt.GridBagConstraints();
00751 constraintsErrorMessagesButton.gridx = 2; constraintsErrorMessagesButton.gridy = 0;
00752 constraintsErrorMessagesButton.fill = java.awt.GridBagConstraints.BOTH;
00753 constraintsErrorMessagesButton.weightx = 1.0;
00754 constraintsErrorMessagesButton.weighty = 1.0;
00755 constraintsErrorMessagesButton.insets = new java.awt.Insets(5, 10, 5, 5);
00756 getPatternButtonsPanel().add(getErrorMessagesButton(), constraintsErrorMessagesButton);
00757
00758
00759 } catch (java.lang.Throwable ivjExc) {
00760
00761
00762 handleException(ivjExc);
00763 }
00764 }
00765 return ivjPatternButtonsPanel;
00766 }
00767
00768
00769
00770
00771
00772 private javax.swing.JPanel getPatternManagerContentPane() {
00773 if (ivjPatternManagerContentPane == null) {
00774 try {
00775 ivjPatternManagerContentPane = new javax.swing.JPanel();
00776 ivjPatternManagerContentPane.setName("PatternManagerContentPane");
00777 ivjPatternManagerContentPane.setBorder(new javax.swing.border.EtchedBorder());
00778 ivjPatternManagerContentPane.setLayout(new java.awt.BorderLayout());
00779 ivjPatternManagerContentPane.setBackground(new java.awt.Color(204,204,255));
00780 getPatternManagerContentPane().add(getPatternManagerSplitPane(), "Center");
00781 getPatternManagerContentPane().add(getButtonsPanel(), "South");
00782
00783
00784 } catch (java.lang.Throwable ivjExc) {
00785
00786
00787 handleException(ivjExc);
00788 }
00789 }
00790 return ivjPatternManagerContentPane;
00791 }
00792
00793
00794
00795
00796
00797 private javax.swing.JSplitPane getPatternManagerSplitPane() {
00798 if (ivjPatternManagerSplitPane == null) {
00799 try {
00800 ivjPatternManagerSplitPane = new javax.swing.JSplitPane(javax.swing.JSplitPane.HORIZONTAL_SPLIT);
00801 ivjPatternManagerSplitPane.setName("PatternManagerSplitPane");
00802 ivjPatternManagerSplitPane.setDividerLocation(200);
00803 getPatternManagerSplitPane().add(getPatternPanel(), "right");
00804 getPatternManagerSplitPane().add(getLeftScrollPane(), "left");
00805
00806
00807 } catch (java.lang.Throwable ivjExc) {
00808
00809
00810 handleException(ivjExc);
00811 }
00812 }
00813 return ivjPatternManagerSplitPane;
00814 }
00815
00816
00817
00818
00819
00820 private javax.swing.JPanel getPatternPanel() {
00821 if (ivjPatternPanel == null) {
00822 try {
00823 ivjPatternPanel = new javax.swing.JPanel();
00824 ivjPatternPanel.setName("PatternPanel");
00825 ivjPatternPanel.setBorder(new javax.swing.border.EtchedBorder());
00826 ivjPatternPanel.setLayout(new java.awt.GridBagLayout());
00827 ivjPatternPanel.setBackground(new java.awt.Color(204,204,255));
00828
00829 java.awt.GridBagConstraints constraintsNameLabel = new java.awt.GridBagConstraints();
00830 constraintsNameLabel.gridx = 0; constraintsNameLabel.gridy = 0;
00831 constraintsNameLabel.fill = java.awt.GridBagConstraints.BOTH;
00832 constraintsNameLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00833 getPatternPanel().add(getNameLabel(), constraintsNameLabel);
00834
00835 java.awt.GridBagConstraints constraintsNameTextField = new java.awt.GridBagConstraints();
00836 constraintsNameTextField.gridx = 1; constraintsNameTextField.gridy = 0;
00837 constraintsNameTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00838 constraintsNameTextField.weightx = 1.0;
00839 constraintsNameTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00840 getPatternPanel().add(getNameTextField(), constraintsNameTextField);
00841
00842 java.awt.GridBagConstraints constraintsScopeLabel = new java.awt.GridBagConstraints();
00843 constraintsScopeLabel.gridx = 0; constraintsScopeLabel.gridy = 1;
00844 constraintsScopeLabel.fill = java.awt.GridBagConstraints.BOTH;
00845 constraintsScopeLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00846 getPatternPanel().add(getScopeLabel(), constraintsScopeLabel);
00847
00848 java.awt.GridBagConstraints constraintsScopeTextField = new java.awt.GridBagConstraints();
00849 constraintsScopeTextField.gridx = 1; constraintsScopeTextField.gridy = 1;
00850 constraintsScopeTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00851 constraintsScopeTextField.weightx = 1.0;
00852 constraintsScopeTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00853 getPatternPanel().add(getScopeTextField(), constraintsScopeTextField);
00854
00855 java.awt.GridBagConstraints constraintsDescriptionLabel = new java.awt.GridBagConstraints();
00856 constraintsDescriptionLabel.gridx = 0; constraintsDescriptionLabel.gridy = 2;
00857 constraintsDescriptionLabel.gridwidth = 2;
00858 constraintsDescriptionLabel.fill = java.awt.GridBagConstraints.BOTH;
00859 constraintsDescriptionLabel.weightx = 1.0;
00860 constraintsDescriptionLabel.insets = new java.awt.Insets(15, 10, 0, 10);
00861 getPatternPanel().add(getDescriptionLabel(), constraintsDescriptionLabel);
00862
00863 java.awt.GridBagConstraints constraintsDescriptionScrollPane = new java.awt.GridBagConstraints();
00864 constraintsDescriptionScrollPane.gridx = 0; constraintsDescriptionScrollPane.gridy = 3;
00865 constraintsDescriptionScrollPane.gridwidth = 2;
00866 constraintsDescriptionScrollPane.fill = java.awt.GridBagConstraints.BOTH;
00867 constraintsDescriptionScrollPane.weightx = 1.0;
00868 constraintsDescriptionScrollPane.weighty = 1.0;
00869 constraintsDescriptionScrollPane.insets = new java.awt.Insets(5, 10, 0, 10);
00870 getPatternPanel().add(getDescriptionScrollPane(), constraintsDescriptionScrollPane);
00871
00872 java.awt.GridBagConstraints constraintsParametersLabel = new java.awt.GridBagConstraints();
00873 constraintsParametersLabel.gridx = 0; constraintsParametersLabel.gridy = 4;
00874 constraintsParametersLabel.fill = java.awt.GridBagConstraints.BOTH;
00875 constraintsParametersLabel.insets = new java.awt.Insets(15, 10, 0, 0);
00876 getPatternPanel().add(getParametersLabel(), constraintsParametersLabel);
00877
00878 java.awt.GridBagConstraints constraintsParametersTextField = new java.awt.GridBagConstraints();
00879 constraintsParametersTextField.gridx = 1; constraintsParametersTextField.gridy = 4;
00880 constraintsParametersTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00881 constraintsParametersTextField.weightx = 1.0;
00882 constraintsParametersTextField.insets = new java.awt.Insets(15, 10, 0, 10);
00883 getPatternPanel().add(getParametersTextField(), constraintsParametersTextField);
00884
00885 java.awt.GridBagConstraints constraintsMappingLabel = new java.awt.GridBagConstraints();
00886 constraintsMappingLabel.gridx = 0; constraintsMappingLabel.gridy = 6;
00887 constraintsMappingLabel.gridwidth = 2;
00888 constraintsMappingLabel.fill = java.awt.GridBagConstraints.BOTH;
00889 constraintsMappingLabel.weightx = 1.0;
00890 constraintsMappingLabel.insets = new java.awt.Insets(15, 10, 0, 10);
00891 getPatternPanel().add(getMappingLabel(), constraintsMappingLabel);
00892
00893 java.awt.GridBagConstraints constraintsFormatLabel = new java.awt.GridBagConstraints();
00894 constraintsFormatLabel.gridx = 0; constraintsFormatLabel.gridy = 5;
00895 constraintsFormatLabel.fill = java.awt.GridBagConstraints.BOTH;
00896 constraintsFormatLabel.insets = new java.awt.Insets(10, 10, 0, 0);
00897 getPatternPanel().add(getFormatLabel(), constraintsFormatLabel);
00898
00899 java.awt.GridBagConstraints constraintsFormatTextField = new java.awt.GridBagConstraints();
00900 constraintsFormatTextField.gridx = 1; constraintsFormatTextField.gridy = 5;
00901 constraintsFormatTextField.fill = java.awt.GridBagConstraints.HORIZONTAL;
00902 constraintsFormatTextField.weightx = 1.0;
00903 constraintsFormatTextField.insets = new java.awt.Insets(10, 10, 0, 10);
00904 getPatternPanel().add(getFormatTextField(), constraintsFormatTextField);
00905
00906 java.awt.GridBagConstraints constraintsMappingScrollPane = new java.awt.GridBagConstraints();
00907 constraintsMappingScrollPane.gridx = 0; constraintsMappingScrollPane.gridy = 7;
00908 constraintsMappingScrollPane.gridwidth = 2;
00909 constraintsMappingScrollPane.fill = java.awt.GridBagConstraints.BOTH;
00910 constraintsMappingScrollPane.weightx = 1.0;
00911 constraintsMappingScrollPane.weighty = 1.0;
00912 constraintsMappingScrollPane.insets = new java.awt.Insets(5, 10, 0, 10);
00913 getPatternPanel().add(getMappingScrollPane(), constraintsMappingScrollPane);
00914
00915 java.awt.GridBagConstraints constraintsPatternButtonsPanel = new java.awt.GridBagConstraints();
00916 constraintsPatternButtonsPanel.gridx = 0; constraintsPatternButtonsPanel.gridy = 8;
00917 constraintsPatternButtonsPanel.gridwidth = 2;
00918 constraintsPatternButtonsPanel.fill = java.awt.GridBagConstraints.BOTH;
00919 constraintsPatternButtonsPanel.weightx = 1.0;
00920 constraintsPatternButtonsPanel.insets = new java.awt.Insets(4, 4, 4, 4);
00921 getPatternPanel().add(getPatternButtonsPanel(), constraintsPatternButtonsPanel);
00922
00923
00924 } catch (java.lang.Throwable ivjExc) {
00925
00926
00927 handleException(ivjExc);
00928 }
00929 }
00930 return ivjPatternPanel;
00931 }
00932
00933
00934
00935
00936
00937 private javax.swing.JTree getPatternTree() {
00938 if (ivjPatternTree == null) {
00939 try {
00940 ivjPatternTree = new javax.swing.JTree();
00941 ivjPatternTree.setName("PatternTree");
00942 ivjPatternTree.setBackground(new java.awt.Color(204,204,204));
00943 ivjPatternTree.setBounds(0, 0, 78, 72);
00944
00945 ivjPatternTree.setUI(new javax.swing.plaf.metal.MetalTreeUI() {
00946 public javax.swing.plaf.metal.MetalTreeUI setAngledColor() {
00947 setHashColor(Color.black);
00948 return this;
00949 }
00950 }.setAngledColor());
00951 ivjPatternTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
00952 ivjPatternTree.setCellRenderer(new DefaultTreeCellRenderer() {
00953 public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
00954 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
00955 setIcon(null);
00956 Object o = ((DefaultMutableTreeNode) value).getUserObject();
00957 if (o instanceof Pattern) {
00958 String text = ((Pattern) o).getScope();
00959 setText("".equals(text) ? "unknown" : text);
00960 if (!((Pattern) o).isValid()) {
00961 setIcon(IconLibrary.errorIcon);
00962 }
00963 } else if (o instanceof String) {
00964 String text = (String) o;
00965 setText("".equals(text) ? "unknown" : text);
00966 }
00967 return this;
00968 }
00969 });
00970 ((DefaultTreeCellRenderer) ivjPatternTree.getCellRenderer()).setBackgroundNonSelectionColor(new Color(204, 204, 204));
00971 ivjPatternTree.putClientProperty("JTree.lineStyle", "Angled");
00972
00973 } catch (java.lang.Throwable ivjExc) {
00974
00975
00976 handleException(ivjExc);
00977 }
00978 }
00979 return ivjPatternTree;
00980 }
00981
00982
00983
00984
00985
00986 private javax.swing.JButton getRemoveMappingButton() {
00987 if (ivjRemoveMappingButton == null) {
00988 try {
00989 ivjRemoveMappingButton = new javax.swing.JButton();
00990 ivjRemoveMappingButton.setName("RemoveMappingButton");
00991 ivjRemoveMappingButton.setMnemonic('r');
00992 ivjRemoveMappingButton.setText("Remove Mapping");
00993 ivjRemoveMappingButton.setBackground(new java.awt.Color(204,204,255));
00994 ivjRemoveMappingButton.setEnabled(false);
00995
00996
00997 } catch (java.lang.Throwable ivjExc) {
00998
00999
01000 handleException(ivjExc);
01001 }
01002 }
01003 return ivjRemoveMappingButton;
01004 }
01005
01006
01007
01008
01009
01010 private javax.swing.JButton getSaveButton() {
01011 if (ivjSaveButton == null) {
01012 try {
01013 ivjSaveButton = new javax.swing.JButton();
01014 ivjSaveButton.setName("SaveButton");
01015 ivjSaveButton.setMnemonic('v');
01016 ivjSaveButton.setText("Save");
01017 ivjSaveButton.setBackground(new java.awt.Color(204,204,255));
01018 ivjSaveButton.setEnabled(false);
01019
01020
01021 } catch (java.lang.Throwable ivjExc) {
01022
01023
01024 handleException(ivjExc);
01025 }
01026 }
01027 return ivjSaveButton;
01028 }
01029
01030
01031
01032
01033
01034 private javax.swing.JLabel getScopeLabel() {
01035 if (ivjScopeLabel == null) {
01036 try {
01037 ivjScopeLabel = new javax.swing.JLabel();
01038 ivjScopeLabel.setName("ScopeLabel");
01039 ivjScopeLabel.setDisplayedMnemonic('s');
01040 ivjScopeLabel.setText("Scope:");
01041 ivjScopeLabel.setForeground(java.awt.Color.black);
01042
01043
01044 } catch (java.lang.Throwable ivjExc) {
01045
01046
01047 handleException(ivjExc);
01048 }
01049 }
01050 return ivjScopeLabel;
01051 }
01052
01053
01054
01055
01056
01057 private javax.swing.JTextField getScopeTextField() {
01058 if (ivjScopeTextField == null) {
01059 try {
01060 ivjScopeTextField = new javax.swing.JTextField();
01061 ivjScopeTextField.setName("ScopeTextField");
01062 ivjScopeTextField.setBorder(BorderFactory.createLoweredBevelBorder());
01063 ivjScopeTextField.setFocusAccelerator('s');
01064
01065
01066 } catch (java.lang.Throwable ivjExc) {
01067
01068
01069 handleException(ivjExc);
01070 }
01071 }
01072 return ivjScopeTextField;
01073 }
01074
01075
01076
01077
01078 private void handleException(java.lang.Throwable exception) {
01079
01080
01081
01082
01083 }
01084
01085
01086
01087
01088
01089 private void initConnections() throws java.lang.Exception {
01090
01091
01092 getPatternTree().addTreeSelectionListener(ivjEventHandler);
01093 getOkButton().addActionListener(ivjEventHandler);
01094 getErrorMessagesButton().addActionListener(ivjEventHandler);
01095 getLoadButton().addActionListener(ivjEventHandler);
01096 }
01097
01098
01099
01100
01101 private void initialize() {
01102 try {
01103
01104
01105 setName("PatternManager");
01106 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
01107 setSize(663, 427);
01108 setTitle("Pattern Manager");
01109 setContentPane(getPatternManagerContentPane());
01110 initConnections();
01111 } catch (java.lang.Throwable ivjExc) {
01112 handleException(ivjExc);
01113 }
01114
01115 updatePatternTree();
01116 setAllEditable(false);
01117
01118 }
01119
01120
01121
01122 public void loadButton_ActionEvents() {
01123 FileChooser.chooser.setCurrentDirectory(new File(System.getProperty("user.dir")));
01124 FileChooser.chooser.setFileFilter(FileChooser.PATTERN);
01125 FileChooser.chooser.setFileSelectionMode(FileChooser.FILES_ONLY);
01126 FileChooser.chooser.setSelectedFile(new File(""));
01127
01128 if (FileChooser.chooser.showDialog(this, "Load") == FileChooser.APPROVE_OPTION) {
01129 try {
01130 if (FileChooser.chooser.getSelectedFile().exists()) {
01131 PatternSaverLoader.load(FileChooser.chooser.getSelectedFile().getCanonicalPath());
01132 updatePatternTree();
01133 } else {
01134 JOptionPane.showMessageDialog(this, "File '" + FileChooser.chooser.getSelectedFile().getCanonicalPath()
01135 + "' does not exist", "Error", JOptionPane.ERROR_MESSAGE);
01136 }
01137 } catch (Exception e) {
01138 JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
01139 }
01140 }
01141 }
01142
01143
01144
01145
01146 public static void main(java.lang.String[] args) {
01147 try {
01148 PatternManager aPatternManager;
01149 aPatternManager = new PatternManager();
01150 aPatternManager.addWindowListener(new java.awt.event.WindowAdapter() {
01151 public void windowClosing(java.awt.event.WindowEvent e) {
01152 System.exit(0);
01153 };
01154 });
01155 aPatternManager.setVisible(true);
01156 } catch (Throwable exception) {
01157 System.err.println("Exception occurred in main() of javax.swing.JFrame");
01158 exception.printStackTrace(System.out);
01159 }
01160 }
01161
01162
01163
01164 public void patternTree_TreeSelectionEvents() {
01165 Object o = getPatternTree().getLastSelectedPathComponent();
01166 if (o != null) {
01167 o = ((DefaultMutableTreeNode) o).getUserObject();
01168 if (o instanceof Pattern) {
01169 Pattern p = (Pattern) o;
01170 String temp = p.getName();
01171 getNameTextField().setText("".equals(temp) ? "unknown" : temp);
01172 temp = p.getScope();
01173 getScopeTextField().setText("".equals(temp) ? "unknown" : temp);
01174 temp = p.getDescription();
01175 getDescriptionTextArea().setText("".equals(temp) ? "none" : temp);
01176 temp = p.getParameters().toString();
01177 getParametersTextField().setText(temp.substring(1, temp.length() - 1));
01178 temp = p.getFormat();
01179 getFormatTextField().setText(temp);
01180 int row = 0;
01181 if (p.hasMapping("ltl"))
01182 row++;
01183 if (p.hasMapping("ctl"))
01184 row++;
01185 boolean isBanderaPattern = "bandera.pattern".equals(p.getFilename());
01186 final Object[][] rowData = new String[row][2];
01187 int i = 0;
01188 if (p.hasMapping("ltl")) {
01189 rowData[i][0] = "Linear Temporal Logic";
01190 rowData[i++][1] = p.getMapping("ltl");
01191 }
01192 if (p.hasMapping("ctl")) {
01193 rowData[i][0] = "Computation Tree Logic";
01194 rowData[i][1] = p.getMapping("ctl");
01195 }
01196 getMappingTable().setBackground(bg);
01197 getMappingTable().setModel(new AbstractTableModel() {
01198 public String getColumnName(int col) {
01199 return columnNames[col].toString();
01200 }
01201 public int getRowCount() {
01202 return rowData.length;
01203 }
01204 public int getColumnCount() {
01205 return columnNames.length;
01206 }
01207 public Object getValueAt(int row, int col) {
01208 return rowData[row][col];
01209 }
01210 public boolean isCellEditable(int row, int col) {
01211 return false;
01212 }
01213 public void setValueAt(Object value, int row, int col) {
01214 rowData[row][col] = value;
01215 fireTableCellUpdated(row, col);
01216 }
01217 });
01218 getMappingTable().sizeColumnsToFit(-1);
01219 getMappingScrollPane().validate();
01220 getMappingScrollPane().repaint();
01221 setAllEditable(!isBanderaPattern);
01222 getErrorMessagesButton().setEnabled(!p.isValid());
01223 } else {
01224 getErrorMessagesButton().setEnabled(false);
01225 setAllEditable(false);
01226 getNameTextField().setText("");
01227 getScopeTextField().setText("");
01228 getDescriptionTextArea().setText("");
01229 getParametersTextField().setText("");
01230 getFormatTextField().setText("");
01231 getMappingTable().setModel(new DefaultTableModel(new Object[0][0], columnNames));
01232 getMappingTable().sizeColumnsToFit(-1);
01233 getMappingScrollPane().validate();
01234 getMappingScrollPane().repaint();
01235 }
01236 } else {
01237 getErrorMessagesButton().setEnabled(false);
01238 setAllEditable(true);
01239 getNameTextField().setText("");
01240 getScopeTextField().setText("");
01241 getDescriptionTextArea().setText("");
01242 getParametersTextField().setText("");
01243 getFormatTextField().setText("");
01244 getErrorMessagesButton().setEnabled(false);
01245 getMappingTable().setModel(new DefaultTableModel(new Object[0][0], columnNames));
01246 getMappingTable().sizeColumnsToFit(-1);
01247 getMappingScrollPane().validate();
01248 getMappingScrollPane().repaint();
01249 }
01250 }
01251
01252
01253
01254
01255 private void setAllEditable(boolean editable) {
01256 getNameTextField().setEditable(editable);
01257 getScopeTextField().setEditable(editable);
01258 getDescriptionTextArea().setEditable(editable);
01259 getParametersTextField().setEditable(editable);
01260 getFormatTextField().setEditable(editable);
01261
01262 if (editable)
01263 getDescriptionTextArea().setBackground(Color.white);
01264 else
01265 getDescriptionTextArea().setBackground(bg);
01266 }
01267
01268
01269
01270 private void updatePatternTree() {
01271 getPatternTree().setModel(new DefaultTreeModel(buildPatternTree(new DefaultMutableTreeNode("Pattern"), PatternSaverLoader.getPatternTable())));
01272 getLeftScrollPane().validate();
01273 getLeftScrollPane().repaint();
01274
01275 }
01276 }