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