KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > refactoring > jaxwssupport > JaxWsXmlRefactoringElementSupport


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.j2ee.refactoring.jaxwssupport;
21
22 import java.io.IOException JavaDoc;
23 import org.netbeans.modules.j2ee.refactoring.rename.AbstractRenameRefactoringElement;
24 import org.netbeans.modules.javacore.internalapi.ExternalChange;
25 import org.netbeans.modules.javacore.internalapi.JavaMetamodel;
26 import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
27 import org.netbeans.modules.websvc.api.jaxws.project.config.Service;
28 import org.openide.ErrorManager;
29 import org.openide.filesystems.FileObject;
30
31 /**
32  * Base class for jax ws refactoring elements.
33  *
34  * @author Erno Mononen
35  */

36 public abstract class JaxWsXmlRefactoringElementSupport extends AbstractRenameRefactoringElement implements ExternalChange {
37     
38     protected JaxWsModel model;
39     protected Service service;
40     
41     /**
42      * Creates a new instance of JaxWsXmlRefactoringElementSupport
43      * @param oldName the fully qualified old name of the implementation class
44      * @param newName the fully qualified new name of the implementation class
45      * @service the service whose implementation class is to be renamed
46      * @parentFile the file object representing jax-ws.xml
47      */

48     public JaxWsXmlRefactoringElementSupport(String JavaDoc oldName, String JavaDoc newName,
49             JaxWsModel model, Service service, FileObject parentFile) {
50         
51         this.oldName = oldName;
52         this.newName = newName;
53         this.model = model;
54         this.parentFile = parentFile;
55         this.service = service;
56     }
57
58     
59     public void performExternalChange() {
60         service.setImplementationClass(newName);
61         writeModel();
62     }
63     
64     public void undoExternalChange() {
65         service.setImplementationClass(oldName);
66         writeModel();
67     }
68     
69     private void writeModel(){
70         try {
71             model.write();
72         } catch (IOException JavaDoc ex) {
73             ErrorManager.getDefault().notify(ex);
74         }
75     }
76     
77     /**
78      * Performs the change represented by this refactoring element.
79      */

80     public void performChange() {
81         JavaMetamodel.getManager().registerExtChange(this);
82     }
83     
84 }
85
Popular Tags