001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.refactoring.api.ui;
043:
044: import java.awt.event.ActionEvent;
045: import javax.swing.Action;
046: import org.netbeans.modules.refactoring.spi.impl.*;
047: import org.openide.util.ContextAwareAction;
048:
049: /**
050: * Factory class providing instances of refactoring actions.
051: * <p><b>Usage:</b></p>
052: * <pre>
053: * Lookup l = Lookups.singleton(node);
054: * Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
055: * a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
056: * </pre>
057: *
058: * For help on creating and registering actions
059: * See <a href=http://wiki.netbeans.org/wiki/view/RefactoringFAQ>Refactoring FAQ</a>
060: *
061: * @author Jan Becicka
062: */
063: public final class RefactoringActionsFactory {
064:
065: /**
066: * defualt event for actionPerformed
067: */
068: public static final ActionEvent DEFAULT_EVENT = new ActionEvent(
069: new Object(), 0, null) {
070: public void setSource(Object newSource) {
071: throw new UnsupportedOperationException();
072: }
073: };
074:
075: private RefactoringActionsFactory() {
076: }
077:
078: /**
079: * Factory method for rename action
080: * @return instance of RenameAction
081: */
082: public static ContextAwareAction renameAction() {
083: return RenameAction.findObject(RenameAction.class, true);
084: }
085:
086: /**
087: * Factory method for MoveAction
088: * @return an instance of MoveAction
089: */
090: public static ContextAwareAction moveAction() {
091: return MoveAction.findObject(MoveAction.class, true);
092: }
093:
094: /**
095: * Factory method for SafeDeleteAction
096: * @return an instance of SafeDeleteAction
097: */
098: public static ContextAwareAction safeDeleteAction() {
099: return SafeDeleteAction
100: .findObject(SafeDeleteAction.class, true);
101: }
102:
103: /**
104: * Factory method for CopyAction
105: * @return an instance of CopyAction
106: */
107: public static ContextAwareAction copyAction() {
108: return SafeDeleteAction.findObject(CopyAction.class, true);
109: }
110:
111: /**
112: * Factory method for WhereUsedAction
113: * @return an instance of WhereUsedAction
114: */
115: public static ContextAwareAction whereUsedAction() {
116: return WhereUsedAction.findObject(WhereUsedAction.class, true);
117: }
118:
119: /**
120: * Factory method for RSMEditorAction
121: * @return an instance of RSMEditorAction
122: */
123: public static Action editorSubmenuAction() {
124: return RSMEditorAction.findObject(RSMEditorAction.class, true);
125: }
126:
127: /**
128: * Factory method for RSMDataObjectAction
129: * @return an instance of RSMDataObjectAction
130: */
131: public static ContextAwareAction popupSubmenuAction() {
132: return RSMDataObjectAction.findObject(
133: RSMDataObjectAction.class, true);
134: }
135: }
|