1 19 20 package org.netbeans.modules.websvc.core.client.wizard; 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.FileNotFoundException ; 25 import java.io.FileReader ; 26 import java.io.IOException ; 27 import java.io.LineNumberReader ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 31 import java.awt.Component ; 32 33 import javax.swing.JPanel ; 34 import javax.swing.JFileChooser ; 35 import javax.swing.JRadioButton ; 36 import javax.swing.filechooser.FileFilter ; 37 import javax.swing.event.DocumentEvent ; 38 import javax.swing.event.DocumentListener ; 39 import javax.swing.ComboBoxModel ; 40 import javax.swing.DefaultComboBoxModel ; 41 import javax.swing.text.JTextComponent ; 42 import javax.xml.parsers.ParserConfigurationException ; 43 import javax.xml.parsers.SAXParser ; 44 import javax.xml.parsers.SAXParserFactory ; 45 import org.netbeans.api.java.classpath.ClassPath; 46 import org.netbeans.modules.websvc.api.jaxws.project.config.Client; 47 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel; 48 import org.netbeans.modules.websvc.api.jaxws.project.config.Service; 49 import org.netbeans.modules.websvc.core.ClientWizardProperties; 50 import org.netbeans.modules.websvc.core.webservices.ui.panels.ProxySettingsDlg; 51 import org.netbeans.modules.websvc.core.webservices.ui.panels.WebProxySetter; 52 import org.netbeans.modules.websvc.core.WsdlRetriever; 53 import org.netbeans.modules.websvc.core.WsdlRetriever; 54 import org.netbeans.modules.websvc.core.jaxws.JaxWsExplorerPanel; 55 import org.netbeans.modules.websvc.core.JaxWsUtils; 56 58 import org.openide.DialogDescriptor; 59 import org.openide.DialogDisplayer; 60 import org.openide.NotifyDescriptor; 61 import org.openide.WizardDescriptor; 62 import org.openide.filesystems.FileUtil; 63 import org.openide.nodes.Node; 64 import org.openide.util.NbBundle; 65 66 import org.netbeans.api.java.project.JavaProjectConstants; 67 import org.netbeans.spi.java.project.support.ui.PackageView; 68 import org.netbeans.api.project.Project; 69 import org.netbeans.api.project.ProjectUtils; 70 import org.netbeans.api.project.SourceGroup; 71 import org.netbeans.api.project.Sources; 72 import org.netbeans.modules.j2ee.api.ejbjar.Car; 73 import org.netbeans.modules.j2ee.api.ejbjar.EjbJar; 74 import org.netbeans.modules.j2ee.common.Util; 75 import org.netbeans.spi.project.ui.templates.support.Templates; 76 77 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 78 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 79 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 80 import org.netbeans.modules.web.api.webmodule.WebModule; 81 import org.netbeans.modules.websvc.api.client.ClientStubDescriptor; 82 83 import org.netbeans.modules.websvc.api.client.WebServicesClientSupport; 84 import org.netbeans.modules.websvc.jaxws.api.JaxWsWsdlCookie; 85 import org.openide.ErrorManager; 86 import org.openide.WizardValidationException; 87 import org.openide.filesystems.FileObject; 88 import org.openide.util.Task; 89 import org.xml.sax.Attributes ; 90 import org.xml.sax.InputSource ; 91 import org.xml.sax.SAXException ; 92 import org.xml.sax.helpers.DefaultHandler ; 93 94 95 99 public final class ClientInfo extends JPanel implements WsdlRetriever.MessageReceiver { 100 101 private static final String PROP_ERROR_MESSAGE = "WizardPanel_errorMessage"; 103 private static final int WSDL_FROM_PROJECT = 0; 104 private static final int WSDL_FROM_FILE = 1; 105 private static final int WSDL_FROM_URL = 2; 106 107 private static final FileFilter WSDL_FILE_FILTER = new WsdlFileFilter(); 108 private static String previousDirectory = ""; 110 private WebServiceClientWizardDescriptor descriptorPanel; 111 private WizardDescriptor wizardDescriptor; 112 113 private boolean settingFields; 114 private int wsdlSource; 115 private File wsdlTmpFile; 116 117 private WsdlRetriever retriever; 119 private String downloadMsg; 120 121 private boolean retrieverFailed = false; 122 private boolean isWaitingForScan = false; 123 124 private Project project; 125 private int projectType; 126 127 public ClientInfo(WebServiceClientWizardDescriptor panel) { 128 descriptorPanel = panel; 129 130 this.settingFields = false; 131 this.wsdlSource = WSDL_FROM_PROJECT; 132 this.wsdlTmpFile = null; 133 this.retriever = null; 134 135 initComponents(); 136 jLblClientType.setVisible(false); 137 jCbxClientType.setVisible(false); 138 jComboBoxJaxVersion.setModel(new DefaultComboBoxModel (new String [] {ClientWizardProperties.JAX_WS, ClientWizardProperties.JAX_RPC})); 139 initUserComponents(); 140 } 141 142 147 private void initComponents() { 149 java.awt.GridBagConstraints gridBagConstraints; 150 151 btnGrpWsdlSource = new javax.swing.ButtonGroup (); 152 jLblChooseSource = new javax.swing.JLabel (); 153 jRbnFilesystem = new javax.swing.JRadioButton (); 154 jTxtWsdlProject = new javax.swing.JTextField (); 155 jBtnBrowse = new javax.swing.JButton (); 156 jRbnProject = new javax.swing.JRadioButton (); 157 jTxtWsdlURL = new javax.swing.JTextField (); 158 jBtnProxy = new javax.swing.JButton (); 159 jTxtLocalFilename = new javax.swing.JTextField (); 160 jLblPackageDescription = new javax.swing.JLabel (); 161 jLblProject = new javax.swing.JLabel (); 162 jTxtProject = new javax.swing.JTextField (); 163 jLblPackageName = new javax.swing.JLabel (); 164 jCbxPackageName = new javax.swing.JComboBox (); 165 jLblClientType = new javax.swing.JLabel (); 166 jCbxClientType = new javax.swing.JComboBox (); 167 jRbnUrl = new javax.swing.JRadioButton (); 168 jBtnBrowse1 = new javax.swing.JButton (); 169 jLabelJaxVersion = new javax.swing.JLabel (); 170 jComboBoxJaxVersion = new javax.swing.JComboBox (); 171 172 setLayout(new java.awt.GridBagLayout ()); 173 174 getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_WsdlSource")); 175 org.openide.awt.Mnemonics.setLocalizedText(jLblChooseSource, NbBundle.getMessage(ClientInfo.class, "LBL_WsdlSource")); 176 gridBagConstraints = new java.awt.GridBagConstraints (); 177 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 180 add(jLblChooseSource, gridBagConstraints); 181 182 btnGrpWsdlSource.add(jRbnFilesystem); 183 org.openide.awt.Mnemonics.setLocalizedText(jRbnFilesystem, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_WsdlSourceFilesystem")); 184 jRbnFilesystem.addActionListener(new java.awt.event.ActionListener () { 185 public void actionPerformed(java.awt.event.ActionEvent evt) { 186 jRbnFilesystemActionPerformed(evt); 187 } 188 }); 189 190 gridBagConstraints = new java.awt.GridBagConstraints (); 191 gridBagConstraints.gridx = 0; 192 gridBagConstraints.gridy = 2; 193 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 194 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 195 add(jRbnFilesystem, gridBagConstraints); 196 jRbnFilesystem.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_WsdlSource")); 197 198 jTxtWsdlProject.setEditable(false); 199 gridBagConstraints = new java.awt.GridBagConstraints (); 200 gridBagConstraints.gridx = 1; 201 gridBagConstraints.gridy = 1; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 203 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 6); 204 add(jTxtWsdlProject, gridBagConstraints); 205 jTxtWsdlProject.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ClientInfo.class, "ACSN_WsdlSourceFilesystem")); 206 jTxtWsdlProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "ACSD_WsdlSourceFile")); 207 208 org.openide.awt.Mnemonics.setLocalizedText(jBtnBrowse, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_Browse")); 209 jBtnBrowse.addActionListener(new java.awt.event.ActionListener () { 210 public void actionPerformed(java.awt.event.ActionEvent evt) { 211 jBtnBrowseActionPerformed(evt); 212 } 213 }); 214 215 gridBagConstraints = new java.awt.GridBagConstraints (); 216 gridBagConstraints.gridx = 2; 217 gridBagConstraints.gridy = 2; 218 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 219 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 220 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 0); 221 add(jBtnBrowse, gridBagConstraints); 222 jBtnBrowse.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(ClientInfo.class).getString("A11Y_BrowseLocalFile")); 223 224 btnGrpWsdlSource.add(jRbnProject); 225 jRbnProject.setSelected(true); 226 org.openide.awt.Mnemonics.setLocalizedText(jRbnProject, NbBundle.getMessage(ClientInfo.class, "LBL_ProjectUrl")); 227 jRbnProject.setFocusable(false); 228 jRbnProject.addActionListener(new java.awt.event.ActionListener () { 229 public void actionPerformed(java.awt.event.ActionEvent evt) { 230 jRbnProjectActionPerformed(evt); 231 } 232 }); 233 234 gridBagConstraints = new java.awt.GridBagConstraints (); 235 gridBagConstraints.gridx = 0; 236 gridBagConstraints.gridy = 1; 237 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 238 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 239 add(jRbnProject, gridBagConstraints); 240 jRbnProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_WsdlSourceUrl")); 241 242 jTxtWsdlURL.setColumns(30); 243 gridBagConstraints = new java.awt.GridBagConstraints (); 244 gridBagConstraints.gridx = 1; 245 gridBagConstraints.gridy = 3; 246 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 247 gridBagConstraints.weightx = 1.0; 248 gridBagConstraints.insets = new java.awt.Insets (0, 6, 12, 6); 249 add(jTxtWsdlURL, gridBagConstraints); 250 jTxtWsdlURL.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ClientInfo.class, "ACSN_WsdlSourceUrl")); 251 jTxtWsdlURL.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "ACSD_WsdlSourceUrl")); 252 253 org.openide.awt.Mnemonics.setLocalizedText(jBtnProxy, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_ProxySettings")); 254 jBtnProxy.addActionListener(new java.awt.event.ActionListener () { 255 public void actionPerformed(java.awt.event.ActionEvent evt) { 256 jBtnProxyActionPerformed(evt); 257 } 258 }); 259 260 gridBagConstraints = new java.awt.GridBagConstraints (); 261 gridBagConstraints.gridx = 2; 262 gridBagConstraints.gridy = 3; 263 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 264 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 265 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 266 gridBagConstraints.insets = new java.awt.Insets (0, 6, 12, 0); 267 add(jBtnProxy, gridBagConstraints); 268 jBtnProxy.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_ProxySettings")); 269 270 gridBagConstraints = new java.awt.GridBagConstraints (); 271 gridBagConstraints.gridx = 1; 272 gridBagConstraints.gridy = 2; 273 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 274 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 6); 275 add(jTxtLocalFilename, gridBagConstraints); 276 jTxtLocalFilename.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(ClientInfo.class).getString("ACSN_WsdlSourceLocalFile")); 277 jTxtLocalFilename.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_LocalFilename")); 278 279 jLblPackageDescription.setLabelFor(jCbxPackageName); 280 org.openide.awt.Mnemonics.setLocalizedText(jLblPackageDescription, NbBundle.getMessage(ClientInfo.class, "LBL_PackageDescription")); 281 gridBagConstraints = new java.awt.GridBagConstraints (); 282 gridBagConstraints.gridx = 0; 283 gridBagConstraints.gridy = 4; 284 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 285 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 286 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 0); 287 add(jLblPackageDescription, gridBagConstraints); 288 289 jLblProject.setLabelFor(jTxtProject); 290 org.openide.awt.Mnemonics.setLocalizedText(jLblProject, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_Project")); 291 gridBagConstraints = new java.awt.GridBagConstraints (); 292 gridBagConstraints.gridx = 0; 293 gridBagConstraints.gridy = 5; 294 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 295 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 6); 296 add(jLblProject, gridBagConstraints); 297 298 jTxtProject.setEditable(false); 299 gridBagConstraints = new java.awt.GridBagConstraints (); 300 gridBagConstraints.gridx = 1; 301 gridBagConstraints.gridy = 5; 302 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 303 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 304 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 0); 305 add(jTxtProject, gridBagConstraints); 306 jTxtProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_Project")); 307 308 jLblPackageName.setLabelFor(jCbxPackageName); 309 org.openide.awt.Mnemonics.setLocalizedText(jLblPackageName, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_PackageName")); 310 gridBagConstraints = new java.awt.GridBagConstraints (); 311 gridBagConstraints.gridx = 0; 312 gridBagConstraints.gridy = 6; 313 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 314 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 6); 315 add(jLblPackageName, gridBagConstraints); 316 317 jCbxPackageName.setEditable(true); 318 gridBagConstraints = new java.awt.GridBagConstraints (); 319 gridBagConstraints.gridx = 1; 320 gridBagConstraints.gridy = 6; 321 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 322 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 323 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 0); 324 add(jCbxPackageName, gridBagConstraints); 325 326 jLblClientType.setLabelFor(jCbxClientType); 327 org.openide.awt.Mnemonics.setLocalizedText(jLblClientType, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_ClientType")); 328 gridBagConstraints = new java.awt.GridBagConstraints (); 329 gridBagConstraints.gridx = 0; 330 gridBagConstraints.gridy = 7; 331 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 332 gridBagConstraints.ipady = 4; 333 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 334 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 6); 335 add(jLblClientType, gridBagConstraints); 336 337 gridBagConstraints = new java.awt.GridBagConstraints (); 338 gridBagConstraints.gridx = 1; 339 gridBagConstraints.gridy = 7; 340 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 341 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 342 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 343 gridBagConstraints.insets = new java.awt.Insets (0, 6, 0, 0); 344 add(jCbxClientType, gridBagConstraints); 345 jCbxClientType.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ClientInfo.class, "A11Y_ClientType")); 346 347 btnGrpWsdlSource.add(jRbnUrl); 348 org.openide.awt.Mnemonics.setLocalizedText(jRbnUrl, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_WsdlUrl")); 349 jRbnUrl.addActionListener(new java.awt.event.ActionListener () { 350 public void actionPerformed(java.awt.event.ActionEvent evt) { 351 jRbnUrlActionPerformed(evt); 352 } 353 }); 354 355 gridBagConstraints = new java.awt.GridBagConstraints (); 356 gridBagConstraints.gridx = 0; 357 gridBagConstraints.gridy = 3; 358 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 359 gridBagConstraints.insets = new java.awt.Insets (0, 0, 12, 0); 360 add(jRbnUrl, gridBagConstraints); 361 jRbnUrl.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(ClientInfo.class).getString("A11Y_WsdlURL")); 362 363 org.openide.awt.Mnemonics.setLocalizedText(jBtnBrowse1, org.openide.util.NbBundle.getMessage(ClientInfo.class, "LBL_Browse1")); 364 jBtnBrowse1.addActionListener(new java.awt.event.ActionListener () { 365 public void actionPerformed(java.awt.event.ActionEvent evt) { 366 jBtnBrowse1ActionPerformed(evt); 367 } 368 }); 369 370 gridBagConstraints = new java.awt.GridBagConstraints (); 371 gridBagConstraints.gridx = 2; 372 gridBagConstraints.gridy = 1; 373 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 374 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 375 gridBagConstraints.insets = new java.awt.Insets (0, 6, 6, 0); 376 add(jBtnBrowse1, gridBagConstraints); 377 jBtnBrowse1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(ClientInfo.class).getString("A11Y_BrowseWSDLProject")); 378 379 jLabelJaxVersion.setLabelFor(jComboBoxJaxVersion); 380 org.openide.awt.Mnemonics.setLocalizedText(jLabelJaxVersion, org.openide.util.NbBundle.getBundle(ClientInfo.class).getString("LBL_JAX_Version")); 381 gridBagConstraints = new java.awt.GridBagConstraints (); 382 gridBagConstraints.gridx = 0; 383 gridBagConstraints.gridy = 8; 384 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 385 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 386 gridBagConstraints.weighty = 1.0; 387 gridBagConstraints.insets = new java.awt.Insets (28, 0, 0, 6); 388 add(jLabelJaxVersion, gridBagConstraints); 389 390 gridBagConstraints = new java.awt.GridBagConstraints (); 391 gridBagConstraints.gridx = 1; 392 gridBagConstraints.gridy = 8; 393 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 394 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 395 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 396 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 397 gridBagConstraints.insets = new java.awt.Insets (24, 6, 0, 0); 398 add(jComboBoxJaxVersion, gridBagConstraints); 399 400 } 402 private void jBtnBrowse1ActionPerformed(java.awt.event.ActionEvent evt) { String result = browseProjectServices(); 405 if (result!=null) jTxtWsdlProject.setText(result); 406 } 408 private void jRbnUrlActionPerformed(java.awt.event.ActionEvent evt) { wsdlSource = WSDL_FROM_URL; 411 enableWsdlSourceFields(false, false, true); 412 descriptorPanel.fireChangeEvent(); 413 } 415 private void jBtnProxyActionPerformed(java.awt.event.ActionEvent evt) { ProxySettingsDlg.showDialog(); 417 wsdlUrlChanged(); 418 } 420 private void jBtnBrowseActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (previousDirectory); 423 chooser.setMultiSelectionEnabled(false); 424 chooser.setAcceptAllFileFilterUsed(false); 425 chooser.addChoosableFileFilter(WSDL_FILE_FILTER); 426 chooser.setFileFilter(WSDL_FILE_FILTER); 427 428 if(chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { 429 File wsdlFile = chooser.getSelectedFile(); 430 jTxtLocalFilename.setText(wsdlFile.getAbsolutePath()); 431 previousDirectory = wsdlFile.getPath(); 432 int result = resolveImports(wsdlFile); 433 if ((result & 0x02) == 0x02) { 434 String proxyHost = WebProxySetter.getInstance().getProxyHost(); 435 if (proxyHost==null || proxyHost.length()==0) 436 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( 437 NbBundle.getMessage(ClientInfo.class,"MSG_SetUpProxyForImports"),NotifyDescriptor.WARNING_MESSAGE)); } 439 if ((result & 0x01) == 0x01) { 440 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( 441 NbBundle.getMessage(ClientInfo.class,"MSG_IdeGeneratedStaticStubOnly"),NotifyDescriptor.WARNING_MESSAGE)); } 443 444 } 445 } 447 private void jRbnFilesystemActionPerformed(java.awt.event.ActionEvent evt) { wsdlSource = WSDL_FROM_FILE; 450 enableWsdlSourceFields(false, true, false); 451 descriptorPanel.fireChangeEvent(); 452 } 454 private void jRbnProjectActionPerformed(java.awt.event.ActionEvent evt) { wsdlSource = WSDL_FROM_PROJECT; 457 enableWsdlSourceFields(true, false, false); 458 descriptorPanel.fireChangeEvent(); 459 } 461 private void enableWsdlSourceFields(boolean fromProject, boolean fromFile, boolean fromUrl) { 462 jTxtWsdlProject.setEnabled(fromProject); 464 jBtnBrowse1.setEnabled(fromProject); 465 466 jTxtLocalFilename.setEnabled(fromFile); 468 jBtnBrowse.setEnabled(fromFile); 469 470 jTxtWsdlURL.setEnabled(fromUrl); 472 } 473 474 private javax.swing.ButtonGroup btnGrpWsdlSource; 476 private javax.swing.JButton jBtnBrowse; 477 private javax.swing.JButton jBtnBrowse1; 478 private javax.swing.JButton jBtnProxy; 479 private javax.swing.JComboBox jCbxClientType; 480 private javax.swing.JComboBox jCbxPackageName; 481 private javax.swing.JComboBox jComboBoxJaxVersion; 482 private javax.swing.JLabel jLabelJaxVersion; 483 private javax.swing.JLabel jLblChooseSource; 484 private javax.swing.JLabel jLblClientType; 485 private javax.swing.JLabel jLblPackageDescription; 486 private javax.swing.JLabel jLblPackageName; 487 private javax.swing.JLabel jLblProject; 488 private javax.swing.JRadioButton jRbnFilesystem; 489 private javax.swing.JRadioButton jRbnProject; 490 private javax.swing.JRadioButton jRbnUrl; 491 private javax.swing.JTextField jTxtLocalFilename; 492 private javax.swing.JTextField jTxtProject; 493 private javax.swing.JTextField jTxtWsdlProject; 494 private javax.swing.JTextField jTxtWsdlURL; 495 497 private void initUserComponents() { 498 500 setName(NbBundle.getMessage(ClientInfo.class, "TITLE_WebServiceClientWizard")); 502 jTxtWsdlURL.getDocument().addDocumentListener(new DocumentListener () { 504 public void changedUpdate(DocumentEvent e) { 505 wsdlUrlChanged(); 506 } 507 public void insertUpdate(DocumentEvent e) { 508 wsdlUrlChanged(); 509 } 510 public void removeUpdate(DocumentEvent e) { 511 wsdlUrlChanged(); 512 } 513 }); 514 jTxtLocalFilename.getDocument().addDocumentListener(new DocumentListener () { 515 public void changedUpdate(DocumentEvent e) { 516 updateTexts(); 517 } 518 public void insertUpdate(DocumentEvent e) { 519 updateTexts(); 520 } 521 public void removeUpdate(DocumentEvent e) { 522 updateTexts(); 523 } 524 }); 525 jTxtWsdlProject.getDocument().addDocumentListener(new DocumentListener () { 526 public void changedUpdate(DocumentEvent e) { 527 wsdlUrlChanged(); 528 } 529 public void insertUpdate(DocumentEvent e) { 530 wsdlUrlChanged(); 531 } 532 public void removeUpdate(DocumentEvent e) { 533 wsdlUrlChanged(); 534 } 535 }); 536 537 Component editorComponent = jCbxPackageName.getEditor().getEditorComponent(); 538 if(editorComponent instanceof JTextComponent ) { 539 ((JTextComponent ) editorComponent).getDocument().addDocumentListener(new DocumentListener () { 540 public void changedUpdate(DocumentEvent e) { 541 updateTexts(); 542 } 543 public void insertUpdate(DocumentEvent e) { 544 updateTexts(); 545 } 546 public void removeUpdate(DocumentEvent e) { 547 updateTexts(); 548 } 549 }); 550 } else { 551 jCbxPackageName.addItemListener(new java.awt.event.ItemListener () { 554 public void itemStateChanged(java.awt.event.ItemEvent evt) { 555 if(!settingFields) { 556 descriptorPanel.fireChangeEvent(); } 558 } 559 }); 560 } 561 562 jCbxPackageName.setRenderer(PackageView.listRenderer()); 563 } 564 565 void store(WizardDescriptor d) { 566 568 if(wsdlSource == WSDL_FROM_PROJECT || wsdlSource == WSDL_FROM_URL) { 569 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_URL, getDownloadUrl()); 570 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_FILE, getDownloadWsdl()); 571 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_SCHEMAS, getDownloadedSchemas()); 572 d.putProperty(ClientWizardProperties.WSDL_FILE_PATH, retriever == null ? "" : retriever.getWsdlFileName()); } else if(wsdlSource == WSDL_FROM_FILE) { 574 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_URL, null); 575 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_FILE, null); 576 d.putProperty(ClientWizardProperties.WSDL_DOWNLOAD_SCHEMAS, null); 577 d.putProperty(ClientWizardProperties.WSDL_FILE_PATH, jTxtLocalFilename.getText().trim()); 578 } 579 d.putProperty(ClientWizardProperties.WSDL_PACKAGE_NAME, getPackageName()); 580 d.putProperty(ClientWizardProperties.CLIENT_STUB_TYPE, jCbxClientType.getSelectedItem()); 581 d.putProperty(ClientWizardProperties.JAX_VERSION, jComboBoxJaxVersion.getSelectedItem()); 582 } 583 584 void read(WizardDescriptor d) { 585 this.wizardDescriptor = d; 587 588 project = Templates.getProject(d); 589 WebModule wm = WebModule.getWebModule(project.getProjectDirectory()); 590 EjbJar em = EjbJar.getEjbJar(project.getProjectDirectory()); 591 Car car = Car.getCar(project.getProjectDirectory()); 592 if (car != null) 593 projectType = 3; 594 else if (em != null) 595 projectType = 2; 596 else if (wm != null) 597 projectType = 1; 598 else 599 projectType = 0; 600 601 if (projectType > 0) { 602 603 if (!Util.isJavaEE5orHigher(project)) { 604 jLblClientType.setVisible(true); 605 jCbxClientType.setVisible(true); 606 } 607 } 608 609 SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 611 ClassPath classPath; 612 FileObject wsimportFO = null; 613 FileObject wscompileFO = null; 614 if (sgs.length > 0) { 615 classPath = ClassPath.getClassPath(sgs[0].getRootFolder(),ClassPath.COMPILE); 616 if (classPath != null) { 617 wsimportFO = classPath.findResource("com/sun/tools/ws/ant/WsImport.class"); wscompileFO = classPath.findResource("com/sun/xml/rpc/tools/ant/Wscompile.class"); } 620 } 621 622 boolean jsr109OldSupported = isJsr109OldSupported(project); 623 boolean jsr109Supported = isJsr109Supported(project); 624 boolean jwsdpSupported = isJwsdpSupported(project); 625 if (projectType > 0) { 626 jLabelJaxVersion.setEnabled(false); 627 jComboBoxJaxVersion.setEnabled(false); 628 if (Util.isJavaEE5orHigher(project)) jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_WS); 630 else{ 631 if((!jsr109OldSupported && !jsr109Supported) 632 || (!jsr109Supported && jsr109OldSupported && jwsdpSupported )){ 633 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_WS); 634 } else{ 635 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_RPC); 636 } 637 } 638 } else { 639 if (Util.isSourceLevel16orHigher(project)) { 640 jLabelJaxVersion.setEnabled(false); 641 jComboBoxJaxVersion.setEnabled(false); 642 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_WS); 643 } else if (Util.getSourceLevel(project).equals("1.5")) { if (wsimportFO != null) { 645 jLabelJaxVersion.setEnabled(false); 646 jComboBoxJaxVersion.setEnabled(false); 647 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_WS); 648 } else if (wscompileFO != null) { 649 jLabelJaxVersion.setEnabled(false); 650 jComboBoxJaxVersion.setEnabled(false); 651 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_RPC); 652 } else { 653 jLabelJaxVersion.setEnabled(true); 654 jComboBoxJaxVersion.setEnabled(true); 655 } 656 } else { 657 jLabelJaxVersion.setEnabled(false); 658 jComboBoxJaxVersion.setEnabled(false); 659 jComboBoxJaxVersion.setSelectedItem(ClientWizardProperties.JAX_RPC); 660 } 661 } 662 663 try { 664 settingFields = true; 665 666 Project p = Templates.getProject(d); 667 668 jTxtProject.setText(ProjectUtils.getInformation(p).getDisplayName()); 669 jTxtWsdlURL.setText((String ) d.getProperty(ClientWizardProperties.WSDL_DOWNLOAD_URL)); 670 jTxtLocalFilename.setText(retriever != null ? retriever.getWsdlFileName() : ""); jTxtWsdlURL.setText((String ) d.getProperty(ClientWizardProperties.WSDL_FILE_PATH)); 672 673 jCbxPackageName.setModel(getPackageModel(p)); 674 jCbxPackageName.setSelectedItem(getPackageItem((String ) d.getProperty(ClientWizardProperties.WSDL_PACKAGE_NAME))); 675 676 Integer source = (Integer ) d.getProperty(ClientWizardProperties.WSDL_SOURCE); 678 if(source == null || source.intValue() < WSDL_FROM_PROJECT || source.intValue() > WSDL_FROM_URL) { 679 source = new Integer (WSDL_FROM_PROJECT); 680 } 681 682 this.wsdlSource = source.intValue(); 683 this.wsdlTmpFile = null; 684 this.retriever = null; 685 this.downloadMsg = null; 686 687 enableWsdlSourceFields(wsdlSource == WSDL_FROM_PROJECT, wsdlSource == WSDL_FROM_FILE, wsdlSource == WSDL_FROM_URL); 688 btnGrpWsdlSource.setSelected(getSelectedRadioButton(wsdlSource).getModel(), true); 689 690 WebServicesClientSupport clientSupport = 695 WebServicesClientSupport.getWebServicesClientSupport(p.getProjectDirectory()); 696 697 Object selectedStub = d.getProperty(ClientWizardProperties.CLIENT_STUB_TYPE); 698 DefaultComboBoxModel stubModel = new DefaultComboBoxModel (); 699 if(clientSupport != null) { 700 List <ClientStubDescriptor> clientStubs = clientSupport.getStubDescriptors(); 701 for(Iterator iter = clientStubs.iterator(); iter.hasNext(); ) { 702 stubModel.addElement(iter.next()); 703 } 704 705 if(!clientStubs.contains(selectedStub)) { 706 selectedStub = null; 707 } 708 709 if ((!jsr109OldSupported && !jsr109Supported) 712 || (!jsr109Supported && jsr109OldSupported && jwsdpSupported)) { 713 selectedStub = getJAXRPCClientStub(clientStubs); 714 jCbxClientType.setEnabled(false); 715 } 716 } else { 717 selectedStub = null; 718 } 719 720 jCbxClientType.setModel(stubModel); 721 722 if(selectedStub != null) { 723 jCbxClientType.setSelectedItem(selectedStub); 724 } 725 } finally { 726 settingFields = false; 727 } 728 } 729 730 private ClientStubDescriptor getJAXRPCClientStub(List <ClientStubDescriptor> clientStubs){ 731 for(ClientStubDescriptor clientStub : clientStubs){ 732 if(clientStub.getName().equals(ClientStubDescriptor.JAXRPC_CLIENT_STUB)){ 733 return clientStub; 734 } 735 } 736 return null; 737 } 738 739 public void validatePanel() throws WizardValidationException { 740 if (!valid(wizardDescriptor)) 741 throw new WizardValidationException(this, "", ""); 743 retrieverFailed = false; 744 retriever = null; 745 if (((projectType != 0 && !Util.isJavaEE5orHigher(project)) 746 || (projectType == 0 && jComboBoxJaxVersion.getSelectedItem().equals(ClientWizardProperties.JAX_RPC))) 747 && (wsdlSource != WSDL_FROM_FILE)) { 748 retriever = new WsdlRetriever(this, 749 wsdlSource==WSDL_FROM_PROJECT?jTxtWsdlProject.getText():jTxtWsdlURL.getText().trim()); 750 751 Task task = new Task(retriever); 752 try { 753 task.run(); 754 task.waitFinished(60000); 756 } catch (InterruptedException ex) { 757 } 758 if (retriever.getState() != WsdlRetriever.STATUS_COMPLETE) { 759 retrieverFailed = true; 760 throw new WizardValidationException(this, "", ""); } else 762 wizardDescriptor.putProperty(ClientWizardProperties.WSDL_FILE_PATH, retriever == null ? "" : retriever.getWsdlFileName()); } 764 } 765 766 private ComboBoxModel getPackageModel(Project p) { 767 ComboBoxModel result; 768 Sources sources = ProjectUtils.getSources(p); 769 SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 770 771 if(groups.length > 1) { 772 result = PackageView.createListView(groups[0]); 785 } else if(groups.length == 1) { 786 result = PackageView.createListView(groups[0]); 788 } else { 789 result = new DefaultComboBoxModel (); 790 } 791 792 return result; 793 } 794 795 private Object getPackageItem(String name) { 796 Object result = name; 797 798 ComboBoxModel model = jCbxPackageName.getModel(); 799 int max = model.getSize(); 800 for (int i = 0; i < max; i++) { 801 Object item = model.getElementAt(i); 802 if(item.toString().equals(name)) { 803 result = item; 804 break; 805 } 806 } 807 808 return result; 809 } 810 811 private String getPackageName() { 812 return jCbxPackageName.getEditor().getItem().toString().trim(); 813 } 814 815 private JRadioButton getSelectedRadioButton(int selected) { 816 JRadioButton result = jRbnProject; 817 818 switch(selected) { 819 case WSDL_FROM_PROJECT: 820 result = jRbnProject; 821 break; 822 case WSDL_FROM_FILE: 823 result = jRbnFilesystem; 824 break; 825 case WSDL_FROM_URL: 826 result = jRbnUrl; 827 break; 828 } 829 830 return result; 831 } 832 833 private byte [] getDownloadWsdl() { 834 byte [] result = null; 835 if(retriever != null && retriever.getState() == WsdlRetriever.STATUS_COMPLETE) { 836 result = retriever.getWsdl(); 837 } 838 return result; 839 } 840 841 private List getDownloadedSchemas() { 842 List result = null; 843 if(retriever != null && retriever.getState() == WsdlRetriever.STATUS_COMPLETE) { 844 result = retriever.getSchemas(); 845 } 846 return result; 847 } 848 849 private String getDownloadUrl() { 850 String result = ""; 852 if(retriever != null) { 853 result = retriever.getWsdlUrl(); 856 } else { 857 if (wsdlSource==WSDL_FROM_URL) 859 result = WsdlRetriever.beautifyUrlName(jTxtWsdlURL.getText().trim()); 860 else if (wsdlSource==WSDL_FROM_PROJECT) 861 result = jTxtWsdlProject.getText().trim(); 862 } 863 return result; 864 } 865 866 boolean valid(final WizardDescriptor wizardDescriptor) { 867 Project p = Templates.getProject(wizardDescriptor); 868 869 876 877 if(!checkNonJsr109Valid(wizardDescriptor)){ 878 return false; 879 } 880 881 WebServicesClientSupport clientSupport = 883 WebServicesClientSupport.getWebServicesClientSupport(p.getProjectDirectory()); 884 List clientStubs = (clientSupport != null) ? clientSupport.getStubDescriptors() : null; 885 if(clientStubs == null || clientStubs.size() == 0) { 886 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_NoStubsDefined")); return false; } 889 890 if (jComboBoxJaxVersion.getSelectedItem().equals(ClientWizardProperties.JAX_RPC)) { 891 SourceGroup[] sgs = JaxWsClientCreator.getJavaSourceGroups(project); 892 if (sgs.length <= 0) { 894 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class,"MSG_MissingSourceRoot")); return false; 896 } 897 } 898 899 if(wsdlSource == WSDL_FROM_PROJECT || wsdlSource == WSDL_FROM_URL) { 900 String wsdlUrl = (wsdlSource == WSDL_FROM_PROJECT?jTxtWsdlProject.getText().trim():jTxtWsdlURL.getText().trim()); 901 if(wsdlUrl == null || wsdlUrl.length() == 0) { 902 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "MSG_EnterURL")); return false; 904 } 905 906 if (retrieverFailed && retriever != null) { 907 if(retriever.getState() < WsdlRetriever.STATUS_COMPLETE) { 908 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "MSG_DownloadProgress", ((downloadMsg != null) ? downloadMsg : NbBundle.getMessage(ClientInfo.class, "LBL_Unknown")))); return false; 911 } 912 913 if(retriever.getState() > WsdlRetriever.STATUS_COMPLETE) { 914 if(downloadMsg != null) { 915 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_DownloadFailed", downloadMsg)); } else { 917 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_DownloadFailedUnknown")); } 919 return false; 920 } 921 } 922 923 926 } else if(wsdlSource == WSDL_FROM_FILE) { 928 String wsdlFilePath = jTxtLocalFilename.getText().trim(); 929 930 if(wsdlFilePath == null || wsdlFilePath.length() == 0) { 931 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "MSG_EnterFilename")); return false; } 934 935 File f = new File (wsdlFilePath); 936 if(f == null) { 937 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_WsdlInvalid")); return false; } 940 941 if(!f.exists()) { 942 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_WsdlDoesNotExist")); return false; } 945 946 if(!"wsdl".equalsIgnoreCase(FileUtil.getExtension(f.getName()))) { 947 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_WsdlInvalid")); return false; } 950 951 FileReader fr = null; 953 LineNumberReader lnReader = null; 954 try { 955 fr = new FileReader (f); 956 if (jComboBoxJaxVersion.getSelectedItem().equals(ClientWizardProperties.JAX_RPC)) { 957 lnReader = new LineNumberReader (fr); 958 if (lnReader != null) { 959 String line = null; 960 try { 961 line = lnReader.readLine(); 962 } catch (IOException ioe) { 963 } 965 while (line != null) { 966 if (line.indexOf("REPLACE_WITH_ACTUAL_URL") > 0) { wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_WrongWsdl")); return false; 969 } try { 971 line = lnReader.readLine(); 972 } catch (IOException ioe) { 973 } 975 } 976 } 977 } 978 } catch (FileNotFoundException fne) { 979 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_WsdlDoesNotExist")); } finally{ 981 try{ 982 if(lnReader != null){ 983 lnReader.close(); 984 } 985 }catch(IOException e){ 986 ErrorManager.getDefault().notify(e); 987 } 988 } 989 990 } 996 997 String packageName = getPackageName(); 998 if(packageName == null || packageName.length() == 0) { 999 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "MSG_EnterJavaPackageName")); return false; } 1002 1003 if(!JaxWsUtils.isJavaPackage(packageName)) { 1004 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_PackageInvalid")); return false; } 1007 1008 JaxWsModel jaxWsModel = (JaxWsModel)p.getLookup().lookup(JaxWsModel.class); 1010 if (jaxWsModel!=null) { 1011 Service[] services = jaxWsModel.getServices(); 1012 for (int i=0;i<services.length;i++) { 1013 if (services[i].getWsdlUrl()!=null && packageName.equals(services[i].getPackageName())) { 1014 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_PackageUsedForService",services[i].getServiceName())); 1015 return false; 1016 } 1017 } 1018 Client[] clients = jaxWsModel.getClients(); 1019 for (int i=0;i<clients.length;i++) { 1020 if (packageName.equals(clients[i].getPackageName())) { 1021 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle.getMessage(ClientInfo.class, "ERR_PackageUsedForClient",clients[i].getName())); 1022 return false; 1023 } 1024 } 1025 1026 } 1027 1028 if(projectHasEmbeddedSpaces()){ 1031 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, 1032 NbBundle.getMessage(ClientInfo.class, "MSG_SPACE_IN_PROJECT_PATH")); } else{ 1034 wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, ""); } 1036 1037 wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); 1054 return true; 1055 } 1056 1057 private boolean projectHasEmbeddedSpaces(){ 1058 FileObject projectDir = project.getProjectDirectory(); 1059 File projectDirFile = FileUtil.toFile(projectDir); 1060 String path = projectDirFile.getAbsolutePath(); 1061 int index = path.indexOf(" "); 1062 return index != -1; 1063 } 1064 1065 private J2eePlatform getJ2eePlatform(Project project){ 1066 J2eeModuleProvider provider = (J2eeModuleProvider) project.getLookup().lookup(J2eeModuleProvider.class); 1067 if(provider != null){ 1068 String serverInstanceID = provider.getServerInstanceID(); 1069 if(serverInstanceID != null && serverInstanceID.length() > 0) { 1070 return Deployment.getDefault().getJ2eePlatform(serverInstanceID); 1071 } 1072 } 1073 return null; 1074 } 1075 1076 private boolean isJsr109Supported(Project project){ 1077 J2eePlatform j2eePlatform = getJ2eePlatform(project); 1078 if(j2eePlatform != null){ 1079 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_JSR109); 1080 } 1081 return false; 1082 } 1083 1084 private boolean isJsr109OldSupported(Project project){ 1085 J2eePlatform j2eePlatform = getJ2eePlatform(project); 1086 if(j2eePlatform != null){ 1087 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSCOMPILE); 1088 } 1089 return false; 1090 } 1091 1092 private boolean isJwsdpSupported(Project project){ 1093 J2eePlatform j2eePlatform = getJ2eePlatform(project); 1094 if(j2eePlatform != null){ 1095 return j2eePlatform.isToolSupported(J2eePlatform.TOOL_JWSDP); 1096 } 1097 return false; 1098 } 1099 1100 1104 private boolean checkNonJsr109Valid(WizardDescriptor wizardDescriptor){ 1105 Project project = Templates.getProject(wizardDescriptor); 1106 boolean jsr109Supported = isJsr109Supported(project); 1107 boolean jsr109oldSupported = isJsr109OldSupported(project); 1108 boolean jwsdpSupported = isJwsdpSupported(project); 1109 if (!jsr109Supported && !jsr109oldSupported || 1110 (!jsr109Supported && jsr109oldSupported && jwsdpSupported)) { 1111 if (Util.isSourceLevel14orLower(project)) { 1112 wizardDescriptor.putProperty("WizardPanel_errorMessage", 1113 NbBundle.getMessage(ClientInfo.class, "ERR_NeedProperSourceLevel")); return false; 1115 } 1116 } 1117 return true; 1118 } 1119 private boolean isWsCompileSupported(Project p) { 1120 boolean result = true; 1124 1125 J2eeModuleProvider provider = (J2eeModuleProvider) p.getLookup().lookup(J2eeModuleProvider.class); 1126 if(provider != null) { 1127 String serverInstanceID = provider.getServerInstanceID(); 1128 if(serverInstanceID != null && serverInstanceID.length() > 0) { 1129 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceID); 1130 if(!j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSCOMPILE)) { 1131 result = false; 1132 } 1133 } 1134 } 1135 1136 return result; 1137 } 1138 1139 private void wsdlUrlChanged() { 1140 retriever = null; 1142 1143 updateTexts(); 1144 } 1145 1146 private void updateTexts() { 1147 if(!settingFields) { 1148 descriptorPanel.fireChangeEvent(); } 1150 } 1151 1152 private boolean isValidUrl(String urlText) { 1153 if(urlText == null || urlText.length() == 0) { 1154 return false; 1155 } 1156 1157 return true; 1163 } 1164 1165 public void setWsdlDownloadMessage(String m) { 1166 downloadMsg = m; 1167 1168 if(retriever.getState() >= WsdlRetriever.STATUS_COMPLETE) { 1170 jTxtWsdlURL.setEditable(true); 1171 jTxtLocalFilename.setText(retriever.getWsdlFileName()); 1172 } 1173 1174 descriptorPanel.fireChangeEvent(); 1175 } 1176 1177 private static class WsdlFileFilter extends FileFilter { 1178 public boolean accept(File f) { 1179 boolean result; 1180 if(f.isDirectory() || "wsdl".equalsIgnoreCase(FileUtil.getExtension(f.getName()))) { result = true; 1182 } else { 1183 result = false; 1184 } 1185 return result; 1186 } 1187 1188 public String getDescription() { 1189 return NbBundle.getMessage(ClientInfo.class, "LBL_WsdlFilterDescription"); } 1191 } 1192 1193 1194 1196 private int resolveImports(File file) { 1197 try { 1198 SAXParserFactory factory = SAXParserFactory.newInstance(); 1199 factory.setNamespaceAware(true); 1200 SAXParser saxParser = factory.newSAXParser(); 1201 ImportsHandler handler= new ImportsHandler(); 1202 saxParser.parse(new InputSource (new FileInputStream (file)), handler); 1203 int httpImport = (handler.isHttpImport()?1:0); 1204 int wsdlImport = (handler.isImportingWsdl()?1:0); 1205 return httpImport*2+wsdlImport; 1206 } catch(ParserConfigurationException ex) { 1207 } catch(SAXException ex) { 1209 } catch(IOException ex) { 1211 } 1213 return 0; 1214 } 1215 1216 1218 private static class ImportsHandler extends DefaultHandler { 1219 1220 private static final String W3C_WSDL_SCHEMA = "http://schemas.xmlsoap.org/wsdl"; private static final String W3C_WSDL_SCHEMA_SLASH = "http://schemas.xmlsoap.org/wsdl/"; 1223 private boolean insideSchema; 1224 private boolean httpImport; 1225 private boolean importingWsdl; 1226 1227 public void startElement(String uri, String localname, String qname, Attributes attributes) throws SAXException { 1228 if(W3C_WSDL_SCHEMA.equals(uri) || W3C_WSDL_SCHEMA_SLASH.equals(uri)) { 1229 if("types".equals(localname)) { insideSchema=true; 1231 } 1232 if("import".equals(localname)) { String wsdlLocation = attributes.getValue("location"); if (wsdlLocation!=null && wsdlLocation.startsWith("http://")) { httpImport=true; 1237 importingWsdl=true; 1238 } 1239 } 1240 } 1241 1242 if(insideSchema && "import".equals(localname)) { String schemaLocation = attributes.getValue("schemaLocation"); if (schemaLocation!=null && schemaLocation.startsWith("http://")) httpImport=true; 1247 } 1248 } 1249 1250 public void endElement(String uri, String localname, String qname) throws SAXException { 1251 if(W3C_WSDL_SCHEMA.equals(uri) || W3C_WSDL_SCHEMA_SLASH.equals(uri)) { 1252 if("types".equals(localname)) { insideSchema=false; 1254 } 1255 } 1256 } 1257 1258 boolean isHttpImport() { 1259 return httpImport; 1260 } 1261 1262 boolean isImportingWsdl() { 1263 return importingWsdl; 1264 } 1265 } 1266 1267 private String browseProjectServices() { 1268 JaxWsExplorerPanel explorerPanel = new JaxWsExplorerPanel(); 1269 DialogDescriptor descriptor = new DialogDescriptor(explorerPanel, 1270 NbBundle.getMessage(ClientInfo.class,"TTL_SelectService")); explorerPanel.setDescriptor(descriptor); 1272 if(DialogDisplayer.getDefault().notify(descriptor).equals(NotifyDescriptor.OK_OPTION)) { 1273 Node serviceNode = explorerPanel.getSelectedService(); 1274 JaxWsWsdlCookie wsdlCookie = (JaxWsWsdlCookie)serviceNode.getCookie(JaxWsWsdlCookie.class); 1275 if (wsdlCookie!=null) return wsdlCookie.getWsdlURL(); 1276 else { 1277 } 1281 } 1282 return null; 1283 } 1284 1285} 1286 | Popular Tags |