1 19 20 package org.netbeans.modules.j2ee.earproject.ui.customizer; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.util.StringTokenizer ; 26 import javax.swing.DefaultListModel ; 27 import javax.swing.JPanel ; 28 import javax.swing.JTable ; 29 import javax.swing.ListSelectionModel ; 30 import javax.swing.event.ListSelectionEvent ; 31 import javax.swing.event.ListSelectionListener ; 32 import javax.swing.table.TableColumn ; 33 import org.openide.DialogDescriptor; 34 import org.openide.DialogDisplayer; 35 import org.openide.util.HelpCtx; 36 import org.openide.util.NbBundle; 37 38 41 public class CustomizerJarContent extends JPanel implements ArchiveCustomizerPanel, ListSelectionListener , HelpCtx.Provider { 42 43 private Dialog dialog; 44 private final AddFilter filterDlg = new AddFilter(); 45 private final DefaultListModel dlm = new DefaultListModel (); 46 private final EarProjectProperties earProperties; 47 private final VisualPropertySupport vps; 48 private final VisualArchiveIncludesSupport vws; 49 private final ActionListener actionListener; 50 51 public CustomizerJarContent(EarProjectProperties earProperties) { 52 initComponents(); 53 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_A11YDesc")); 54 55 this.earProperties = earProperties; 56 vps = new VisualPropertySupport(earProperties); 57 vws = new VisualArchiveIncludesSupport( earProperties.getProject(), 58 (String ) earProperties.get(EarProjectProperties.J2EE_PLATFORM), 59 jTableAddContent, 60 jButtonAddJar, 61 jButtonAddLib, 62 jButtonAddProject, 63 jButtonRemove); 64 65 jListExContent.setModel(dlm); 66 67 70 actionListener = new ActionListener () { 71 public void actionPerformed(ActionEvent event) { 72 if (event.getSource() == DialogDescriptor.OK_OPTION) { 73 dlm.addElement(filterDlg.getExpression()); 74 setExcludeProperty(); 75 closeDialog(); 76 } 77 } 78 }; 79 80 jListExContent.getSelectionModel().addListSelectionListener(this); 81 initTableVisualProperties(jTableAddContent); 82 } 83 84 private void initTableVisualProperties(JTable table) { 85 table.setRowHeight(jTableAddContent.getRowHeight() + 4); 87 table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 88 table.setIntercellSpacing(new java.awt.Dimension (0, 0)); 89 table.getParent().setBackground(table.getBackground()); 91 92 table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 95 TableColumn column = table.getColumnModel().getColumn(0); 96 column.setMinWidth(230); 97 column.setWidth(230); 98 column.setMinWidth(75); 99 column = table.getColumnModel().getColumn(1); 100 column.setMinWidth(126); 101 column.setWidth(126); 102 column.setMinWidth(28); 103 } 104 105 public void initValues() { 106 vps.register(jTextFieldFileName, EarProjectProperties.JAR_NAME); 107 vps.register(jCheckBoxCommpress, EarProjectProperties.JAR_COMPRESS); 108 vps.register(vws, EarProjectProperties.JAR_CONTENT_ADDITIONAL); 109 110 dlm.removeAllElements(); 111 String exclude = (String ) earProperties.get(EarProjectProperties.BUILD_CLASSES_EXCLUDES); 112 if (exclude != null) { 113 StringTokenizer excludeTokenizer = new StringTokenizer (exclude, ","); while (excludeTokenizer.hasMoreElements()) { 115 dlm.addElement(excludeTokenizer.nextToken()); 116 } 117 } else { 118 dlm.addElement("**/*.java"); } 120 121 valueChanged(null); 123 } 124 125 130 private void initComponents() { 132 java.awt.GridBagConstraints gridBagConstraints; 133 134 jPanel1 = new javax.swing.JPanel (); 135 jLabelFileName = new javax.swing.JLabel (); 136 jTextFieldFileName = new javax.swing.JTextField (); 137 jCheckBoxCommpress = new javax.swing.JCheckBox (); 138 jLabelExContent = new javax.swing.JLabel (); 139 jScrollPane1 = new javax.swing.JScrollPane (); 140 jListExContent = new javax.swing.JList (); 141 jButtonAddFilter = new javax.swing.JButton (); 142 jButtonRemoveFilter = new javax.swing.JButton (); 143 jLabelAddContent = new javax.swing.JLabel (); 144 jScrollPane2 = new javax.swing.JScrollPane (); 145 jTableAddContent = new javax.swing.JTable (); 146 jButtonAddJar = new javax.swing.JButton (); 147 jButtonAddLib = new javax.swing.JButton (); 148 jButtonAddProject = new javax.swing.JButton (); 149 jButtonRemove = new javax.swing.JButton (); 150 151 setLayout(new java.awt.GridBagLayout ()); 152 153 jPanel1.setLayout(new java.awt.GridBagLayout ()); 154 155 jLabelFileName.setLabelFor(jTextFieldFileName); 156 org.openide.awt.Mnemonics.setLocalizedText(jLabelFileName, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_FileName_JLabel")); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 159 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 11); 160 jPanel1.add(jLabelFileName, gridBagConstraints); 161 162 jTextFieldFileName.setEditable(false); 163 gridBagConstraints = new java.awt.GridBagConstraints (); 164 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 165 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 166 gridBagConstraints.weightx = 1.0; 167 jPanel1.add(jTextFieldFileName, gridBagConstraints); 168 jTextFieldFileName.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_FileName_A11YDesc")); 169 170 gridBagConstraints = new java.awt.GridBagConstraints (); 171 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 172 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 173 gridBagConstraints.weightx = 1.0; 174 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 175 add(jPanel1, gridBagConstraints); 176 177 org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxCommpress, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_Commpres_JCheckBox")); 178 gridBagConstraints = new java.awt.GridBagConstraints (); 179 gridBagConstraints.gridx = 0; 180 gridBagConstraints.gridy = 1; 181 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 182 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 183 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 184 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 185 add(jCheckBoxCommpress, gridBagConstraints); 186 jCheckBoxCommpress.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_Commpres_A11YDesc")); 187 188 jLabelExContent.setLabelFor(jListExContent); 189 org.openide.awt.Mnemonics.setLocalizedText(jLabelExContent, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_Content_JLabel")); 190 gridBagConstraints = new java.awt.GridBagConstraints (); 191 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 192 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 193 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 194 gridBagConstraints.insets = new java.awt.Insets (12, 0, 2, 0); 195 add(jLabelExContent, gridBagConstraints); 196 197 jScrollPane1.setViewportView(jListExContent); 198 jListExContent.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_Content_A11YDesc")); 199 200 gridBagConstraints = new java.awt.GridBagConstraints (); 201 gridBagConstraints.gridheight = 2; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 203 gridBagConstraints.weighty = 1.0; 204 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 11); 205 add(jScrollPane1, gridBagConstraints); 206 207 org.openide.awt.Mnemonics.setLocalizedText(jButtonAddFilter, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_AddFilter_JButton")); 208 jButtonAddFilter.addActionListener(new java.awt.event.ActionListener () { 209 public void actionPerformed(java.awt.event.ActionEvent evt) { 210 jButtonAddFilterActionPerformed(evt); 211 } 212 }); 213 214 gridBagConstraints = new java.awt.GridBagConstraints (); 215 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 216 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 217 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 218 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 219 add(jButtonAddFilter, gridBagConstraints); 220 jButtonAddFilter.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_AddFilter_A11YDesc")); 221 222 org.openide.awt.Mnemonics.setLocalizedText(jButtonRemoveFilter, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_RemoveFilter_JButton")); 223 jButtonRemoveFilter.addActionListener(new java.awt.event.ActionListener () { 224 public void actionPerformed(java.awt.event.ActionEvent evt) { 225 jButtonRemoveFilterActionPerformed(evt); 226 } 227 }); 228 229 gridBagConstraints = new java.awt.GridBagConstraints (); 230 gridBagConstraints.gridx = 1; 231 gridBagConstraints.gridy = 4; 232 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 233 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 234 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 235 add(jButtonRemoveFilter, gridBagConstraints); 236 jButtonRemoveFilter.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_Remove_A11YDesc")); 237 238 jLabelAddContent.setLabelFor(jTableAddContent); 239 org.openide.awt.Mnemonics.setLocalizedText(jLabelAddContent, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_AddContent_JLabel")); 240 gridBagConstraints = new java.awt.GridBagConstraints (); 241 gridBagConstraints.gridx = 0; 242 gridBagConstraints.gridy = 5; 243 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 244 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 245 gridBagConstraints.insets = new java.awt.Insets (11, 0, 2, 0); 246 add(jLabelAddContent, gridBagConstraints); 247 248 jTableAddContent.setModel(new javax.swing.table.DefaultTableModel ( 249 new Object [][] { 250 251 }, 252 new String [] { 253 254 } 255 )); 256 jScrollPane2.setViewportView(jTableAddContent); 257 jTableAddContent.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "LBL_AACH_ProjectJarFiles_JLabel")); 258 259 gridBagConstraints = new java.awt.GridBagConstraints (); 260 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 261 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 262 gridBagConstraints.weightx = 1.0; 263 gridBagConstraints.weighty = 1.0; 264 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 265 add(jScrollPane2, gridBagConstraints); 266 267 org.openide.awt.Mnemonics.setLocalizedText(jButtonAddJar, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_AddJar_JButton")); 268 gridBagConstraints = new java.awt.GridBagConstraints (); 269 gridBagConstraints.gridx = 1; 270 gridBagConstraints.gridy = 6; 271 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 272 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 273 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 274 add(jButtonAddJar, gridBagConstraints); 275 jButtonAddJar.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_AddJar_A11YDesc")); 276 277 org.openide.awt.Mnemonics.setLocalizedText(jButtonAddLib, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_AddLib_JButton")); 278 gridBagConstraints = new java.awt.GridBagConstraints (); 279 gridBagConstraints.gridx = 1; 280 gridBagConstraints.gridy = 7; 281 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 282 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 283 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 284 add(jButtonAddLib, gridBagConstraints); 285 jButtonAddLib.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_AddLib_A11YDesc")); 286 287 org.openide.awt.Mnemonics.setLocalizedText(jButtonAddProject, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_AddProject_JButton")); 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 1; 290 gridBagConstraints.gridy = 8; 291 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 292 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 293 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 294 add(jButtonAddProject, gridBagConstraints); 295 jButtonAddProject.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_AddProject_A11YDesc")); 296 297 org.openide.awt.Mnemonics.setLocalizedText(jButtonRemove, NbBundle.getMessage(CustomizerJarContent.class, "LBL_CustomizeEAR_Remove_JButton")); 298 gridBagConstraints = new java.awt.GridBagConstraints (); 299 gridBagConstraints.gridx = 1; 300 gridBagConstraints.gridy = 9; 301 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 302 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 303 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 304 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 305 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 306 add(jButtonRemove, gridBagConstraints); 307 jButtonRemove.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerJarContent.class, "ACS_CustomizeEAR_AdditionalRemove_A11YDesc")); 308 309 } 310 312 private void jButtonRemoveFilterActionPerformed(java.awt.event.ActionEvent evt) { Object [] items = jListExContent.getSelectedValues(); 314 for (int i = 0; i < items.length; i++) { 315 dlm.removeElement(items[i]); 316 } 317 setExcludeProperty(); 318 } 320 private void jButtonAddFilterActionPerformed(java.awt.event.ActionEvent evt) { DialogDescriptor descriptor = new DialogDescriptor(filterDlg, NbBundle.getMessage(CustomizerJarContent.class, "LBL_AddFilter_Title"), true, actionListener); Object [] closingOptions = {DialogDescriptor.CANCEL_OPTION}; 323 descriptor.setClosingOptions(closingOptions); 324 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 325 dialog.setVisible(true); 326 } 328 private javax.swing.JButton jButtonAddFilter; 330 private javax.swing.JButton jButtonAddJar; 331 private javax.swing.JButton jButtonAddLib; 332 private javax.swing.JButton jButtonAddProject; 333 private javax.swing.JButton jButtonRemove; 334 private javax.swing.JButton jButtonRemoveFilter; 335 private javax.swing.JCheckBox jCheckBoxCommpress; 336 private javax.swing.JLabel jLabelAddContent; 337 private javax.swing.JLabel jLabelExContent; 338 private javax.swing.JLabel jLabelFileName; 339 private javax.swing.JList jListExContent; 340 private javax.swing.JPanel jPanel1; 341 private javax.swing.JScrollPane jScrollPane1; 342 private javax.swing.JScrollPane jScrollPane2; 343 private javax.swing.JTable jTableAddContent; 344 private javax.swing.JTextField jTextFieldFileName; 345 347 private void closeDialog() { 348 if (dialog != null) { 349 dialog.dispose(); 350 } 351 } 352 353 public void valueChanged(ListSelectionEvent e) { 354 jButtonRemoveFilter.setEnabled(!(jListExContent.isSelectionEmpty())); 355 } 356 357 private void setExcludeProperty() { 358 String exclude = dlm.toString(); 359 exclude = exclude.replaceAll(" ", ""); exclude = exclude.substring(1, exclude.length() -1); 361 earProperties.put(EarProjectProperties.BUILD_CLASSES_EXCLUDES, exclude); 362 } 363 364 367 public HelpCtx getHelpCtx() { 368 return new HelpCtx(CustomizerJarContent.class); 369 } 370 371 } 372 | Popular Tags |