1 19 20 package org.netbeans.modules.websvc.core.dev.wizard.design; 21 22 import org.netbeans.modules.websvc.core.dev.wizard.*; 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 import java.io.File ; 26 import java.io.IOException ; 27 import java.net.MalformedURLException ; 28 import java.net.URL ; 29 import java.util.ArrayList ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Map ; 33 import javax.swing.JFileChooser ; 34 import javax.swing.event.ChangeEvent ; 35 import javax.swing.event.ChangeListener ; 36 import javax.swing.event.DocumentEvent ; 37 import javax.swing.event.DocumentListener ; 38 import javax.swing.filechooser.FileFilter ; 39 import javax.xml.parsers.ParserConfigurationException ; 40 import javax.xml.transform.stream.StreamSource ; 41 import org.netbeans.api.project.Project; 42 import org.netbeans.modules.j2ee.common.Util; 43 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 44 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 45 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModel; 46 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModelListener; 47 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModeler; 48 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlModelerFactory; 49 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlPort; 50 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlService; 51 import org.netbeans.modules.websvc.core.dev.wizard.nodes.WsdlNode; 52 import org.netbeans.modules.websvc.jaxws.api.JAXWSSupport; 53 import org.netbeans.modules.websvc.jaxws.api.WsdlWrapperGenerator; 54 import org.netbeans.modules.websvc.jaxws.api.WsdlWrapperHandler; 55 import org.openide.DialogDescriptor; 56 import org.openide.DialogDisplayer; 57 import org.openide.ErrorManager; 58 import org.openide.NotifyDescriptor; 59 import org.openide.WizardDescriptor; 60 import org.openide.filesystems.FileObject; 61 import org.openide.filesystems.FileUtil; 62 import org.openide.nodes.Node; 63 import org.openide.util.HelpCtx; 64 import org.openide.util.NbBundle; 65 import org.openide.util.RequestProcessor; 66 import org.xml.sax.SAXException ; 67 68 72 public class WSDesignFromWSDLPanel extends javax.swing.JPanel implements HelpCtx.Provider, DocumentListener { 73 74 private final List <ChangeListener > listeners = new ArrayList <ChangeListener >(); 75 private static String previousDirectory = ""; 76 private final FileFilter WSDL_FILE_FILTER = new WsdlFileFilter(); 77 private boolean isWaitingForScan = false; 78 79 private WsdlModeler wsdlModeler; 80 private WsdlModel wsdlModel; 81 private WsdlService service; 82 private WsdlPort port; 83 private WsdlServiceHandler wsdlServiceHandler; 84 private Project project; 85 private WizardDescriptor wizardDescriptor; 86 87 private JAXWSSupport wss; 88 private boolean jsr109Supported; 89 private boolean jsr109oldSupported; 90 private boolean jwsdpSupported; 91 92 private RequestProcessor.Task generateWsdlModelTask; 93 private URL wsdlURL; 94 95 96 public WSDesignFromWSDLPanel(Project project) { 97 this.project = project; 98 initComponents(); 99 initJsr109Info(); 100 101 jTextFieldWSDLFile.getDocument().addDocumentListener(this); 102 103 generateWsdlModelTask = RequestProcessor.getDefault().create(new Runnable () { 104 public void run() { 105 106 WsdlWrapperHandler handler = null; 107 try { 108 handler=WsdlWrapperGenerator.parse(wsdlURL.toExternalForm()); 109 } catch (ParserConfigurationException ex) { 110 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex); 111 } catch (SAXException ex) { 112 String mes = NbBundle.getMessage(WebServiceFromWSDLPanel.class, "ERR_SAXException", ex.getLocalizedMessage()); NotifyDescriptor desc = new NotifyDescriptor.Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); 114 DialogDisplayer.getDefault().notify(desc); 115 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex); 116 } catch (IOException ex) { 117 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex); 118 } 119 if (handler!=null && !handler.isServiceElement()) { 120 StreamSource source = new StreamSource (wsdlURL.toExternalForm()); 121 try { 122 File wsdlFile = new File (System.getProperty("java.io.tmpdir"), WsdlWrapperGenerator.getWrapperName(wsdlURL)); 124 if(!wsdlFile.exists()) { 125 try { 126 wsdlFile.createNewFile(); 127 } catch(IOException ex) { 128 String mes = NbBundle.getMessage(WebServiceFromWSDLPanel.class, "ERR_UnableToCreateTempFile", wsdlFile.getPath()); NotifyDescriptor desc = new NotifyDescriptor.Message(mes, NotifyDescriptor.Message.ERROR_MESSAGE); 130 DialogDisplayer.getDefault().notify(desc); 131 return; 132 } 133 } 134 WsdlWrapperGenerator.generateWrapperWSDLContent(wsdlFile,source,handler.getTargetNsPrefix(),wsdlURL.toExternalForm()); 135 wsdlURL=wsdlFile.toURL(); 136 } catch (IOException ex) { 137 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL,ex); 138 } 139 } 140 141 final WsdlWrapperHandler wsdlHandler = handler; 142 143 wsdlModeler = WsdlModelerFactory.getDefault().getWsdlModeler(wsdlURL); 144 wsdlModeler.generateWsdlModel(new WsdlModelListener() { 145 public void modelCreated(WsdlModel model) { 146 wsdlModel=model; 147 if (wsdlModel==null) { 148 String serviceName=null; 149 String portName=null; 150 try { 151 wsdlServiceHandler = WsdlServiceHandler.parse(wsdlURL.toExternalForm()); 152 serviceName = wsdlServiceHandler.getServiceName(); 153 portName = wsdlServiceHandler.getPortName(); 154 } catch (ParserConfigurationException ex) { 155 } catch (SAXException ex) { 156 } catch (IOException ex) {} 157 if (serviceName!=null && portName!=null) { 158 jTextFieldPort.setText(serviceName + "#" + portName); 159 } else { 160 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message( 161 NbBundle.getMessage(WebServiceFromWSDLPanel.class,"TXT_CannotGenerateService", 162 wsdlModeler.getCreationException().getLocalizedMessage()), 163 NotifyDescriptor.WARNING_MESSAGE) 164 ); 165 } 166 } else { 167 jButtonBrowsePort.setEnabled(true); 168 List services = wsdlModel.getServices(); 169 if (services != null && services.size() > 0) { 170 service = (WsdlService) services.get(0); 171 List ports = service.getPorts(); 172 if (ports != null && ports.size() > 0) 173 port = (WsdlPort) ports.get(0); 174 } 175 } 176 177 if (service != null && port != null) { 178 jTextFieldPort.setText(service.getName() + "#" + port.getName()); if (wsdlHandler!=null) { 180 String bindingType = wsdlHandler.getBindingTypeForPort(port.getName()); 181 if (bindingType!=null) port.setSOAPVersion(bindingType); 182 } 183 } 184 185 fireChange(); } 187 }); 188 } 189 }); 190 } 191 192 197 private void initComponents() { 199 200 jLabelWSDLFile = new javax.swing.JLabel (); 201 jTextFieldWSDLFile = new javax.swing.JTextField (); 202 jButtonWSDLFileBrowse = new javax.swing.JButton (); 203 jLabelPortDescription = new javax.swing.JLabel (); 204 jLabelPort = new javax.swing.JLabel (); 205 jTextFieldPort = new javax.swing.JTextField (); 206 jButtonBrowsePort = new javax.swing.JButton (); 207 fromWsdlCB = new javax.swing.JCheckBox (); 208 209 jLabelWSDLFile.setDisplayedMnemonic(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("MNE_WSDL_File").charAt(0)); 210 jLabelWSDLFile.setLabelFor(jTextFieldWSDLFile); 211 jLabelWSDLFile.setText(org.openide.util.NbBundle.getMessage(WSDesignFromWSDLPanel.class, "LBL_WSDL_File")); 213 jButtonWSDLFileBrowse.setMnemonic(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("MNE_Browse").charAt(0)); 214 jButtonWSDLFileBrowse.setText(org.openide.util.NbBundle.getMessage(WSDesignFromWSDLPanel.class, "LBL_Browse")); jButtonWSDLFileBrowse.addActionListener(new java.awt.event.ActionListener () { 216 public void actionPerformed(java.awt.event.ActionEvent evt) { 217 jButtonWSDLFileBrowseActionPerformed(evt); 218 } 219 }); 220 221 jLabelPortDescription.setText(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("LBL_PortMessage")); 223 jLabelPort.setDisplayedMnemonic(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("MNE_WebServicePort").charAt(0)); 224 jLabelPort.setLabelFor(jTextFieldPort); 225 jLabelPort.setText(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("LBL_WebServicePort")); 227 jTextFieldPort.setEditable(false); 228 229 jButtonBrowsePort.setMnemonic(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("MNE_BrowsePort").charAt(0)); 230 jButtonBrowsePort.setText(org.openide.util.NbBundle.getBundle(WSDesignFromWSDLPanel.class).getString("LBL_Browse")); jButtonBrowsePort.setEnabled(false); 232 jButtonBrowsePort.addActionListener(new java.awt.event.ActionListener () { 233 public void actionPerformed(java.awt.event.ActionEvent evt) { 234 jButtonBrowsePortActionPerformed(evt); 235 } 236 }); 237 238 fromWsdlCB.setSelected(true); 239 fromWsdlCB.setText(org.openide.util.NbBundle.getMessage(WSDesignFromWSDLPanel.class, "CB_Create_from_WSDL")); fromWsdlCB.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 241 fromWsdlCB.setMargin(new java.awt.Insets (0, 0, 0, 0)); 242 fromWsdlCB.addActionListener(new java.awt.event.ActionListener () { 243 public void actionPerformed(java.awt.event.ActionEvent evt) { 244 fromWsdlCBActionPerformed(evt); 245 } 246 }); 247 248 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); 249 this.setLayout(layout); 250 layout.setHorizontalGroup( 251 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 252 .add(layout.createSequentialGroup() 253 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 254 .add(layout.createSequentialGroup() 255 .addContainerGap() 256 .add(jLabelPortDescription)) 257 .add(layout.createSequentialGroup() 258 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 259 .add(jLabelPort) 260 .add(layout.createSequentialGroup() 261 .addContainerGap() 262 .add(jLabelWSDLFile)) 263 .add(layout.createSequentialGroup() 264 .addContainerGap() 265 .add(fromWsdlCB))) 266 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 267 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 268 .add(layout.createSequentialGroup() 269 .add(jTextFieldWSDLFile, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE) 270 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 271 .add(jButtonWSDLFileBrowse)) 272 .add(layout.createSequentialGroup() 273 .add(jTextFieldPort, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 575, Short.MAX_VALUE) 274 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) 275 .add(jButtonBrowsePort, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))))) 276 .addContainerGap()) 277 ); 278 layout.setVerticalGroup( 279 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) 280 .add(layout.createSequentialGroup() 281 .add(20, 20, 20) 282 .add(fromWsdlCB) 283 .add(18, 18, 18) 284 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 285 .add(jButtonWSDLFileBrowse) 286 .add(jTextFieldWSDLFile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) 287 .add(jLabelWSDLFile)) 288 .add(16, 16, 16) 289 .add(jLabelPortDescription) 290 .add(17, 17, 17) 291 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) 292 .add(jLabelPort) 293 .add(jButtonBrowsePort) 294 .add(jTextFieldPort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) 295 .addContainerGap(149, Short.MAX_VALUE)) 296 ); 297 298 jTextFieldWSDLFile.getAccessibleContext().setAccessibleDescription(null); 299 jButtonWSDLFileBrowse.getAccessibleContext().setAccessibleDescription(null); 300 jTextFieldPort.getAccessibleContext().setAccessibleDescription(null); 301 } 303 private void fromWsdlCBActionPerformed(java.awt.event.ActionEvent evt) { boolean enabled = this.fromWsdlCB.isSelected(); 305 this.enableWidgets(enabled); 306 } 308 private void jButtonBrowsePortActionPerformed(java.awt.event.ActionEvent evt) { Node root = new WsdlNode(wsdlModel); 310 PortChooser chooser = new PortChooser(root); 311 final DialogDescriptor dd = new DialogDescriptor(chooser, org.openide.util.NbBundle.getMessage(WebServiceFromWSDLPanel.class, "LBL_SelectPortDescription")); 313 chooser.addPropertyChangeListener(new PropertyChangeListener () { 314 public void propertyChange(PropertyChangeEvent evt) { 315 if (evt.getPropertyName().equals(PortChooser.IS_VALID)) { 316 Object newvalue = evt.getNewValue(); 317 if ((newvalue != null) && (newvalue instanceof Boolean )) { 318 dd.setValid(((Boolean ) newvalue).booleanValue()); 319 } 320 } 321 } 322 }); 323 324 Object result = DialogDisplayer.getDefault().notify(dd); 325 326 if (result == DialogDescriptor.OK_OPTION) { 327 if (Util.isJavaEE5orHigher(project) || 328 (!jsr109Supported && !jsr109oldSupported || 329 (!jsr109Supported && jsr109oldSupported && jwsdpSupported ))) { 330 jTextFieldPort.setText(chooser.getSelectedPortOwnerName() + "#" + chooser.getSelectedNodes()[0].getDisplayName()); service = wsdlModel.getServiceByName(chooser.getSelectedPortOwnerName()); 332 port = service.getPortByName(chooser.getSelectedNodes()[0].getDisplayName()); 333 } 334 } 335 } 337 private void jButtonWSDLFileBrowseActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser (previousDirectory); 339 chooser.setMultiSelectionEnabled(false); 340 chooser.setAcceptAllFileFilterUsed(false); 341 chooser.addChoosableFileFilter(WSDL_FILE_FILTER); 342 chooser.setFileFilter(WSDL_FILE_FILTER); 343 344 if(chooser.showOpenDialog(WSDesignFromWSDLPanel.this) == JFileChooser.APPROVE_OPTION) { 345 File wsdlFile = chooser.getSelectedFile(); 346 jTextFieldWSDLFile.setText(wsdlFile.getAbsolutePath()); 347 previousDirectory = wsdlFile.getPath(); 348 } 349 } 351 352 private javax.swing.JCheckBox fromWsdlCB; 354 private javax.swing.JButton jButtonBrowsePort; 355 private javax.swing.JButton jButtonWSDLFileBrowse; 356 private javax.swing.JLabel jLabelPort; 357 private javax.swing.JLabel jLabelPortDescription; 358 private javax.swing.JLabel jLabelWSDLFile; 359 private javax.swing.JTextField jTextFieldPort; 360 private javax.swing.JTextField jTextFieldWSDLFile; 361 363 void validate(WizardDescriptor wizardDescriptor) { 364 } 365 366 private void initJsr109Info() { 367 wss = JAXWSSupport.getJAXWSSupport(project.getProjectDirectory()); 368 if (wss != null) { 369 Map properties = wss.getAntProjectHelper().getStandardPropertyEvaluator().getProperties(); 370 String serverInstance = (String )properties.get("j2ee.server.instance"); if (serverInstance != null) { 372 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstance); 373 if (j2eePlatform != null) { 374 jsr109Supported = j2eePlatform.isToolSupported(J2eePlatform.TOOL_JSR109); 375 jsr109oldSupported = j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSCOMPILE); 376 jwsdpSupported = j2eePlatform.isToolSupported(J2eePlatform.TOOL_JWSDP); 377 } 378 } 379 } 380 } 381 382 386 private boolean checkNonJsr109Valid() { 387 if (wss != null) { 388 if(!jsr109Supported && !jsr109oldSupported || 389 (!jsr109Supported && jsr109oldSupported && jwsdpSupported )){ 390 if (Util.isSourceLevel14orLower(project)) { 391 wizardDescriptor.putProperty("WizardPanel_errorMessage", 392 NbBundle.getMessage(WebServiceFromWSDLPanel.class, "ERR_NeedProperSourceLevel")); return false; 394 } 395 } 396 } 397 return true; 398 } 399 400 private boolean projectHasEmbeddedSpaces(){ 401 FileObject projectDir = project.getProjectDirectory(); 402 File projectDirFile = FileUtil.toFile(projectDir); 403 String path = projectDirFile.getAbsolutePath(); 404 int index = path.indexOf(" "); 405 return index != -1; 406 } 407 408 boolean isValid(WizardDescriptor wizardDescriptor) { 409 if(!checkNonJsr109Valid()){ 411 return false; 412 } 413 414 String wsdlFilePath = jTextFieldWSDLFile.getText().trim(); 415 416 if(wsdlFilePath == null || wsdlFilePath.length() == 0) { 417 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "MSG_EnterWsdlName")); return false; } 421 422 File f = new File (wsdlFilePath); 423 String wsdlFileText = f.getAbsolutePath(); 424 f = getCanonicalFile(f); 425 if(f == null) { 426 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "ERR_WsdlInvalid")); return false; } 430 431 if(!f.exists()) { 432 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "ERR_WsdlDoesNotExist")); return false; } 436 437 if (Util.isJavaEE5orHigher(project) || 438 (!jsr109Supported && !jsr109oldSupported || 439 (!jsr109Supported && jsr109oldSupported && jwsdpSupported ))) { 440 if (wsdlModel != null) { 441 if (service == null) { 442 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "MSG_NoService")); return false; 444 } 445 446 if (port == null) { 447 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "MSG_NoPort")); return false; 449 } 450 } else { 451 if (wsdlServiceHandler!=null && wsdlServiceHandler.getServiceName()!=null && wsdlServiceHandler.getPortName()!=null) { 452 return true; 453 } else { 454 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(WebServiceFromWSDLPanel.class, "MSG_NoPort")); return false; 456 } 457 } 458 } 459 460 if(projectHasEmbeddedSpaces()){ 463 wizardDescriptor.putProperty("WizardPanel_errorMessage", 464 NbBundle.getMessage(WebServiceFromWSDLPanel.class, "MSG_SPACE_IN_PROJECT_PATH")); } else{ 466 wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); } 468 wizardDescriptor.putProperty("WizardPanel_errorMessage", ""); 485 return true; 486 } 487 488 void store(WizardDescriptor d) { 489 d.putProperty(WizardProperties.WEB_SERVICE_TYPE, getServiceType()); 490 d.putProperty(WizardProperties.WSDL_FILE_PATH, jTextFieldWSDLFile.getText().trim()); 491 d.putProperty(WizardProperties.WSDL_MODEL, wsdlModel); 492 d.putProperty(WizardProperties.WSDL_MODELER, wsdlModeler); 493 d.putProperty(WizardProperties.WSDL_SERVICE, service); 494 d.putProperty(WizardProperties.WSDL_PORT, port); 495 d.putProperty(WizardProperties.WSDL_SERVICE_HANDLER,wsdlServiceHandler); 496 } 497 498 public int getServiceType() { 499 if (!this.fromWsdlCB.isSelected()) 500 return WizardProperties.FROM_SCRATCH; 501 else 502 return -1; } 504 505 void read(WizardDescriptor wizardDescriptor) { 506 this.wizardDescriptor = wizardDescriptor; 507 } 508 509 public HelpCtx getHelpCtx() { 510 return new HelpCtx(WebServiceFromWSDLPanel.class); 511 } 512 513 public void addChangeListener(ChangeListener l) { 514 listeners.add(l); 515 } 516 517 public void removeChangeListener(ChangeListener l) { 518 listeners.remove(l); 519 } 520 521 private void fireChange() { 522 ChangeEvent e = new ChangeEvent (this); 523 Iterator <ChangeListener > it = listeners.iterator(); 524 while (it.hasNext()) { 525 it.next().stateChanged(e); 526 } 527 } 528 529 private void updatePortBrowseButton() { 530 wsdlModel = null; 531 service = null; 532 port = null; 533 jTextFieldPort.setText(""); 535 String wsdlFilePath = jTextFieldWSDLFile.getText().trim(); 536 537 if(wsdlFilePath == null || wsdlFilePath.length() == 0) { 538 jButtonBrowsePort.setEnabled(false); 539 } else { 540 File f = new File (wsdlFilePath); 541 String wsdlFileText = f.getAbsolutePath(); 542 f = getCanonicalFile(f); 543 if(f == null) { 544 jButtonBrowsePort.setEnabled(false); 545 } else if(!f.exists()) { 546 jButtonBrowsePort.setEnabled(false); 547 } else { 548 fireChange(); if (Util.isJavaEE5orHigher(project) || 550 (!jsr109Supported && !jsr109oldSupported || 551 (!jsr109Supported && jsr109oldSupported && jwsdpSupported))) { 552 createModel(); 553 } 554 } 555 } 556 } 557 558 private void createModel() { 559 File normalizedWsdlFilePath = FileUtil.normalizeFile(new File (jTextFieldWSDLFile.getText().trim())); 560 wsdlURL = null; 561 try { 562 wsdlURL = normalizedWsdlFilePath.toURL(); 563 } catch (MalformedURLException ex) { 564 ex.printStackTrace(); 565 } 566 567 generateWsdlModelTask.schedule(1000); 568 } 569 570 public void insertUpdate(DocumentEvent e) { 571 updatePortBrowseButton(); 572 fireChange(); 573 } 574 575 public void removeUpdate(DocumentEvent e) { 576 updatePortBrowseButton(); 577 fireChange(); 578 } 579 580 public void changedUpdate(DocumentEvent e) { 581 updatePortBrowseButton(); 582 fireChange(); 583 } 584 585 590 public static File getCanonicalFile(File f) { 591 File f1; 592 try { 593 f1 = f.getCanonicalFile(); 594 } catch (java.io.IOException e) { 595 f1 = null; 596 } 597 return f1; 598 } 599 600 private static class WsdlFileFilter extends FileFilter { 601 public boolean accept(File f) { 602 boolean result; 603 if(f.isDirectory() || "wsdl".equalsIgnoreCase(FileUtil.getExtension(f.getName()))) { result = true; 605 } else { 606 result = false; 607 } 608 return result; 609 } 610 611 public String getDescription() { 612 return NbBundle.getMessage(WebServiceFromWSDLPanel.class, "LBL_WsdlFilterDescription"); } 614 } 615 616 private void enableWidgets(boolean enable){ 617 this.jButtonBrowsePort.setEnabled(enable); 618 this.jButtonWSDLFileBrowse.setEnabled(enable); 619 this.jLabelPort.setEnabled(enable); 620 this.jLabelPortDescription.setEnabled(enable); 621 this.jLabelWSDLFile.setEnabled(enable); 622 this.jTextFieldPort.setEnabled(enable); 623 this.jTextFieldWSDLFile.setEnabled(enable); 624 } 625 } 626 | Popular Tags |