1 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 ; 15 import java.awt.Frame ; 16 17 21 public class RMISearchConfigurationConnectionEditDialog extends javax.swing.JDialog 22 { 23 private RMISearchConfiguration.Connection connection; 24 private ShareGroups shareGroups; 25 private boolean isOK; 26 27 public static boolean showDialog(Component frameComp, RMISearchConfiguration.Connection connection) 28 { 29 Frame 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 37 public RMISearchConfigurationConnectionEditDialog(java.awt.Frame 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 72 private void initComponents() { 74 jPanel1 = new javax.swing.JPanel (); 75 nodeNameLabel = new javax.swing.JLabel (); 76 nodeNameTextField = new javax.swing.JTextField (); 77 jPanel7 = new javax.swing.JPanel (); 78 shareGroupsCheckBox = new javax.swing.JCheckBox (); 79 shareGroupsButton = new javax.swing.JButton (); 80 jPanel3 = new javax.swing.JPanel (); 81 OKButton = new javax.swing.JButton (); 82 cancelButton = new javax.swing.JButton (); 83 84 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 85 setTitle("SearchNet Connection"); 86 jPanel1.setLayout(new java.awt.GridLayout (3, 0)); 87 88 jPanel1.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (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 (jPanel7, javax.swing.BoxLayout.X_AXIS)); 95 96 shareGroupsCheckBox.setText("Share Groups"); 97 shareGroupsCheckBox.addActionListener(new java.awt.event.ActionListener () 98 { 99 public void actionPerformed(java.awt.event.ActionEvent 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 () 110 { 111 public void actionPerformed(java.awt.event.ActionEvent 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 (300, 35)); 124 OKButton.setText("OK"); 125 OKButton.addActionListener(new java.awt.event.ActionListener () 126 { 127 public void actionPerformed(java.awt.event.ActionEvent 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 () 137 { 138 public void actionPerformed(java.awt.event.ActionEvent 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 } 151 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 154 } 156 private void OKButtonActionPerformed(java.awt.event.ActionEvent evt) { String 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 } 175 private void shareGroupsButtonActionPerformed(java.awt.event.ActionEvent evt) { StringListEditDialog.showDialog(this, shareGroups.getList(), "Share Group", "Share Groups Editor"); 178 } 180 private void shareGroupsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { shareGroupsButton.setEnabled(shareGroupsCheckBox.isSelected()); 183 } 185 private javax.swing.JButton OKButton; 187 private javax.swing.JButton cancelButton; 188 private javax.swing.JPanel jPanel1; 189 private javax.swing.JPanel jPanel3; 190 private javax.swing.JPanel jPanel7; 191 private javax.swing.JLabel nodeNameLabel; 192 private javax.swing.JTextField nodeNameTextField; 193 private javax.swing.JButton shareGroupsButton; 194 private javax.swing.JCheckBox shareGroupsCheckBox; 195 197 } 198 | Popular Tags |