KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > api > impl > ActionsImplementationFactory


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.refactoring.api.impl;
21
22 import org.netbeans.modules.refactoring.spi.ui.ActionsImplementationProvider;
23 import org.openide.util.Lookup;
24
25 /**
26  * @author Jan Becicka
27  */

28 public final class ActionsImplementationFactory {
29     
30     private ActionsImplementationFactory(){}
31     
32     private static final Lookup.Result<ActionsImplementationProvider> implementations =
33         Lookup.getDefault().lookup(new Lookup.Template(ActionsImplementationProvider.class));
34
35     public static boolean canRename(Lookup lookup) {
36         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
37             if (rafi.canRename(lookup)) {
38                 return true;
39             }
40         }
41         return false;
42     }
43     
44     public static void doRename(Lookup lookup) {
45         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
46             if (rafi.canRename(lookup)) {
47                 rafi.doRename(lookup);
48             }
49         }
50     }
51
52     public static boolean canFindUsages(Lookup lookup) {
53         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
54             if (rafi.canFindUsages(lookup)) {
55                 return true;
56             }
57         }
58         return false;
59     }
60     
61     public static void doFindUsages(Lookup lookup) {
62         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
63             if (rafi.canFindUsages(lookup)) {
64                 rafi.doFindUsages(lookup);
65             }
66         }
67     }
68     public static boolean canDelete(Lookup lookup) {
69         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
70             if (rafi.canDelete(lookup)) {
71                 return true;
72             }
73         }
74         return false;
75     }
76     
77     public static void doDelete(Lookup lookup) {
78         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
79             if (rafi.canDelete(lookup)) {
80                 rafi.doDelete(lookup);
81             }
82         }
83     }
84     
85     public static void doMove(Lookup lookup) {
86         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
87             if (rafi.canMove(lookup)) {
88                 rafi.doMove(lookup);
89             }
90         }
91     }
92     
93     public static boolean canMove(Lookup lookup) {
94         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
95             if (rafi.canMove(lookup)) {
96                 return true;
97             }
98         }
99         return false;
100     }
101
102     public static void doCopy(Lookup lookup) {
103         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
104             if (rafi.canCopy(lookup)) {
105                 rafi.doCopy(lookup);
106             }
107         }
108     }
109     
110     public static boolean canCopy(Lookup lookup) {
111         for (ActionsImplementationProvider rafi: implementations.allInstances()) {
112             if (rafi.canCopy(lookup)) {
113                 return true;
114             }
115         }
116         return false;
117     }
118     
119 }
120
Popular Tags