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.xml.wsdl.refactoring;
44
import java.io.IOException;
45
import java.util.ArrayList;
46
import java.util.Collection;
47
import java.util.HashSet;
48
import java.util.List;
50
import java.util.concurrent.ExecutionException;
51
import org.netbeans.modules.refactoring.api.AbstractRefactoring;
52
import org.netbeans.modules.refactoring.api.Problem;
53
import org.netbeans.modules.refactoring.api.ProgressEvent;
54
import org.netbeans.modules.refactoring.spi.ProgressProviderAdapter;
55
import org.netbeans.modules.refactoring.spi.RefactoringElementImplementation;
56
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag;
57
import org.netbeans.modules.refactoring.api.WhereUsedQuery;
58
import org.netbeans.modules.refactoring.spi.RefactoringPlugin;
59
import org.netbeans.modules.xml.refactoring.ErrorItem;
60
import org.netbeans.modules.xml.refactoring.spi.SharedUtils;
61
import org.netbeans.modules.xml.xam.Component;
62
import org.netbeans.modules.xml.xam.Named;
63
import org.netbeans.modules.xml.xam.Referenceable;
64
import org.openide.ErrorManager;
70
* @author Sonali Kochar
72
public class WSDLWhereUsedRefactoringPlugin extends WSDLRefactoringPlugin {
76
public void cancelRequest() {
80
public Problem fastCheckParameters() {
84
private WhereUsedQuery query;
88
* Creates a new instance of WSDLWhereUsedRefactoringPlugin
90
public WSDLWhereUsedRefactoringPlugin(WhereUsedQuery refactoring) {
91
this.query = refactoring;
94
/** Checks pre-conditions of the refactoring and returns problems.
95
* @return Problems found or null (if no problems were identified)
97
public Problem preCheck() {
101
/** Checks parameters of the refactoring.
102
* @return Problems found or null (if no problems were identified)
104
public Problem checkParameters() {
105
Problem problem = null;
110
/** Collects refactoring elements for a given refactoring.
111
* @param refactoringElements Collection of refactoring elements - the implementation of this method
112
* should add refactoring elements to this collections. It should make no assumptions about the collection
114
* @return Problems found or null (if no problems were identified)
116
public Problem prepare(RefactoringElementsBag refactoringElements) {
117
// System.out.println("WSDLWhereUsedRefactoring:: prepare called");
118
Referenceable ref = query.getRefactoringSource().lookup(Referenceable.class);
122
session = refactoringElements.getSession();
123
fireProgressListenerStart(ProgressEvent.START, -1);
124
Component searchRoot = query.getContext().lookup(Component.class);
125
this.findErrors = new ArrayList<ErrorItem>();
126
Set<Component> searchRoots = new HashSet<Component>();
127
if(searchRoot == null )
128
searchRoots = getSearchRoots(ref);
130
searchRoots.add(searchRoot);
132
for (Component root : searchRoots) {
133
List<WSDLRefactoringElement> elements = find(ref, root);
134
for (WSDLRefactoringElement element : elements) {
135
//System.out.println("WSDLWhereusedRefactoring::adding element");
136
refactoringElements.add(query, element);
137
fireProgressListenerStep();
142
fireProgressListenerStop();
143
//System.out.println("done");
148
public void doRefactoring(List<RefactoringElementImplementation> elements) throws IOException {