1 19 20 package org.netbeans.modules.web.project.ui.wizards; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import java.util.Set ; 25 import java.util.TreeSet ; 26 import javax.swing.DefaultComboBoxModel ; 27 import org.netbeans.api.project.Project; 28 import org.netbeans.api.project.ProjectInformation; 29 import org.netbeans.api.project.ProjectUtils; 30 import org.netbeans.api.project.ui.OpenProjects; 31 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 32 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 33 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModuleContainer; 34 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 35 import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerManager; 36 import org.netbeans.modules.web.project.api.WebProjectUtilities; 37 import org.netbeans.modules.web.project.ui.FoldersListSettings; 38 import org.openide.WizardDescriptor; 39 import org.openide.util.NbBundle; 40 41 public class PanelOptionsVisual extends javax.swing.JPanel { 42 43 private PanelConfigureProject panel; 44 private String sourceStructure; 45 private boolean contextModified = false; 46 private final DefaultComboBoxModel serversModel = new DefaultComboBoxModel (); 47 48 private J2eeVersionWarningPanel warningPanel; 49 50 private static final String J2EE_SPEC_13_LABEL = NbBundle.getMessage(PanelOptionsVisual.class, "J2EESpecLevel_13"); private static final String J2EE_SPEC_14_LABEL = NbBundle.getMessage(PanelOptionsVisual.class, "J2EESpecLevel_14"); private static final String JAVA_EE_SPEC_50_LABEL = NbBundle.getMessage(PanelOptionsVisual.class, "JavaEESpecLevel_50"); 54 private List earProjects; 55 56 57 public PanelOptionsVisual(PanelConfigureProject panel) { 58 initComponents(); 59 setJ2eeVersionWarningPanel(); 60 this.panel = panel; 61 initServers(FoldersListSettings.getDefault().getLastUsedServer()); 62 if (j2eeSpecComboBox.getModel().getSize() > 0) { 64 j2eeSpecComboBox.setSelectedIndex(0); 65 } 66 initJSrcStructureSpecs(); 67 initEnterpriseApplications(); 68 } 69 70 protected int computeHeight() { 71 return srcStructComboBox.getFontMetrics(srcStructComboBox.getFont()).getHeight() * 9 + 100; 72 } 73 74 79 private void initComponents() { 81 java.awt.GridBagConstraints gridBagConstraints; 82 83 srcStructLabel = new javax.swing.JLabel (); 84 srcStructComboBox = new javax.swing.JComboBox (); 85 jLabelEnterprise = new javax.swing.JLabel (); 86 jComboBoxEnterprise = new javax.swing.JComboBox (); 87 jPanel1 = new javax.swing.JPanel (); 88 serverInstanceLabel = new javax.swing.JLabel (); 89 serverInstanceComboBox = new javax.swing.JComboBox (); 90 j2eeSpecLabel = new javax.swing.JLabel (); 91 j2eeSpecComboBox = new javax.swing.JComboBox (); 92 jLabelContextPath = new javax.swing.JLabel (); 93 jTextFieldContextPath = new javax.swing.JTextField (); 94 manageServersButton = new javax.swing.JButton (); 95 warningPlaceHolderPanel = new javax.swing.JPanel (); 96 setAsMainCheckBox = new javax.swing.JCheckBox (); 97 98 setLayout(new java.awt.GridBagLayout ()); 99 100 srcStructLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_SourceStructure_CheckBoxMnemonic").charAt(0)); 101 srcStructLabel.setLabelFor(srcStructComboBox); 102 srcStructLabel.setText(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_SourceStructure_Label")); 103 gridBagConstraints = new java.awt.GridBagConstraints (); 104 gridBagConstraints.gridx = 0; 105 gridBagConstraints.gridy = 0; 106 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 107 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 108 add(srcStructLabel, gridBagConstraints); 109 srcStructLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NWP1_SourceStructureComboBox_A11YDesc")); 110 111 srcStructComboBox.setPrototypeDisplayValue("MMMMMMMMMMMMMMM" ); 112 srcStructComboBox.addActionListener(new java.awt.event.ActionListener () { 113 public void actionPerformed(java.awt.event.ActionEvent evt) { 114 srcStructComboBoxActionPerformed(evt); 115 } 116 }); 117 118 gridBagConstraints = new java.awt.GridBagConstraints (); 119 gridBagConstraints.gridx = 1; 120 gridBagConstraints.gridy = 0; 121 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 122 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 123 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 124 add(srcStructComboBox, gridBagConstraints); 125 126 jLabelEnterprise.setDisplayedMnemonic(org.openide.util.NbBundle.getBundle(PanelOptionsVisual.class).getString("LBL_NWP1_AddToEnterprise_LabelMnemonic").charAt(0)); 127 jLabelEnterprise.setLabelFor(jComboBoxEnterprise); 128 jLabelEnterprise.setText(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_AddToEnterprise_Label")); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.gridx = 0; 131 gridBagConstraints.gridy = 1; 132 gridBagConstraints.gridwidth = 2; 133 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 134 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 135 add(jLabelEnterprise, gridBagConstraints); 136 jLabelEnterprise.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NWP1_AddToEnterpriseComboBox_A11YDesc")); 137 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.gridx = 2; 140 gridBagConstraints.gridy = 1; 141 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 142 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 143 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 144 add(jComboBoxEnterprise, gridBagConstraints); 145 jComboBoxEnterprise.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NWP1_AddToEnterpriseComboBox_A11YDesc")); 146 147 jPanel1.setLayout(new java.awt.GridBagLayout ()); 148 149 serverInstanceLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_Server_LabelMnemonic").charAt(0)); 150 serverInstanceLabel.setLabelFor(serverInstanceComboBox); 151 serverInstanceLabel.setText(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_Server")); 152 gridBagConstraints = new java.awt.GridBagConstraints (); 153 gridBagConstraints.gridx = 0; 154 gridBagConstraints.gridy = 0; 155 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 156 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 157 jPanel1.add(serverInstanceLabel, gridBagConstraints); 158 159 serverInstanceComboBox.setModel(serversModel); 160 serverInstanceComboBox.addActionListener(new java.awt.event.ActionListener () { 161 public void actionPerformed(java.awt.event.ActionEvent evt) { 162 serverInstanceComboBoxActionPerformed(evt); 163 } 164 }); 165 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridx = 1; 168 gridBagConstraints.gridy = 0; 169 gridBagConstraints.gridwidth = 2; 170 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 172 gridBagConstraints.weightx = 1.0; 173 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 6); 174 jPanel1.add(serverInstanceComboBox, gridBagConstraints); 175 serverInstanceComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACS_NWP1_Server_ComboBox_A11YDesc")); 176 177 j2eeSpecLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_J2EESpecLevel_CheckBoxMnemonic").charAt(0)); 178 j2eeSpecLabel.setLabelFor(j2eeSpecComboBox); 179 j2eeSpecLabel.setText(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_J2EESpecLevel_Label")); 180 gridBagConstraints = new java.awt.GridBagConstraints (); 181 gridBagConstraints.gridx = 0; 182 gridBagConstraints.gridy = 1; 183 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 184 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 11); 185 jPanel1.add(j2eeSpecLabel, gridBagConstraints); 186 187 j2eeSpecComboBox.setPrototypeDisplayValue("MMMMMMMMM" ); 188 j2eeSpecComboBox.addActionListener(new java.awt.event.ActionListener () { 189 public void actionPerformed(java.awt.event.ActionEvent evt) { 190 j2eeSpecComboBoxActionPerformed(evt); 191 } 192 }); 193 194 gridBagConstraints = new java.awt.GridBagConstraints (); 195 gridBagConstraints.gridx = 1; 196 gridBagConstraints.gridy = 1; 197 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 198 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 199 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 200 jPanel1.add(j2eeSpecComboBox, gridBagConstraints); 201 j2eeSpecComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NPW1_J2EESpecLevel_A11YDesc")); 202 203 jLabelContextPath.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_ContextPath_CheckBoxMnemonic").charAt(0)); 204 jLabelContextPath.setLabelFor(jTextFieldContextPath); 205 jLabelContextPath.setText(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_ContextPath_Label")); 206 gridBagConstraints = new java.awt.GridBagConstraints (); 207 gridBagConstraints.gridx = 0; 208 gridBagConstraints.gridy = 2; 209 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 210 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 211 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 11); 212 jPanel1.add(jLabelContextPath, gridBagConstraints); 213 214 jTextFieldContextPath.addKeyListener(new java.awt.event.KeyAdapter () { 215 public void keyReleased(java.awt.event.KeyEvent evt) { 216 jTextFieldContextPathKeyReleased(evt); 217 } 218 }); 219 220 gridBagConstraints = new java.awt.GridBagConstraints (); 221 gridBagConstraints.gridx = 1; 222 gridBagConstraints.gridy = 2; 223 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 224 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 225 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 226 jPanel1.add(jTextFieldContextPath, gridBagConstraints); 227 jTextFieldContextPath.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NWP1_ContextPath_A11YDesc")); 228 229 org.openide.awt.Mnemonics.setLocalizedText(manageServersButton, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_ManageServers")); 230 manageServersButton.addActionListener(new java.awt.event.ActionListener () { 231 public void actionPerformed(java.awt.event.ActionEvent evt) { 232 manageServersButtonActionPerformed(evt); 233 } 234 }); 235 236 gridBagConstraints = new java.awt.GridBagConstraints (); 237 gridBagConstraints.gridx = 3; 238 gridBagConstraints.gridy = 0; 239 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 240 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 241 jPanel1.add(manageServersButton, gridBagConstraints); 242 manageServersButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ASCN_ManageServers")); 243 manageServersButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ASCD_ManageServers")); 244 245 gridBagConstraints = new java.awt.GridBagConstraints (); 246 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 247 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 248 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 249 add(jPanel1, gridBagConstraints); 250 251 warningPlaceHolderPanel.setLayout(new java.awt.BorderLayout ()); 252 253 gridBagConstraints = new java.awt.GridBagConstraints (); 254 gridBagConstraints.gridx = 0; 255 gridBagConstraints.gridy = 3; 256 gridBagConstraints.gridwidth = 3; 257 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 258 gridBagConstraints.weightx = 1.0; 259 add(warningPlaceHolderPanel, gridBagConstraints); 260 261 setAsMainCheckBox.setMnemonic(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_SetAsMain_CheckBoxMnemonic").charAt(0)); 262 setAsMainCheckBox.setSelected(true); 263 setAsMainCheckBox.setText(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_SetAsMain_CheckBox")); 264 setAsMainCheckBox.setMargin(new java.awt.Insets (0, 0, 0, 0)); 265 gridBagConstraints = new java.awt.GridBagConstraints (); 266 gridBagConstraints.gridx = 0; 267 gridBagConstraints.gridy = 4; 268 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 269 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 270 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 271 gridBagConstraints.weightx = 1.0; 272 gridBagConstraints.weighty = 1.0; 273 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 274 add(setAsMainCheckBox, gridBagConstraints); 275 setAsMainCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACS_LBL_NWP1_SetAsMain_A11YDesc")); 276 277 } 279 private void manageServersButtonActionPerformed(java.awt.event.ActionEvent evt) { ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 281 String lastSelectedServerInstanceID = null; 282 if (serverInstanceWrapper != null) { 283 lastSelectedServerInstanceID = serverInstanceWrapper.getServerInstanceID(); 284 } 285 ServerManager.showCustomizer(lastSelectedServerInstanceID); 286 String lastSelectedJ2eeSpecLevel = (String ) j2eeSpecComboBox.getSelectedItem(); 287 initServers(lastSelectedServerInstanceID); 289 if (lastSelectedJ2eeSpecLevel != null) { 290 j2eeSpecComboBox.setSelectedItem(lastSelectedJ2eeSpecLevel); 291 } 292 } 294 private void j2eeSpecComboBoxActionPerformed(java.awt.event.ActionEvent evt) { setJ2eeVersionWarningPanel(); 296 } 298 private void serverInstanceComboBoxActionPerformed(java.awt.event.ActionEvent evt) { String prevSelectedItem = (String ) j2eeSpecComboBox.getSelectedItem(); 300 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 302 if (serverInstanceWrapper != null) { 303 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceWrapper.getServerInstanceID()); 304 Set supportedVersions = j2eePlatform.getSupportedSpecVersions(J2eeModule.WAR); 305 j2eeSpecComboBox.removeAllItems(); 306 if (supportedVersions.contains(J2eeModule.JAVA_EE_5)) { 307 j2eeSpecComboBox.addItem(JAVA_EE_SPEC_50_LABEL); 308 } 309 if (supportedVersions.contains(J2eeModule.J2EE_14)) { 310 j2eeSpecComboBox.addItem(J2EE_SPEC_14_LABEL); 311 } 312 if (supportedVersions.contains(J2eeModule.J2EE_13)) { 313 j2eeSpecComboBox.addItem(J2EE_SPEC_13_LABEL); 314 } 315 if (prevSelectedItem != null) { 316 j2eeSpecComboBox.setSelectedItem(prevSelectedItem); 317 } 318 } else { 319 j2eeSpecComboBox.removeAllItems(); 320 } 321 panel.fireChangeEvent(); 323 } 325 private void srcStructComboBoxActionPerformed(java.awt.event.ActionEvent evt) { switch (srcStructComboBox.getSelectedIndex()) { 327 case 0: sourceStructure = WebProjectUtilities.SRC_STRUCT_BLUEPRINTS; 328 break; 329 case 1: sourceStructure = WebProjectUtilities.SRC_STRUCT_JAKARTA; 330 } 331 } 333 private void jTextFieldContextPathKeyReleased(java.awt.event.KeyEvent evt) { contextModified = true; 335 } 337 boolean valid(WizardDescriptor wizardDescriptor) { 338 if (getSelectedServer() == null) { 339 String errMsg = NbBundle.getMessage(PanelOptionsVisual.class, "MSG_NoServer"); 340 wizardDescriptor.putProperty( "WizardPanel_errorMessage", errMsg); return false; 342 } 343 return true; 344 } 345 346 void store(WizardDescriptor d) { 347 d.putProperty(WizardProperties.SET_AS_MAIN, setAsMainCheckBox.isSelected() ? Boolean.TRUE : Boolean.FALSE ); 348 d.putProperty(WizardProperties.SERVER_INSTANCE_ID, getSelectedServer()); 349 d.putProperty(WizardProperties.SOURCE_STRUCTURE, sourceStructure); 350 d.putProperty(WizardProperties.J2EE_LEVEL, getSelectedJ2eeSpec()); 351 d.putProperty(WizardProperties.CONTEXT_PATH, jTextFieldContextPath.getText().trim()); 352 d.putProperty(WizardProperties.EAR_APPLICATION, getSelectedEarApplication()); 353 if (warningPanel != null && warningPanel.getDowngradeAllowed()) { 356 d.putProperty(WizardProperties.JAVA_PLATFORM, warningPanel.getSuggestedJavaPlatformName()); 357 358 String j2ee = getSelectedJ2eeSpec(); 359 if (j2ee != null) { 360 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 361 FoldersListSettings fls = FoldersListSettings.getDefault(); 362 String srcLevel = "1.6"; if ((warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_14) && fls.isAgreedSetSourceLevel14()) || 364 (warningType.equals(J2eeVersionWarningPanel.WARN_SET_JDK_14) && fls.isAgreedSetJdk14())) 365 srcLevel = "1.4"; else if ((warningType.equals(J2eeVersionWarningPanel.WARN_SET_SOURCE_LEVEL_15) && fls.isAgreedSetSourceLevel15()) || 367 (warningType.equals(J2eeVersionWarningPanel.WARN_SET_JDK_15) && fls.isAgreedSetJdk15())) 368 srcLevel = "1.5"; 370 d.putProperty(WizardProperties.SOURCE_LEVEL, srcLevel); 371 } 372 } else 373 d.putProperty(WizardProperties.SOURCE_LEVEL, null); 374 } 375 376 void read(WizardDescriptor d) { 377 } 378 379 private javax.swing.JComboBox j2eeSpecComboBox; 381 private javax.swing.JLabel j2eeSpecLabel; 382 private javax.swing.JComboBox jComboBoxEnterprise; 383 private javax.swing.JLabel jLabelContextPath; 384 private javax.swing.JLabel jLabelEnterprise; 385 private javax.swing.JPanel jPanel1; 386 protected javax.swing.JTextField jTextFieldContextPath; 387 private javax.swing.JButton manageServersButton; 388 private javax.swing.JComboBox serverInstanceComboBox; 389 private javax.swing.JLabel serverInstanceLabel; 390 private javax.swing.JCheckBox setAsMainCheckBox; 391 private javax.swing.JComboBox srcStructComboBox; 392 private javax.swing.JLabel srcStructLabel; 393 private javax.swing.JPanel warningPlaceHolderPanel; 394 396 400 private void initServers(String selectedServerInstanceID) { 401 serversModel.removeAllElements(); 403 Set <ServerInstanceWrapper> servers = new TreeSet <ServerInstanceWrapper>(); 404 ServerInstanceWrapper selectedItem = null; 405 boolean sjasFound = false; 406 for (String serverInstanceID : Deployment.getDefault().getServerInstanceIDs()) { 407 String displayName = Deployment.getDefault().getServerInstanceDisplayName(serverInstanceID); 408 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceID); 409 if (displayName != null && j2eePlatform != null && j2eePlatform.getSupportedModuleTypes().contains(J2eeModule.WAR)) { 410 ServerInstanceWrapper serverWrapper = new ServerInstanceWrapper(serverInstanceID, displayName); 411 if (selectedItem == null || !sjasFound) { 413 if (selectedServerInstanceID != null) { 414 if (selectedServerInstanceID.equals(serverInstanceID)) { 415 selectedItem = serverWrapper; 416 } 417 } else { 418 String shortName = Deployment.getDefault().getServerID(serverInstanceID); 420 if ("J2EE".equals(shortName)) { selectedItem = serverWrapper; 422 sjasFound = true; 423 } 424 else 425 if ("JBoss4".equals(shortName)) { selectedItem = serverWrapper; 427 } 428 } 429 } 430 servers.add(serverWrapper); 431 } 432 } 433 for (ServerInstanceWrapper item : servers) { 434 serversModel.addElement(item); 435 } 436 if (selectedItem != null) { 437 serversModel.setSelectedItem(selectedItem); 439 } else if (serversModel.getSize() > 0) { 440 serversModel.setSelectedItem(serversModel.getElementAt(0)); 442 } 443 } 444 445 private String getSelectedJ2eeSpec() { 446 Object item = j2eeSpecComboBox.getSelectedItem(); 447 return item == null ? null 448 : item.equals(JAVA_EE_SPEC_50_LABEL) ? J2eeModule.JAVA_EE_5 : 449 ( item.equals(J2EE_SPEC_14_LABEL) ? J2eeModule.J2EE_14 : J2eeModule.J2EE_13); 450 } 451 452 private String getSelectedServer() { 453 ServerInstanceWrapper serverInstanceWrapper = (ServerInstanceWrapper) serversModel.getSelectedItem(); 454 if (serverInstanceWrapper == null) { 455 return null; 456 } 457 return serverInstanceWrapper.getServerInstanceID(); 458 } 459 460 private void initJSrcStructureSpecs() { 461 srcStructComboBox.addItem(NbBundle.getMessage(PanelOptionsVisual.class, "SourceStructure_0")); srcStructComboBox.addItem(NbBundle.getMessage(PanelOptionsVisual.class, "SourceStructure_1")); srcStructComboBox.setSelectedIndex(0); 464 } 465 466 protected boolean isContextModified() { 467 return contextModified; 468 } 469 470 private Project getSelectedEarApplication() { 471 int idx = jComboBoxEnterprise.getSelectedIndex(); 472 return (idx <= 0) ? null : (Project) earProjects.get(idx - 1); 473 } 474 475 private void initEnterpriseApplications() { 476 jComboBoxEnterprise.addItem(NbBundle.getMessage(PanelOptionsVisual.class, "LBL_NWP1_AddToEnterprise_None")); jComboBoxEnterprise.setSelectedIndex(0); 478 479 Project[] allProjects = OpenProjects.getDefault().getOpenProjects(); 480 earProjects = new ArrayList (); 481 for (int i = 0; i < allProjects.length; i++) { 482 J2eeModuleContainer container = (J2eeModuleContainer) allProjects[i].getLookup().lookup(J2eeModuleContainer.class); 483 ProjectInformation projectInfo = ProjectUtils.getInformation(allProjects[i]); 484 if (container != null) { 485 earProjects.add(projectInfo.getProject()); 486 jComboBoxEnterprise.addItem(projectInfo.getDisplayName()); 487 } 488 } 489 if (earProjects.size() <= 0) { 490 jComboBoxEnterprise.setEnabled(false); 491 } 492 } 493 494 private void setJ2eeVersionWarningPanel() { 495 String j2ee = getSelectedJ2eeSpec(); 496 if (j2ee == null) 497 return; 498 String warningType = J2eeVersionWarningPanel.findWarningType(j2ee); 499 if (warningType == null && warningPanel == null) 500 return; 501 if (warningPanel == null) { 502 warningPanel = new J2eeVersionWarningPanel(warningType); 503 warningPlaceHolderPanel.add(warningPanel, java.awt.BorderLayout.CENTER); 504 warningPanel.setWarningType(warningType); 505 } else { 506 warningPanel.setWarningType(warningType); 507 } 508 } 509 510 514 private static class ServerInstanceWrapper implements Comparable { 515 516 private final String serverInstanceID; 517 private final String displayName; 518 519 ServerInstanceWrapper(String serverInstanceID, String displayName) { 520 this.serverInstanceID = serverInstanceID; 521 this.displayName = displayName; 522 } 523 524 public String getServerInstanceID() { 525 return serverInstanceID; 526 } 527 528 public String toString() { 529 return displayName; 530 } 531 532 public int compareTo(Object o) { 533 return toString().compareTo(o.toString()); 534 } 535 } 536 } 537 | Popular Tags |