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;
043:
044: import org.openide.util.Lookup;
045:
046: /**
047: * Ability for a project to have various actions (e.g. Build) invoked on it.
048: * Should be registered in a project's lookup and will be used by UI infrastructure.
049: * @see org.netbeans.api.project.Project#getLookup
050: * @see <a href="@org-apache-tools-ant-module@/org/apache/tools/ant/module/api/support/ActionUtils.html"><code>ActionUtils</code></a>
051: * @see <a href="@org-netbeans-modules-projectuiapi@/org/netbeans/spi/project/ui/support/ProjectSensitiveActions.html#projectCommandAction(java.lang.String,%20java.lang.String,%20javax.swing.Icon)"><code>ProjectSensitiveActions.projectCommandAction(...)</code></a>
052: * @author Jesse Glick
053: */
054: public interface ActionProvider {
055:
056: /**
057: * Standard command to incrementally build the project.
058: */
059: String COMMAND_BUILD = "build"; // NOI18N
060:
061: /**
062: * Standard command for compiling set of files
063: */
064: String COMMAND_COMPILE_SINGLE = "compile.single"; // NOI18N
065:
066: /**
067: * Standard command to clean build products.
068: */
069: String COMMAND_CLEAN = "clean"; // NOI18N
070:
071: /**
072: * Standard command to do a "clean" (forced) rebuild.
073: */
074: String COMMAND_REBUILD = "rebuild"; // NOI18N
075:
076: /**
077: * Standard command for running the project
078: */
079: String COMMAND_RUN = "run"; // NOI18N
080:
081: /**
082: * Standard command for running one file
083: */
084: String COMMAND_RUN_SINGLE = "run.single"; // NOI18N
085:
086: /**
087: * Standard command for running tests on given projects
088: */
089: String COMMAND_TEST = "test"; // NOI18N
090:
091: /**
092: * Standard command for running one test file
093: */
094: String COMMAND_TEST_SINGLE = "test.single"; // NOI18N
095:
096: /**
097: * Standard command for running the project in debugger
098: */
099: String COMMAND_DEBUG = "debug"; // NOI18N
100:
101: /**
102: * Standard command for running single file in debugger
103: */
104: String COMMAND_DEBUG_SINGLE = "debug.single"; // NOI18N
105:
106: /**
107: * Standard command for running one test in debugger
108: */
109: String COMMAND_DEBUG_TEST_SINGLE = "debug.test.single"; // NOI18N
110:
111: /**
112: * Standard command for starting app in debugger and stopping at the
113: * beginning of app whatever that means.
114: */
115: String COMMAND_DEBUG_STEP_INTO = "debug.stepinto"; // NOI18N
116:
117: /**
118: * Standard command for deleting the project.
119: *
120: * @since 1.6
121: */
122: String COMMAND_DELETE = "delete"; // NOI18N
123:
124: /**
125: * Standard command for deleting the project.
126: *
127: * @since 1.7
128: */
129: String COMMAND_COPY = "copy"; // NOI18N
130:
131: /**
132: * Standard command for moving the project.
133: *
134: * @since 1.7
135: */
136: String COMMAND_MOVE = "move"; // NOI18N
137:
138: /**
139: * Standard command for renaming the project.
140: *
141: * @since 1.7
142: */
143: String COMMAND_RENAME = "rename"; // NOI18N
144:
145: /**
146: * Get a list of all commands which this project supports.
147: * @return a list of command names suitable for {@link #invokeAction}
148: * @see #COMMAND_BUILD
149: * @see #COMMAND_CLEAN
150: * @see #COMMAND_REBUILD
151: */
152: String[] getSupportedActions();
153:
154: /**
155: * Run a project command.
156: * Will be invoked in the event thread.
157: * The context may be ignored by some commands, but some may need it in order
158: * to get e.g. the selected source file to build by itself, etc.
159: * @param command a predefined command name (must be among {@link #getSupportedActions})
160: * @param context any action context, e.g. for a node selection
161: * (as in {@link ContextAwareAction})
162: * @throws IllegalArgumentException if the requested command is not supported
163: */
164: void invokeAction(String command, Lookup context)
165: throws IllegalArgumentException;
166:
167: /**
168: * Tells whether the command can be invoked in given context and thus if
169: * actions representing this command should be enabled or disabled.
170: * The context may be ignored by some commands, but some may need it in order
171: * to get e.g. the selected source file to build by itself, etc.
172: * @param command a predefined command name (must be among {@link #getSupportedActions})
173: * @param context any action context, e.g. for a node selection
174: * (as in {@link ContextAwareAction})
175: * @throws IllegalArgumentException if the requested command is not supported
176: */
177: boolean isActionEnabled(String command, Lookup context)
178: throws IllegalArgumentException;
179:
180: }
|