View | Details | Raw Unified | Return to bug 181517
Collapse All | Expand All

(-)src/org/eclipse/rse/internal/remotecdt/Messages.java (+3 lines)
Lines 10-15 Link Here
10
 * Ewa Matejska          (PalmSource) - [158783] browse button for cdt remote path
10
 * Ewa Matejska          (PalmSource) - [158783] browse button for cdt remote path
11
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
11
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
12
 * Anna Dushistova       (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
12
 * Anna Dushistova       (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
13
 * Anna Dushistova       (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.rse.internal.remotecdt;
15
package org.eclipse.rse.internal.remotecdt;
15
16
Lines 26-31 Link Here
26
27
27
	public static String Remote_GDB_Debugger_Options;
28
	public static String Remote_GDB_Debugger_Options;
28
29
30
	public static String RemoteCMainTab_Prerun;
31
29
	public static String RemoteCMainTab_Program;
32
	public static String RemoteCMainTab_Program;
30
33
31
	public static String RemoteCMainTab_Remote_Path_Browse_Button;
34
	public static String RemoteCMainTab_Remote_Path_Browse_Button;
(-)src/org/eclipse/rse/internal/remotecdt/IRemoteConnectionConfigurationConstants.java (-2 / +6 lines)
Lines 1-12 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 PalmSource, Inc.
2
 * Copyright (c) 2006 PalmSource, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
7
 * 
8
 * Contributors: 
8
 * Contributors: 
9
 * Ewa Matejska (PalmSource) - Adapted from IGDBServerMILaunchConfigurationConstants
9
 * Ewa Matejska    (PalmSource) - Adapted from IGDBServerMILaunchConfigurationConstants
10
 * Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
13
Lines 40-43 Link Here
40
	public static final String ATTR_SKIP_DOWNLOAD_TO_TARGET = 
41
	public static final String ATTR_SKIP_DOWNLOAD_TO_TARGET = 
41
				DebugPlugin.getUniqueIdentifier() + ".ATTR_SKIP_DOWNLOAD_TO_TARGET"; //$NON-NLS-1$
42
				DebugPlugin.getUniqueIdentifier() + ".ATTR_SKIP_DOWNLOAD_TO_TARGET"; //$NON-NLS-1$
42
43
44
45
	public static final String ATTR_PRERUN_COMMANDS = DebugPlugin.getUniqueIdentifier() + ".ATTR_PRERUN_CMDS"; //$NON-NLS-1$
46
43
}
47
}
(-)src/org/eclipse/rse/internal/remotecdt/messages.properties (+2 lines)
Lines 10-15 Link Here
10
# Ewa Matejska          (PalmSource) - [158783] browse button for cdt remote path
10
# Ewa Matejska          (PalmSource) - [158783] browse button for cdt remote path
11
# Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
11
# Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
12
# Anna Dushistova       (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
12
# Anna Dushistova       (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
13
# Anna Dushistova       (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
13
################################################################################
14
################################################################################
14
15
15
# NLS_MESSAGEFORMAT_VAR
16
# NLS_MESSAGEFORMAT_VAR
Lines 29-34 Link Here
29
RemoteRunLaunchDelegate_8=Executing {0} {1}
30
RemoteRunLaunchDelegate_8=Executing {0} {1}
30
RemoteRunLaunchDelegate_9=Starting Program
31
RemoteRunLaunchDelegate_9=Starting Program
31
32
33
RemoteCMainTab_Prerun=Commands to execute before application
32
RemoteCMainTab_Program=Remote Absolute File Path for C/C++ Application:
34
RemoteCMainTab_Program=Remote Absolute File Path for C/C++ Application:
33
RemoteCMainTab_SkipDownload=Skip download to target path.
35
RemoteCMainTab_SkipDownload=Skip download to target path.
34
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
36
Remote_GDB_Debugger_Options=Remote GDB Debugger Options
(-)src/org/eclipse/rse/internal/remotecdt/RemoteCMainTab.java (-5 / +38 lines)
Lines 6-18 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Ewa Matejska (PalmSource) - initial API and implementation
9
 * Ewa Matejska          (PalmSource) - initial API and implementation
10
 * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
10
 * Martin Oberhuber      (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
11
 * Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
11
 * Martin Oberhuber      (Wind River) - [196934] hide disabled system types in remotecdt combo
12
 * Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
12
 * Yu-Fen Kuo            (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
13
 * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
13
 * Martin Oberhuber      (Wind River) - [cleanup] Avoid using SystemStartHere in production code
14
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
14
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
15
 * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
15
 * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
16
 * Anna Dushistova       (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.rse.internal.remotecdt;
19
package org.eclipse.rse.internal.remotecdt;
Lines 63-68 Link Here
63
	private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
64
	private static final String SKIP_DOWNLOAD_BUTTON_TEXT = Messages.RemoteCMainTab_SkipDownload;
64
	private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
65
	private static final String REMOTE_PROG_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoProgram;
65
	private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
66
	private static final String CONNECTION_TEXT_ERROR = Messages.RemoteCMainTab_ErrorNoConnection;
67
	private static final String PRE_RUN_LABEL_TEXT = Messages.RemoteCMainTab_Prerun;
66
68
67
	/* Defaults */
69
	/* Defaults */
68
	private static final String REMOTE_PATH_DEFAULT = EMPTY_STRING;
70
	private static final String REMOTE_PATH_DEFAULT = EMPTY_STRING;
Lines 81-86 Link Here
81
	private static int initializedRSE = 0;  //0=not initialized; -1=initializing; 1=initialized
83
	private static int initializedRSE = 0;  //0=not initialized; -1=initializing; 1=initialized
82
84
83
	SystemNewConnectionAction action = null;
85
	SystemNewConnectionAction action = null;
86
	private Text preRunText;
87
	private Label preRunLabel;
84
88
85
	public RemoteCMainTab(boolean terminalOption) {
89
	public RemoteCMainTab(boolean terminalOption) {
86
		super(terminalOption);
90
		super(terminalOption);
Lines 241-246 Link Here
241
				updateLaunchConfigurationDialog();
245
				updateLaunchConfigurationDialog();
242
			}
246
			}
243
		});
247
		});
248
		
249
		//Commands to run before execution
250
		preRunLabel = new Label(mainComp, SWT.NONE);
251
		preRunLabel.setText(PRE_RUN_LABEL_TEXT);
252
		gd = new GridData();
253
		gd.horizontalSpan = 2;
254
		preRunLabel.setLayoutData(gd);
255
256
		preRunText = new Text(mainComp, SWT.MULTI | SWT.BORDER);
257
		gd = new GridData(GridData.FILL_HORIZONTAL);
258
		gd.horizontalSpan = 2;
259
		preRunText.setLayoutData(gd);
260
		preRunText.addModifyListener(new ModifyListener() {
261
262
			public void modifyText(ModifyEvent evt) {
263
				updateLaunchConfigurationDialog();
264
			}
265
		});
266
244
	}
267
	}
245
268
246
	/*
269
	/*
Lines 279-284 Link Here
279
				remoteProgText.getText());
302
				remoteProgText.getText());
280
		config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET,
303
		config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET,
281
				skipDownloadButton.getSelection());
304
				skipDownloadButton.getSelection());
305
		config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS, preRunText.getText());
282
		super.performApply(config);
306
		super.performApply(config);
283
	}
307
	}
284
308
Lines 514-519 Link Here
514
			// Ignore
538
			// Ignore
515
		}
539
		}
516
		remoteProgText.setText(targetPath);
540
		remoteProgText.setText(targetPath);
541
		
542
		String prelaunchCmd = null;
543
		try {
544
			prelaunchCmd = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS,
545
						 ""); //$NON-NLS-1$
546
		} catch (CoreException e) {
547
			// Ignore
548
		}
549
		preRunText.setText(prelaunchCmd);
517
	}
550
	}
518
551
519
	protected void updateSkipDownloadFromConfig(ILaunchConfiguration config) {
552
	protected void updateSkipDownloadFromConfig(ILaunchConfiguration config) {
(-)src/org/eclipse/rse/internal/remotecdt/RemoteRunLaunchDelegate.java (-6 / +9 lines)
Lines 13-18 Link Here
13
 * Anna Dushistova  (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
13
 * Anna Dushistova  (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
14
 * Anna Dushistova  (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
14
 * Anna Dushistova  (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
15
 * Anna Dushistova  (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
15
 * Anna Dushistova  (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
16
 * Anna Dushistova  (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
19
Lines 82-87 Link Here
82
83
83
		String arguments = getProgramArguments(config);
84
		String arguments = getProgramArguments(config);
84
		String remoteExePath = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, ""); //$NON-NLS-1$
85
		String remoteExePath = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, ""); //$NON-NLS-1$
86
		String prelaunchCmd = config.getAttribute(IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS, ""); //$NON-NLS-1$
85
		
87
		
86
		if(monitor==null) 
88
		if(monitor==null) 
87
			monitor = new NullProgressMonitor();
89
			monitor = new NullProgressMonitor();
Lines 111-117 Link Here
111
					if(arguments != null && !arguments.equals("")) //$NON-NLS-1$
113
					if(arguments != null && !arguments.equals("")) //$NON-NLS-1$
112
						command_arguments += " " + arguments; //$NON-NLS-1$
114
						command_arguments += " " + arguments; //$NON-NLS-1$
113
					monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9); 
115
					monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9); 
114
					remoteShellProcess = remoteShellExec(config, gdbserver_command,
116
					remoteShellProcess = remoteShellExec(config, prelaunchCmd,gdbserver_command,
115
														 command_arguments, new SubProgressMonitor(monitor, 5));
117
														 command_arguments, new SubProgressMonitor(monitor, 5));
116
					DebugPlugin.newProcess(launch, remoteShellProcess, Messages.RemoteRunLaunchDelegate_RemoteShell);
118
					DebugPlugin.newProcess(launch, remoteShellProcess, Messages.RemoteRunLaunchDelegate_RemoteShell);
117
119
Lines 174-184 Link Here
174
				remoteFileDownload(config, launch, exePath.toString(),remoteExePath, new SubProgressMonitor(monitor,80));
176
				remoteFileDownload(config, launch, exePath.toString(),remoteExePath, new SubProgressMonitor(monitor,80));
175
				// Use a remote shell to launch the binary.
177
				// Use a remote shell to launch the binary.
176
				monitor.setTaskName(Messages.RemoteRunLaunchDelegate_12); 
178
				monitor.setTaskName(Messages.RemoteRunLaunchDelegate_12); 
177
				remoteProcess = remoteShellExec(config, remoteExePath, arguments, new SubProgressMonitor(monitor,20));
179
				remoteProcess = remoteShellExec(config, prelaunchCmd, remoteExePath, arguments, new SubProgressMonitor(monitor,20));
178
				DebugPlugin.newProcess(launch, remoteProcess, renderProcessLabel(exePath.toOSString()));
180
				DebugPlugin.newProcess(launch, remoteProcess, renderProcessLabel(exePath.toOSString()));
179
			} catch (CoreException e) {
181
			} catch (CoreException e) {
180
				if(remoteProcess != null)
181
					remoteProcess.destroy();
182
				throw e;
182
				throw e;
183
			} finally {
183
			} finally {
184
				monitor.done();
184
				monitor.done();
Lines 270-276 Link Here
270
			fileService.upload(file, remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(),
270
			fileService.upload(file, remotePath.removeLastSegments(1).toString(), remotePath.lastSegment(),
271
					true, null, null, new SubProgressMonitor(monitor, 85));				
271
					true, null, null, new SubProgressMonitor(monitor, 85));				
272
			// Need to change the permissions to match the original file permissions because of a bug in upload
272
			// Need to change the permissions to match the original file permissions because of a bug in upload
273
			Process p = remoteShellExec(config, "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$
273
			Process p = remoteShellExec(config,"", "chmod", "+x " + spaceEscapify(remotePath.toString()), new SubProgressMonitor(monitor, 5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
274
			Thread.sleep(500);
274
			Thread.sleep(500);
275
			p.destroy();
275
			p.destroy();
276
		} catch (SystemOperationCancelledException e) {
276
		} catch (SystemOperationCancelledException e) {
Lines 288-294 Link Here
288
		return currentConnection.getHostName();
288
		return currentConnection.getHostName();
289
	}
289
	}
290
290
291
	protected Process remoteShellExec(ILaunchConfiguration config, String remoteCommandPath,
291
	protected Process remoteShellExec(ILaunchConfiguration config, String prelaunchCmd, String remoteCommandPath,
292
			String arguments, IProgressMonitor monitor) throws CoreException {
292
			String arguments, IProgressMonitor monitor) throws CoreException {
293
		// The exit command is called to force the remote shell to close after our command
293
		// The exit command is called to force the remote shell to close after our command
294
		// is executed. This is to prevent a running process at the end of the debug session.
294
		// is executed. This is to prevent a running process at the end of the debug session.
Lines 296-303 Link Here
296
		monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, remoteCommandPath,arguments), 10);
296
		monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, remoteCommandPath,arguments), 10);
297
		String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
297
		String real_remote_command = arguments == null ? spaceEscapify(remoteCommandPath) :
298
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
298
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
299
299
		String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
300
		String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
300
301
302
		if(!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
303
		    remote_command = prelaunchCmd + CMD_DELIMITER + remote_command;
301
		
304
		
302
		IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE, new SubProgressMonitor(monitor,7));
305
		IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE, new SubProgressMonitor(monitor,7));
303
306

Return to bug 181517