KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > ruby > rubyproject > execution > ExecutionDescriptor


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 package org.netbeans.modules.ruby.rubyproject.execution;
20
21 import java.io.File JavaDoc;
22 import java.util.ArrayList JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.openide.filesystems.FileObject;
26
27
28 /**
29  * An ExecutionDescriptor describes a program to be executed, the arguments
30  * and environment to be used, as well as preferences such as whether the
31  * running process should be in the background (no progress bar), and so on.
32  *
33  * @author Tor Norbye
34  */

35 public class ExecutionDescriptor {
36     File JavaDoc pwd;
37     File JavaDoc cmd;
38     boolean inputVisible;
39     String JavaDoc displayName;
40     Runnable JavaDoc postBuildAction;
41     FileLocator fileLocator;
42     String JavaDoc[] args;
43     String JavaDoc additionalArgs;
44     String JavaDoc initialArgs;
45     FileObject fileObject;
46     boolean showProgress = true;
47     boolean showSuspended;
48     List JavaDoc<OutputRecognizer> outputRecognizers = new ArrayList JavaDoc<OutputRecognizer>();
49
50     /** Creates a new instance of ExecutionDescriptor */
51     public ExecutionDescriptor() {
52     }
53
54     public ExecutionDescriptor(final String JavaDoc displayName, final File JavaDoc pwd, final String JavaDoc... args) {
55         this.displayName = displayName;
56         this.pwd = pwd;
57         this.args = args;
58         assert (pwd != null) && pwd.exists() : pwd;
59     }
60
61     public ExecutionDescriptor cmd(final File JavaDoc cmd) {
62         this.cmd = cmd;
63         assert (cmd != null) && cmd.exists() : cmd;
64
65         return this;
66     }
67
68     public ExecutionDescriptor postBuild(Runnable JavaDoc postBuildAction) {
69         this.postBuildAction = postBuildAction;
70
71         return this;
72     }
73
74     public ExecutionDescriptor fileLocator(FileLocator fileLocator) {
75         this.fileLocator = fileLocator;
76
77         return this;
78     }
79
80     /** Set FileObject associated with this execution (typically the source file).
81      * This is not injected in the argument list in any way, but for example
82      * the Rerun action will get disabled if this file is deleted.
83      */

84     public ExecutionDescriptor fileObject(FileObject fileObject) {
85         this.fileObject = fileObject;
86
87         return this;
88     }
89
90     public ExecutionDescriptor addOutputRecognizer(OutputRecognizer recognizer) {
91         outputRecognizers.add(recognizer);
92
93         return this;
94     }
95
96     public ExecutionDescriptor allowInput() {
97         this.inputVisible = true;
98
99         return this;
100     }
101
102     public ExecutionDescriptor showProgress(boolean showProgress) {
103         this.showProgress = showProgress;
104
105         return this;
106     }
107
108     public ExecutionDescriptor showSuspended(boolean showSuspended) {
109         this.showSuspended = showSuspended;
110
111         return this;
112     }
113
114     /** Arguments that will be parsed and appended AFTER the target */
115     public ExecutionDescriptor additionalArgs(String JavaDoc additionalArgs) {
116         this.additionalArgs = additionalArgs;
117
118         return this;
119     }
120
121     /** Arguments that will be parsed and prepended BEFORE the target */
122     public ExecutionDescriptor initialArgs(String JavaDoc initialArgs) {
123         this.initialArgs = initialArgs;
124
125         return this;
126     }
127 }
128
Popular Tags