KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * GenerateTriggersOfContractDialog.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 SOFA.SOFAnet.Repository.BundleInfo;
11 import javax.swing.*;
12 import java.rmi.RemoteException JavaDoc;
13 import java.util.*;
14 import java.awt.Component JavaDoc;
15 import java.awt.Frame JavaDoc;
16
17 /**
18  *
19  * @author Ladislav Sobr
20  */

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

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

140   private void chooseContractButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_chooseContractButtonActionPerformed
141
{//GEN-HEADEREND:event_chooseContractButtonActionPerformed
142
ContractDesc[] contractDescs = null;
143     try
144     {
145       contractDescs = admin.contractDescsList();
146     }
147     catch (RemoteException JavaDoc 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   }//GEN-LAST:event_chooseContractButtonActionPerformed
159

160   private void generateTriggersOfContractButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_generateTriggersOfContractButtonActionPerformed
161
{//GEN-HEADEREND:event_generateTriggersOfContractButtonActionPerformed
162
String JavaDoc 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 JavaDoc 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   }//GEN-LAST:event_generateTriggersOfContractButtonActionPerformed
193

194   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
195
{//GEN-HEADEREND:event_cancelButtonActionPerformed
196
dispose();
197   }//GEN-LAST:event_cancelButtonActionPerformed
198

199  // Variables declaration - do not modify//GEN-BEGIN:variables
200
private javax.swing.JButton JavaDoc cancelButton;
201   private javax.swing.JButton JavaDoc chooseContractButton;
202   private javax.swing.JLabel JavaDoc contractIDLabel;
203   private javax.swing.JTextField JavaDoc contractIDTextField;
204   private javax.swing.JCheckBox JavaDoc firstDeleteCheckBox;
205   private javax.swing.JButton JavaDoc generateTriggersOfContractButton;
206   private javax.swing.JPanel JavaDoc jPanel1;
207   private javax.swing.JPanel JavaDoc jPanel2;
208   private javax.swing.JPanel JavaDoc jPanel3;
209   private javax.swing.JPanel JavaDoc jPanel4;
210   private javax.swing.JPanel JavaDoc jPanel5;
211   // End of variables declaration//GEN-END:variables
212

213 }
214
Popular Tags