1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards; 26 27 import javax.swing.event.ChangeEvent ; 29 import javax.swing.event.TableModelEvent ; 30 import javax.swing.event.TableModelListener ; 31 import javax.swing.ListSelectionModel ; 32 import org.openide.util.NbBundle; 33 import java.util.ResourceBundle ; 34 35 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 36 37 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldGroup; 38 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants; 39 import org.netbeans.modules.j2ee.sun.sunresources.beans.FieldHelper; 40 41 45 public class JmsPropertyVisualPanel extends javax.swing.JPanel implements WizardConstants, TableModelListener { 46 47 private final JmsPropertyPanel panel; 48 private ResourceBundle bundle = NbBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.sunresources.wizards.Bundle"); private FieldGroup generalGroup; 50 private FieldGroup propertiesGroup; 51 private FieldGroup propertiesGroup2; 52 private PropertiesTableModel tableModel; 53 private javax.swing.table.TableColumn propNameColumn; 54 private javax.swing.table.TableColumn propValueColumn; 55 private ResourceConfigHelper helper; 56 57 58 public JmsPropertyVisualPanel(JmsPropertyPanel panel) { 59 this.panel = panel; 60 this.helper = panel.getHelper(); 61 this.generalGroup = panel.getFieldGroup(__General); this.propertiesGroup = panel.getFieldGroup(__Properties); this.propertiesGroup2 = panel.getFieldGroup(__Properties2); tableModel = new PropertiesTableModel(this.helper.getData()); 65 initComponents(); 66 propNameColumn = propertyTable.getColumnModel().getColumn(0); 67 setPropTableCellEditor(); 68 tableModel.addTableModelListener(this); 69 propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 70 propertyTable.setRowSelectionAllowed(true); 71 72 setName(NbBundle.getMessage(JmsPropertyVisualPanel.class, "TITLE_JMSPropertyPanel")); } 75 76 81 private void initComponents() { 83 java.awt.GridBagConstraints gridBagConstraints; 84 85 descriptionTextArea = new javax.swing.JTextArea (); 86 propertyInfo = new javax.swing.JLabel (); 87 jScrollPane1 = new javax.swing.JScrollPane (); 88 propertyTable = new javax.swing.JTable (); 89 buttonsPane = new javax.swing.JPanel (); 90 addButton = new javax.swing.JButton (); 91 removeButton = new javax.swing.JButton (); 92 93 setLayout(new java.awt.GridBagLayout ()); 94 95 setMinimumSize(new java.awt.Dimension (627, 305)); 96 setPreferredSize(new java.awt.Dimension (627, 305)); 97 getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("TITLE_JMSPropertyPanel")); 98 getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("JMSPropertyPanel_Description")); 99 descriptionTextArea.setEditable(false); 100 descriptionTextArea.setLineWrap(true); 101 descriptionTextArea.setText(NbBundle.getMessage(JmsPropertyVisualPanel.class, "JMSPropertyPanel_Description", this.helper.getData().getString(__ResType))); 102 descriptionTextArea.setWrapStyleWord(true); 103 descriptionTextArea.setFocusable(false); 104 descriptionTextArea.setMinimumSize(new java.awt.Dimension (500, 17)); 105 descriptionTextArea.setOpaque(false); 106 descriptionTextArea.setPreferredSize(new java.awt.Dimension (500, 17)); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 0; 110 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 111 gridBagConstraints.weightx = 1.0; 112 gridBagConstraints.weighty = 1.0; 113 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 11); 114 add(descriptionTextArea, gridBagConstraints); 115 descriptionTextArea.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("JMSPropertyPanel_Description")); 116 descriptionTextArea.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(JmsPropertyVisualPanel.class, "JMSPropertyPanel_Description", this.helper.getData().getString(__ResType))); 117 118 propertyInfo.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_properties_Mnemonic").charAt(0)); 119 propertyInfo.setLabelFor(propertyTable); 120 propertyInfo.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_properties")); 121 gridBagConstraints = new java.awt.GridBagConstraints (); 122 gridBagConstraints.gridx = 0; 123 gridBagConstraints.gridy = 1; 124 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 125 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 11); 126 add(propertyInfo, gridBagConstraints); 127 propertyInfo.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_propTableJMS_A11yDesc")); 128 129 jScrollPane1.setPreferredSize(new java.awt.Dimension (453, 17)); 130 propertyTable.setModel(tableModel); 131 jScrollPane1.setViewportView(propertyTable); 132 propertyTable.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_AddProperty")); 133 propertyTable.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_propTableJMS_A11yDesc")); 134 135 gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.gridx = 0; 137 gridBagConstraints.gridy = 2; 138 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 139 gridBagConstraints.insets = new java.awt.Insets (10, 12, 10, 11); 140 add(jScrollPane1, gridBagConstraints); 141 jScrollPane1.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_AddProperty")); 142 jScrollPane1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_propTableJMS_A11yDesc")); 143 144 buttonsPane.setLayout(new java.awt.GridBagLayout ()); 145 146 addButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_Add_Mnemonic").charAt(0)); 147 addButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_Add")); 148 addButton.addActionListener(new java.awt.event.ActionListener () { 149 public void actionPerformed(java.awt.event.ActionEvent evt) { 150 addButtonActionPerformed(evt); 151 } 152 }); 153 154 gridBagConstraints = new java.awt.GridBagConstraints (); 155 gridBagConstraints.gridx = 0; 156 gridBagConstraints.gridy = 0; 157 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 158 gridBagConstraints.insets = new java.awt.Insets (0, 12, 12, 12); 159 buttonsPane.add(addButton, gridBagConstraints); 160 addButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_AddButtonA11yDesc")); 161 162 removeButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_Remove_Mnemonic").charAt(0)); 163 removeButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_Remove")); 164 removeButton.addActionListener(new java.awt.event.ActionListener () { 165 public void actionPerformed(java.awt.event.ActionEvent evt) { 166 removeButtonActionPerformed(evt); 167 } 168 }); 169 170 gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.gridx = 0; 172 gridBagConstraints.gridy = 1; 173 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 174 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 12); 175 buttonsPane.add(removeButton, gridBagConstraints); 176 removeButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_RemoveButtonA11yDesc")); 177 178 gridBagConstraints = new java.awt.GridBagConstraints (); 179 gridBagConstraints.gridx = 1; 180 gridBagConstraints.gridy = 2; 181 gridBagConstraints.ipady = 150; 182 add(buttonsPane, gridBagConstraints); 183 buttonsPane.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("LBL_AddProperty")); 184 buttonsPane.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/sunresources/wizards/Bundle").getString("ACS_propTableJMS_A11yDesc")); 185 186 } 187 189 private void addButtonActionPerformed(java.awt.event.ActionEvent evt) { propertyTable.editingStopped(new ChangeEvent (this)); 193 ResourceConfigData data = this.helper.getData(); 194 data.addProperty(new NameValuePair()); 195 tableModel.fireTableDataChanged(); 196 } 198 private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) { int selectedRow = propertyTable.getSelectedRow(); 201 if (selectedRow != -1) { 202 propertyTable.editingStopped(new ChangeEvent (this)); 204 this.helper.getData().removeProperty(selectedRow); 205 tableModel.fireTableDataChanged(); 206 } 207 } 209 public void tableChanged(TableModelEvent evt) { 210 setPropTableCellEditor(); 211 this.panel.fireChange(evt.getSource()); 212 } 213 214 public void setPropTableCellEditor() { 215 216 javax.swing.JComboBox propNameComboBox = new javax.swing.JComboBox (); 217 String resType = this.helper.getData().getString(__ResType); 218 219 String [] remainingProperties = null; 220 if (resType.equals("javax.jms.Queue")||resType.equals("javax.jms.Topic")) { remainingProperties = FieldHelper.getRemainingFieldNames(propertiesGroup, this.helper.getData().getPropertyNames()); 222 } else { 223 remainingProperties = FieldHelper.getRemainingFieldNames(propertiesGroup2, this.helper.getData().getPropertyNames()); 224 } 225 for (int i = 0; i < remainingProperties.length; i++) 226 propNameComboBox.addItem(remainingProperties[i]); 227 propNameComboBox.setEditable(true); 228 this.propNameColumn = propertyTable.getColumnModel().getColumn(0); 229 propNameColumn.setCellEditor(new javax.swing.DefaultCellEditor (propNameComboBox)); 230 this.propValueColumn = propertyTable.getColumnModel().getColumn(1); 231 232 javax.swing.DefaultCellEditor editor = new javax.swing.DefaultCellEditor (new javax.swing.JTextField ()); 233 editor.setClickCountToStart(1); 234 propValueColumn.setCellEditor(editor); 235 } 236 237 public void refreshFields() { 238 239 ResourceConfigData data = this.helper.getData(); 240 ((PropertiesTableModel)propertyTable.getModel()).setData(this.helper.getData()); 241 descriptionTextArea.setText(NbBundle.getMessage(JmsPropertyVisualPanel.class, "JMSPropertyPanel_Description", data.getString(__ResType))); } 243 244 private javax.swing.JButton addButton; 246 private javax.swing.JPanel buttonsPane; 247 private javax.swing.JTextArea descriptionTextArea; 248 private javax.swing.JScrollPane jScrollPane1; 249 private javax.swing.JLabel propertyInfo; 250 private javax.swing.JTable propertyTable; 251 private javax.swing.JButton removeButton; 252 254 public void setInitialFocus(){ 255 new setFocus(addButton); 256 } 257 } 258 | Popular Tags |