1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.ui.wizards; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.io.File ; 26 import java.io.IOException ; 27 import java.math.BigDecimal ; 28 import java.text.MessageFormat ; 29 import java.util.ArrayList ; 30 import java.util.List ; 31 import java.util.Set ; 32 import java.util.TreeSet ; 33 import javax.swing.DefaultComboBoxModel ; 34 import javax.swing.JButton ; 35 import javax.swing.JFileChooser ; 36 import javax.swing.JPanel ; 37 import javax.swing.event.DocumentEvent ; 38 import javax.swing.event.DocumentListener ; 39 import org.netbeans.api.project.Project; 40 import org.netbeans.api.project.ProjectInformation; 41 import org.netbeans.api.project.ProjectManager; 42 import org.netbeans.api.project.ProjectUtils; 43 import org.netbeans.api.project.ui.OpenProjects; 44 import org.netbeans.modules.j2ee.dd.api.ejb.DDProvider; 45 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 46 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 47 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 48 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModuleContainer; 49 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 50 import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerManager; 51 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProvider; 52 import org.netbeans.modules.j2ee.ejbjarproject.ui.FoldersListSettings; 53 import org.netbeans.spi.project.support.ant.GeneratedFilesHelper; 54 import org.netbeans.spi.project.ui.support.ProjectChooser; 55 import org.netbeans.spi.project.ui.templates.support.Templates; 56 import org.openide.DialogDescriptor; 57 import org.openide.DialogDisplayer; 58 import org.openide.ErrorManager; 59 import org.openide.NotifyDescriptor; 60 import org.openide.WizardDescriptor; 61 import org.openide.WizardValidationException; 62 import org.openide.filesystems.FileObject; 63 import org.openide.filesystems.FileUtil; 64 import org.openide.util.NbBundle; 65 66 69 public class ImportLocationVisual extends JPanel { 70 71 private static final String J2EE_SPEC_15_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "J2EESpecLevel_15"); 72 private static final String J2EE_SPEC_14_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "J2EESpecLevel_14"); 73 private static final String J2EE_SPEC_13_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "J2EESpecLevel_13"); 74 75 private final DefaultComboBoxModel serversModel = new DefaultComboBoxModel (); 76 private final ImportLocation panel; 77 private final DocumentListener documentListener; 78 private List earProjects; 79 private BigDecimal ejbJarXmlVersion; 80 private WizardDescriptor wizardDescriptor; 81 private J2eeVersionWarningPanel warningPanel; 82 83 84 public ImportLocationVisual (ImportLocation panel) { 85 this.panel = panel; 86 initComponents (); 87 setJ2eeVersionWarningPanel(); 88 initServers(FoldersListSettings.getDefault().getLastUsedServer()); 89 if (j2eeSpecComboBox.getModel().getSize() > 0) { 91 j2eeSpecComboBox.setSelectedIndex(0); 92 } 93 initEnterpriseApplications(); 94 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_NWP1_NamePanel_A11YDesc")); setName(NbBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("LBL_IW_ImportTitle")); putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(ImportLocationVisual.class, "TXT_ImportEJBModule")); this.projectName.setText(""); 98 99 documentListener = new DocumentListener () { 100 public void insertUpdate(DocumentEvent e) { 101 update(e); 102 } 103 104 public void removeUpdate(DocumentEvent e) { 105 update(e); 106 } 107 108 public void changedUpdate(DocumentEvent e) { 109 update(e); 110 } 111 }; 112 this.projectName.getDocument().addDocumentListener(documentListener); 113 this.projectFolder.getDocument().addDocumentListener(documentListener); 114 this.projectLocation.getDocument().addDocumentListener(documentListener); 115 116 } 117 118 123 private void initComponents() { 125 java.awt.GridBagConstraints gridBagConstraints; 126 127 jLabelSrcLocationDesc = new javax.swing.JLabel (); 128 jLabelSrcLocation = new javax.swing.JLabel (); 129 projectLocation = new javax.swing.JTextField (); 130 browseProjectLocation = new javax.swing.JButton (); 131 jLabelPrjLocationDesc = new javax.swing.JLabel (); 132 jLabelPrjName = new javax.swing.JLabel (); 133 projectName = new javax.swing.JTextField (); 134 jLabelPrjLocation = new javax.swing.JLabel (); 135 projectFolder = new javax.swing.JTextField (); 136 browseProjectFolder = new javax.swing.JButton (); 137 jSeparator1 = new javax.swing.JSeparator (); 138 jPanel1 = new javax.swing.JPanel (); 139 jCheckBox1 = new javax.swing.JCheckBox (); 140 serverInstanceLabel = new javax.swing.JLabel (); 141 serverInstanceComboBox = new javax.swing.JComboBox (); 142 jLabel7 = new javax.swing.JLabel (); 143 j2eeSpecComboBox = new javax.swing.JComboBox (); 144 addToAppLabel = new javax.swing.JLabel (); 145 addToAppComboBox = new javax.swing.JComboBox (); 146 warningPlaceHolderPanel = new javax.swing.JPanel (); 147 manageServersButton = new javax.swing.JButton (); 148 149 setLayout(new java.awt.GridBagLayout ()); 150 151 setNextFocusableComponent(projectLocation); 152 getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_ImportLocationVisual_A11Name")); 153 getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_ImportLocationVisual_A11Desc")); 154 org.openide.awt.Mnemonics.setLocalizedText(jLabelSrcLocationDesc, NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationSrcDesc")); 155 gridBagConstraints = new java.awt.GridBagConstraints (); 156 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 157 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 158 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 159 add(jLabelSrcLocationDesc, gridBagConstraints); 160 161 jLabelSrcLocation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 162 jLabelSrcLocation.setLabelFor(projectLocation); 163 org.openide.awt.Mnemonics.setLocalizedText(jLabelSrcLocation, NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationSrc_Label")); 164 gridBagConstraints = new java.awt.GridBagConstraints (); 165 gridBagConstraints.gridx = 0; 166 gridBagConstraints.gridy = 1; 167 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 168 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 169 add(jLabelSrcLocation, gridBagConstraints); 170 jLabelSrcLocation.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_Location_A11Desc")); 171 172 projectLocation.setNextFocusableComponent(browseProjectLocation); 173 projectLocation.addFocusListener(new java.awt.event.FocusAdapter () { 174 public void focusLost(java.awt.event.FocusEvent evt) { 175 projectLocationFocusLost(evt); 176 } 177 }); 178 179 gridBagConstraints = new java.awt.GridBagConstraints (); 180 gridBagConstraints.gridx = 1; 181 gridBagConstraints.gridy = 1; 182 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 183 gridBagConstraints.weightx = 1.0; 184 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 185 add(projectLocation, gridBagConstraints); 186 projectLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_IW_ImportLocation_A11YDesc")); 187 188 org.openide.awt.Mnemonics.setLocalizedText(browseProjectLocation, NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_BrowseLocation_Button_w")); 189 browseProjectLocation.setNextFocusableComponent(projectName); 190 browseProjectLocation.addActionListener(new java.awt.event.ActionListener () { 191 public void actionPerformed(java.awt.event.ActionEvent evt) { 192 browseProjectLocationActionPerformed(evt); 193 } 194 }); 195 196 gridBagConstraints = new java.awt.GridBagConstraints (); 197 gridBagConstraints.gridx = 2; 198 gridBagConstraints.gridy = 1; 199 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 200 add(browseProjectLocation, gridBagConstraints); 201 browseProjectLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_IW_ImportLocationBrowse_A11YDesc")); 202 203 org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjLocationDesc, NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationPrjDesc")); 204 gridBagConstraints = new java.awt.GridBagConstraints (); 205 gridBagConstraints.gridx = 0; 206 gridBagConstraints.gridy = 2; 207 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 208 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 209 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 210 add(jLabelPrjLocationDesc, gridBagConstraints); 211 212 jLabelPrjName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 213 jLabelPrjName.setLabelFor(projectName); 214 org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjName, org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ProjectName_Label")); 215 gridBagConstraints = new java.awt.GridBagConstraints (); 216 gridBagConstraints.gridx = 0; 217 gridBagConstraints.gridy = 3; 218 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 219 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 220 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 221 add(jLabelPrjName, gridBagConstraints); 222 jLabelPrjName.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_ProjectName_A11Desc")); 223 224 projectName.setNextFocusableComponent(projectFolder); 225 gridBagConstraints = new java.awt.GridBagConstraints (); 226 gridBagConstraints.gridx = 1; 227 gridBagConstraints.gridy = 3; 228 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 229 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 230 add(projectName, gridBagConstraints); 231 projectName.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_ProjectName_A11YDesc")); 232 233 jLabelPrjLocation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 234 jLabelPrjLocation.setLabelFor(projectFolder); 235 org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjLocation, NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_CreatedProjectFolder_Lablel")); 236 gridBagConstraints = new java.awt.GridBagConstraints (); 237 gridBagConstraints.gridx = 0; 238 gridBagConstraints.gridy = 4; 239 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 240 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 241 add(jLabelPrjLocation, gridBagConstraints); 242 jLabelPrjLocation.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_ProjectFolder_A11Desc")); 243 244 projectFolder.setNextFocusableComponent(browseProjectFolder); 245 gridBagConstraints = new java.awt.GridBagConstraints (); 246 gridBagConstraints.gridx = 1; 247 gridBagConstraints.gridy = 4; 248 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 249 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 250 add(projectFolder, gridBagConstraints); 251 projectFolder.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NPW1_ProjectLocation_A11YDesc")); 252 253 org.openide.awt.Mnemonics.setLocalizedText(browseProjectFolder, NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_BrowseLocation_Button")); 254 browseProjectFolder.setNextFocusableComponent(addToAppComboBox); 255 browseProjectFolder.addActionListener(new java.awt.event.ActionListener () { 256 public void actionPerformed(java.awt.event.ActionEvent evt) { 257 browseProjectFolderActionPerformed(evt); 258 } 259 }); 260 261 gridBagConstraints = new java.awt.GridBagConstraints (); 262 gridBagConstraints.gridx = 2; 263 gridBagConstraints.gridy = 4; 264 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 265 add(browseProjectFolder, gridBagConstraints); 266 browseProjectFolder.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_BrowseLocation_A11YDesc")); 267 268 gridBagConstraints = new java.awt.GridBagConstraints (); 269 gridBagConstraints.gridx = 0; 270 gridBagConstraints.gridy = 5; 271 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 272 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 273 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 274 gridBagConstraints.weightx = 1.0; 275 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 276 add(jSeparator1, gridBagConstraints); 277 278 jPanel1.setLayout(new java.awt.GridBagLayout ()); 279 280 jCheckBox1.setSelected(true); 281 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("LBL_IW_SetAsMainProject_CheckBox")); 282 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 283 gridBagConstraints = new java.awt.GridBagConstraints (); 284 gridBagConstraints.gridx = 0; 285 gridBagConstraints.gridy = 4; 286 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 287 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 288 gridBagConstraints.weightx = 1.0; 289 gridBagConstraints.weighty = 1.0; 290 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 291 jPanel1.add(jCheckBox1, gridBagConstraints); 292 jCheckBox1.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_SetAsMainProject_A11YDesc")); 293 294 serverInstanceLabel.setLabelFor(serverInstanceComboBox); 295 org.openide.awt.Mnemonics.setLocalizedText(serverInstanceLabel, org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Server")); 296 gridBagConstraints = new java.awt.GridBagConstraints (); 297 gridBagConstraints.gridx = 0; 298 gridBagConstraints.gridy = 1; 299 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 300 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 301 jPanel1.add(serverInstanceLabel, gridBagConstraints); 302 303 serverInstanceComboBox.setModel(serversModel); 304 serverInstanceComboBox.setNextFocusableComponent(manageServersButton); 305 serverInstanceComboBox.addActionListener(new java.awt.event.ActionListener () { 306 public void actionPerformed(java.awt.event.ActionEvent evt) { 307 serverInstanceComboBoxActionPerformed(evt); 308 } 309 }); 310 311 gridBagConstraints = new java.awt.GridBagConstraints (); 312 gridBagConstraints.gridx = 1; 313 gridBagConstraints.gridy = 1; 314 gridBagConstraints.gridwidth = 2; 315 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 316 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 317 gridBagConstraints.weightx = 1.0; 318 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 319 jPanel1.add(serverInstanceComboBox, gridBagConstraints); 320 serverInstanceComboBox.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_SelectServerInstance_A11YDesc")); 321 322 jLabel7.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_SelectJ2EEVersion_LabelMnemonic").charAt(0)); 323 jLabel7.setLabelFor(j2eeSpecComboBox); 324 jLabel7.setText(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_J2EESpecLevel_Label")); 325 gridBagConstraints = new java.awt.GridBagConstraints (); 326 gridBagConstraints.gridx = 0; 327 gridBagConstraints.gridy = 2; 328 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 329 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 330 jPanel1.add(jLabel7, gridBagConstraints); 331 332 j2eeSpecComboBox.setPrototypeDisplayValue("MMMMMMMMM" ); 333 j2eeSpecComboBox.addActionListener(new java.awt.event.ActionListener () { 334 public void actionPerformed(java.awt.event.ActionEvent evt) { 335 j2eeSpecComboBoxActionPerformed(evt); 336 } 337 }); 338 339 gridBagConstraints = new java.awt.GridBagConstraints (); 340 gridBagConstraints.gridx = 1; 341 gridBagConstraints.gridy = 2; 342 gridBagConstraints.gridwidth = 2; 343 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 344 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 345 jPanel1.add(j2eeSpecComboBox, gridBagConstraints); 346 j2eeSpecComboBox.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("ACS_LBL_IW_SelectJ2EEVersion_A11YDesc")); 347 348 addToAppLabel.setLabelFor(addToAppComboBox); 349 org.openide.awt.Mnemonics.setLocalizedText(addToAppLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbjarproject/ui/wizards/Bundle").getString("LBL_NWP1_AddToEApp_CheckBox")); 350 gridBagConstraints = new java.awt.GridBagConstraints (); 351 gridBagConstraints.gridx = 0; 352 gridBagConstraints.gridy = 0; 353 gridBagConstraints.gridwidth = 2; 354 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 355 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 356 jPanel1.add(addToAppLabel, gridBagConstraints); 357 358 addToAppComboBox.setNextFocusableComponent(serverInstanceComboBox); 359 addToAppComboBox.addActionListener(new java.awt.event.ActionListener () { 360 public void actionPerformed(java.awt.event.ActionEvent evt) { 361 addToAppComboBoxActionPerformed(evt); 362 } 363 }); 364 365 gridBagConstraints = new java.awt.GridBagConstraints (); 366 gridBagConstraints.gridx = 2; 367 gridBagConstraints.gridy = 0; 368 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 369 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 370 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 371 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 372 jPanel1.add(addToAppComboBox, gridBagConstraints); 373 374 warningPlaceHolderPanel.setLayout(new java.awt.BorderLayout ()); 375 376 gridBagConstraints = new java.awt.GridBagConstraints (); 377 gridBagConstraints.gridx = 0; 378 gridBagConstraints.gridy = 3; 379 gridBagConstraints.gridwidth = 3; 380 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 381 gridBagConstraints.weightx = 1.0; 382 jPanel1.add(warningPlaceHolderPanel, gridBagConstraints); 383 384 org.openide.awt.Mnemonics.setLocalizedText(manageServersButton, org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_ManageServers")); 385 manageServersButton.setNextFocusableComponent(j2eeSpecComboBox); 386 manageServersButton.addActionListener(new java.awt.event.ActionListener () { 387 public void actionPerformed(java.awt.event.ActionEvent evt) { 388 manageServersButtonActionPerformed(evt); 389 } 390 }); 391 392 gridBagConstraints = new java.awt.GridBagConstraints (); 393 gridBagConstraints.gridx = 3; 394 gridBagConstraints.gridy = 1; 395 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 396 gridBagConstraints.insets = new java.awt.Insets (0, 6, 5, 0); 397 jPanel1.add(manageServersButton, gridBagConstraints); 398 manageServersButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ASCN_ManageServers")); 399 manageServersButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ASCD_ManageServers")); 400 401 gridBagConstraints = new java.awt.GridBagConstraints (); 402 gridBagConstraints.gridx = 0; 403 gridBagConstraints.gridy = 6; 404 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 405 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 406 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 407 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 408 gridBagConstraints.weightx = 1.0; 409 gridBagConstraints.weighty = 1.0; 410 add(jPanel1, gridBagConstraints); 411 412 } 414 private void projectLocationFocusLost(java.awt.event.FocusEvent evt) { File f = new File (projectLocation.getText().trim()); 416 if (f.isDirectory()) { 417 updateJ2EEVersion(); 418 } 419 } 421 private void manageServersButtonActionPerformed(java.awt.event.ActionEvent evt) { ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 423 String lastSelectedServerInstanceID = null; 424 if (serverInstanceWrapper != null) { 425 lastSelectedServerInstanceID = serverInstanceWrapper.getServerInstanceID(); 426 } 427 ServerManager.showCustomizer(lastSelectedServerInstanceID); 428 String lastSelectedJ2eeSpecLevel = (String ) j2eeSpecComboBox.getSelectedItem(); 429 initServers(lastSelectedServerInstanceID); 431 if (lastSelectedJ2eeSpecLevel != null) { 432 j2eeSpecComboBox.setSelectedItem(lastSelectedJ2eeSpecLevel); 433 } 434 } 436 private void j2eeSpecComboBoxActionPerformed(java.awt.event.ActionEvent evt) { panel.stateChanged(null); 438 } 440 private void addToAppComboBoxActionPerformed(java.awt.event.ActionEvent evt) { } 444 private void serverInstanceComboBoxActionPerformed(java.awt.event.ActionEvent evt) { String prevSelectedItem = (String ) j2eeSpecComboBox.getSelectedItem(); 446 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 448 if (serverInstanceWrapper != null) { 449 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceWrapper.getServerInstanceID()); 450 Set supportedVersions = j2eePlatform.getSupportedSpecVersions(J2eeModule.EJB); 451 j2eeSpecComboBox.removeAllItems(); 452 if (supportedVersions.contains(J2eeModule.JAVA_EE_5)) { 453 j2eeSpecComboBox.addItem(J2EE_SPEC_15_LABEL); 454 } 455 if (supportedVersions.contains(J2eeModule.J2EE_14)) { 456 j2eeSpecComboBox.addItem(J2EE_SPEC_14_LABEL); 457 } 458 if (prevSelectedItem != null) { 459 j2eeSpecComboBox.setSelectedItem(prevSelectedItem); 460 } 461 } else { 462 j2eeSpecComboBox.removeAllItems(); 463 } 464 panel.fireChangeEvent(); 466 } 468 private void browseProjectFolderActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 470 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 471 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 472 if (projectFolder.getText().length() > 0 && getProjectFolder().exists()) { 473 chooser.setSelectedFile(getProjectFolder()); 474 } else if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) { 475 chooser.setSelectedFile(getProjectLocation()); 476 } else { 477 chooser.setSelectedFile(ProjectChooser.getProjectsFolder()); 478 } 479 chooser.setDialogTitle(NbBundle.getMessage(ImportLocationVisual.class, "LBL_SelectNewLocation")); if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 481 File projectDir = FileUtil.normalizeFile(chooser.getSelectedFile()); 482 projectFolder.setText(projectDir.getAbsolutePath()); 483 } 484 } 486 private void browseProjectLocationActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (); 488 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 489 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 490 if (projectLocation.getText().length() > 0 && getProjectLocation().exists()) { 491 chooser.setSelectedFile(getProjectLocation()); 492 } else { 493 File currentDirectory = null; 495 FileObject existingSourcesFO = Templates.getExistingSourcesFolder(wizardDescriptor); 496 if (existingSourcesFO != null) { 497 File existingSourcesFile = FileUtil.toFile(existingSourcesFO); 498 if (existingSourcesFile != null && existingSourcesFile.isDirectory()) { 499 currentDirectory = existingSourcesFile; 500 } 501 } 502 if (currentDirectory != null) { 503 chooser.setCurrentDirectory(currentDirectory); 504 } else { 505 chooser.setSelectedFile(ProjectChooser.getProjectsFolder()); 506 } 507 } 508 509 chooser.setDialogTitle(NbBundle.getMessage(ImportLocationVisual.class, "LBL_SelectExistingLocation")); if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 511 projectLocation.setText(FileUtil.normalizeFile(chooser.getSelectedFile()).getAbsolutePath()); 512 updateJ2EEVersion(); 513 updateProjectName(); 514 updateProjectFolder(); 515 panel.stateChanged(null); 516 } 517 } 519 private javax.swing.JComboBox addToAppComboBox; 521 private javax.swing.JLabel addToAppLabel; 522 private javax.swing.JButton browseProjectFolder; 523 private javax.swing.JButton browseProjectLocation; 524 private javax.swing.JComboBox j2eeSpecComboBox; 525 private javax.swing.JCheckBox jCheckBox1; 526 private javax.swing.JLabel jLabel7; 527 private javax.swing.JLabel jLabelPrjLocation; 528 private javax.swing.JLabel jLabelPrjLocationDesc; 529 private javax.swing.JLabel jLabelPrjName; 530 private javax.swing.JLabel jLabelSrcLocation; 531 private javax.swing.JLabel jLabelSrcLocationDesc; 532 private javax.swing.JPanel jPanel1; 533 private javax.swing.JSeparator jSeparator1; 534 private javax.swing.JButton manageServersButton; 535 public javax.swing.JTextField projectFolder; 536 public javax.swing.JTextField projectLocation; 537 public javax.swing.JTextField projectName; 538 private javax.swing.JComboBox serverInstanceComboBox; 539 private javax.swing.JLabel serverInstanceLabel; 540 private javax.swing.JPanel warningPlaceHolderPanel; 541 543 private void setJ2eeVersionWarning() { 544 String errorMessage; 545 String selectedItem = (String )j2eeSpecComboBox.getSelectedItem(); 546 547 if (J2EE_SPEC_14_LABEL.equals(selectedItem) && new BigDecimal (EjbJar.VERSION_2_0).equals(ejbJarXmlVersion)) { 548 errorMessage = NbBundle.getMessage(ImportLocationVisual.class, "MSG_EjbJarXMLNotSupported"); 549 } else { 550 errorMessage = null; 551 } 552 if (wizardDescriptor != null) { 553 wizardDescriptor.putProperty("WizardPanel_errorMessage", errorMessage); } 555 556 setJ2eeVersionWarningPanel(); 557 } 558 559 private boolean ignoreEvent = false; 560 561 private String lastComputedPrjName = null; 562 private String computeProjectName() { 563 String cPrjName = null; 564 FileObject fo = FileUtil.toFileObject(getProjectLocation()); 565 if (fo != null) { 566 cPrjName = fo.getName(); 567 } 568 return cPrjName; 569 } 570 571 private String lastComputedPrjFolder = null; 572 private String computeProjectFolder() { 573 String cPrjFolder = null; 574 if (isValidProjectLocation()) { 575 cPrjFolder = getProjectLocation().getAbsolutePath(); 576 } 577 return cPrjFolder; 578 } 579 580 private void update(DocumentEvent e) { 581 if (ignoreEvent) { 582 return; 584 } 585 586 ignoreEvent = true; 588 589 if (projectLocation.getDocument() == e.getDocument()) { 590 updateProjectName(); 591 updateProjectFolder(); 592 } 593 594 ignoreEvent = false; 596 597 panel.stateChanged(null); 598 } 599 600 private void updateProjectName() { 601 String prjName = computeProjectName(); 602 if ((lastComputedPrjName != null) && (!lastComputedPrjName.equals(projectName.getText().trim()))) { 603 return; 604 } 605 lastComputedPrjName = prjName; 606 if (prjName != null) { 607 projectName.setText(prjName); 608 } 609 } 610 611 private void updateProjectFolder() { 612 String prjFolder = computeProjectFolder(); 613 if ((lastComputedPrjFolder != null) && (!lastComputedPrjFolder.equals(projectFolder.getText().trim()))) { 614 return; 615 } 616 lastComputedPrjFolder = prjFolder; 617 if (prjFolder != null) { 618 projectFolder.setText(prjFolder); 619 } else { 620 projectFolder.setText(""); } 622 } 623 624 private void updateJ2EEVersion() { 625 File f = new File (projectLocation.getText().trim()); 626 FileObject fo = FileUtil.toFileObject(FileUtil.normalizeFile(f)); 627 if (fo != null) { 628 FileObject configFilesPath = FileSearchUtility.guessConfigFilesPath(fo); 629 if (configFilesPath != null) { 630 FileObject ejbJarXML = configFilesPath.getFileObject(EjbJarProvider.FILE_DD); 631 checkEjbJarXmlJ2eeVersion(ejbJarXML); 632 } else { 633 j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_15_LABEL); 635 } 636 } 637 } 638 639 private boolean isValidProjectLocation() { 640 return (getProjectLocation().exists() && getProjectLocation().isDirectory() && 641 projectLocation.getText().length() > 0 && (!projectLocation.getText().endsWith(":"))); } 643 644 public boolean valid(WizardDescriptor wizardDescriptor) { 645 File prjDir = new File (projectLocation.getText().trim()); 646 String prjName = projectName.getText().trim(); 648 649 if (getSelectedServerInstanceID() == null) { 650 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(ImportLocationVisual.class,"MSG_NoServer")); return false; 652 } 653 654 if (!prjDir.isDirectory()) { 655 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(ImportLocationVisual.class,"MSG_ProvideExistingSourcesLocation")); return false; } 658 659 665 671 if (prjName == null || prjName.length() == 0) { 672 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(ImportLocationVisual.class,"MSG_ProvideProjectName")); return false; } 675 676 String result = checkValidity (this.projectName.getText(), this.projectFolder.getText()); 677 if (result != null) { 678 wizardDescriptor.putProperty( "WizardPanel_errorMessage", result); return false; 680 } 681 682 wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); 684 setJ2eeVersionWarning(); 685 686 return true; 687 } 688 689 static String checkValidity (final String projectName, final String projectLocation) { 690 File projLoc = new File (projectLocation).getAbsoluteFile(); 691 692 if (PanelProjectLocationVisual.getCanonicalFile(projLoc) == null) { 693 return NbBundle.getMessage(ImportLocationVisual.class, "MSG_IllegalProjectLocation"); 694 } 695 696 while (projLoc != null && !projLoc.exists()) { 697 projLoc = projLoc.getParentFile(); 698 } 699 if (projLoc == null || !projLoc.canWrite()) { 700 return NbBundle.getMessage(ImportLocationVisual.class,"MSG_ProjectFolderReadOnly"); 701 } 702 703 File destFolder = FileUtil.normalizeFile(new File ( projectLocation )); 704 File [] kids = destFolder.listFiles(); 705 if ( destFolder.exists() && kids != null && kids.length > 0) { 706 String file = null; 707 for (int i=0; i< kids.length; i++) { 708 String childName = kids[i].getName(); 709 if ("nbproject".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_NetBeansProject"); 711 } 712 else if ("build".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_BuildFolder"); 714 } 715 else if ("dist".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_DistFolder"); 717 } 718 else if ("build.xml".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_BuildXML"); 720 } 721 else if ("manifest.mf".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_Manifest"); 723 } 724 if (file != null) { 725 String format = NbBundle.getMessage (ImportLocationVisual.class,"MSG_ProjectFolderInvalid"); 726 return MessageFormat.format(format, new Object [] {file}); 727 } 728 } 729 } 730 731 if (destFolder.isDirectory()) { 732 FileObject destFO = FileUtil.toFileObject(destFolder); 733 assert destFO != null : "No FileObject for " + destFolder; 734 boolean clear; 735 try { 736 clear = ProjectManager.getDefault().findProject(destFO) == null; 737 } catch (IOException e) { 738 clear = false; 739 } 740 if (!clear) { 741 return NbBundle.getMessage(ImportLocationVisual.class, "MSG_ProjectFolderHasDeletedProject"); 742 } 743 } 744 return null; 745 } 746 747 void read (WizardDescriptor d) { 748 wizardDescriptor = d; 749 } 750 751 void store( WizardDescriptor d ) { 752 String name = projectName.getText().trim(); 753 String moduleLoc = projectLocation.getText().trim(); 754 755 if (name.equals("") || moduleLoc.equals("")) { 756 return; 757 } 758 759 d.putProperty(WizardProperties.PROJECT_DIR, new File (projectFolder.getText().trim())); 760 File moduleLocFile = new File (moduleLoc); 761 d.putProperty(WizardProperties.SOURCE_ROOT, moduleLocFile); 762 d.putProperty(WizardProperties.NAME, name); 763 d.putProperty(WizardProperties.JAVA_ROOT, FileSearchUtility.guessJavaRootsAsFiles(FileUtil.toFileObject(FileUtil.normalizeFile(moduleLocFile)))); 764 d.putProperty(WizardProperties.SERVER_INSTANCE_ID, getSelectedServerInstanceID()); 765 d.putProperty(WizardProperties.J2EE_LEVEL, getSelectedJ2eeSpec()); 766 d.putProperty(WizardProperties.EAR_APPLICATION, getSelectedEarApplication()); 767 if (warningPanel != null && warningPanel.getDowngradeAllowed()) { 768 d.putProperty(WizardProperties.JAVA_PLATFORM, warningPanel.getSuggestedJavaPlatformName()); 769 770 String j2ee = getSelectedJ2eeSpec(); 771 if (j2ee != null) { 772 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 773 FoldersListSettings fls = FoldersListSettings.getDefault(); 774 String srcLevel = "1.6"; if (warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_14) && fls.isAgreedSetSourceLevel14()) 776 srcLevel = "1.4"; else if (warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_15) && fls.isAgreedSetSourceLevel15()) 778 srcLevel = "1.5"; 780 d.putProperty(WizardProperties.SOURCE_LEVEL, srcLevel); 781 } 782 } else 783 d.putProperty(WizardProperties.SOURCE_LEVEL, null); 784 785 } 787 788 private Dialog dialog; 790 791 void validate (WizardDescriptor d) throws WizardValidationException { 792 File dirF = new File (projectFolder.getText()); 793 JButton ok = new JButton (NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Buildfile_OK")); ok.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_IW_BuildFileDialog_OKButton_LabelMnemonic")); ok.setMnemonic(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BuildFileDialog_OK_LabelMnemonic").charAt(0)); JButton cancel = new JButton (NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Buildfile_Cancel")); cancel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_IW_BuildFileDialog_CancelButton_LabelMnemonic")); cancel.setMnemonic(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BuildFileDialog_Cancel_LabelMnemonic").charAt(0)); 800 final ImportBuildfile ibf = new ImportBuildfile(dirF.getAbsolutePath(), ok); 801 if ((new File (dirF, GeneratedFilesHelper.BUILD_XML_PATH)).exists()) { 802 ActionListener actionListener = new ActionListener () { 803 public void actionPerformed(ActionEvent event) { 804 Object src = event.getSource(); 805 if (src instanceof JButton ) { 806 String name = ((JButton ) src).getText(); 807 if (name.equals(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Buildfile_OK"))) { closeDialog(); 809 } else if (name.equals(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Buildfile_Cancel"))) { NotifyDescriptor ndesc = new NotifyDescriptor.Confirmation(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_Buildfile_CancelConfirmation"), NotifyDescriptor.YES_NO_OPTION); Object ret = DialogDisplayer.getDefault().notify(ndesc); 812 if (ret == NotifyDescriptor.YES_OPTION) { 813 closeDialog(); 814 } 815 } 816 } 817 } 818 }; 819 820 DialogDescriptor descriptor = new DialogDescriptor( 821 ibf, 822 NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BuildfileTitle"), true, 824 new Object [] {ok, cancel}, 825 DialogDescriptor.OK_OPTION, 826 DialogDescriptor.DEFAULT_ALIGN, 827 null, 828 actionListener 829 ); 830 831 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 832 dialog.setVisible(true); 833 } else { 834 return; 835 } 836 } 837 838 private void closeDialog() { 839 dialog.dispose(); 840 } 841 842 private boolean isParentOf(FileObject dir, FileObject[] fos) { 843 boolean result = true; 844 if (fos != null) { 845 for (int i = 0; i < fos.length; i++) { 846 result = FileUtil.isParentOf(dir, fos[i]); 847 if (!result) { 848 return result; 849 } 850 } 851 } 852 return result; 853 } 854 855 859 private void initServers(String selectedServerInstanceID) { 860 serversModel.removeAllElements(); 862 Set <ServerInstanceWrapper> servers = new TreeSet <ServerInstanceWrapper>(); 863 ServerInstanceWrapper selectedItem = null; 864 boolean sjasFound = false; 865 for (String serverInstanceID : Deployment.getDefault().getServerInstanceIDs()) { 866 String displayName = Deployment.getDefault().getServerInstanceDisplayName(serverInstanceID); 867 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceID); 868 if (displayName != null && j2eePlatform != null && j2eePlatform.getSupportedModuleTypes().contains(J2eeModule.EJB)) { 869 ServerInstanceWrapper serverWrapper = new ServerInstanceWrapper(serverInstanceID, displayName); 870 if (selectedItem == null || !sjasFound) { 872 if (selectedServerInstanceID != null) { 873 if (selectedServerInstanceID.equals(serverInstanceID)) { 874 selectedItem = serverWrapper; 875 } 876 } else { 877 String shortName = Deployment.getDefault().getServerID(serverInstanceID); 879 if ("J2EE".equals(shortName)) { selectedItem = serverWrapper; 881 sjasFound = true; 882 } 883 else 884 if ("JBoss4".equals(shortName)) { selectedItem = serverWrapper; 886 } 887 } 888 } 889 servers.add(serverWrapper); 890 } 891 } 892 for (ServerInstanceWrapper item : servers) { 893 serversModel.addElement(item); 894 } 895 if (selectedItem != null) { 896 serversModel.setSelectedItem(selectedItem); 898 } else if (serversModel.getSize() > 0) { 899 serversModel.setSelectedItem(serversModel.getElementAt(0)); 901 } 902 } 903 904 public String getSelectedServerInstanceID() { 905 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 906 if (serverInstanceWrapper == null) { 907 return null; 908 } 909 return serverInstanceWrapper.getServerInstanceID(); 910 } 911 912 public String getSelectedJ2eeSpec() { 913 Object item = j2eeSpecComboBox.getSelectedItem(); 914 return item == null ? null 915 : item.equals(J2EE_SPEC_14_LABEL) ? J2eeModule.J2EE_14 916 : item.equals(J2EE_SPEC_15_LABEL) ? J2eeModule.JAVA_EE_5 : J2eeModule.J2EE_13; 917 } 918 919 private File getAsFile(String filename) { 920 return FileUtil.normalizeFile(new File (filename)); 921 } 922 923 public File getProjectLocation() { 924 return getAsFile(projectLocation.getText()); 925 } 926 927 public File getProjectFolder() { 928 return getAsFile(projectFolder.getText()); 929 } 930 931 public String getProjectName() { 932 return projectName.getText(); 933 } 934 935 private Project getSelectedEarApplication() { 936 int idx = addToAppComboBox.getSelectedIndex(); 937 return (idx <= 0) ? null : (Project) earProjects.get(idx - 1); 938 } 939 940 private void initEnterpriseApplications() { 941 addToAppComboBox.addItem(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_AddToEApp_None")); 942 addToAppComboBox.setSelectedIndex(0); 943 944 Project[] allProjects = OpenProjects.getDefault().getOpenProjects(); 945 earProjects = new ArrayList (); 946 for (int i = 0; i < allProjects.length; i++) { 947 J2eeModuleContainer container = (J2eeModuleContainer) allProjects[i].getLookup().lookup(J2eeModuleContainer.class); 948 ProjectInformation projectInfo = ProjectUtils.getInformation(allProjects[i]); 949 if (container != null) { 950 earProjects.add(projectInfo.getProject()); 951 addToAppComboBox.addItem(projectInfo.getDisplayName()); 952 } 953 } 954 if (earProjects.size() <= 0) { 955 addToAppComboBox.setEnabled(false); 956 } 957 } 958 959 private BigDecimal getEjbJarXmlVersion(FileObject ejbJarXml) throws IOException { 960 if (ejbJarXml != null) { 961 EjbJar ejbJar = null; 962 org.netbeans.modules.j2ee.api.ejbjar.EjbJar apiEjbJar = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(ejbJarXml); 963 if (apiEjbJar != null) { 964 ejbJar = DDProvider.getDefault().getMergedDDRoot(apiEjbJar.getMetadataUnit()); 965 } else { 966 ejbJar = DDProvider.getDefault().getDDRoot(ejbJarXml); 967 } 968 if (ejbJar != null) { 969 return ejbJar.getVersion(); 970 } 971 } 972 return null; 973 } 974 975 private void checkEjbJarXmlJ2eeVersion(FileObject ejbJarXml) { 976 try { 977 BigDecimal version = getEjbJarXmlVersion(ejbJarXml); 978 ejbJarXmlVersion = version; 979 if (version == null) { 980 return; 981 } 982 983 if(new BigDecimal (EjbJar.VERSION_2_0).equals(version)) { 984 j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_13_LABEL); 985 } else if(new BigDecimal (EjbJar.VERSION_2_1).equals(version)) { 986 j2eeSpecComboBox.setSelectedItem(J2EE_SPEC_14_LABEL); 987 } 988 } catch (IOException e) { 989 final ErrorManager errorManager = ErrorManager.getDefault(); 990 String message = NbBundle.getMessage(ImportLocationVisual.class, "MSG_EjbJarXmlCorrupted"); errorManager.notify(errorManager.annotate(e, message)); 992 } 993 } 994 995 private void setJ2eeVersionWarningPanel() { 996 String j2ee = getSelectedJ2eeSpec(); 997 if (j2ee == null) { 998 return; 999 } 1000 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 1001 if (warningType == null && warningPanel == null) { 1002 return; 1003 } 1004 if (warningPanel == null) { 1005 warningPanel = new J2eeVersionWarningPanel(warningType); 1006 warningPlaceHolderPanel.add(warningPanel, java.awt.BorderLayout.CENTER); 1007 warningPanel.setWarningType(warningType); 1008 } else { 1009 warningPanel.setWarningType(warningType); 1010 } 1011 } 1012 1013 1017 private static class ServerInstanceWrapper implements Comparable { 1018 1019 private final String serverInstanceID; 1020 private final String displayName; 1021 1022 ServerInstanceWrapper(String serverInstanceID, String displayName) { 1023 this.serverInstanceID = serverInstanceID; 1024 this.displayName = displayName; 1025 } 1026 1027 public String getServerInstanceID() { 1028 return serverInstanceID; 1029 } 1030 1031 public String toString() { 1032 return displayName; 1033 } 1034 1035 public int compareTo(Object o) { 1036 return toString().compareTo(o.toString()); 1037 } 1038 } 1039} 1040 | Popular Tags |