KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * RMISearchConfigurationConnectionEditDialog.java
3  *
4  * Created on 24. květen 2004, 11:39
5  */

6
7 package SOFA.SOFAnet.Browser;
8
9 import javax.swing.*;
10 import SOFA.SOFAnet.Repository.ShareGroups;
11 import SOFA.SOFAnet.Repository.NodeInfo;
12 import SOFA.SOFAnet.Search.RMI.RMISearchConfiguration;
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 RMISearchConfigurationConnectionEditDialog extends javax.swing.JDialog JavaDoc
22 {
23   private RMISearchConfiguration.Connection connection;
24   private ShareGroups shareGroups;
25   private boolean isOK;
26
27   public static boolean showDialog(Component JavaDoc frameComp, RMISearchConfiguration.Connection connection)
28   {
29     Frame JavaDoc frame = JOptionPane.getFrameForComponent(frameComp);
30     RMISearchConfigurationConnectionEditDialog dialog = new RMISearchConfigurationConnectionEditDialog(frame, true, connection);
31     dialog.setLocationRelativeTo(frameComp);
32     dialog.setVisible(true);
33     return dialog.isOK();
34   }
35   
36   /** Creates new form RMISearchConfigurationConnectionEditDialog */
37   public RMISearchConfigurationConnectionEditDialog(java.awt.Frame JavaDoc parent, boolean modal, RMISearchConfiguration.Connection connection)
38   {
39     super(parent, modal);
40     this.connection = connection;
41     shareGroups = connection.getShareGroups();
42     isOK = false;
43     initComponents();
44
45     nodeNameTextField.setText(connection.getNodeName());
46     
47     if (shareGroups != null)
48     {
49       shareGroupsCheckBox.setSelected(true);
50       shareGroupsButton.setEnabled(true);
51     }
52     else
53     {
54       shareGroupsCheckBox.setSelected(false);
55       shareGroupsButton.setEnabled(false);
56     }
57     
58     if (shareGroups != null) shareGroups = (ShareGroups)shareGroups.clone();
59     else shareGroups = new ShareGroups();
60   }
61   
62   public boolean isOK()
63   {
64     return isOK;
65   }
66   
67   /** This method is called from within the constructor to
68    * initialize the form.
69    * WARNING: Do NOT modify this code. The content of this method is
70    * always regenerated by the Form Editor.
71    */

72   private void initComponents()//GEN-BEGIN:initComponents
73
{
74     jPanel1 = new javax.swing.JPanel JavaDoc();
75     nodeNameLabel = new javax.swing.JLabel JavaDoc();
76     nodeNameTextField = new javax.swing.JTextField JavaDoc();
77     jPanel7 = new javax.swing.JPanel JavaDoc();
78     shareGroupsCheckBox = new javax.swing.JCheckBox JavaDoc();
79     shareGroupsButton = new javax.swing.JButton JavaDoc();
80     jPanel3 = new javax.swing.JPanel JavaDoc();
81     OKButton = new javax.swing.JButton JavaDoc();
82     cancelButton = new javax.swing.JButton JavaDoc();
83
84     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
85     setTitle("SearchNet Connection");
86     jPanel1.setLayout(new java.awt.GridLayout JavaDoc(3, 0));
87
88     jPanel1.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(5, 5, 5, 5)));
89     nodeNameLabel.setText("Node Name:");
90     jPanel1.add(nodeNameLabel);
91
92     jPanel1.add(nodeNameTextField);
93
94     jPanel7.setLayout(new javax.swing.BoxLayout JavaDoc(jPanel7, javax.swing.BoxLayout.X_AXIS));
95
96     shareGroupsCheckBox.setText("Share Groups");
97     shareGroupsCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
98     {
99       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
100       {
101         shareGroupsCheckBoxActionPerformed(evt);
102       }
103     });
104
105     jPanel7.add(shareGroupsCheckBox);
106
107     shareGroupsButton.setText("Edit Share Groups");
108     shareGroupsButton.setEnabled(false);
109     shareGroupsButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
110     {
111       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
112       {
113         shareGroupsButtonActionPerformed(evt);
114       }
115     });
116
117     jPanel7.add(shareGroupsButton);
118
119     jPanel1.add(jPanel7);
120
121     getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
122
123     jPanel3.setPreferredSize(new java.awt.Dimension JavaDoc(300, 35));
124     OKButton.setText("OK");
125     OKButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
126     {
127       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
128       {
129         OKButtonActionPerformed(evt);
130       }
131     });
132
133     jPanel3.add(OKButton);
134
135     cancelButton.setText("Cancel");
136     cancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
137     {
138       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
139       {
140         cancelButtonActionPerformed(evt);
141       }
142     });
143
144     jPanel3.add(cancelButton);
145
146     getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
147
148     pack();
149   }//GEN-END:initComponents
150

151   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
152
{//GEN-HEADEREND:event_cancelButtonActionPerformed
153
dispose();
154   }//GEN-LAST:event_cancelButtonActionPerformed
155

156   private void OKButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_OKButtonActionPerformed
157
{//GEN-HEADEREND:event_OKButtonActionPerformed
158
String JavaDoc nodeName = nodeNameTextField.getText().trim();
159     
160     if (nodeName.length() == 0)
161     {
162       JOptionPane.showMessageDialog(this, "Empty node name", "Error", JOptionPane.ERROR_MESSAGE);
163       return;
164     }
165     
166     if (!shareGroupsCheckBox.isSelected()) shareGroups = null;
167     
168     connection.setNodeName(nodeName);
169     connection.setShareGroups(shareGroups);
170     
171     isOK = true;
172     dispose();
173   }//GEN-LAST:event_OKButtonActionPerformed
174

175   private void shareGroupsButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_shareGroupsButtonActionPerformed
176
{//GEN-HEADEREND:event_shareGroupsButtonActionPerformed
177
StringListEditDialog.showDialog(this, shareGroups.getList(), "Share Group", "Share Groups Editor");
178   }//GEN-LAST:event_shareGroupsButtonActionPerformed
179

180   private void shareGroupsCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_shareGroupsCheckBoxActionPerformed
181
{//GEN-HEADEREND:event_shareGroupsCheckBoxActionPerformed
182
shareGroupsButton.setEnabled(shareGroupsCheckBox.isSelected());
183   }//GEN-LAST:event_shareGroupsCheckBoxActionPerformed
184

185   // Variables declaration - do not modify//GEN-BEGIN:variables
186
private javax.swing.JButton JavaDoc OKButton;
187   private javax.swing.JButton JavaDoc cancelButton;
188   private javax.swing.JPanel JavaDoc jPanel1;
189   private javax.swing.JPanel JavaDoc jPanel3;
190   private javax.swing.JPanel JavaDoc jPanel7;
191   private javax.swing.JLabel JavaDoc nodeNameLabel;
192   private javax.swing.JTextField JavaDoc nodeNameTextField;
193   private javax.swing.JButton JavaDoc shareGroupsButton;
194   private javax.swing.JCheckBox JavaDoc shareGroupsCheckBox;
195   // End of variables declaration//GEN-END:variables
196

197 }
198
Popular Tags