KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * DeleteComponentsDialog.java
3  *
4  * Created on 17. květen 2004, 19:21
5  */

6
7 package SOFA.SOFAnet.Browser;
8
9 import SOFA.SOFAnet.Admin.RMI.*;
10 import SOFA.SOFAnode.TR.ComponentInfo;
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 DeleteComponentsDialog extends javax.swing.JDialog JavaDoc
22 {
23   private RMIAdminInterface admin;
24   private DefaultListModel content;
25   private ComponentInfo[] components;
26   private boolean isOK;
27   
28   public static boolean showDialog(Component JavaDoc frameComp, RMIAdminInterface admin, ComponentInfo[] components)
29   {
30     Frame JavaDoc frame = JOptionPane.getFrameForComponent(frameComp);
31     DeleteComponentsDialog dialog = new DeleteComponentsDialog(frame, true, admin, components);
32     dialog.setLocationRelativeTo(frameComp);
33     dialog.setVisible(true);
34     return dialog.isOK();
35   }
36   
37   /** Creates new form DeleteComponentsDialog */
38   public DeleteComponentsDialog(java.awt.Frame JavaDoc parent, boolean modal, RMIAdminInterface admin, ComponentInfo[] components)
39   {
40     super(parent, modal);
41     this.admin = admin;
42     this.components = components;
43     isOK = false;
44     content = new DefaultListModel();
45     initComponents();
46     
47     for (int i = 0; i < components.length; i++) content.addElement(components[i].getName() + "[" + components[i].getImplementationVersion() + "]");
48   }
49
50   public boolean isOK()
51   {
52     return isOK;
53   }
54   
55   /** This method is called from within the constructor to
56    * initialize the form.
57    * WARNING: Do NOT modify this code. The content of this method is
58    * always regenerated by the Form Editor.
59    */

60   private void initComponents()//GEN-BEGIN:initComponents
61
{
62     jPanel1 = new javax.swing.JPanel JavaDoc();
63     jLabel1 = new javax.swing.JLabel JavaDoc();
64     jPanel2 = new javax.swing.JPanel JavaDoc();
65     jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
66     contentList = new javax.swing.JList JavaDoc();
67     jPanel4 = new javax.swing.JPanel JavaDoc();
68     subcomponentsCheckBox = new javax.swing.JCheckBox JavaDoc();
69     interfacesCheckBox = new javax.swing.JCheckBox JavaDoc();
70     jPanel3 = new javax.swing.JPanel JavaDoc();
71     yesButton = new javax.swing.JButton JavaDoc();
72     noButton = new javax.swing.JButton JavaDoc();
73     cancelButton = new javax.swing.JButton JavaDoc();
74
75     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
76     setTitle("Delete Components from TR");
77     jLabel1.setText("Do you really want to delete these components from TR?");
78     jPanel1.add(jLabel1);
79
80     getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
81
82     jPanel2.setLayout(new java.awt.BorderLayout JavaDoc());
83
84     contentList.setModel(content);
85     contentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
86     jScrollPane1.setViewportView(contentList);
87
88     jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);
89
90     jPanel4.setLayout(new java.awt.GridLayout JavaDoc(2, 0));
91
92     subcomponentsCheckBox.setText("Including Subcomponents");
93     jPanel4.add(subcomponentsCheckBox);
94
95     interfacesCheckBox.setText("Including Interfaces");
96     jPanel4.add(interfacesCheckBox);
97
98     jPanel2.add(jPanel4, java.awt.BorderLayout.SOUTH);
99
100     getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
101
102     yesButton.setText("Yes");
103     yesButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
104     {
105       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
106       {
107         yesButtonActionPerformed(evt);
108       }
109     });
110
111     jPanel3.add(yesButton);
112
113     noButton.setText("No");
114     noButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
115     {
116       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
117       {
118         noButtonActionPerformed(evt);
119       }
120     });
121
122     jPanel3.add(noButton);
123
124     cancelButton.setText("Cancel");
125     cancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
126     {
127       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
128       {
129         cancelButtonActionPerformed(evt);
130       }
131     });
132
133     jPanel3.add(cancelButton);
134
135     getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
136
137     pack();
138   }//GEN-END:initComponents
139

140   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
141
{//GEN-HEADEREND:event_cancelButtonActionPerformed
142
dispose();
143   }//GEN-LAST:event_cancelButtonActionPerformed
144

145   private void noButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_noButtonActionPerformed
146
{//GEN-HEADEREND:event_noButtonActionPerformed
147
dispose();
148   }//GEN-LAST:event_noButtonActionPerformed
149

150   private void yesButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_yesButtonActionPerformed
151
{//GEN-HEADEREND:event_yesButtonActionPerformed
152
boolean interfaces = interfacesCheckBox.isSelected();
153     boolean subcomponents = subcomponentsCheckBox.isSelected();
154     
155     try
156     {
157       admin.deleteComponentsFromTR(components, interfaces, subcomponents);
158     }
159     catch (RemoteException JavaDoc e)
160     {
161       JOptionPane.showMessageDialog(this, e, "Error", JOptionPane.ERROR_MESSAGE);
162       dispose();
163       return;
164     }
165     catch (RMIAdminException e)
166     {
167       JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
168       dispose();
169       return;
170     }
171     
172     isOK = true;
173     dispose();
174   }//GEN-LAST:event_yesButtonActionPerformed
175

176   // Variables declaration - do not modify//GEN-BEGIN:variables
177
private javax.swing.JButton JavaDoc cancelButton;
178   private javax.swing.JList JavaDoc contentList;
179   private javax.swing.JCheckBox JavaDoc interfacesCheckBox;
180   private javax.swing.JLabel JavaDoc jLabel1;
181   private javax.swing.JPanel JavaDoc jPanel1;
182   private javax.swing.JPanel JavaDoc jPanel2;
183   private javax.swing.JPanel JavaDoc jPanel3;
184   private javax.swing.JPanel JavaDoc jPanel4;
185   private javax.swing.JScrollPane JavaDoc jScrollPane1;
186   private javax.swing.JButton JavaDoc noButton;
187   private javax.swing.JCheckBox JavaDoc subcomponentsCheckBox;
188   private javax.swing.JButton JavaDoc yesButton;
189   // End of variables declaration//GEN-END:variables
190

191 }
192
Popular Tags