KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Browser > DeleteTriggersOfContractDialog


1 /*
2  * DeleteTriggersOfContractDialog.java
3  *
4  * Created on 20. květen 2004, 14:50
5  */

6
7 package SOFA.SOFAnet.Browser;
8
9 import SOFA.SOFAnet.Admin.RMI.*;
10 import javax.swing.*;
11 import java.rmi.RemoteException JavaDoc;
12 import java.util.*;
13 import java.awt.Component JavaDoc;
14 import java.awt.Frame JavaDoc;
15
16 /**
17  *
18  * @author Ladislav Sobr
19  */

20 public class DeleteTriggersOfContractDialog extends javax.swing.JDialog JavaDoc
21 {
22   private RMIAdminInterface admin;
23   private boolean isOK;
24   
25   public static boolean showDialog(Component JavaDoc frameComp, RMIAdminInterface admin, String JavaDoc defaultContractID)
26   {
27     Frame JavaDoc 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   /** Creates new form DeleteTriggersOfContractDialog */
35   public DeleteTriggersOfContractDialog(java.awt.Frame JavaDoc parent, boolean modal, RMIAdminInterface admin, String JavaDoc 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   /** This method is called from within the constructor to
51    * initialize the form.
52    * WARNING: Do NOT modify this code. The content of this method is
53    * always regenerated by the Form Editor.
54    */

55   private void initComponents()//GEN-BEGIN:initComponents
56
{
57     jPanel4 = new javax.swing.JPanel JavaDoc();
58     jPanel1 = new javax.swing.JPanel JavaDoc();
59     jPanel5 = new javax.swing.JPanel JavaDoc();
60     contractIDLabel = new javax.swing.JLabel JavaDoc();
61     contractIDTextField = new javax.swing.JTextField JavaDoc();
62     jPanel2 = new javax.swing.JPanel JavaDoc();
63     chooseContractButton = new javax.swing.JButton JavaDoc();
64     jPanel3 = new javax.swing.JPanel JavaDoc();
65     deleteTriggersOfContractButton = new javax.swing.JButton JavaDoc();
66     cancelButton = new javax.swing.JButton JavaDoc();
67
68     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
69     setTitle("Delete Triggers Of Contract");
70     jPanel4.setLayout(new java.awt.BorderLayout JavaDoc());
71
72     jPanel4.setMinimumSize(new java.awt.Dimension JavaDoc(400, 93));
73     jPanel4.setPreferredSize(new java.awt.Dimension JavaDoc(400, 150));
74     jPanel1.setLayout(new java.awt.BorderLayout JavaDoc());
75
76     jPanel1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(1, 10, 1, 10)));
77     jPanel1.setMinimumSize(new java.awt.Dimension JavaDoc(26, 23));
78     jPanel1.setPreferredSize(new java.awt.Dimension JavaDoc(26, 23));
79     jPanel5.setLayout(new java.awt.GridLayout JavaDoc(2, 0));
80
81     contractIDLabel.setText("Contract ID (name):");
82     jPanel5.add(contractIDLabel);
83
84     contractIDTextField.setMinimumSize(new java.awt.Dimension JavaDoc(200, 21));
85     contractIDTextField.setPreferredSize(new java.awt.Dimension JavaDoc(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 JavaDoc()
94     {
95       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
107     {
108       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
118     {
119       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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   }//GEN-END:initComponents
133

134   private void chooseContractButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_chooseContractButtonActionPerformed
135
{//GEN-HEADEREND:event_chooseContractButtonActionPerformed
136
ContractDesc[] contractDescs = null;
137     try
138     {
139       contractDescs = admin.contractDescsList();
140     }
141     catch (RemoteException JavaDoc 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   }//GEN-LAST:event_chooseContractButtonActionPerformed
153

154   private void deleteTriggersOfContractButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_deleteTriggersOfContractButtonActionPerformed
155
{//GEN-HEADEREND:event_deleteTriggersOfContractButtonActionPerformed
156
String JavaDoc 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 JavaDoc 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   }//GEN-LAST:event_deleteTriggersOfContractButtonActionPerformed
186

187   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
188
{//GEN-HEADEREND:event_cancelButtonActionPerformed
189
dispose();
190   }//GEN-LAST:event_cancelButtonActionPerformed
191

192   
193   // Variables declaration - do not modify//GEN-BEGIN:variables
194
private javax.swing.JButton JavaDoc cancelButton;
195   private javax.swing.JButton JavaDoc chooseContractButton;
196   private javax.swing.JLabel JavaDoc contractIDLabel;
197   private javax.swing.JTextField JavaDoc contractIDTextField;
198   private javax.swing.JButton JavaDoc deleteTriggersOfContractButton;
199   private javax.swing.JPanel JavaDoc jPanel1;
200   private javax.swing.JPanel JavaDoc jPanel2;
201   private javax.swing.JPanel JavaDoc jPanel3;
202   private javax.swing.JPanel JavaDoc jPanel4;
203   private javax.swing.JPanel JavaDoc jPanel5;
204   // End of variables declaration//GEN-END:variables
205

206 }
207
Popular Tags