KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * InstallBundleDialog.java
3  *
4  * Created on 10. květen 2004, 22:42
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 DeleteBinaryBundleDialog 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 defaultBundleName)
27   {
28     Frame JavaDoc frame = JOptionPane.getFrameForComponent(frameComp);
29     DeleteBinaryBundleDialog dialog = new DeleteBinaryBundleDialog(frame, true, admin, defaultBundleName);
30     dialog.setLocationRelativeTo(frameComp);
31     dialog.setVisible(true);
32     return dialog.isOK();
33   }
34   
35   /** Creates new form DeleteBinaryBundleDialog */
36   public DeleteBinaryBundleDialog(java.awt.Frame JavaDoc parent, boolean modal, RMIAdminInterface admin, String JavaDoc defaultBundleName)
37   {
38     super(parent, modal);
39     this.admin = admin;
40     isOK = false;
41     initComponents();
42     
43     bundleNameTextField.setText(defaultBundleName);
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     bundleNameLabel = new javax.swing.JLabel JavaDoc();
62     bundleNameTextField = new javax.swing.JTextField JavaDoc();
63     jPanel2 = new javax.swing.JPanel JavaDoc();
64     chooseBinaryBundleButton = new javax.swing.JButton JavaDoc();
65     jPanel3 = new javax.swing.JPanel JavaDoc();
66     deleteBinaryBundleButton = new javax.swing.JButton JavaDoc();
67     cancelButton = new javax.swing.JButton JavaDoc();
68
69     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
70     setTitle("Delete Binary Bundle");
71     jPanel4.setLayout(new java.awt.BorderLayout JavaDoc());
72
73     jPanel4.setMinimumSize(new java.awt.Dimension JavaDoc(400, 93));
74     jPanel4.setPreferredSize(new java.awt.Dimension JavaDoc(400, 150));
75     jPanel1.setLayout(new java.awt.BorderLayout JavaDoc());
76
77     jPanel1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(1, 10, 1, 10)));
78     jPanel1.setMinimumSize(new java.awt.Dimension JavaDoc(26, 23));
79     jPanel1.setPreferredSize(new java.awt.Dimension JavaDoc(26, 23));
80     jPanel5.setLayout(new java.awt.GridLayout JavaDoc(3, 0));
81
82     bundleNameLabel.setText("Bundle Name:");
83     jPanel5.add(bundleNameLabel);
84
85     bundleNameTextField.setMinimumSize(new java.awt.Dimension JavaDoc(200, 21));
86     bundleNameTextField.setPreferredSize(new java.awt.Dimension JavaDoc(200, 21));
87     jPanel5.add(bundleNameTextField);
88
89     jPanel1.add(jPanel5, java.awt.BorderLayout.NORTH);
90
91     jPanel4.add(jPanel1, java.awt.BorderLayout.CENTER);
92
93     chooseBinaryBundleButton.setText("Choose Binary Bundle");
94     chooseBinaryBundleButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
95     {
96       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
97       {
98         chooseBinaryBundleButtonActionPerformed(evt);
99       }
100     });
101
102     jPanel2.add(chooseBinaryBundleButton);
103
104     jPanel4.add(jPanel2, java.awt.BorderLayout.NORTH);
105
106     deleteBinaryBundleButton.setText("Delete Binary Bundle");
107     deleteBinaryBundleButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
108     {
109       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
110       {
111         deleteBinaryBundleButtonActionPerformed(evt);
112       }
113     });
114
115     jPanel3.add(deleteBinaryBundleButton);
116
117     cancelButton.setText("Cancel");
118     cancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
119     {
120       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
121       {
122         cancelButtonActionPerformed(evt);
123       }
124     });
125
126     jPanel3.add(cancelButton);
127
128     jPanel4.add(jPanel3, java.awt.BorderLayout.SOUTH);
129
130     getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER);
131
132     pack();
133   }//GEN-END:initComponents
134

135   private void chooseBinaryBundleButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_chooseBinaryBundleButtonActionPerformed
136
{//GEN-HEADEREND:event_chooseBinaryBundleButtonActionPerformed
137
String JavaDoc[] bundles = null;
138     try
139     {
140       bundles = admin.binBundlesList();
141     }
142     catch (RemoteException JavaDoc e)
143     {
144       JOptionPane.showMessageDialog(this, "RMI Error occured while accessing SOFA net node:\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
145       return;
146     }
147
148     Arrays.sort(bundles);
149     
150     String JavaDoc result = ListDialog.showDialog(this, this, "Binary Bundles:", "Choose Binary Bundle to Uninstall", bundles, null, null, false, true);
151     if (result.length() != 0) bundleNameTextField.setText(result);
152     
153   }//GEN-LAST:event_chooseBinaryBundleButtonActionPerformed
154

155   private void deleteBinaryBundleButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_deleteBinaryBundleButtonActionPerformed
156
{//GEN-HEADEREND:event_deleteBinaryBundleButtonActionPerformed
157
String JavaDoc bundleName = bundleNameTextField.getText();
158
159     BundleInfo bundleInfo = new BundleInfo();
160     try
161     {
162       bundleInfo.fromBundleName(bundleName);
163     }
164     catch (BundleInfo.InvalidBundleNameException e)
165     {
166       JOptionPane.showMessageDialog(this, "Invalid name of bundle:\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
167       return;
168     }
169     
170     try
171     {
172       admin.deleteBinaryBundle(bundleName);
173     }
174     catch (RemoteException JavaDoc e)
175     {
176       JOptionPane.showMessageDialog(this, e, "Error", JOptionPane.ERROR_MESSAGE);
177       dispose();
178       return;
179     }
180     catch (RMIAdminException e)
181     {
182       JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
183       dispose();
184       return;
185     }
186     
187     JOptionPane.showMessageDialog(this, "Binary Bundle '" + bundleName + "' successfully deleted");
188     
189     isOK = true;
190     dispose();
191   }//GEN-LAST:event_deleteBinaryBundleButtonActionPerformed
192

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

198   
199   // Variables declaration - do not modify//GEN-BEGIN:variables
200
private javax.swing.JLabel JavaDoc bundleNameLabel;
201   private javax.swing.JTextField JavaDoc bundleNameTextField;
202   private javax.swing.JButton JavaDoc cancelButton;
203   private javax.swing.JButton JavaDoc chooseBinaryBundleButton;
204   private javax.swing.JButton JavaDoc deleteBinaryBundleButton;
205   private javax.swing.JPanel JavaDoc jPanel1;
206   private javax.swing.JPanel JavaDoc jPanel2;
207   private javax.swing.JPanel JavaDoc jPanel3;
208   private javax.swing.JPanel JavaDoc jPanel4;
209   private javax.swing.JPanel JavaDoc jPanel5;
210   // End of variables declaration//GEN-END:variables
211

212 }
213
Popular Tags