KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > launchConfigurations > AntProcess


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
14 import java.util.HashMap JavaDoc;
15 import java.util.Map JavaDoc;
16
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.PlatformObject;
19 import org.eclipse.debug.core.DebugEvent;
20 import org.eclipse.debug.core.DebugPlugin;
21 import org.eclipse.debug.core.ILaunch;
22 import org.eclipse.debug.core.model.IProcess;
23 import org.eclipse.debug.core.model.IStreamsProxy;
24 import org.eclipse.debug.ui.console.IConsole;
25
26 public class AntProcess extends PlatformObject implements IProcess, IProgressMonitor {
27     
28     private AntStreamsProxy fProxy;
29     private String JavaDoc fLabel = null;
30     private ILaunch fLaunch = null;
31     private Map JavaDoc fAttributes = null;
32     private boolean fTerminated = false;
33     private boolean fCancelled = false;
34     private IConsole fConsole = null;
35     
36     public AntProcess(String JavaDoc label, ILaunch launch, Map JavaDoc attributes) {
37         fLabel = label;
38         fLaunch = launch;
39         if (attributes == null) {
40             fAttributes = new HashMap JavaDoc();
41         } else {
42             fAttributes = attributes;
43         }
44         String JavaDoc captureOutput= launch.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT);
45         if(!("false".equals(captureOutput))) { //$NON-NLS-1$
46
fProxy= new AntStreamsProxy();
47         }
48         launch.addProcess(this);
49     }
50
51     /**
52      * @see org.eclipse.debug.core.model.IProcess#getLabel()
53      */

54     public String JavaDoc getLabel() {
55         return fLabel;
56     }
57
58     /**
59      * @see org.eclipse.debug.core.model.IProcess#getLaunch()
60      */

61     public ILaunch getLaunch() {
62         return fLaunch;
63     }
64
65     /**
66      * @see org.eclipse.debug.core.model.IProcess#getStreamsProxy()
67      */

68     public IStreamsProxy getStreamsProxy() {
69         return fProxy;
70     }
71
72     /**
73      * @see org.eclipse.debug.core.model.IProcess#setAttribute(java.lang.String, java.lang.String)
74      */

75     public void setAttribute(String JavaDoc key, String JavaDoc value) {
76         fAttributes.put(key, value);
77     }
78
79     /**
80      * @see org.eclipse.debug.core.model.IProcess#getAttribute(java.lang.String)
81      */

82     public String JavaDoc getAttribute(String JavaDoc key) {
83         return (String JavaDoc)fAttributes.get(key);
84     }
85
86     /**
87      * @see org.eclipse.debug.core.model.IProcess#getExitValue()
88      */

89     public int getExitValue() {
90         return 0;
91     }
92
93     /**
94      * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
95      */

96     public boolean canTerminate() {
97         return !isCanceled() && !isTerminated();
98     }
99
100     /**
101      * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
102      */

103     public boolean isTerminated() {
104         return fTerminated;
105     }
106     
107     protected void terminated() {
108         if (!fTerminated) {
109             fTerminated = true;
110             if (DebugPlugin.getDefault() != null) {
111                 DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
112             }
113         }
114     }
115
116     /**
117      * @see org.eclipse.debug.core.model.ITerminate#terminate()
118      */

119     public void terminate() {
120         setCanceled(true);
121     }
122
123     /**
124      * Returns the console associated with this process, or <code>null</code> if
125      * none.
126      *
127      * @return console, or <code>null</code>
128      */

129     public IConsole getConsole() {
130         return fConsole;
131     }
132     
133     /**
134      * Sets the console associated with this process.
135      *
136      * @param console
137      */

138     public void setConsole(IConsole console) {
139         fConsole = console;
140     }
141     
142     // IProgressMonitor implemented to support termination.
143

144     /**
145      * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
146      */

147     public void beginTask(String JavaDoc name, int totalWork) {
148     }
149
150     /**
151      * @see org.eclipse.core.runtime.IProgressMonitor#done()
152      */

153     public void done() {
154     }
155
156     /**
157      * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
158      */

159     public void internalWorked(double work) {
160     }
161
162     /**
163      * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
164      */

165     public boolean isCanceled() {
166         return fCancelled;
167     }
168
169     /**
170      * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
171      */

172     public void setCanceled(boolean value) {
173         fCancelled = value;
174     }
175
176     /**
177      * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
178      */

179     public void setTaskName(String JavaDoc name) {
180     }
181
182     /**
183      * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
184      */

185     public void subTask(String JavaDoc name) {
186     }
187
188     /**
189      * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
190      */

191     public void worked(int work) {
192     }
193 }
194
Popular Tags