1 19 20 package org.netbeans.modules.web.project.ui.wizards; 21 22 import java.awt.Dimension ; 23 import java.io.File ; 24 import java.io.IOException ; 25 import java.text.MessageFormat ; 26 import java.util.ArrayList ; 27 import java.util.List ; 28 import java.util.Set ; 29 import java.util.TreeSet ; 30 31 import javax.swing.*; 32 import javax.swing.event.DocumentEvent ; 33 import javax.swing.event.DocumentListener ; 34 import javax.swing.text.Document ; 35 import org.netbeans.api.project.ProjectUtils; 36 import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerManager; 37 import org.netbeans.modules.web.project.Utils; 38 39 import org.openide.WizardDescriptor; 40 import org.openide.filesystems.FileObject; 41 import org.openide.filesystems.FileUtil; 42 import org.openide.util.HelpCtx; 43 import org.openide.util.NbBundle; 44 45 import org.netbeans.api.project.Project; 46 import org.netbeans.api.project.ProjectInformation; 47 import org.netbeans.api.project.ProjectManager; 48 import org.netbeans.api.project.ui.OpenProjects; 49 import org.netbeans.spi.project.ui.support.ProjectChooser; 50 51 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 52 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 53 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModuleContainer; 54 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 55 import org.netbeans.modules.web.project.ui.*; 56 import org.netbeans.spi.project.ui.templates.support.Templates; 57 58 62 public class ImportLocationVisual extends SettingsPanel implements HelpCtx.Provider { 63 64 private ImportWebProjectWizardIterator.ThePanel panel; 65 private Document moduleDocument; 66 private Document nameDocument; 67 private boolean contextModified = false; 68 private boolean locationModified = false; 69 private boolean locationComputed = false; 70 private WizardDescriptor wizardDescriptor; 71 72 private J2eeVersionWarningPanel warningPanel; 73 74 private String generatedProjectName = ""; 75 private int generatedProjectNameIndex = 0; 76 private final DefaultComboBoxModel serversModel = new DefaultComboBoxModel(); 77 private List earProjects; 78 79 private static final String J2EE_SPEC_13_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "J2EESpecLevel_13"); private static final String J2EE_SPEC_14_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "J2EESpecLevel_14"); private static final String JAVA_EE_5_LABEL = NbBundle.getMessage(ImportLocationVisual.class, "JavaEESpecLevel_50"); 83 84 public ImportLocationVisual (ImportWebProjectWizardIterator.ThePanel panel) { 85 this.panel = panel; 86 initComponents (); 87 initServers(FoldersListSettings.getDefault().getLastUsedServer()); 88 if (j2eeSpecComboBox.getModel().getSize() > 0) { 90 j2eeSpecComboBox.setSelectedIndex(0); 91 } 92 initEnterpriseApplications(); 93 94 setJ2eeVersionWarningPanel(); 95 96 computeSize(); 98 99 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_NWP1_NamePanel_A11YDesc")); 101 setName(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_ImportTitle")); 103 moduleDocument = moduleLocationTextField.getDocument (); 104 nameDocument = projectNameTextField.getDocument(); 105 106 moduleLocationTextField.getDocument().addDocumentListener(new DocumentListener () { 107 public void changedUpdate(DocumentEvent e) { 108 locationDataChanged(e); 109 } 110 public void insertUpdate(DocumentEvent e) { 111 locationDataChanged(e); 112 } 113 public void removeUpdate(DocumentEvent e) { 114 locationDataChanged(e); 115 } 116 }); 117 118 projectNameTextField.getDocument().addDocumentListener (new DocumentListener () { 119 public void changedUpdate(DocumentEvent e) { 120 nameDataChanged(e); 121 } 122 public void insertUpdate(DocumentEvent e) { 123 nameDataChanged(e); 124 } 125 public void removeUpdate(DocumentEvent e) { 126 nameDataChanged(e); 127 } 128 }); 129 130 projectLocationTextField.getDocument().addDocumentListener (new DocumentListener () { 131 public void changedUpdate(DocumentEvent e) { 132 fireChanges(); 133 } 134 public void insertUpdate(DocumentEvent e) { 135 fireChanges(); 136 } 137 public void removeUpdate(DocumentEvent e) { 138 fireChanges(); 139 } 140 }); 141 142 } 143 144 private void computeSize() { 145 double srcLocLabelLength = jLabelSrcLocationDesc.getFontMetrics(jLabelSrcLocationDesc.getFont()).getStringBounds(jLabelSrcLocationDesc.getText(), getGraphics()).getWidth() * 0.85; 146 int width = new Double (srcLocLabelLength).intValue(); 147 if (width < 500) 148 width = 500; 149 int height = jComboBoxEnterprise.getFontMetrics(jComboBoxEnterprise.getFont()).getHeight() * 13 + 150; 150 if (height > 340) { 151 Dimension dim = new Dimension (width, height); 152 setMinimumSize(dim); 153 setPreferredSize(dim); 154 } 155 } 156 157 void read(WizardDescriptor settings) { 158 wizardDescriptor = settings; 159 160 File projectLocation = (File ) settings.getProperty ("projdir"); if (projectLocation == null || projectLocation.getParentFile() == null || !projectLocation.getParentFile().isDirectory ()) 162 projectLocation = ProjectChooser.getProjectsFolder(); 163 else 164 projectLocation = projectLocation.getParentFile(); 165 166 if(generatedProjectNameIndex == 0) { 167 generatedProjectName = (String ) settings.getProperty ("name"); if (generatedProjectName == null) { 169 generatedProjectNameIndex = FoldersListSettings.getDefault().getNewProjectCount() + 1; 170 String formater = NbBundle.getMessage(ImportLocationVisual.class,"LBL_NPW1_DefaultProjectName"); 171 while ((generatedProjectName = validFreeProjectName(projectLocation, formater, generatedProjectNameIndex)) == null) 172 generatedProjectNameIndex++; 173 settings.putProperty (NewWebProjectWizardIterator.PROP_NAME_INDEX, Integer.valueOf(generatedProjectNameIndex)); 174 } 175 moduleLocationTextField.selectAll(); 178 } 179 } 180 181 void store (WizardDescriptor settings) { 182 File srcRoot = null; 183 String srcPath = moduleLocationTextField.getText(); 184 if (srcPath.length() > 0) { 185 srcRoot = FileUtil.normalizeFile(new File (srcPath)); 186 } 187 if (srcRoot != null) 188 FoldersListSettings.getDefault().setLastUsedImportLocation(srcRoot); 189 settings.putProperty (WizardProperties.SOURCE_ROOT, srcRoot); 190 settings.putProperty (WizardProperties.NAME, projectNameTextField.getText().trim()); 191 192 final String projectLocation = projectLocationTextField.getText().trim(); 193 if (projectLocation.length() >= 0) { 194 settings.putProperty (WizardProperties.PROJECT_DIR, new File (projectLocation)); 195 } 196 197 String contextPath = jTextFieldContextPath.getText().trim(); 198 if (!contextPath.startsWith("/")) contextPath = "/" + contextPath; settings.putProperty(WizardProperties.CONTEXT_PATH, contextPath); 201 final Integer nameIndex = projectNameTextField.getText().equals(generatedProjectName) ? 202 Integer.valueOf(generatedProjectNameIndex) : null; 203 settings.putProperty(NewWebProjectWizardIterator.PROP_NAME_INDEX, nameIndex); 204 205 settings.putProperty(WizardProperties.SET_AS_MAIN, setAsMainCheckBox.isSelected() ? Boolean.TRUE : Boolean.FALSE ); 206 settings.putProperty(WizardProperties.SERVER_INSTANCE_ID, getSelectedServer()); 207 settings.putProperty(WizardProperties.J2EE_LEVEL, getSelectedJ2eeSpec()); 208 settings.putProperty(WizardProperties.EAR_APPLICATION, getSelectedEarApplication()); 209 210 if (warningPanel != null && warningPanel.getDowngradeAllowed()) { 211 settings.putProperty(WizardProperties.JAVA_PLATFORM, warningPanel.getSuggestedJavaPlatformName()); 212 213 String j2ee = getSelectedJ2eeSpec(); 214 if (j2ee != null) { 215 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 216 FoldersListSettings fls = FoldersListSettings.getDefault(); 217 String srcLevel = "1.6"; if (warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_14) && fls.isAgreedSetSourceLevel14()) 219 srcLevel = "1.4"; else if (warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_15) && fls.isAgreedSetSourceLevel15()) 221 srcLevel = "1.5"; 223 settings.putProperty(WizardProperties.SOURCE_LEVEL, srcLevel); 224 } 225 } else 226 settings.putProperty(WizardProperties.SOURCE_LEVEL, null); 227 } 228 229 boolean valid (WizardDescriptor settings) { 230 String sourceLocationPath = moduleLocationTextField.getText().trim(); 231 if (sourceLocationPath.length() == 0) { 232 setErrorMessage("MSG_ProvideExistingSourcesLocation"); return false; 234 } 235 File f = new File (sourceLocationPath); 236 if (!f.isDirectory() || !f.canRead()) { 237 String format = NbBundle.getMessage(ImportLocationVisual.class, "MSG_IllegalSources"); wizardDescriptor.putProperty( "WizardPanel_errorMessage", MessageFormat.format(format, new Object [] {sourceLocationPath})); return false; 240 } 241 242 String projectLocationPath = projectLocationTextField.getText().trim(); 243 f = new File (projectLocationPath); 244 String projectName = projectNameTextField.getText().trim(); 245 f = new File (f, projectName); 246 f = PanelProjectLocationVisual.getCanonicalFile(f); 247 if(f == null || !projectName.equals(f.getName())) { 248 settings.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(ImportLocationVisual.class, "MSG_ProvideProjectName")); 249 return false; } 251 252 if(projectLocationPath.length() == 0) { 253 setErrorMessage("MSG_ProvideProjectFolder"); return false; 255 } 256 File projectLocation; 257 if (locationComputed) 258 projectLocation = ProjectChooser.getProjectsFolder(); 259 else 260 projectLocation = new File (projectLocationPath); 261 if (projectLocation.exists() && !projectLocation.canWrite()) { 262 setErrorMessage("MSG_ProjectLocationRO"); return false; 265 } 266 267 File destFolder = FileUtil.normalizeFile(new File (projectLocationPath)); 268 269 if (destFolder.isDirectory()) { 271 FileObject destFO = FileUtil.toFileObject(destFolder); 272 assert destFO != null : "No FileObject for " + destFolder; 273 boolean clear = false; 274 try { 275 clear = ProjectManager.getDefault().findProject(destFO) == null; 276 } catch (IOException e) { 277 } 279 if (!clear) { 280 setErrorMessage("MSG_ProjectFolderHasDeletedProject"); return false; 282 } 283 } 284 285 286 File [] kids = destFolder.listFiles(); 287 if ( destFolder.exists() && kids != null && kids.length > 0) { 288 String file = null; 289 for (int i=0; i< kids.length; i++) { 290 String childName = kids[i].getName(); 291 if ("nbproject".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_NetBeansProject"); 293 } 294 else if ("build".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_BuildFolder"); 296 } 297 else if ("WEB-INF".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_WebInfFolder"); 299 } 300 else if ("dist".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_DistFolder"); 302 } 303 else if ("manifest.mf".equals(childName)) { file = NbBundle.getMessage (ImportLocationVisual.class,"TXT_Manifest"); 305 } 306 if (file != null) { 307 String format = NbBundle.getMessage (ImportLocationVisual.class,"MSG_ProjectFolderInvalid"); 308 wizardDescriptor.putProperty( "WizardPanel_errorMessage", MessageFormat.format(format, new Object [] {file})); return false; 310 } 311 } 312 } 313 314 setErrorMessage(null); 315 return true; 316 } 317 318 private void setErrorMessage(String messageId) { 319 wizardDescriptor.putProperty( "WizardPanel_errorMessage", 320 messageId == null ? null : NbBundle.getMessage(ImportLocationVisual.class, messageId)); 321 } 322 323 324 329 private void initComponents() { 331 java.awt.GridBagConstraints gridBagConstraints; 332 333 jLabelSrcLocationDesc = new javax.swing.JLabel (); 334 jLabelSrcLocation = new javax.swing.JLabel (); 335 moduleLocationTextField = new javax.swing.JTextField (); 336 jButtonSrcLocation = new javax.swing.JButton (); 337 jLabelPrjLocationDesc = new javax.swing.JLabel (); 338 jLabelPrjName = new javax.swing.JLabel (); 339 projectNameTextField = new javax.swing.JTextField (); 340 jLabelPrjLocation = new javax.swing.JLabel (); 341 projectLocationTextField = new javax.swing.JTextField (); 342 jButtonPrjLocation = new javax.swing.JButton (); 343 jSeparator1 = new javax.swing.JSeparator (); 344 jPanelOptions = new javax.swing.JPanel (); 345 jLabelEnterprise = new javax.swing.JLabel (); 346 jComboBoxEnterprise = new javax.swing.JComboBox (); 347 setAsMainCheckBox = new javax.swing.JCheckBox (); 348 jPanel1 = new javax.swing.JPanel (); 349 serverInstanceLabel = new javax.swing.JLabel (); 350 serverInstanceComboBox = new javax.swing.JComboBox (); 351 j2eeSpecLabel = new javax.swing.JLabel (); 352 j2eeSpecComboBox = new javax.swing.JComboBox (); 353 jLabelContextPath = new javax.swing.JLabel (); 354 jTextFieldContextPath = new javax.swing.JTextField (); 355 manageServersButton = new javax.swing.JButton (); 356 warningPlaceHolderPanel = new javax.swing.JPanel (); 357 358 setLayout(new java.awt.GridBagLayout ()); 359 360 org.openide.awt.Mnemonics.setLocalizedText(jLabelSrcLocationDesc, NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationSrcDesc")); gridBagConstraints = new java.awt.GridBagConstraints (); 362 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 363 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 364 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 365 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 366 add(jLabelSrcLocationDesc, gridBagConstraints); 367 368 jLabelSrcLocation.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_ImportLocation_LabelMnemonic").charAt(0)); 369 jLabelSrcLocation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 370 jLabelSrcLocation.setLabelFor(moduleLocationTextField); 371 jLabelSrcLocation.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationSrc_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 373 gridBagConstraints.gridx = 0; 374 gridBagConstraints.gridy = 1; 375 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 376 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 377 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 378 add(jLabelSrcLocation, gridBagConstraints); 379 gridBagConstraints = new java.awt.GridBagConstraints (); 380 gridBagConstraints.gridx = 1; 381 gridBagConstraints.gridy = 1; 382 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 383 gridBagConstraints.weightx = 1.0; 384 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 385 add(moduleLocationTextField, gridBagConstraints); 386 moduleLocationTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_IW_ImportLocation_A11YDesc")); 388 jButtonSrcLocation.setMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_BrowseLocation_MNE").charAt(0)); 389 jButtonSrcLocation.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_BrowseLocation_Button")); jButtonSrcLocation.addActionListener(new java.awt.event.ActionListener () { 391 public void actionPerformed(java.awt.event.ActionEvent evt) { 392 jButtonSrcLocationActionPerformed(evt); 393 } 394 }); 395 gridBagConstraints = new java.awt.GridBagConstraints (); 396 gridBagConstraints.gridx = 2; 397 gridBagConstraints.gridy = 1; 398 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 399 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 400 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 401 add(jButtonSrcLocation, gridBagConstraints); 402 jButtonSrcLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_IW_ImportLocationBrowse_A11YDesc")); 404 org.openide.awt.Mnemonics.setLocalizedText(jLabelPrjLocationDesc, NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_LocationPrjDesc")); gridBagConstraints = new java.awt.GridBagConstraints (); 406 gridBagConstraints.gridx = 0; 407 gridBagConstraints.gridy = 2; 408 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 409 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 410 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 411 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 412 add(jLabelPrjLocationDesc, gridBagConstraints); 413 414 jLabelPrjName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ProjectName_LabelMnemonic").charAt(0)); 415 jLabelPrjName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 416 jLabelPrjName.setLabelFor(projectNameTextField); 417 jLabelPrjName.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ProjectName_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 419 gridBagConstraints.gridx = 0; 420 gridBagConstraints.gridy = 3; 421 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 422 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 423 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 424 add(jLabelPrjName, gridBagConstraints); 425 gridBagConstraints = new java.awt.GridBagConstraints (); 426 gridBagConstraints.gridx = 1; 427 gridBagConstraints.gridy = 3; 428 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 429 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 430 add(projectNameTextField, gridBagConstraints); 431 projectNameTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_ProjectName_A11YDesc")); 433 jLabelPrjLocation.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ProjectLocation_LabelMnemonic").charAt(0)); 434 jLabelPrjLocation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); 435 jLabelPrjLocation.setLabelFor(projectLocationTextField); 436 jLabelPrjLocation.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_CreatedProjectFolder_Lablel")); gridBagConstraints = new java.awt.GridBagConstraints (); 438 gridBagConstraints.gridx = 0; 439 gridBagConstraints.gridy = 4; 440 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 441 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 442 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 443 add(jLabelPrjLocation, gridBagConstraints); 444 445 projectLocationTextField.addKeyListener(new java.awt.event.KeyAdapter () { 446 public void keyReleased(java.awt.event.KeyEvent evt) { 447 projectLocationTextFieldKeyReleased(evt); 448 } 449 }); 450 gridBagConstraints = new java.awt.GridBagConstraints (); 451 gridBagConstraints.gridx = 1; 452 gridBagConstraints.gridy = 4; 453 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 454 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 455 add(projectLocationTextField, gridBagConstraints); 456 projectLocationTextField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NPW1_ProjectLocation_A11YDesc")); 458 jButtonPrjLocation.setMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_BrowseProjectFolder_MNE").charAt(0)); 459 jButtonPrjLocation.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BrowseProjectLocation_Button")); jButtonPrjLocation.addActionListener(new java.awt.event.ActionListener () { 461 public void actionPerformed(java.awt.event.ActionEvent evt) { 462 jButtonPrjLocationActionPerformed(evt); 463 } 464 }); 465 gridBagConstraints = new java.awt.GridBagConstraints (); 466 gridBagConstraints.gridx = 2; 467 gridBagConstraints.gridy = 4; 468 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 469 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 470 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 471 add(jButtonPrjLocation, gridBagConstraints); 472 jButtonPrjLocation.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_BrowseLocation_A11YDesc")); 474 gridBagConstraints = new java.awt.GridBagConstraints (); 475 gridBagConstraints.gridx = 0; 476 gridBagConstraints.gridy = 5; 477 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 478 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 479 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 480 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 481 add(jSeparator1, gridBagConstraints); 482 483 jPanelOptions.setLayout(new java.awt.GridBagLayout ()); 484 485 jLabelEnterprise.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_AddToEnterprise_LabelMnemonic").charAt(0)); 486 jLabelEnterprise.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_AddToEnterprise_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 488 gridBagConstraints.gridx = 0; 489 gridBagConstraints.gridy = 0; 490 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 491 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 492 jPanelOptions.add(jLabelEnterprise, gridBagConstraints); 493 gridBagConstraints = new java.awt.GridBagConstraints (); 494 gridBagConstraints.gridx = 1; 495 gridBagConstraints.gridy = 0; 496 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 497 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 498 gridBagConstraints.weightx = 1.0; 499 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 500 jPanelOptions.add(jComboBoxEnterprise, gridBagConstraints); 501 jComboBoxEnterprise.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_AddToEnterpriseComboBox_A11YDesc")); 503 setAsMainCheckBox.setMnemonic(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_SetAsMain_CheckBoxMnemonic").charAt(0)); 504 setAsMainCheckBox.setSelected(true); 505 setAsMainCheckBox.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_SetAsMain_CheckBox")); setAsMainCheckBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 507 gridBagConstraints = new java.awt.GridBagConstraints (); 508 gridBagConstraints.gridx = 0; 509 gridBagConstraints.gridy = 3; 510 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 511 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 512 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 513 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 514 gridBagConstraints.weightx = 1.0; 515 gridBagConstraints.weighty = 1.0; 516 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 517 jPanelOptions.add(setAsMainCheckBox, gridBagConstraints); 518 setAsMainCheckBox.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_SetAsMain_A11YDesc")); 520 jPanel1.setLayout(new java.awt.GridBagLayout ()); 521 522 serverInstanceLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_Server_LabelMnemonic").charAt(0)); 523 serverInstanceLabel.setLabelFor(serverInstanceComboBox); 524 serverInstanceLabel.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_Server")); gridBagConstraints = new java.awt.GridBagConstraints (); 526 gridBagConstraints.gridx = 0; 527 gridBagConstraints.gridy = 0; 528 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 529 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 530 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 531 jPanel1.add(serverInstanceLabel, gridBagConstraints); 532 533 serverInstanceComboBox.setModel(serversModel); 534 serverInstanceComboBox.addActionListener(new java.awt.event.ActionListener () { 535 public void actionPerformed(java.awt.event.ActionEvent evt) { 536 serverInstanceComboBoxActionPerformed(evt); 537 } 538 }); 539 gridBagConstraints = new java.awt.GridBagConstraints (); 540 gridBagConstraints.gridx = 1; 541 gridBagConstraints.gridy = 0; 542 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 543 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 544 gridBagConstraints.weightx = 1.0; 545 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 546 jPanel1.add(serverInstanceComboBox, gridBagConstraints); 547 serverInstanceComboBox.getAccessibleContext().setAccessibleName("Server"); 548 serverInstanceComboBox.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_NWP1_Server_ComboBox_A11YDesc")); 550 j2eeSpecLabel.setDisplayedMnemonic(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_J2EESpecLevel_CheckBoxMnemonic").charAt(0)); 551 j2eeSpecLabel.setLabelFor(j2eeSpecComboBox); 552 j2eeSpecLabel.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_J2EESpecLevel_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 554 gridBagConstraints.gridx = 0; 555 gridBagConstraints.gridy = 1; 556 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 557 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 558 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 559 jPanel1.add(j2eeSpecLabel, gridBagConstraints); 560 561 j2eeSpecComboBox.setPrototypeDisplayValue("MMMMMMMMM" ); 562 j2eeSpecComboBox.addActionListener(new java.awt.event.ActionListener () { 563 public void actionPerformed(java.awt.event.ActionEvent evt) { 564 j2eeSpecComboBoxActionPerformed(evt); 565 } 566 }); 567 gridBagConstraints = new java.awt.GridBagConstraints (); 568 gridBagConstraints.gridx = 1; 569 gridBagConstraints.gridy = 1; 570 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 571 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 572 jPanel1.add(j2eeSpecComboBox, gridBagConstraints); 573 j2eeSpecComboBox.getAccessibleContext().setAccessibleName("J2EE Version"); 574 j2eeSpecComboBox.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NPW1_J2EESpecLevel_A11YDesc")); 576 jLabelContextPath.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ContextPath_CheckBoxMnemonic").charAt(0)); 577 jLabelContextPath.setLabelFor(jTextFieldContextPath); 578 jLabelContextPath.setText(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_ContextPath_Label")); gridBagConstraints = new java.awt.GridBagConstraints (); 580 gridBagConstraints.gridx = 0; 581 gridBagConstraints.gridy = 2; 582 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 583 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 584 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 585 jPanel1.add(jLabelContextPath, gridBagConstraints); 586 587 jTextFieldContextPath.addKeyListener(new java.awt.event.KeyAdapter () { 588 public void keyReleased(java.awt.event.KeyEvent evt) { 589 jTextFieldContextPathKeyReleased(evt); 590 } 591 }); 592 gridBagConstraints = new java.awt.GridBagConstraints (); 593 gridBagConstraints.gridx = 1; 594 gridBagConstraints.gridy = 2; 595 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 596 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 597 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 598 gridBagConstraints.weightx = 1.0; 599 gridBagConstraints.weighty = 1.0; 600 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 601 jPanel1.add(jTextFieldContextPath, gridBagConstraints); 602 jTextFieldContextPath.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "ACS_LBL_NWP1_ContextPath_A11YDesc")); 604 org.openide.awt.Mnemonics.setLocalizedText(manageServersButton, org.openide.util.NbBundle.getMessage(ImportLocationVisual.class, "LBL_ManageServers")); manageServersButton.addActionListener(new java.awt.event.ActionListener () { 606 public void actionPerformed(java.awt.event.ActionEvent evt) { 607 manageServersButtonActionPerformed(evt); 608 } 609 }); 610 gridBagConstraints = new java.awt.GridBagConstraints (); 611 gridBagConstraints.gridx = 2; 612 gridBagConstraints.gridy = 0; 613 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 614 gridBagConstraints.insets = new java.awt.Insets (0, 6, 5, 0); 615 jPanel1.add(manageServersButton, gridBagConstraints); 616 manageServersButton.getAccessibleContext().setAccessibleName(null); 617 manageServersButton.getAccessibleContext().setAccessibleDescription(null); 618 619 gridBagConstraints = new java.awt.GridBagConstraints (); 620 gridBagConstraints.gridx = 0; 621 gridBagConstraints.gridy = 1; 622 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 623 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 624 jPanelOptions.add(jPanel1, gridBagConstraints); 625 626 warningPlaceHolderPanel.setLayout(new java.awt.BorderLayout ()); 627 gridBagConstraints = new java.awt.GridBagConstraints (); 628 gridBagConstraints.gridx = 0; 629 gridBagConstraints.gridy = 2; 630 gridBagConstraints.gridwidth = 2; 631 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 632 gridBagConstraints.weightx = 1.0; 633 jPanelOptions.add(warningPlaceHolderPanel, gridBagConstraints); 634 635 gridBagConstraints = new java.awt.GridBagConstraints (); 636 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 637 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 638 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 639 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 640 gridBagConstraints.weightx = 1.0; 641 gridBagConstraints.weighty = 1.0; 642 add(jPanelOptions, gridBagConstraints); 643 } 645 private void j2eeSpecComboBoxActionPerformed(java.awt.event.ActionEvent evt) { setJ2eeVersionWarningPanel(); 647 } 649 private void manageServersButtonActionPerformed(java.awt.event.ActionEvent evt) { ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 651 String lastSelectedServerInstanceID = null; 652 if (serverInstanceWrapper != null) { 653 lastSelectedServerInstanceID = serverInstanceWrapper.getServerInstanceID(); 654 } 655 ServerManager.showCustomizer(lastSelectedServerInstanceID); 656 String lastSelectedJ2eeSpecLevel = (String ) j2eeSpecComboBox.getSelectedItem(); 657 initServers(lastSelectedServerInstanceID); 659 if (lastSelectedJ2eeSpecLevel != null) { 660 j2eeSpecComboBox.setSelectedItem(lastSelectedJ2eeSpecLevel); 661 } 662 } 664 private void serverInstanceComboBoxActionPerformed(java.awt.event.ActionEvent evt) { String prevSelectedItem = (String ) j2eeSpecComboBox.getSelectedItem(); 666 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 668 if (serverInstanceWrapper != null) { 669 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceWrapper.getServerInstanceID()); 670 Set supportedVersions = j2eePlatform.getSupportedSpecVersions(J2eeModule.WAR); 671 j2eeSpecComboBox.removeAllItems(); 672 if (supportedVersions.contains(J2eeModule.JAVA_EE_5)) { 673 j2eeSpecComboBox.addItem(JAVA_EE_5_LABEL); 674 } 675 if (supportedVersions.contains(J2eeModule.J2EE_14)) { 676 j2eeSpecComboBox.addItem(J2EE_SPEC_14_LABEL); 677 } 678 if (supportedVersions.contains(J2eeModule.J2EE_13)) { 679 j2eeSpecComboBox.addItem(J2EE_SPEC_13_LABEL); 680 } 681 if (prevSelectedItem != null) { 682 j2eeSpecComboBox.setSelectedItem(prevSelectedItem); 683 } 684 } else { 685 j2eeSpecComboBox.removeAllItems(); 686 } 687 panel.fireChangeEvent(); 689 } 691 private void projectLocationTextFieldKeyReleased(java.awt.event.KeyEvent evt) { locationModified = true; 693 } 695 private void jTextFieldContextPathKeyReleased(java.awt.event.KeyEvent evt) { contextModified = true; 697 } 699 private void jButtonPrjLocationActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = org.netbeans.modules.web.project.ui.FileChooser.createDirectoryChooser( 701 "ImportLocationVisual.Project", projectLocationTextField.getText()); chooser.setDialogTitle(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BrowseProjectFolder")); 703 if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 704 File projectDir = chooser.getSelectedFile(); 705 projectLocationTextField.setText( projectDir.getAbsolutePath()); 706 } 707 } 709 private void jButtonSrcLocationActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); 711 FileUtil.preventFileChooserSymlinkTraversal(chooser, null); 712 chooser.setFileSelectionMode (JFileChooser.DIRECTORIES_ONLY); 713 chooser.setDialogTitle(NbBundle.getMessage(ImportLocationVisual.class, "LBL_IW_BrowseExistingSource")); 714 715 if (moduleLocationTextField.getText().length() > 0 && getProjectLocation().exists()) { 716 chooser.setSelectedFile(getProjectLocation()); 717 } else { 718 File currentDirectory = null; 720 FileObject existingSourcesFO = Templates.getExistingSourcesFolder(wizardDescriptor); 721 if (existingSourcesFO != null) { 722 File existingSourcesFile = FileUtil.toFile(existingSourcesFO); 723 if (existingSourcesFile != null && existingSourcesFile.isDirectory()) { 724 currentDirectory = existingSourcesFile; 725 } 726 } 727 if (currentDirectory != null) { 728 chooser.setCurrentDirectory(currentDirectory); 729 } else { 730 File lastUsedImportLoc = (File ) FoldersListSettings.getDefault().getLastUsedImportLocation(); 731 if (lastUsedImportLoc != null) 732 chooser.setCurrentDirectory(lastUsedImportLoc.getParentFile()); 733 else 734 chooser.setSelectedFile(ProjectChooser.getProjectsFolder()); 735 } 736 } 737 738 if ( JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { 739 File projectDir = FileUtil.normalizeFile(chooser.getSelectedFile()); 740 moduleLocationTextField.setText(projectDir.getAbsolutePath()); 741 } 742 } 744 private javax.swing.JComboBox j2eeSpecComboBox; 746 private javax.swing.JLabel j2eeSpecLabel; 747 private javax.swing.JButton jButtonPrjLocation; 748 private javax.swing.JButton jButtonSrcLocation; 749 private javax.swing.JComboBox jComboBoxEnterprise; 750 private javax.swing.JLabel jLabelContextPath; 751 private javax.swing.JLabel jLabelEnterprise; 752 private javax.swing.JLabel jLabelPrjLocation; 753 private javax.swing.JLabel jLabelPrjLocationDesc; 754 private javax.swing.JLabel jLabelPrjName; 755 private javax.swing.JLabel jLabelSrcLocation; 756 private javax.swing.JLabel jLabelSrcLocationDesc; 757 private javax.swing.JPanel jPanel1; 758 private javax.swing.JPanel jPanelOptions; 759 private javax.swing.JSeparator jSeparator1; 760 protected javax.swing.JTextField jTextFieldContextPath; 761 private javax.swing.JButton manageServersButton; 762 public javax.swing.JTextField moduleLocationTextField; 763 public javax.swing.JTextField projectLocationTextField; 764 public javax.swing.JTextField projectNameTextField; 765 private javax.swing.JComboBox serverInstanceComboBox; 766 private javax.swing.JLabel serverInstanceLabel; 767 private javax.swing.JCheckBox setAsMainCheckBox; 768 private javax.swing.JPanel warningPlaceHolderPanel; 769 771 private String lastComputedPrjName = null; 772 private String computeProjectName() { 773 String cPrjName = null; 774 FileObject fo = FileUtil.toFileObject(getProjectLocation()); 775 if (fo != null) { 776 cPrjName = fo.getName(); 777 } 778 return cPrjName; 779 } 780 781 private String lastComputedPrjFolder = null; 782 private String computeProjectFolder() { 783 return getProjectLocation().getAbsolutePath(); 784 } 785 786 private String lastComputedContextPath = null; 787 private String computeContextPath() { 788 return Utils.createDefaultContext(projectNameTextField.getText()); 789 } 790 791 boolean ignoreLocEvent = false; 792 private void locationDataChanged(DocumentEvent de) { 794 if (!ignoreLocEvent) { 795 ignoreLocEvent = true; 796 if (de.getDocument() == moduleDocument) { 797 updateProjectName(); 798 updateProjectFolder(); 799 } 800 ignoreLocEvent = false; 801 } 802 fireChanges(); 803 } 804 805 boolean ignoreNameEvent = false; 806 private void nameDataChanged(DocumentEvent de) { 808 if (!ignoreNameEvent) { 809 ignoreNameEvent = true; 810 if (de.getDocument() == nameDocument) { 811 updateProjectFolder(); 812 updateContextPath(); 813 } 814 ignoreNameEvent = false; 815 } 816 fireChanges(); 817 } 818 819 private void updateProjectName() { 820 String prjName = computeProjectName(); 821 if ((lastComputedPrjName != null) && (!lastComputedPrjName.equals(projectNameTextField.getText().trim()))) { 822 return; 823 } 824 lastComputedPrjName = prjName; 825 if (prjName != null) { 826 projectNameTextField.setText(prjName); 827 } 828 } 829 830 private void updateProjectFolder() { 831 String prjFolder = computeProjectFolder(); 832 if ((lastComputedPrjFolder != null) && (!lastComputedPrjFolder.equals(projectLocationTextField.getText().trim()))) { 833 return; 834 } 835 lastComputedPrjFolder = prjFolder; 836 if (prjFolder != null) { 837 projectLocationTextField.setText(prjFolder); 838 } else { 839 projectLocationTextField.setText(""); } 841 } 842 843 private void updateContextPath() { 844 String ctxPath = computeContextPath(); 845 if ((lastComputedContextPath != null) && (!lastComputedContextPath.equals(jTextFieldContextPath.getText().trim()))) { 846 return; 847 } 848 lastComputedContextPath = ctxPath; 849 if (ctxPath != null) { 850 jTextFieldContextPath.setText(ctxPath); 851 } 852 } 853 854 private void fireChanges() { 855 panel.fireChangeEvent(); 856 } 857 858 861 public HelpCtx getHelpCtx() { 862 return new HelpCtx(ImportLocationVisual.class); 863 } 864 865 869 private void initServers(String selectedServerInstanceID) { 870 serversModel.removeAllElements(); 872 Set <ServerInstanceWrapper> servers = new TreeSet <ServerInstanceWrapper>(); 873 ServerInstanceWrapper selectedItem = null; 874 boolean sjasFound = false; 875 for (String serverInstanceID : Deployment.getDefault().getServerInstanceIDs()) { 876 String displayName = Deployment.getDefault().getServerInstanceDisplayName(serverInstanceID); 877 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceID); 878 if (displayName != null && j2eePlatform != null && j2eePlatform.getSupportedModuleTypes().contains(J2eeModule.WAR)) { 879 ServerInstanceWrapper serverWrapper = new ServerInstanceWrapper(serverInstanceID, displayName); 880 if (selectedItem == null || !sjasFound) { 882 if (selectedServerInstanceID != null) { 883 if (selectedServerInstanceID.equals(serverInstanceID)) { 884 selectedItem = serverWrapper; 885 } 886 } else { 887 String shortName = Deployment.getDefault().getServerID(serverInstanceID); 889 if ("J2EE".equals(shortName)) { selectedItem = serverWrapper; 891 sjasFound = true; 892 } 893 else 894 if ("JBoss4".equals(shortName)) { selectedItem = serverWrapper; 896 } 897 } 898 } 899 servers.add(serverWrapper); 900 } 901 } 902 for (ServerInstanceWrapper item : servers) { 903 serversModel.addElement(item); 904 } 905 if (selectedItem != null) { 906 serversModel.setSelectedItem(selectedItem); 908 } else if (serversModel.getSize() > 0) { 909 serversModel.setSelectedItem(serversModel.getElementAt(0)); 911 } 912 } 913 914 private Project getSelectedEarApplication() { 915 int idx = jComboBoxEnterprise.getSelectedIndex(); 916 return (idx <= 0) ? null : (Project) earProjects.get(idx - 1); 917 } 918 919 private void initEnterpriseApplications() { 920 jComboBoxEnterprise.addItem(NbBundle.getMessage(ImportLocationVisual.class, "LBL_NWP1_AddToEnterprise_None")); 921 jComboBoxEnterprise.setSelectedIndex(0); 922 923 Project[] allProjects = OpenProjects.getDefault().getOpenProjects(); 924 earProjects = new ArrayList (); 925 for (int i = 0; i < allProjects.length; i++) { 926 J2eeModuleContainer container = (J2eeModuleContainer) allProjects[i].getLookup().lookup(J2eeModuleContainer.class); 927 ProjectInformation projectInfo = ProjectUtils.getInformation(allProjects[i]); 928 if (container != null) { 929 earProjects.add(projectInfo.getProject()); 930 jComboBoxEnterprise.addItem(projectInfo.getDisplayName()); 931 } 932 } 933 if (earProjects.size() <= 0) { 934 jComboBoxEnterprise.setEnabled(false); 935 } 936 } 937 938 private String getSelectedJ2eeSpec() { 939 Object item = j2eeSpecComboBox.getSelectedItem(); 940 String value = null; 941 if (item != null){ 942 if (item.equals(JAVA_EE_5_LABEL)) value = J2eeModule.JAVA_EE_5; 943 else if (item.equals(J2EE_SPEC_14_LABEL)) value = J2eeModule.J2EE_14; 944 else if (item.equals(J2EE_SPEC_13_LABEL)) value = J2eeModule.J2EE_13; 945 } 946 return value; 947 } 948 949 private String getSelectedServer() { 950 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 951 if (serverInstanceWrapper == null) { 952 return null; 953 } 954 return serverInstanceWrapper.getServerInstanceID(); 955 } 956 957 private String validFreeProjectName (final File parentFolder, final String formater, final int index) { 958 String name = MessageFormat.format (formater, new Object []{Integer.valueOf(index)}); 959 File file = new File (parentFolder, name); 960 return file.exists() ? null : name; 961 } 962 963 private void setJ2eeVersionWarningPanel() { 964 String j2ee = getSelectedJ2eeSpec(); 965 if (j2ee == null) 966 return; 967 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 968 if (warningType == null && warningPanel == null) 969 return; 970 if (warningPanel == null) { 971 warningPanel = new J2eeVersionWarningPanel(warningType); 972 warningPlaceHolderPanel.add(warningPanel, java.awt.BorderLayout.CENTER); 973 warningPanel.setWarningType(warningType); 974 } else { 975 warningPanel.setWarningType(warningType); 976 } 977 } 978 979 public File getProjectLocation() { 980 return getAsFile(moduleLocationTextField.getText()); 981 } 982 983 private File getAsFile(String filename) { 984 return FileUtil.normalizeFile(new File (filename)); 985 } 986 987 991 private static class ServerInstanceWrapper implements Comparable { 992 993 private final String serverInstanceID; 994 private final String displayName; 995 996 ServerInstanceWrapper(String serverInstanceID, String displayName) { 997 this.serverInstanceID = serverInstanceID; 998 this.displayName = displayName; 999 } 1000 1001 public String getServerInstanceID() { 1002 return serverInstanceID; 1003 } 1004 1005 public String toString() { 1006 return displayName; 1007 } 1008 1009 public int compareTo(Object o) { 1010 return toString().compareTo(o.toString()); 1011 } 1012 } 1013} 1014 | Popular Tags |