1 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 ; 13 import java.util.*; 14 import java.awt.Component ; 15 import java.awt.Frame ; 16 17 21 public class DeleteComponentsDialog extends javax.swing.JDialog 22 { 23 private RMIAdminInterface admin; 24 private DefaultListModel content; 25 private ComponentInfo[] components; 26 private boolean isOK; 27 28 public static boolean showDialog(Component frameComp, RMIAdminInterface admin, ComponentInfo[] components) 29 { 30 Frame 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 38 public DeleteComponentsDialog(java.awt.Frame 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 60 private void initComponents() { 62 jPanel1 = new javax.swing.JPanel (); 63 jLabel1 = new javax.swing.JLabel (); 64 jPanel2 = new javax.swing.JPanel (); 65 jScrollPane1 = new javax.swing.JScrollPane (); 66 contentList = new javax.swing.JList (); 67 jPanel4 = new javax.swing.JPanel (); 68 subcomponentsCheckBox = new javax.swing.JCheckBox (); 69 interfacesCheckBox = new javax.swing.JCheckBox (); 70 jPanel3 = new javax.swing.JPanel (); 71 yesButton = new javax.swing.JButton (); 72 noButton = new javax.swing.JButton (); 73 cancelButton = new javax.swing.JButton (); 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 ()); 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 (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 () 104 { 105 public void actionPerformed(java.awt.event.ActionEvent 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 () 115 { 116 public void actionPerformed(java.awt.event.ActionEvent 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 () 126 { 127 public void actionPerformed(java.awt.event.ActionEvent 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 } 140 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 143 } 145 private void noButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 148 } 150 private void yesButtonActionPerformed(java.awt.event.ActionEvent evt) { boolean interfaces = interfacesCheckBox.isSelected(); 153 boolean subcomponents = subcomponentsCheckBox.isSelected(); 154 155 try 156 { 157 admin.deleteComponentsFromTR(components, interfaces, subcomponents); 158 } 159 catch (RemoteException 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 } 176 private javax.swing.JButton cancelButton; 178 private javax.swing.JList contentList; 179 private javax.swing.JCheckBox interfacesCheckBox; 180 private javax.swing.JLabel jLabel1; 181 private javax.swing.JPanel jPanel1; 182 private javax.swing.JPanel jPanel2; 183 private javax.swing.JPanel jPanel3; 184 private javax.swing.JPanel jPanel4; 185 private javax.swing.JScrollPane jScrollPane1; 186 private javax.swing.JButton noButton; 187 private javax.swing.JCheckBox subcomponentsCheckBox; 188 private javax.swing.JButton yesButton; 189 191 } 192 | Popular Tags |