1 6 7 package SOFA.SOFAnet.Browser; 8 9 import SOFA.SOFAnet.Admin.RMI.*; 10 import SOFA.SOFAnet.Repository.BundleInfo; 11 import javax.swing.*; 12 import java.rmi.RemoteException ; 13 import java.util.*; 14 import java.awt.Component ; 15 import java.awt.Frame ; 16 17 21 public class GenerateTriggersOfContractDialog extends javax.swing.JDialog 22 { 23 private RMIAdminInterface admin; 24 private boolean isOK; 25 26 public static boolean showDialog(Component frameComp, RMIAdminInterface admin, String defaultContractID) 27 { 28 Frame frame = JOptionPane.getFrameForComponent(frameComp); 29 GenerateTriggersOfContractDialog dialog = new GenerateTriggersOfContractDialog(frame, true, admin, defaultContractID); 30 dialog.setLocationRelativeTo(frameComp); 31 dialog.setVisible(true); 32 return dialog.isOK(); 33 } 34 35 36 public GenerateTriggersOfContractDialog(java.awt.Frame parent, boolean modal, RMIAdminInterface admin, String defaultContractID) 37 { 38 super(parent, modal); 39 this.admin = admin; 40 isOK = false; 41 initComponents(); 42 43 contractIDTextField.setText(defaultContractID); 44 } 45 46 public boolean isOK() 47 { 48 return isOK; 49 } 50 51 56 private void initComponents() { 58 jPanel4 = new javax.swing.JPanel (); 59 jPanel1 = new javax.swing.JPanel (); 60 jPanel5 = new javax.swing.JPanel (); 61 contractIDLabel = new javax.swing.JLabel (); 62 contractIDTextField = new javax.swing.JTextField (); 63 firstDeleteCheckBox = new javax.swing.JCheckBox (); 64 jPanel2 = new javax.swing.JPanel (); 65 chooseContractButton = new javax.swing.JButton (); 66 jPanel3 = new javax.swing.JPanel (); 67 generateTriggersOfContractButton = new javax.swing.JButton (); 68 cancelButton = new javax.swing.JButton (); 69 70 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 71 setTitle("Generate Triggers of Contract"); 72 jPanel4.setLayout(new java.awt.BorderLayout ()); 73 74 jPanel4.setMinimumSize(new java.awt.Dimension (400, 93)); 75 jPanel4.setPreferredSize(new java.awt.Dimension (400, 150)); 76 jPanel1.setLayout(new java.awt.BorderLayout ()); 77 78 jPanel1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (1, 10, 1, 10))); 79 jPanel1.setMinimumSize(new java.awt.Dimension (26, 23)); 80 jPanel1.setPreferredSize(new java.awt.Dimension (26, 23)); 81 jPanel5.setLayout(new java.awt.GridLayout (3, 0)); 82 83 contractIDLabel.setText("Contract ID (name):"); 84 jPanel5.add(contractIDLabel); 85 86 contractIDTextField.setMinimumSize(new java.awt.Dimension (200, 21)); 87 contractIDTextField.setPreferredSize(new java.awt.Dimension (200, 21)); 88 jPanel5.add(contractIDTextField); 89 90 firstDeleteCheckBox.setSelected(true); 91 firstDeleteCheckBox.setText("Delete Triggers of Contract First"); 92 jPanel5.add(firstDeleteCheckBox); 93 94 jPanel1.add(jPanel5, java.awt.BorderLayout.NORTH); 95 96 jPanel4.add(jPanel1, java.awt.BorderLayout.CENTER); 97 98 chooseContractButton.setText("Choose Contract"); 99 chooseContractButton.addActionListener(new java.awt.event.ActionListener () 100 { 101 public void actionPerformed(java.awt.event.ActionEvent evt) 102 { 103 chooseContractButtonActionPerformed(evt); 104 } 105 }); 106 107 jPanel2.add(chooseContractButton); 108 109 jPanel4.add(jPanel2, java.awt.BorderLayout.NORTH); 110 111 generateTriggersOfContractButton.setText("Generate Triggers of Contract"); 112 generateTriggersOfContractButton.addActionListener(new java.awt.event.ActionListener () 113 { 114 public void actionPerformed(java.awt.event.ActionEvent evt) 115 { 116 generateTriggersOfContractButtonActionPerformed(evt); 117 } 118 }); 119 120 jPanel3.add(generateTriggersOfContractButton); 121 122 cancelButton.setText("Cancel"); 123 cancelButton.addActionListener(new java.awt.event.ActionListener () 124 { 125 public void actionPerformed(java.awt.event.ActionEvent evt) 126 { 127 cancelButtonActionPerformed(evt); 128 } 129 }); 130 131 jPanel3.add(cancelButton); 132 133 jPanel4.add(jPanel3, java.awt.BorderLayout.SOUTH); 134 135 getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER); 136 137 pack(); 138 } 140 private void chooseContractButtonActionPerformed(java.awt.event.ActionEvent evt) { ContractDesc[] contractDescs = null; 143 try 144 { 145 contractDescs = admin.contractDescsList(); 146 } 147 catch (RemoteException e) 148 { 149 JOptionPane.showMessageDialog(this, "RMI Error occured while accessing SOFA net node:\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 150 return; 151 } 152 153 Arrays.sort(contractDescs); 154 155 ContractDesc result = (ContractDesc)ListDialog.showDialog(this, this, "Contracts:", "Choose Contract to Generate Triggers From", contractDescs, null, null, false, true); 156 if (result != null) contractIDTextField.setText(result.name); 157 158 } 160 private void generateTriggersOfContractButtonActionPerformed(java.awt.event.ActionEvent evt) { String contractID = contractIDTextField.getText(); 163 boolean firstDelete = firstDeleteCheckBox.isSelected(); 164 165 if (contractID.length() == 0) 166 { 167 JOptionPane.showMessageDialog(this, "Empty Contract ID", "Error", JOptionPane.ERROR_MESSAGE); 168 return; 169 } 170 171 try 172 { 173 admin.generateTriggersOfContract(contractID, firstDelete); 174 } 175 catch (RemoteException e) 176 { 177 JOptionPane.showMessageDialog(this, e, "Error", JOptionPane.ERROR_MESSAGE); 178 dispose(); 179 return; 180 } 181 catch (RMIAdminException e) 182 { 183 JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); 184 dispose(); 185 return; 186 } 187 188 JOptionPane.showMessageDialog(this, "Triggers of Contract '" + contractID + "' successfully generated"); 189 190 isOK = true; 191 dispose(); 192 } 194 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 197 } 199 private javax.swing.JButton cancelButton; 201 private javax.swing.JButton chooseContractButton; 202 private javax.swing.JLabel contractIDLabel; 203 private javax.swing.JTextField contractIDTextField; 204 private javax.swing.JCheckBox firstDeleteCheckBox; 205 private javax.swing.JButton generateTriggersOfContractButton; 206 private javax.swing.JPanel jPanel1; 207 private javax.swing.JPanel jPanel2; 208 private javax.swing.JPanel jPanel3; 209 private javax.swing.JPanel jPanel4; 210 private javax.swing.JPanel jPanel5; 211 213 } 214 | Popular Tags |