KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > java > ui > JavaActionsImplementationFactory


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.refactoring.java.ui;
21
22 import org.netbeans.modules.refactoring.java.spi.ui.JavaActionsImplementationProvider;
23 import org.openide.util.Lookup;
24
25 /**
26  * @author Jan Becicka
27  */

28 public final class JavaActionsImplementationFactory {
29     
30     private JavaActionsImplementationFactory(){}
31     
32     private static final Lookup.Result<JavaActionsImplementationProvider> implementations =
33         Lookup.getDefault().lookup(new Lookup.Template(JavaActionsImplementationProvider.class));
34
35     public static boolean canChangeParameters(Lookup lookup) {
36         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
37             if (rafi.canChangeParameters(lookup)) {
38                 return true;
39             }
40         }
41         return false;
42     }
43     
44     public static void doChangeParameters(Lookup lookup) {
45         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
46             if (rafi.canChangeParameters(lookup)) {
47                 rafi.doChangeParameters(lookup);
48                 return;
49             }
50         }
51     }
52
53     public static boolean canEncapsulateFields(Lookup lookup) {
54         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
55             if (rafi.canEncapsulateFields(lookup)) {
56                 return true;
57             }
58         }
59         return false;
60     }
61     
62     public static void doEncapsulateFields(Lookup lookup) {
63         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
64             if (rafi.canEncapsulateFields(lookup)) {
65                 rafi.doEncapsulateFields(lookup);
66                 return;
67             }
68         }
69     }
70     public static boolean canExtractInterface(Lookup lookup) {
71         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
72             if (rafi.canExtractInterface(lookup)) {
73                 return true;
74             }
75         }
76         return false;
77     }
78     
79     public static void doExtractInterface(Lookup lookup) {
80         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
81             if (rafi.canExtractInterface(lookup)) {
82                 rafi.doExtractInterface(lookup);
83                 return;
84             }
85         }
86     }
87     
88     public static void doExtractSuperClass(Lookup lookup) {
89         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
90             if (rafi.canExtractSuperClass(lookup)) {
91                 rafi.doExtractSuperClass(lookup);
92                 return;
93             }
94         }
95     }
96     
97     public static boolean canExtractSuperClass(Lookup lookup) {
98         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
99             if (rafi.canExtractSuperClass(lookup)) {
100                 return true;
101             }
102         }
103         return false;
104     }
105
106     public static void doInnerToOuter(Lookup lookup) {
107         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
108             if (rafi.canInnerToOuter(lookup)) {
109                 rafi.doInnerToOuter(lookup);
110                 return;
111             }
112         }
113     }
114     
115     public static boolean canInnerToOuter(Lookup lookup) {
116         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
117             if (rafi.canInnerToOuter(lookup)) {
118                 return true;
119             }
120         }
121         return false;
122     }
123
124     public static void doPullUp(Lookup lookup) {
125         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
126             if (rafi.canPullUp(lookup)) {
127                 rafi.doPullUp(lookup);
128                 return;
129             }
130         }
131     }
132     
133     public static boolean canPullUp(Lookup lookup) {
134         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
135             if (rafi.canPullUp(lookup)) {
136                 return true;
137             }
138         }
139         return false;
140     }
141
142     public static void doPushDown(Lookup lookup) {
143         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
144             if (rafi.canPushDown(lookup)) {
145                 rafi.doPushDown(lookup);
146                 return;
147             }
148         }
149     }
150     
151     public static boolean canPushDown(Lookup lookup) {
152         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
153             if (rafi.canPushDown(lookup)) {
154                 return true;
155             }
156         }
157         return false;
158     }
159
160     public static void doUseSuperType(Lookup lookup) {
161         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
162             if (rafi.canUseSuperType(lookup)) {
163                 rafi.doUseSuperType(lookup);
164                 return;
165             }
166         }
167     }
168     
169     public static boolean canUseSuperType(Lookup lookup) {
170         for (JavaActionsImplementationProvider rafi: implementations.allInstances()) {
171             if (rafi.canUseSuperType(lookup)) {
172                 return true;
173             }
174         }
175         return false;
176     }
177     
178     
179 }
180
Popular Tags