KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > registry > nodes > WebServicePaletteItem


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.registry.nodes;
21
22 //import com.sun.beans2.live.LiveBean;
23
//import com.sun.rave.palette.BeanPaletteItem;
24
//import com.sun.rave.project.ProjectManager;
25
//import com.sun.rave.project.BuildCookie;
26
//import com.sun.rave.project.model.GenericFolder;
27
//import com.sun.rave.project.model.Portfolio;
28
//import com.sun.rave.project.model.Project;
29
//import com.sun.rave.project.model.LibraryReference;
30
//import com.sun.rave.project.model.SymbolicPath;
31
//import com.sun.rave.project.model.WebAppProject;
32
//import com.sun.rave.project.model.Reference;
33
//import com.sun.rave.project.model.SymbolicPath;
34
//import org.netbeans.modules.websvc.registry.jaxrpc.Wsdl2Java;
35
import org.netbeans.modules.websvc.registry.model.WebServiceData;
36 //import org.netbeans.modules.websvc.registry.util.DebugMonitor;
37
//import org.netbeans.modules.websvc.registry.util.JarUtil;
38
//import org.netbeans.modules.websvc.registry.util.WebProxySetter;
39
//import org.netbeans.modules.websvc.registry.util.Util;
40
//import com.sun.xml.rpc.util.JavaCompilerHelper;
41
import java.io.*;
42 //import java.net.URL;
43
//import java.net.MalformedURLException;
44
//import java.net.URLClassLoader;
45
//import java.util.Date;
46
//import java.util.ArrayList;
47
import javax.swing.ImageIcon JavaDoc;
48 //import org.netbeans.modules.editor.java.JCUpdater;
49
//import org.openide.ErrorManager;
50
//import org.openide.awt.StatusDisplayer;
51
//import org.openide.compiler.CompilerJob;
52
//import org.openide.compiler.Compiler;
53
//import org.openide.cookies.CompilerCookie;
54
//import org.openide.filesystems.FileLock;
55
//import org.openide.filesystems.FileObject;
56
//import org.openide.filesystems.FileUtil;
57
//import org.openide.filesystems.FileStateInvalidException;
58
//import org.openide.loaders.DataObject;
59
//import org.openide.util.NbBundle;
60
//import org.openide.util.RequestProcessor;
61
//import org.openide.DialogDescriptor;
62
//import org.openide.DialogDisplayer;
63
//import org.openide.NotifyDescriptor;
64
//import org.openide.windows.TopComponent;
65
//import com.sun.rave.designer.DesignerTopComp;
66
//import org.openide.nodes.Node;
67

68 // FIXME NEW AFTER COPY-PASTE FROM RAVE
69
import java.awt.datatransfer.Transferable JavaDoc;
70 import java.awt.datatransfer.DataFlavor JavaDoc;
71 import java.awt.datatransfer.UnsupportedFlavorException JavaDoc;
72
73 /**
74  * Construct a palette like item to drag and drop the webservices on to the web designer
75  *
76  * @author Winston Prakash
77  */

78 public class WebServicePaletteItem implements Transferable JavaDoc { // FIXME COPY-PASTE FROM RAVE extends BeanPaletteItem {
79
private String JavaDoc proxyName;
80     private String JavaDoc wsdlFileName;
81     private String JavaDoc wsdlFileNameExt = "wsdl";
82
83     private WebServiceData data;
84
85     public final static String JavaDoc WEB_SERVICE_PREFIX = "Web Service - ";
86     public final static String JavaDoc WEB_SERVICE_REFERENCE_NODE="Web Service Support";
87
88     public WebServicePaletteItem(WebServiceData data) {
89 // super(null, null, new ImageIcon("org/netbeans/modules/websvc/registry/resources/webservice.png"));
90
this.data = data;
91         String JavaDoc wsName = data.getName();
92         wsdlFileName = wsName.substring(wsName.lastIndexOf('.') + 1, wsName.length());
93         proxyName = data.getProxy();
94     }
95
96 // public void annotateCreate(LiveBean liveBean) {
97
// // NOP
98
// }
99
//
100
// /**
101
// * Overriding to tell the Designer which class to create
102
// */
103
// public String getBeanClassName() {
104
// return getWebServiceProxyBean();
105
// }
106
//
107
// /**
108
// * This method will get the first project found from the Project Manager.
109
// */
110
// public Project getProject(){
111
// ProjectManager pMgr = ProjectManager.getDefault();
112
// Portfolio folio = pMgr.getPortfolio();
113
// if (folio != null) {
114
// Project[] projects = folio.getProjects();
115
// if (projects.length > 0) {
116
// if ((projects[0] instanceof WebAppProject)) {
117
// return projects[0];
118
// }else{
119
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(WebServicesNode.class, NbBundle.getMessage(WebServicePaletteItem.class, "INCORRECT_PROJECT")),2);
120
// }
121
// } else {
122
// DebugMonitor.println(NbBundle.getMessage(WebServicePaletteItem.class, "EMPTY_PORTFOLIO"));
123
// }
124
// } else {
125
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(WebServicesNode.class, NbBundle.getMessage(WebServicePaletteItem.class, "EMPTY_PORTFOLIO_ERROR")),2);
126
// }
127
// return null;
128
// }
129
//
130
// /** When the user drags and drop the webservice on to the designer, designer requires the class name of a
131
// * bean to create necessary code using insync.
132
// * Steps - Get the project to which the designer belongs to (currently project[0] is used - XXXX
133
// * Get the backing folder of the project
134
// * Copy the webservice client jar to the Portfolio Manager "References" node.
135
// * Extract the webservice wrapper client, the webservice icon file, and webservice
136
// * beaninfo from the webservice client jar
137
// * Copy the webservice wrapper client, the webservice icon file, and webservice
138
// * beaninfo to the backing folder
139
// * Change the webservice wrapper client and beaninfo package names to match the project package names
140
// * Return the wrapper client as a bean to designer.
141
// *
142
// * Note- for TP stabilization, instead of copying to the "reference" node, extract the jar to the project path and change the
143
// * package names.
144
// *
145
// * Rewritten 2/19/2004 by David Botterill
146
// */
147
// public String getWebServiceProxyBean(){
148
// FileObject wsdlFileObject = null;
149
// FileObject proxyFileObject = null;
150
//
151
// WebAppProject webAppProject = (WebAppProject)getProject();
152
//
153
// /**
154
// * Get the FileObject for the target folder for the web service client wrapper and beaninfo
155
// */
156
// FileObject clientWrapperTargetFolderObject = this.getClientWrapperFolder(webAppProject);
157
//
158
// File clientWrapperTargetFolderFile = FileUtil.toFile(clientWrapperTargetFolderObject);
159
//
160
//
161
// if(null == clientWrapperTargetFolderFile) {
162
// /**
163
// * just return, the method that created the File is responsible for logging why
164
// * the file is null.
165
// */
166
// return null;
167
// }
168
//
169
// /**
170
// * Form the Web Service client name
171
// */
172
//
173
// String displayName = data.getDisplayName();
174
// if(null == displayName) {
175
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_NO_WSNAME"));
176
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"),2);
177
// return null;
178
// }
179
// String webServiceClientPkgName = data.getPackageName();
180
//
181
// String webServiceClientDisplayName = displayName.substring(displayName.lastIndexOf('.') + 1, displayName.length()) + "Client";
182
// String webServiceClientFullName = webServiceClientPkgName + "." + webServiceClientDisplayName;
183
//
184
//
185
// /**
186
// * If the web service client has already been added to the page, display a dialog and return null.
187
// */
188
// if (isWebServiceInPage(displayName)) {
189
//
190
// String msg = data.getDisplayName() + " " + NbBundle.getMessage(this.getClass(), "WS_EXISTS_ERROR");
191
// NotifyDescriptor d = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
192
// DialogDisplayer.getDefault().notify(d);
193
//
194
// return null;
195
// }
196
// /**
197
// * If the web service client has already been added to the project, simply return the webservice name;
198
// */
199
// if (isWebServiceInProject(displayName)) {
200
//
201
//
202
// return webServiceClientFullName;
203
// }
204
//
205
//
206
// /**
207
// * Get the FileObject for the web services within the project.
208
// */
209
// FileObject jarTargetFolderObject = this.getProjectSrcFolder(webAppProject);
210
//
211
// if(null == jarTargetFolderObject) {
212
// /**
213
// * just return, the method that created the FileObject is responsible for logging why
214
// * the FileObject is null.
215
// */
216
// return null;
217
// }
218
//
219
//
220
// /**
221
// * Get the jar file name of the web service client.
222
// */
223
// String jarFileName = data.getProxyJarFileName();
224
//
225
// /**
226
// * We should always get back the jar file name at this point. But, if we
227
// * don't, return null, log an error and display a message.
228
// */
229
// if(null == jarFileName) {
230
// /**
231
// * If we are here, the user chose a WSDL URL that was preloaded and the jar doesn't exist.
232
// * So let's create it.
233
// *
234
// */
235
//
236
// jarFileName = System.getProperty("netbeans.user") +"/websvc/" + "webservice" + new Date().getTime() + ".jar";
237
// if(!Util.createWSJar(data,null,jarFileName)) {
238
// /**
239
// * One likely cause is that the HTTP Proxy setting so show a dialog with this hint.
240
// */
241
// String msg = data.getDisplayName() + " " + NbBundle.getMessage(this.getClass(), "WS_WSDL2JAVA_ERROR");
242
// NotifyDescriptor d = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
243
// DialogDisplayer.getDefault().notify(d);
244
//
245
// return null;
246
// }
247
//
248
// }
249
// /**
250
// * create a File reference for the jar file created for the web service client
251
// */
252
//
253
// File jarFile = new File(jarFileName);
254
//
255
// /**
256
// * Add the web service client jar to the Project
257
// */
258
// addJarToProject(displayName,jarFileName);
259
//
260
// /**
261
// * Now copy/change the client wrapper file and beaninfo from the default package to the project package.
262
// */
263
//
264
// // changePackages(jarFile,clientWrapperTargetFolderObject, webServiceClientDisplayName, displayName);
265
//
266
// /**
267
// * Copy the image file for the tray over to the new package.
268
// */
269
// //copyImageToProject(clientWrapperTargetFolderObject);
270
//
271
//
272
// /* For debugging classloader issues
273
// URLClassLoader classLoader = (URLClassLoader)this.getProject().getClassLoader();
274
//
275
// URL [] urls = classLoader.getURLs();
276
//
277
// System.out.println(this.getClass().getName() + "classloader=" + classLoader);
278
//
279
// for(int ii=0; ii < urls.length; ii++) {
280
// System.out.println(this.getClass().getName() + "url[" + ii + "]=" + urls[ii]);
281
// }
282
// */
283
// /*
284
// // Run the Java Auto Complete updater on the Project source folder
285
// // to autocomplete the just added W/S bean and beaninfo files
286
// GenericFolder projectSubFolder = webAppProject.getSrcFolder();
287
// final DataObject projectFolderDataObject = projectSubFolder.getDataObject();
288
// new RequestProcessor().post(new Runnable() {
289
// public void run() {
290
// JCUpdater update = new JCUpdater();
291
// update.processDataObject(projectFolderDataObject, null);
292
// }
293
// });
294
// **/
295
//
296
//
297
// return webServiceClientFullName;
298
// }
299
//
300
// private boolean isWebServiceInPage(String inDisplayName) {
301
// boolean foundNode = false;
302
// TopComponent formView = DesignerTopComp.findCurrent();
303
// if (formView == null) {
304
// return foundNode;
305
// }
306
//
307
// /**
308
// * We need to find out what nodes are displayed in the tray on the designer. The designer shows all
309
// * the activated nodes in the tray.
310
// */
311
// Node [] nodes = formView.getActivatedNodes();
312
//
313
// /**
314
// * go through each node and check if it's a WebServiceNode and it's name matches the Display Name passed in.
315
// **/
316
// for(int ii=0; ii < nodes.length; ii++) {
317
// if(nodes[ii] instanceof WebServicesNode) {
318
// WebServicesNode currentNode = (WebServicesNode)nodes[ii];
319
// if(currentNode.getName().equals(inDisplayName)) {
320
// foundNode = true;
321
// }
322
// }
323
// }
324
//
325
//
326
// return foundNode;
327
//
328
// }
329
//
330
// private boolean isWebServiceInProject(String inDisplayName) {
331
// WebAppProject webAppProject = (WebAppProject)getProject();
332
// Reference [] references = webAppProject.getReferences();
333
// boolean foundReference = false;
334
//
335
// for(int ii=0; ii < references.length; ii++) {
336
// if(references[ii] != null && references[ii].getDisplayName() != null) {
337
// if(references[ii].getDisplayName().equalsIgnoreCase(this.WEB_SERVICE_PREFIX + inDisplayName)) {
338
// foundReference = true;
339
// break;
340
//
341
// }
342
// }
343
// }
344
//
345
// return foundReference;
346
//
347
// }
348
//
349
// /**
350
// * This method will determine where the source folder is for the project.
351
// * exist).
352
// * @return FileObject of the project source code folder representing
353
// * @param inProject The WebAppProject to look in for the web service source code folder.
354
// */
355
// private FileObject getProjectSrcFolder(WebAppProject inProject) {
356
// FileObject returnFileObject = null;
357
// /**
358
// * First we need to get the target project backing folder so we know where to
359
// * copy the web service client source and beaninfo.
360
// */
361
// GenericFolder projectSubFolder = inProject.getSrcFolder();
362
//
363
// /**
364
// * now we need to know the project folder so we can add the webservice folder to it.
365
// */
366
// DataObject projectFolderDataObject = projectSubFolder.getDataObject();
367
//
368
// /**
369
// * Make sure we got a valid DataObject
370
// */
371
// if(projectFolderDataObject == null) {
372
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_NO_DATAOBJ"));
373
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_NO_DATAOBJ"),2);
374
// return null;
375
// }
376
//
377
// returnFileObject = projectFolderDataObject.getPrimaryFile();
378
// /**
379
// * Make sure we have a valid FileObject
380
// */
381
// if (returnFileObject == null) {
382
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_MISSING_PROJECT_FILE"));
383
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_MISSING_PROJECT_FILE"),2);
384
// return null;
385
// }
386
//
387
//
388
// return returnFileObject;
389
// }
390
//
391
//
392
// /**
393
// * This method will determine the folder for the project source code package.
394
// * @param inProject The WebAppProject to look in for the web service source code folder.
395
// * @return FileObject of the web service source code folder representing the package of
396
// * the generated web service source code.
397
// */
398
// private FileObject getClientWrapperFolder(WebAppProject inProject) {
399
//
400
// FileObject returnFileObject = null;
401
// /**
402
// * Get the folder the client wrapper code should go in. This is the same package
403
// * as the rest of the web application.
404
// */
405
// /**
406
// * Now get the folder of the project source.
407
// */
408
// GenericFolder projectSubFolder = inProject.getBackingFolder();
409
//
410
// // assert projectSubFolder != null;
411
// DataObject dObj = projectSubFolder.getDataObject();
412
// /**
413
// * Make sure we got a valid DataObject
414
// */
415
// if(dObj == null) {
416
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_NO_DATAOBJ"));
417
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_NO_DATAOBJ"));
418
// return null;
419
// }
420
//
421
// returnFileObject = dObj.getPrimaryFile();
422
//
423
// /**
424
// * Make sure we have a valid FileObject
425
// */
426
// if (returnFileObject == null) {
427
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_MISSING_PROJECT_FILE"));
428
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_MISSING_PROJECT_FILE"));
429
// return null;
430
// }
431
//
432
//
433
// return returnFileObject;
434
//
435
// }
436
// /**
437
// * This method adds the jar file for the web service client to the project references.
438
// * @param inWebServiceName The web service name to use for the name of the reference
439
// * @param inJarFileName The name of the jar file to add to the project resources.
440
// */
441
// private void addJarToProject(String inWebServiceName, String inJarFileName) {
442
//
443
// Project project = this.getProject();
444
// /**
445
// * Copy the jar file over to the project.
446
// */
447
// String projectAbsPath = project.getAbsolutePath();
448
// String projectDataRoot = project.getProjectDataRoot();
449
//
450
// File webservicesDataDir = new File(projectAbsPath + File.separator + projectDataRoot + File.separator + "webservice_clients");
451
// /**
452
// * Make sure the directory exists.
453
// */
454
// if(!webservicesDataDir.exists()) {
455
// webservicesDataDir.mkdir();
456
// }
457
//
458
// /**
459
// * strip any leading path information off.
460
// */
461
// String newJarFileName = null;
462
//
463
// newJarFileName = inJarFileName;
464
//
465
// if(newJarFileName.indexOf("/") != -1) {
466
// newJarFileName = inJarFileName.substring(inJarFileName.lastIndexOf("/")+1);
467
// }
468
// if(newJarFileName.indexOf("\\") != -1) {
469
// newJarFileName = inJarFileName.substring(inJarFileName.lastIndexOf("\\")+1);
470
// }
471
//
472
// File newJarFile = new File(webservicesDataDir.getAbsolutePath(),newJarFileName);
473
//
474
// File oldJarFile = new File(inJarFileName);
475
//
476
// try {
477
// FileOutputStream outStream = new FileOutputStream(newJarFile);
478
// DataInputStream in = new DataInputStream(new FileInputStream(oldJarFile));
479
// DataOutputStream out = new DataOutputStream(outStream);
480
//
481
// byte[] bytes = new byte[1024];
482
// int byteCount = in.read(bytes);
483
//
484
// while ( byteCount > -1 ) {
485
// out.write( bytes, 0, byteCount );
486
// byteCount = in.read(bytes);
487
// }
488
// out.flush();
489
// out.close();
490
// outStream.close();
491
// in.close();
492
//
493
// } catch (IOException ioe) {
494
// ErrorManager.getDefault().notify(ioe);
495
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(WebServicesNode.class, "JAR_COPY_ERROR"),2);
496
// return;
497
// }
498
//
499
// /**
500
// * Create the library reference to add to the project.
501
// */
502
// LibraryReference libraryRef = new LibraryReference(this.WEB_SERVICE_PREFIX + inWebServiceName,project);
503
// /**
504
// * Setting the DisplayName important because we are going to use this to get the reference for this jar later.
505
// */
506
// libraryRef.setDisplayName(this.WEB_SERVICE_PREFIX + inWebServiceName);
507
//
508
// /**
509
// * Specify where the definition file will live for this reference.
510
// */
511
// libraryRef.setSymbolicPath(new SymbolicPath("{project.home}/project-data/lib/references/" + inWebServiceName + ".xml"));
512
//
513
// /**
514
// * Specify the path to the web services client jar file.
515
// */
516
// SymbolicPath jarPath = new SymbolicPath("{project.home}/project-data/webservice_clients/" + newJarFileName);
517
//
518
// /**
519
// * Tell the project what actions to take with this library reference
520
// */
521
// libraryRef.addPathAction(jarPath, LibraryReference.ACTION_CLASSPATH);
522
// libraryRef.addPathAction(jarPath, LibraryReference.ACTION_COPY);
523
//
524
//
525
// /**
526
// * Add the path to the reference.
527
// */
528
// libraryRef.addClassPath(jarPath);
529
//
530
// /**
531
// * Add the reference to the project.
532
// */
533
// project.addReference(libraryRef);
534
//
535
//
536
//
537
// }
538
//
539
//
540
//
541
//
542
// /**
543
// * This method will extract the web service client files to the correct project directory
544
// * changing the package statements in the process. This method will also compile the new
545
// * java files putting the classes in the same directory that the java files were copied.
546
// * @param inJarFile The jar file to extract the web service client files from
547
// * @param toPackage the FileObject to copy the web service client files to
548
// * @param webServiceClientName The java name of the web service client
549
// * @param shortWSName the web service name given to the element within Creator, the same names that
550
// * shows up in the Server Navigator
551
// */
552
// private void changePackages(File inJarFile, FileObject toPackage,String webServiceClientName, String displayName) {
553
// FileObject newClientJavaObject = null;
554
// FileObject oldClientJavaObject = null;
555
// FileObject newClientBeanInfoJavaObject = null;
556
// FileObject oldClientBeanInfoJavaObject = null;
557
//
558
// /**
559
// * Get the name of the package where the client code will be copied to.
560
// */
561
// String toPackageName = toPackage.getPackageName('.');
562
//
563
// JarUtil jarUtil = new JarUtil(inJarFile);
564
//
565
// String wsClientJarFilename = Wsdl2Java.DEFAULT_TARGET_PACKAGE + "/" + webServiceClientName + ".java";
566
// String wsClientBeanInfoJarFilename = Wsdl2Java.DEFAULT_TARGET_PACKAGE + "/" + webServiceClientName + "BeanInfo.java";
567
//
568
// try {
569
// newClientJavaObject = toPackage.createData(webServiceClientName,"java");
570
// }catch(IOException ioe){
571
// ErrorManager.getDefault().notify(ioe);
572
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"));
573
// }
574
//
575
// try{
576
//
577
// PrintWriter out = new PrintWriter(newClientJavaObject.getOutputStream(newClientJavaObject.lock()));
578
// BufferedReader in = jarUtil.openFile(wsClientJarFilename);
579
//
580
// /**
581
// * Read through the java source for the client wrapper and write it out to the new package, when we hit
582
// * the package statement, change it to be the new package.
583
// */
584
// String currentLine = "";
585
// String outLine = "";
586
// while((currentLine = in.readLine()) != null) {
587
// if(currentLine.indexOf("package ") == 0) {
588
// outLine = "package " + toPackageName + ";";
589
// } else {
590
// outLine = currentLine;
591
// }
592
//
593
// out.println(outLine);
594
// }
595
//
596
// out.close();
597
// in.close();
598
//
599
// }catch(IOException ioe){
600
// ErrorManager.getDefault().notify(ioe);
601
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"));
602
// }
603
//
604
// /**
605
// * Now copy the BeanInfo
606
// */
607
// try {
608
// newClientBeanInfoJavaObject = toPackage.createData(webServiceClientName + "BeanInfo","java");
609
// }catch(IOException ioe){
610
// ErrorManager.getDefault().notify(ioe);
611
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"));
612
// }
613
//
614
// try{
615
// PrintWriter out = new PrintWriter(newClientBeanInfoJavaObject.getOutputStream(newClientBeanInfoJavaObject.lock()));
616
// BufferedReader in = jarUtil.openFile(wsClientBeanInfoJarFilename);
617
//
618
//
619
// /**
620
// * Read through the java source for the client wrapper and write it out to the new package, when we hit
621
// * the package statement, change it to be the new package.
622
// */
623
// String currentLine = "";
624
// String outLine = "";
625
// while((currentLine = in.readLine()) != null) {
626
// if(currentLine.indexOf("package ") == 0) {
627
// outLine = "package " + toPackageName + ";";
628
// } else {
629
// outLine = currentLine;
630
// }
631
//
632
// out.println(outLine);
633
// }
634
//
635
// out.close();
636
// in.close();
637
//
638
//
639
// }catch(IOException ioe){
640
// ErrorManager.getDefault().notify(ioe);
641
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"));
642
// }
643
//
644
//
645
// /**
646
// * Now we need to compile the new class files
647
// */
648
//
649
// /**
650
// * Get the to path for the destination of the compile.
651
// */
652
// File toPackageFile = FileUtil.toFile(toPackage);
653
//
654
// String destinationDir = toPackageFile.getParentFile().getAbsolutePath();
655
//
656
// /**
657
// * Create a classpath for the compile
658
// */
659
// String classPath = "";
660
//
661
// /**
662
// * Get the web service support and client jar locations from the project references to add to the classpath.
663
// */
664
// WebAppProject webAppProject = (WebAppProject)getProject();
665
// Reference [] references = webAppProject.getReferences();
666
//
667
// for(int ii=0; ii < references.length; ii++) {
668
// if(references[ii] != null && references[ii].getDisplayName() != null) {
669
// if(references[ii].getDisplayName().equalsIgnoreCase(this.WEB_SERVICE_REFERENCE_NODE) ||
670
// references[ii].getDisplayName().equalsIgnoreCase(this.WEB_SERVICE_PREFIX + displayName)) {
671
// LibraryReference libRef = (LibraryReference)references[ii];
672
// SymbolicPath [] classpaths = libRef.getClassPaths();
673
// for(int jj=0; jj < classpaths.length; jj++) {
674
// classPath += File.pathSeparator + classpaths[jj].getResolvedPath();
675
// }
676
// }
677
// }
678
// }
679
//
680
// /**
681
// * Now we have to compile the new web service client wrapper and beaninfo so the classes will be available for the designer.
682
// */
683
// compileWSClientFiles(destinationDir, classPath, newClientJavaObject, newClientBeanInfoJavaObject);
684
//
685
//
686
// /**
687
// * Now refresh the folder
688
// * TODO: determine whether we should ignore the getFileSystem exception
689
// */
690
// try {
691
// toPackage.getFileSystem().refresh(true);
692
// } catch(FileStateInvalidException fsie) {
693
// //ignore
694
// }
695
// }
696
//
697
//
698
// /** Compile the proxy client just created */
699
// private void compileWSClientFiles(String inDestDir, String inClasspath,
700
// FileObject inWrapperObject, FileObject inWrapperBeanInfoObjectd){
701
//
702
// ArrayList argList = new ArrayList();
703
//
704
// argList.add("-d");
705
// argList.add(inDestDir);
706
// argList.add("-classpath");
707
// argList.add(inClasspath);
708
// /**
709
// * TODO: get the debug flag for the Creator environment.
710
// */
711
// argList.add("-g");
712
//
713
// /**
714
// * Now add the files to be compiled
715
// */
716
// File wrapperFile = FileUtil.toFile(inWrapperObject);
717
// argList.add(wrapperFile.getAbsolutePath());
718
// File wrapperBeanInfoFile = FileUtil.toFile(inWrapperBeanInfoObjectd);
719
// argList.add(wrapperBeanInfoFile.getAbsolutePath());
720
//
721
// String [] args = (String [])argList.toArray(new String[0]);
722
//
723
// // ByteArrayOutputStream javacOutput = new ByteArrayOutputStream();
724
//
725
// /**
726
// * Define a temp file for the compile results.
727
// */
728
// String outputDir = System.getProperty("user.home");
729
// File outputDirFile = new File(outputDir);
730
// File tempFile = null;
731
// try{
732
// tempFile = File.createTempFile("wstemp","ws",outputDirFile);
733
// }catch (IOException ioe){
734
// ErrorManager.getDefault().notify(ioe);
735
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"),2);
736
// return;
737
// }
738
//
739
// FileOutputStream out = null;
740
//
741
// try {
742
// out = new FileOutputStream(tempFile);
743
// } catch(FileNotFoundException fnfe) {
744
//
745
// ErrorManager.getDefault().notify(fnfe);
746
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"),2);
747
// return;
748
// }
749
//
750
// JavaCompilerHelper compilerHelper = new JavaCompilerHelper(out);
751
//
752
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_CLIENTWRAPPER_COMPILING"));
753
//
754
// boolean result = compilerHelper.compile(args);
755
// if (!result) {
756
// ErrorManager.getDefault().log(this.getClass().getName() + NbBundle.getMessage(this.getClass(), "WS_CLIENTWRAPPER_COMPILE_ERROR") + tempFile == null ? "" : tempFile.getAbsolutePath());
757
// StatusDisplayer.getDefault().displayError(NbBundle.getMessage(this.getClass(), "WS_DROP_ERROR"),2);
758
// } else {
759
// StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(this.getClass(), "WS_CLIENTWRAPPER_COMPILE_OK"));
760
// /**
761
// * clean up the output file since the compile was successful
762
// */
763
// tempFile.delete();
764
// }
765
//
766
// }
767

768     // FIXME NEW AFTER COPY-PASTE FROM RAVE
769
public Object JavaDoc getTransferData(java.awt.datatransfer.DataFlavor JavaDoc dataFlavor) throws java.awt.datatransfer.UnsupportedFlavorException JavaDoc, java.io.IOException JavaDoc {
770         return null;
771     }
772
773     public java.awt.datatransfer.DataFlavor JavaDoc[] getTransferDataFlavors() {
774         return null;
775     }
776
777     public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor JavaDoc dataFlavor) {
778         return false;
779     }
780
781 }
782
Popular Tags