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.spi.project.ui.support;
043:
044: import javax.swing.Action;
045: import org.netbeans.modules.project.uiapi.Utilities;
046:
047: /**
048: * Factory for commonly needed generic project actions.
049: * @author Jesse Glick, Petr Hrebejk
050: */
051: public class CommonProjectActions {
052:
053: /**
054: * {@link org.openide.filesystems.FileObject} value honored by {@link #newProjectAction}
055: * that defines initial value for existing sources directory choosers.
056: *
057: * @since org.netbeans.modules.projectuiapi/1 1.3
058: */
059: public static final String EXISTING_SOURCES_FOLDER = "existingSourcesFolder";
060:
061: private CommonProjectActions() {
062: }
063:
064: /**
065: * Create an action "Set As Main Project".
066: * It should be invoked with an action context containing
067: * one {@link org.netbeans.api.project.Project}.
068: * <p class="nonnormative">
069: * You might include this in the context menu of a logical view.
070: * </p>
071: * @return an action
072: */
073: public static Action setAsMainProjectAction() {
074: return Utilities.getActionsFactory().setAsMainProjectAction();
075: }
076:
077: /**
078: * Create an action "Customize Project".
079: * It should be invoked with an action context containing
080: * one {@link org.netbeans.api.project.Project}.
081: * <p class="nonnormative">
082: * You might include this in the context menu of a logical view.
083: * </p>
084: * @return an action
085: */
086: public static Action customizeProjectAction() {
087: return Utilities.getActionsFactory().customizeProjectAction();
088: }
089:
090: /**
091: * Create an action "Open Subprojects".
092: * It should be invoked with an action context containing
093: * one or more {@link org.netbeans.api.project.Project}s.
094: * <p class="nonnormative">
095: * You might include this in the context menu of a logical view.
096: * </p>
097: * @return an action
098: * @see org.netbeans.spi.project.SubprojectProvider
099: */
100: public static Action openSubprojectsAction() {
101: return Utilities.getActionsFactory().openSubprojectsAction();
102: }
103:
104: /**
105: * Create an action "Close Project".
106: * It should be invoked with an action context containing
107: * one or more {@link org.netbeans.api.project.Project}s.
108: * <p class="nonnormative">
109: * You might include this in the context menu of a logical view.
110: * </p>
111: * @return an action
112: */
113: public static Action closeProjectAction() {
114: return Utilities.getActionsFactory().closeProjectAction();
115: }
116:
117: /**
118: * Create an action project dependent "New File" action.
119: * <p class="nonnormative">
120: * You might include this in the context menu of a logical view.
121: * </p>
122: * @return an action
123: * @see org.netbeans.spi.project.ui.PrivilegedTemplates
124: * @see org.netbeans.spi.project.ui.RecommendedTemplates
125: */
126: public static Action newFileAction() {
127: return Utilities.getActionsFactory().newFileAction();
128: }
129:
130: /**
131: * Create an action "Delete Project".
132: * It should be invoked with an action context containing
133: * one or more {@link org.netbeans.api.project.Project}s.
134: * <p class="nonnormative">
135: * You might include this in the context menu of a logical view.
136: * </p>
137: * @since 1.8
138: * @return an action
139: */
140: public static Action deleteProjectAction() {
141: return Utilities.getActionsFactory().deleteProjectAction();
142: }
143:
144: /**
145: * Create an action "Copy Project".
146: * It should be invoked with an action context containing
147: * one or more {@link org.netbeans.api.project.Project}s.
148: * <p class="nonnormative">
149: * You might include this in the context menu of a logical view.
150: * </p>
151: * @since 1.10
152: * @return an action
153: */
154: public static Action copyProjectAction() {
155: return Utilities.getActionsFactory().copyProjectAction();
156: }
157:
158: /**
159: * Create an action "Move Project".
160: * It should be invoked with an action context containing
161: * one or more {@link org.netbeans.api.project.Project}s.
162: * <p class="nonnormative">
163: * You might include this in the context menu of a logical view.
164: * </p>
165: * @since 1.10
166: * @return an action
167: */
168: public static Action moveProjectAction() {
169: return Utilities.getActionsFactory().moveProjectAction();
170: }
171:
172: /**
173: * Create an action "Rename Project".
174: * It should be invoked with an action context containing
175: * one or more {@link org.netbeans.api.project.Project}s.
176: * <p class="nonnormative">
177: * You might include this in the context menu of a logical view.
178: * </p>
179: * @since 1.10
180: * @return an action
181: */
182: public static Action renameProjectAction() {
183: return Utilities.getActionsFactory().renameProjectAction();
184: }
185:
186: /**
187: * Creates action that invokes <b>New Project</b> wizard.
188: *
189: * <p>{@link #EXISTING_SOURCES_FOLDER} keyed action
190: * value can carry {@link org.openide.filesystems.FileObject} that points
191: * to existing sources folder. {@link Action#putValue Set this value}
192: * if you open the wizard and you know user
193: * expectations about initial value for wizard
194: * choosers that refers to existing sources location.
195: *
196: * @return an action
197: *
198: * @since org.netbeans.modules.projectuiapi/1 1.3
199: */
200: public static Action newProjectAction() {
201: return Utilities.getActionsFactory().newProjectAction();
202: }
203:
204: /**
205: * Creates an action that sets the configuration of the selected project.
206: * It should be displayed with an action context containing
207: * exactly one {@link org.netbeans.api.project.Project}.
208: * The action itself should not be invoked but you may use its popup presenter.
209: * <p class="nonnormative">
210: * You might include this in the context menu of a logical view.
211: * </p>
212: * @return an action
213: * @since org.netbeans.modules.projectuiapi/1 1.17
214: * @see org.netbeans.spi.project.ProjectConfigurationProvider
215: */
216: public static Action setProjectConfigurationAction() {
217: return Utilities.getActionsFactory()
218: .setProjectConfigurationAction();
219: }
220:
221: }
|