KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > api > ui > RefactoringActionsFactory


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.ui;
21
22 import java.awt.event.ActionEvent JavaDoc;
23 import javax.swing.Action JavaDoc;
24 import org.netbeans.modules.refactoring.spi.impl.*;
25 import org.openide.util.ContextAwareAction;
26
27 /**
28  * Factory class providing instances of refactoring actions.
29  * <p><b>Usage:</b></p>
30  * <pre>
31  * Lookup l = Lookups.singleton(node);
32  * Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
33  * a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
34  * </pre>
35  *
36  * For help on creating and registering actions
37  * See <a HREF=http://wiki.netbeans.org/wiki/view/RefactoringFAQ>Refactoring FAQ</a>
38  *
39  * @author Jan Becicka
40  */

41 public final class RefactoringActionsFactory {
42     
43     /**
44      * defualt event for actionPerformed
45      */

46     public static final ActionEvent JavaDoc DEFAULT_EVENT = new ActionEvent JavaDoc(new Object JavaDoc(), 0, null) {
47         public void setSource(Object JavaDoc newSource) {
48             throw new UnsupportedOperationException JavaDoc();
49         }
50     };
51     
52     private RefactoringActionsFactory(){}
53     
54
55     /**
56      * Factory method for rename action
57      * @return instance of RenameAction
58      */

59     public static ContextAwareAction renameAction() {
60         return RenameAction.findObject(RenameAction.class, true);
61     }
62
63     /**
64      * Factory method for MoveAction
65      * @return an instance of MoveAction
66      */

67     public static ContextAwareAction moveAction() {
68         return MoveAction.findObject(MoveAction.class, true);
69     }
70     
71     /**
72      * Factory method for SafeDeleteAction
73      * @return an instance of SafeDeleteAction
74      */

75     public static ContextAwareAction safeDeleteAction() {
76         return SafeDeleteAction.findObject(SafeDeleteAction.class, true);
77     }
78     
79     /**
80      * Factory method for CopyAction
81      * @return an instance of CopyAction
82      */

83     public static ContextAwareAction copyAction() {
84         return SafeDeleteAction.findObject(CopyAction.class, true);
85     }
86     
87     /**
88      * Factory method for WhereUsedAction
89      * @return an instance of WhereUsedAction
90      */

91     public static ContextAwareAction whereUsedAction() {
92         return WhereUsedAction.findObject(WhereUsedAction.class, true);
93     }
94     
95     /**
96      * Factory method for RSMEditorAction
97      * @return an instance of RSMEditorAction
98      */

99     public static Action JavaDoc editorSubmenuAction() {
100         return RSMEditorAction.findObject(RSMEditorAction.class, true);
101     }
102     
103     /**
104      * Factory method for RSMDataObjectAction
105      * @return an instance of RSMDataObjectAction
106      */

107     public static ContextAwareAction popupSubmenuAction() {
108         return RSMDataObjectAction.findObject(RSMDataObjectAction.class, true);
109     }
110 }
111
Popular Tags