2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.j2ee.refactoring.rename;
45
import java.io.IOException;
46
import java.text.MessageFormat;
47
import java.util.ArrayList;
48
import java.util.Collection;
49
import java.util.Iterator;
51
import javax.jmi.reflect.RefObject;
52
import org.netbeans.api.project.FileOwnerQuery;
53
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.jmi.javamodel.ClassDefinition;
56
import org.netbeans.jmi.javamodel.Method;
57
import org.netbeans.jmi.javamodel.UnresolvedClass;
58
import org.netbeans.modules.j2ee.dd.api.web.Filter;
59
import org.netbeans.modules.j2ee.dd.api.web.Listener;
60
import org.netbeans.modules.j2ee.dd.api.web.Servlet;
61
import org.netbeans.modules.j2ee.dd.api.web.WebApp;
62
import org.netbeans.jmi.javamodel.JavaClass;
63
import org.netbeans.jmi.javamodel.Resource;
64
import org.netbeans.modules.j2ee.dd.api.webservices.PortComponent;
65
import org.netbeans.modules.j2ee.dd.api.webservices.PortComponentHandler;
66
import org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription;
67
import org.netbeans.modules.j2ee.dd.api.webservices.Webservices;
68
import org.netbeans.modules.j2ee.refactoring.Utility;
69
import org.netbeans.modules.javacore.api.JavaModel;
70
import org.netbeans.modules.javacore.internalapi.ExternalChange;
71
import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
72
import org.netbeans.modules.refactoring.api.AbstractRefactoring;
73
import org.netbeans.modules.refactoring.api.Problem;
74
import org.netbeans.modules.refactoring.api.RefactoringSession;
75
import org.netbeans.modules.refactoring.api.RenameRefactoring;
76
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
77
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
78
import org.netbeans.modules.schema2beans.QName;
79
import org.netbeans.modules.web.api.webmodule.WebModule;
80
import org.netbeans.modules.websvc.api.webservices.WebServicesSupport;
81
import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
82
import org.netbeans.modules.websvc.wsdl.config.api.Configuration;
83
import org.netbeans.spi.project.support.ant.AntProjectHelper;
84
import org.netbeans.spi.project.support.ant.EditableProperties;
85
import org.openide.ErrorManager;
86
import org.openide.filesystems.FileObject;
87
import org.openide.filesystems.FileUtil;
88
import org.openide.util.NbBundle;
92
* @author Martin Grebac
94
public final class WebservicesXmlRenameRefactoring {
96
private static final ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.j2ee.refactoring.rename"); // NOI18N
98
/* stores collection of interface refactorings to be invoked */
99
ArrayList otherRefactors = new ArrayList();
101
public WebservicesXmlRenameRefactoring() { }
103
public Problem preCheck(RefObject refObject) {
105
Problem problem = null;
106
if (refObject instanceof Method) {
108
Method method = (Method)refObject;
109
Resource res = method.getResource();
110
FileObject fo = JavaModel.getFileObject(res);
111
Collection wsmodules = Utility.getRelevantWSModules(fo);
112
Iterator wsIter = wsmodules.iterator();
113
String methodName = method.getName();
114
ClassDefinition classDef = method.getDeclaringClass(); // get affected class
116
if ((wsmodules != null) && (wsmodules.size() > 0)) { // there are web/ejb modules that can be affected by the change
117
while (wsIter.hasNext()) {
118
WebServicesSupport ws = (WebServicesSupport)wsIter.next();
120
FileObject webservicesXmlFO = ws.getWebservicesDD();
121
Webservices webservicesXmlDD = null;
123
webservicesXmlDD = org.netbeans.modules.j2ee.dd.api.webservices.DDProvider.getDefault().getDDRoot(webservicesXmlFO);
124
} catch (IOException ioe) {
128
if ((webservicesXmlDD != null) && (webservicesXmlDD.getStatus()!=Webservices.STATE_INVALID_UNPARSABLE)) {
129
WebserviceDescription[] wservices = webservicesXmlDD.getWebserviceDescription();
130
err.log("Web Services: " + wservices); //NOI18N
131
if ((wservices != null) && (wservices.length > 0)) {
132
for (int w=0; w < wservices.length; w++) {
133
WebserviceDescription webService = (WebserviceDescription)wservices[w];
134
err.log("Web Service: " + webService); //NOI18N
136
PortComponent[] ports = webService.getPortComponent();
137
err.log("Ports: " + ports);
138
if ((ports != null) && (ports.length > 0)) {
139
for (int p=0; p < ports.length; p++) {
141
/* First check for presence in webservices.xml port */
142
PortComponent portComponent = (PortComponent)ports[p];
143
err.log("Port Component: " + portComponent); //NOI18N
145
/* try to locate the local wscompile config file:
146
* get project for webservices.xml, get name of the webservice and try to find properties of the type
147
* $propertyname-config.name - if found, get the property valu and the path and locate the descriptor,
148
* then get the dd api descriptor object
151
String portName = portComponent.getPortComponentName();
152
Project project = FileOwnerQuery.getOwner(webservicesXmlFO);
153
Map properties = ws.getAntProjectHelper().getStandardPropertyEvaluator().getProperties();
154
String propertyName = portName + WebServicesConstants.CONFIG_PROP_SUFFIX;
155
String propertyValue = (String)properties.get(propertyName);
157
if (propertyValue != null) { // there's such property in the project
158
FileObject wsConfigXmlFO = null;
160
File f = new File(propertyValue);
161
if (f.isAbsolute()) {
162
wsConfigXmlFO = FileUtil.toFileObject(f);
164
wsConfigXmlFO = project.getProjectDirectory().getFileObject(propertyValue);
166
if (wsConfigXmlFO != null) {
167
Configuration wsConfigXmlDD = null;
169
if (wsConfigXmlFO != null) {
170
wsConfigXmlDD = org.netbeans.modules.websvc.wsdl.config.api.DDProvider.getDefault().getDDRoot(wsConfigXmlFO);
172
} catch (IOException ioe) {
175
if (wsConfigXmlDD != null) {
176
org.netbeans.modules.websvc.wsdl.config.api.Service service = wsConfigXmlDD.getService();
177
if (service != null) {
178
org.netbeans.modules.websvc.wsdl.config.api.Interface[] interfaces = service.getInterface();
179
if ((interfaces != null) && (interfaces.length > 0)) {
180
for (int ii=0; ii < interfaces.length; ii++) {
181
org.netbeans.modules.websvc.wsdl.config.api.Interface iface = interfaces[ii];
182
String servant = iface.getServantName();
183
String iname = iface.getName();
185
if (classDef.getName().equals(iname)) {
187
JavaClass jcl = (JavaClass)JavaModel.getDefaultExtent().getType().resolve(servant);
188
Method beanMethod = null;
189
if (!(jcl instanceof UnresolvedClass)) {
190
beanMethod = jcl.getMethod(methodName, Utility.getTypedParams(method.getParameters()), false); //NOI18N
191
err.log("beanmethod: " + beanMethod); //NOI18N
194
RenameRefactoring renameBeanMethod = new RenameRefactoring(beanMethod);
195
Problem prob = renameBeanMethod.preCheck();
196
problem = Utility.addProblemsToEnd(problem, prob);
197
otherRefactors.add(renameBeanMethod);
199
} else if (classDef.getName().equals(servant)) {
201
JavaClass jcl = (JavaClass)JavaModel.getDefaultExtent().getType().resolve(iname);
202
Method iMethod = null;
203
if (!(jcl instanceof UnresolvedClass)) {
204
iMethod = jcl.getMethod(methodName, Utility.getTypedParams(method.getParameters()), false); //NOI18N
205
err.log("ifacemethod: " + iMethod); //NOI18N
208
RenameRefactoring renameIfaceMethod = new RenameRefactoring(iMethod);
209
Problem prob = renameIfaceMethod.preCheck();
210
problem = Utility.addProblemsToEnd(problem, prob);
211
otherRefactors.add(renameIfaceMethod);
217
Problem newProblem = new Problem(false, NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesConfigXmlRenameInvalidProblem")); //NOI18N
218
problem = Utility.addProblemsToEnd(problem, newProblem);
232
err.log("other refactors: " + otherRefactors); //NOI18N
236
public Problem fastCheckParameters(RefObject refObject, String newName) {
237
Problem problem = null;
238
if (refObject instanceof Method) {
239
for (int i=0; i < otherRefactors.size(); i++) {
240
RenameRefactoring rr = (RenameRefactoring)otherRefactors.get(i);
241
rr.setNewName(newName);
242
Problem p = rr.fastCheckParameters();
243
problem = Utility.addProblemsToEnd(problem, p);
249
public Problem checkParameters(RefObject refObject, String newName) {
250
return fastCheckParameters(refObject, newName);
253
/** Find usages in web deployment descriptor: web.xml
255
public Problem prepare(AbstractRefactoring refactor, RefObject refObject, String newName, RefactoringElementsBag refactoringElements) {
257
RefactoringSession session = refactoringElements.getSession();
258
Problem problem = null;
259
if (refObject instanceof JavaClass) {
261
JavaClass jClass = (JavaClass)refObject;
263
String name = jClass.getName();
264
err.log("name: " + name); //NOI18N
266
String newSimpleName = newName;
267
err.log("newSimpleName: " + newSimpleName); //NOI18N
269
newName = name.substring(0, name.lastIndexOf('.') + 1) + newName;
270
err.log("newName: " + newName); //NOI18N
272
Resource res = jClass.getResource();
273
FileObject fo = JavaModel.getFileObject(res);
275
WebServicesSupport wsm = WebServicesSupport.getWebServicesSupport(fo);
276
if (wsm != null) { // the class is in a module with web services support
278
FileObject webservicesXmlFO = wsm.getWebservicesDD();
279
Webservices webservicesXmlDD = null;
281
webservicesXmlDD = org.netbeans.modules.j2ee.dd.api.webservices.DDProvider.getDefault().getDDRoot(webservicesXmlFO);
282
} catch (IOException ioe) {
286
if ((webservicesXmlDD != null) && (webservicesXmlDD.getStatus()!=Webservices.STATE_INVALID_UNPARSABLE)) {
287
WebserviceDescription[] wservices = webservicesXmlDD.getWebserviceDescription();
288
err.log("Web Services: " + wservices); //NOI18N
289
if ((wservices != null) && (wservices.length > 0)) {
290
for (int w=0; w < wservices.length; w++) {
291
WebserviceDescription webService = (WebserviceDescription)wservices[w];
292
err.log("Web Service: " + webService); //NOI18N
294
/* And update the actual web service reference direct in webservices.xml */
295
PortComponent[] ports = webService.getPortComponent();
296
err.log("Ports: " + ports);
297
if ((ports != null) && (ports.length > 0)) {
298
for (int p=0; p < ports.length; p++) {
300
/* First check for presence in webservices.xml port */
301
PortComponent portComponent = (PortComponent)ports[p];
302
err.log("Port Component: " + portComponent); //NOI18N
304
// check message handlers
305
PortComponentHandler[] handlers = portComponent.getHandler();
306
for (int k = 0; k < handlers.length; k++) {
307
if (name.equals(handlers[k].getHandlerClass())){
308
RefactoringElementImplementation elem = new WebservicesHandlerRenameRefactoringElement(webservicesXmlDD, name, newName, handlers[k], webservicesXmlFO);
309
refactoringElements.add(refactor, elem);
313
// wsdl-port is generated from sei class name as well
314
QName wsdlPort = portComponent.getWsdlPort();
315
err.log("WSDL Port: " + wsdlPort); //NOI18N
316
if (wsdlPort != null) {
317
String localPart = wsdlPort.getLocalPart();
318
if (jClass.getSimpleName().concat("Port").equals(localPart)) { //NOI18N
319
String newLocalPart = newSimpleName.concat("Port"); //NOI18N
320
QName newPort = new QName(wsdlPort.getNamespaceURI(), newLocalPart, wsdlPort.getPrefix());
321
RefactoringElementImplementation elem =
322
new WebservicesWsdlPortRenameRefactoringElement(
323
webservicesXmlDD, wsdlPort, newPort, portComponent, webservicesXmlFO); //NOI18N
324
refactoringElements.add(refactor, elem);
328
String serviceEndpointInterface = portComponent.getServiceEndpointInterface();
329
err.log("serviceEndpointInterface: " + serviceEndpointInterface); //NOI18N
330
if ((serviceEndpointInterface != null) && (serviceEndpointInterface.equals(name))) {
331
RefactoringElementImplementation elem = new WebservicesSEIRenameRefactoringElement(webservicesXmlDD, name, newName, portComponent, webservicesXmlFO);
332
refactoringElements.add(refactor, elem);
334
/* try to locate the local wscompile config file:
335
* get project for webservices.xml, get name of the webservice and try to find properties of the type
336
* $propertyname-config.name - if found, get the property valu and the path and locate the descriptor,
337
* then get the dd api descriptor object
339
String portName = portComponent.getPortComponentName();
340
Project project = FileOwnerQuery.getOwner(webservicesXmlFO);
341
Map properties = wsm.getAntProjectHelper().getStandardPropertyEvaluator().getProperties();
342
String propertyName = portName + WebServicesConstants.CONFIG_PROP_SUFFIX;
343
String propertyValue = (String)properties.get(propertyName);
344
if (propertyValue != null) { // there's such property in the project
345
FileObject wsConfigXmlFO = null;
347
File f = new File(propertyValue);
348
if (f.isAbsolute()) {
349
wsConfigXmlFO = FileUtil.toFileObject(f);
351
wsConfigXmlFO = project.getProjectDirectory().getFileObject(propertyValue);
353
if (wsConfigXmlFO != null) {
354
Configuration wsConfigXmlDD = null;
356
wsConfigXmlDD = org.netbeans.modules.websvc.wsdl.config.api.DDProvider.getDefault().getDDRoot(wsConfigXmlFO);
357
} catch (IOException ioe) {
360
if (wsConfigXmlDD != null) {
361
org.netbeans.modules.websvc.wsdl.config.api.Service service = wsConfigXmlDD.getService();
362
if (service != null) {
363
org.netbeans.modules.websvc.wsdl.config.api.Interface[] interfaces = service.getInterface();
364
if ((interfaces != null) && (interfaces.length > 0)) {
365
for (int ii=0; ii < interfaces.length; ii++) {
366
org.netbeans.modules.websvc.wsdl.config.api.Interface iface = interfaces[ii];
367
String servant = iface.getServantName();
368
String iname = iface.getName();
369
if ((servant != null) && (servant.equals(name))) {
370
RefactoringElementImplementation elem = new WebservicesConfigXmlServantRenameRefactoringElement(wsConfigXmlDD, name, newName, iface, wsConfigXmlFO);
371
refactoringElements.add(refactor, elem);
373
if ((iname != null) && (iname.equals(name))) {
374
RefactoringElementImplementation elem = new WebservicesConfigXmlInterfaceRenameRefactoringElement(wsConfigXmlDD, name, newName, iface, wsConfigXmlFO);
375
refactoringElements.add(refactor, elem);
381
Problem newProblem = new Problem(false, NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesConfigXmlRenameInvalidProblem")); //NOI18N
382
problem = Utility.addProblemsToEnd(problem, newProblem);
390
} else if (webservicesXmlDD != null) {
391
Problem newProblem = new Problem(false, NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesXmlRenameInvalidProblem")); //NOI18N
392
if (problem == null) {
393
problem = newProblem;
395
if (newProblem != null) problem.setNext(newProblem);
398
} //refactor webservices.xml
401
if (refObject instanceof Method) {
402
for (int i=0; i < otherRefactors.size(); i++) {
403
RenameRefactoring rr = (RenameRefactoring)otherRefactors.get(i);
404
Problem p = rr.prepare(session);
405
problem = Utility.addProblemsToEnd(problem, p);
413
public final class WebservicesSEIRenameRefactoringElement extends AbstractRenameRefactoringElement implements ExternalChange {
415
protected Webservices webservicesXmlDD;
416
private PortComponent portComponent;
418
/** Creates a new instance of WebservicesSEIRenameRefactoringElement */
419
public WebservicesSEIRenameRefactoringElement(Webservices webservicesXmlDD, String oldName, String newName, PortComponent portComponent, FileObject parentFile) {
420
this.webservicesXmlDD = webservicesXmlDD;
421
this.oldName = oldName;
422
this.newName = newName;
423
this.portComponent = portComponent;
424
this.parentFile = parentFile;
427
/** Returns text describing the refactoring formatted for display (using HTML tags).
428
* @return Formatted text.
430
public String getDisplayText() {
431
Object[] args = new Object [] {parentFile.getNameExt(), oldName, newName};
432
return MessageFormat.format(NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesXmlSEIRename"), args); //NOI18N
435
/** Performs the change represented by this refactoring element.
437
public void performChange() {
438
JavaMetamodel.getManager().registerExtChange(this);
441
public void performExternalChange() {
442
portComponent.setServiceEndpointInterface(newName);
444
webservicesXmlDD.write(parentFile);
445
} catch (IOException ioe) {
450
public void undoExternalChange() {
451
portComponent.setServiceEndpointInterface(oldName);
453
webservicesXmlDD.write(parentFile);
454
} catch (IOException ioe) {
461
* Rename refactoring element for message handlers.
463
public final class WebservicesHandlerRenameRefactoringElement extends AbstractRenameRefactoringElement implements ExternalChange {
465
protected Webservices webservicesXmlDD;
466
private PortComponentHandler handler;
468
public WebservicesHandlerRenameRefactoringElement(Webservices webservicesXmlDD, String oldName, String newName, PortComponentHandler handler, FileObject parentFile) {
469
this.webservicesXmlDD = webservicesXmlDD;
470
this.oldName = oldName;
471
this.newName = newName;
472
this.handler = handler;
473
this.parentFile = parentFile;
476
/** Returns text describing the refactoring formatted for display (using HTML tags).
477
* @return Formatted text.
479
public String getDisplayText() {
480
Object[] args = new Object [] {parentFile.getNameExt(), oldName, newName};
481
return MessageFormat.format(NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesXmlHandlerRename"), args); //NOI18N
484
/** Performs the change represented by this refactoring element.
486
public void performChange() {
487
JavaMetamodel.getManager().registerExtChange(this);
490
public void performExternalChange() {
491
handler.setHandlerClass(newName);
495
public void undoExternalChange() {
496
handler.setHandlerClass(oldName);
500
private void write(){
502
webservicesXmlDD.write(parentFile);
503
} catch (IOException ioe) {
504
ErrorManager.getDefault().notify(ioe);
508
public final class WebservicesWsdlPortRenameRefactoringElement extends AbstractRenameRefactoringElement implements ExternalChange {
510
protected Webservices webservicesXmlDD;
511
private PortComponent portComponent;
513
private QName oldPort;
514
private QName newPort;
516
/** Creates a new instance of WebservicesWsdlPortRenameRefactoringElement */
517
public WebservicesWsdlPortRenameRefactoringElement(Webservices webservicesXmlDD, QName oldPort, QName newPort, PortComponent portComponent, FileObject parentFile) {
518
this.webservicesXmlDD = webservicesXmlDD;
519
this.oldPort = oldPort;
520
this.newPort = newPort;
521
this.portComponent = portComponent;
522
this.parentFile = parentFile;
525
/** Returns text describing the refactoring formatted for display (using HTML tags).
526
* @return Formatted text.
528
public String getDisplayText() {
529
String oldStr = oldPort.getPrefix() + ":" + oldPort.getLocalPart(); //NOI18N
530
String newStr = newPort.getPrefix() + ":" + newPort.getLocalPart(); //NOI18N
532
Object[] args = new Object [] {parentFile.getNameExt(), oldStr, newStr};
533
return MessageFormat.format(NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesXmlWsdlPortRename"), args); //NOI18N
536
/** Performs the change represented by this refactoring element.
538
public void performChange() {
539
JavaMetamodel.getManager().registerExtChange(this);
542
public void performExternalChange() {
543
portComponent.setWsdlPort(newPort);
545
webservicesXmlDD.write(parentFile);
546
} catch (IOException ioe) {
551
public void undoExternalChange() {
552
portComponent.setWsdlPort(oldPort);
554
webservicesXmlDD.write(parentFile);
555
} catch (IOException ioe) {
561
public final class WebservicesConfigXmlServantRenameRefactoringElement extends AbstractRenameRefactoringElement implements ExternalChange {
563
protected Configuration wsConfigXmlDD;
564
private org.netbeans.modules.websvc.wsdl.config.api.Interface iface;
566
/** Creates a new instance of WebservicesConfigXmlServantRenameRefactoringElement */
567
public WebservicesConfigXmlServantRenameRefactoringElement(Configuration wsConfigXmlDD, String oldName, String newName, org.netbeans.modules.websvc.wsdl.config.api.Interface iface, FileObject parentFile) {
568
this.wsConfigXmlDD = wsConfigXmlDD;
569
this.oldName = oldName;
570
this.newName = newName;
572
this.parentFile = parentFile;
575
/** Returns text describing the refactoring formatted for display (using HTML tags).
576
* @return Formatted text.
578
public String getDisplayText() {
579
Object[] args = new Object [] {parentFile.getNameExt(), oldName, newName};
580
return MessageFormat.format(NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesConfigXmlServantRename"), args); //NOI18N
583
/** Performs the change represented by this refactoring element.
585
public void performChange() {
586
JavaMetamodel.getManager().registerExtChange(this);
589
public void performExternalChange() {
590
iface.setServantName(newName);
592
wsConfigXmlDD.write(parentFile);
593
} catch (IOException ioe) {
598
public void undoExternalChange() {
599
iface.setServantName(oldName);
601
wsConfigXmlDD.write(parentFile);
602
} catch (IOException ioe) {
608
public final class WebservicesConfigXmlInterfaceRenameRefactoringElement extends AbstractRenameRefactoringElement implements ExternalChange {
610
protected Configuration wsConfigXmlDD;
611
private org.netbeans.modules.websvc.wsdl.config.api.Interface iface;
613
/** Creates a new instance of WebservicesConfigXmlInterfaceRenameRefactoringElement */
614
public WebservicesConfigXmlInterfaceRenameRefactoringElement(Configuration wsConfigXmlDD, String oldName, String newName, org.netbeans.modules.websvc.wsdl.config.api.Interface iface, FileObject parentFile) {
615
this.wsConfigXmlDD = wsConfigXmlDD;
616
this.oldName = oldName;
617
this.newName = newName;
619
this.parentFile = parentFile;
622
/** Returns text describing the refactoring formatted for display (using HTML tags).
623
* @return Formatted text.
625
public String getDisplayText() {
626
Object[] args = new Object [] {parentFile.getNameExt(), oldName, newName};
627
return MessageFormat.format(NbBundle.getMessage(WebservicesXmlRenameRefactoring.class, "TXT_WebservicesConfigXmlInterfaceRename"), args); //NOI18N
630
/** Performs the change represented by this refactoring element.
632
public void performChange() {
633
JavaMetamodel.getManager().registerExtChange(this);
636
public void performExternalChange() {
637
iface.setName(newName);
639
wsConfigXmlDD.write(parentFile);
640
} catch (IOException ioe) {
645
public void undoExternalChange() {
646
iface.setName(oldName);
648
wsConfigXmlDD.write(parentFile);
649
} catch (IOException ioe) {