|
Lines 13-19
Link Here
|
| 13 |
package org.eclipse.tm.internal.terminal.local; |
13 |
package org.eclipse.tm.internal.terminal.local; |
| 14 |
|
14 |
|
| 15 |
import java.io.OutputStream; |
15 |
import java.io.OutputStream; |
|
|
16 |
import java.text.Format; |
| 17 |
import java.text.MessageFormat; |
| 18 |
|
| 16 |
import org.eclipse.core.runtime.CoreException; |
19 |
import org.eclipse.core.runtime.CoreException; |
|
|
20 |
import org.eclipse.core.runtime.IStatus; |
| 21 |
import org.eclipse.core.runtime.Status; |
| 17 |
import org.eclipse.debug.core.DebugEvent; |
22 |
import org.eclipse.debug.core.DebugEvent; |
| 18 |
import org.eclipse.debug.core.DebugException; |
23 |
import org.eclipse.debug.core.DebugException; |
| 19 |
import org.eclipse.debug.core.DebugPlugin; |
24 |
import org.eclipse.debug.core.DebugPlugin; |
|
Lines 26-31
Link Here
|
| 26 |
import org.eclipse.debug.core.model.IStreamMonitor; |
31 |
import org.eclipse.debug.core.model.IStreamMonitor; |
| 27 |
import org.eclipse.debug.core.model.IStreamsProxy; |
32 |
import org.eclipse.debug.core.model.IStreamsProxy; |
| 28 |
import org.eclipse.debug.ui.IDebugUIConstants; |
33 |
import org.eclipse.debug.ui.IDebugUIConstants; |
|
|
34 |
import org.eclipse.jface.dialogs.ErrorDialog; |
| 35 |
import org.eclipse.swt.widgets.Display; |
| 36 |
import org.eclipse.swt.widgets.Shell; |
| 29 |
import org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchUtilities; |
37 |
import org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchUtilities; |
| 30 |
import org.eclipse.tm.internal.terminal.local.process.LocalTerminalProcessFactory; |
38 |
import org.eclipse.tm.internal.terminal.local.process.LocalTerminalProcessFactory; |
| 31 |
import org.eclipse.tm.internal.terminal.local.process.LocalTerminalProcessRegistry; |
39 |
import org.eclipse.tm.internal.terminal.local.process.LocalTerminalProcessRegistry; |
|
Lines 171-192
Link Here
|
| 171 |
control.setState(TerminalState.CONNECTING); |
179 |
control.setState(TerminalState.CONNECTING); |
| 172 |
ILaunchConfigurationWorkingCopy workingCopy = null; |
180 |
ILaunchConfigurationWorkingCopy workingCopy = null; |
| 173 |
ILaunchConfiguration configuration = null; |
181 |
ILaunchConfiguration configuration = null; |
|
|
182 |
String configurationName = null; |
| 174 |
try { |
183 |
try { |
| 175 |
|
184 |
|
| 176 |
String configurationName = settings.getLaunchConfigurationName(); |
185 |
configurationName = settings.getLaunchConfigurationName(); |
| 177 |
configuration = LocalTerminalUtilities.findLaunchConfiguration(configurationName); |
186 |
configuration = LocalTerminalUtilities.findLaunchConfiguration(configurationName); |
|
|
187 |
} |
| 188 |
catch (CoreException exception) { |
| 178 |
|
189 |
|
| 179 |
// Always set the the process factory ID and enable console output (there is no need |
190 |
Shell shell = Display.getDefault().getActiveShell(); |
| 180 |
// to restore these attributes afterwards; disabling console output does not make |
191 |
String title = LocalTerminalMessages.errorTitleCouldNotConnectToTerminal; |
| 181 |
// sense for terminal launches and will be overridden when the configuration is |
192 |
Format text; |
| 182 |
// actually launched): |
193 |
text = new MessageFormat(LocalTerminalMessages.errorLaunchConfigurationNoLongerExists); |
| 183 |
// |
194 |
String message = text.format(new Object[] {configurationName}); |
|
|
195 |
IStatus status = new Status(IStatus.ERROR, LocalTerminalActivator.PLUGIN_ID, message); |
| 196 |
ErrorDialog.openError(shell, title, null, status); |
| 197 |
control.setState(TerminalState.CLOSED); |
| 198 |
return; |
| 199 |
} |
| 200 |
try { |
| 201 |
|
| 202 |
String oldFactoryID = configuration.getAttribute(ATTR_PROCESS_FACTORY_ID, (String)null); |
| 184 |
workingCopy = configuration.getWorkingCopy(); |
203 |
workingCopy = configuration.getWorkingCopy(); |
| 185 |
workingCopy.setAttribute(ATTR_CAPTURE_OUTPUT, true); |
204 |
workingCopy.setAttribute(ATTR_CAPTURE_OUTPUT, true); |
| 186 |
workingCopy.setAttribute(ATTR_CAPTURE_IN_CONSOLE, true); |
205 |
workingCopy.setAttribute(ATTR_CAPTURE_IN_CONSOLE, true); |
| 187 |
workingCopy.setAttribute(ATTR_PROCESS_FACTORY_ID, LocalTerminalProcessFactory.ID); |
206 |
workingCopy.setAttribute(ATTR_PROCESS_FACTORY_ID, LocalTerminalProcessFactory.ID); |
| 188 |
configuration = workingCopy.doSave(); |
207 |
configuration = workingCopy.doSave(); |
| 189 |
launch = configuration.launch(ILaunchManager.RUN_MODE, null); |
208 |
try { |
|
|
209 |
|
| 210 |
launch = configuration.launch(ILaunchManager.RUN_MODE, null); |
| 211 |
} |
| 212 |
finally { |
| 213 |
|
| 214 |
// The process factory ID is used to distinguish between launches that originate |
| 215 |
// from the terminal connector and launches that originate from the launch dialog. |
| 216 |
// After launching, the original ID is restored so that the launch is not mistaken |
| 217 |
// as originating from the terminal connector UI when it is launched via the launch |
| 218 |
// dialog the next time: |
| 219 |
// |
| 220 |
workingCopy = configuration.getWorkingCopy(); |
| 221 |
workingCopy.setAttribute(ATTR_PROCESS_FACTORY_ID, oldFactoryID); |
| 222 |
workingCopy.doSave(); |
| 223 |
} |
| 190 |
|
224 |
|
| 191 |
// To prevent a console from being allocated, the launch will actually not contain a |
225 |
// To prevent a console from being allocated, the launch will actually not contain a |
| 192 |
// reference to the runtime process. The process has to be obtained from the |
226 |
// reference to the runtime process. The process has to be obtained from the |
|
Lines 257-265
Link Here
|
| 257 |
// |
291 |
// |
| 258 |
LocalTerminalProcessRegistry.addProcessBackToFinishedLaunch(launch); |
292 |
LocalTerminalProcessRegistry.addProcessBackToFinishedLaunch(launch); |
| 259 |
|
293 |
|
| 260 |
// Now, terminate the process if it hasn't been terminated already: |
294 |
// Now, terminate the process if it was ever started and hasn't been terminated already: |
| 261 |
// |
295 |
// |
| 262 |
if (launch.canTerminate()) { |
296 |
if (launch != null && launch.canTerminate()) { |
| 263 |
|
297 |
|
| 264 |
launch.terminate(); |
298 |
launch.terminate(); |
| 265 |
// |
299 |
// |