mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Bug 267951 - Patch from Anna to support system types without files subsystem.
This commit is contained in:
parent
3f6473cfed
commit
bfb0f1ab9c
3 changed files with 214 additions and 97 deletions
|
@ -0,0 +1,153 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2009 MontaVista Software, Inc.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anna Dushistova (MontaVista) - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.launch.remote;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.services.IService;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
|
||||
|
||||
public class RSEHelper {
|
||||
|
||||
public static IHost getRemoteConnectionByName(String remoteConnection) {
|
||||
if (remoteConnection == null)
|
||||
return null;
|
||||
IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
|
||||
for (int i = 0; i < connections.length; i++)
|
||||
if (connections[i].getAliasName().equals(remoteConnection))
|
||||
return connections[i];
|
||||
return null; // TODO Connection is not found in the list--need to react
|
||||
// somehow, throw the exception?
|
||||
|
||||
}
|
||||
|
||||
public static IService getConnectedRemoteFileService(
|
||||
IHost currentConnection, IProgressMonitor monitor) throws Exception {
|
||||
final ISubSystem subsystem = getFileSubsystem(currentConnection);
|
||||
|
||||
if (subsystem == null)
|
||||
throw new Exception(Messages.RemoteRunLaunchDelegate_4);
|
||||
|
||||
try {
|
||||
subsystem.connect(monitor, false);
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
} catch (OperationCanceledException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
|
||||
if (!subsystem.isConnected())
|
||||
throw new Exception(Messages.RemoteRunLaunchDelegate_5);
|
||||
|
||||
return ((IFileServiceSubSystem) subsystem).getFileService();
|
||||
}
|
||||
|
||||
public static IService getConnectedRemoteShellService(
|
||||
IHost currentConnection, IProgressMonitor monitor) throws Exception {
|
||||
ISubSystem subsystem = getSubSystemWithShellService(currentConnection);
|
||||
if (subsystem != null) {
|
||||
try {
|
||||
subsystem.connect(monitor, false);
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
} catch (OperationCanceledException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
}
|
||||
if (!subsystem.isConnected())
|
||||
throw new Exception(Messages.RemoteRunLaunchDelegate_5);
|
||||
|
||||
return (IShellService) subsystem.getSubSystemConfiguration()
|
||||
.getService(currentConnection).getAdapter(
|
||||
IShellService.class);
|
||||
} else {
|
||||
throw new Exception(Messages.RemoteRunLaunchDelegate_4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first shell service associated with the host.
|
||||
*
|
||||
* @param host
|
||||
* the connection
|
||||
* @return shell service object, or <code>null</code> if not found.
|
||||
*/
|
||||
public static IShellService getShellService(IHost host) {
|
||||
ISubSystem ss = getSubSystemWithShellService(host);
|
||||
if (ss != null) {
|
||||
return (IShellService) ss.getSubSystemConfiguration().getService(
|
||||
host).getAdapter(IShellService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the first IShellServiceSubSystem service associated with the host.
|
||||
*
|
||||
* @param host
|
||||
* the connection
|
||||
* @return shell service subsystem, or <code>null</code> if not found.
|
||||
*/
|
||||
public static ISubSystem getSubSystemWithShellService(IHost host) {
|
||||
if (host == null)
|
||||
return null;
|
||||
ISubSystem[] subSystems = host.getSubSystems();
|
||||
IShellService ssvc = null;
|
||||
for (int i = 0; subSystems != null && i < subSystems.length; i++) {
|
||||
IService svc = subSystems[i].getSubSystemConfiguration()
|
||||
.getService(host);
|
||||
if (svc != null) {
|
||||
ssvc = (IShellService) svc.getAdapter(IShellService.class);
|
||||
if (ssvc != null) {
|
||||
return subSystems[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ISubSystem getFileSubsystem(IHost host) {
|
||||
if (host == null)
|
||||
return null;
|
||||
ISubSystem[] subSystems = host.getSubSystems();
|
||||
for (int i = 0; i < subSystems.length; i++) {
|
||||
if (subSystems[i] instanceof IFileServiceSubSystem)
|
||||
return subSystems[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IHost[] getSuitableConnections() {
|
||||
ArrayList shellConnections = new ArrayList(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
|
||||
.getHostsBySubSystemConfigurationCategory("shells"))); //$NON-NLS-1$
|
||||
ArrayList terminalConnections = new ArrayList(Arrays.asList(RSECorePlugin.getTheSystemRegistry()
|
||||
.getHostsBySubSystemConfigurationCategory("terminals")));//$NON-NLS-1$
|
||||
|
||||
Iterator iter = terminalConnections.iterator();
|
||||
while(iter.hasNext()){
|
||||
Object terminalConnection = iter.next();
|
||||
if(!shellConnections.contains(terminalConnection)){
|
||||
shellConnections.add(terminalConnection);
|
||||
}
|
||||
}
|
||||
|
||||
return (IHost[]) shellConnections.toArray(new IHost[shellConnections.size()]);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
* Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
|
||||
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||
* Anna Dushistova (MontaVista) - [223728] [remotecdt] connection combo is not populated until RSE is activated
|
||||
* Anna Dushistova (MontaVista) - [267951] [remotecdt] Support systemTypes without files subsystem
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.launch.remote;
|
||||
|
@ -368,15 +369,8 @@ public class RemoteCMainTab extends CMainTab {
|
|||
int currentSelection = connectionCombo.getSelectionIndex();
|
||||
String remoteConnection = currentSelection >= 0 ? connectionCombo
|
||||
.getItem(currentSelection) : null;
|
||||
if (remoteConnection == null)
|
||||
return null;
|
||||
IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
|
||||
int i = 0;
|
||||
for (i = 0; i < connections.length; i++)
|
||||
if (connections[i].getAliasName().equals(remoteConnection))
|
||||
break;
|
||||
return connections[i];
|
||||
}
|
||||
return RSEHelper.getRemoteConnectionByName(remoteConnection);
|
||||
}
|
||||
|
||||
protected void handleRemoteBrowseSelected() {
|
||||
IHost currentConnectionSelected = getCurrentConnection();
|
||||
|
@ -494,8 +488,7 @@ public class RemoteCMainTab extends CMainTab {
|
|||
}
|
||||
// already initialized
|
||||
connectionCombo.removeAll();
|
||||
IHost[] connections = RSECorePlugin.getTheSystemRegistry()
|
||||
.getHostsBySubSystemConfigurationCategory("shells"); //$NON-NLS-1$
|
||||
IHost[] connections = RSEHelper.getSuitableConnections();
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
IRSESystemType sysType = connections[i].getSystemType();
|
||||
if (sysType != null && sysType.isEnabled()) {
|
||||
|
@ -609,6 +602,18 @@ public class RemoteCMainTab extends CMainTab {
|
|||
}
|
||||
if ((skipDownloadButton != null) && !skipDownloadButton.isDisposed()) {
|
||||
skipDownloadButton.setSelection(getDefaultSkipDownload());
|
||||
if(RSEHelper.getFileSubsystem(getCurrentConnection()) == null){
|
||||
skipDownloadButton.setEnabled(false);
|
||||
} else {
|
||||
skipDownloadButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
if((remoteBrowseButton!=null) && !remoteBrowseButton.isDisposed()){
|
||||
if(RSEHelper.getFileSubsystem(getCurrentConnection()) == null){
|
||||
remoteBrowseButton.setEnabled(false);
|
||||
} else {
|
||||
remoteBrowseButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,6 +649,9 @@ public class RemoteCMainTab extends CMainTab {
|
|||
private boolean getDefaultSkipDownload() {
|
||||
IHost host = getCurrentConnection();
|
||||
if (host != null) {
|
||||
if(RSEHelper.getFileSubsystem(host) == null){
|
||||
return true;
|
||||
}
|
||||
IPropertySet propertySet = host
|
||||
.getPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT);
|
||||
if (propertySet != null) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
||||
* Nikita Shulga (EmbeddedAlley) - [265236][remotecdt] Wait for RSE to initialize before querying it for host list
|
||||
* Anna Dushistova (MontaVista) - [267951] [remotecdt] Support systemTypes without files subsystem
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.launch.remote;
|
||||
|
@ -37,7 +38,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
|
@ -50,20 +50,14 @@ import org.eclipse.debug.core.model.IProcess;
|
|||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.services.IService;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem;
|
||||
|
||||
public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||
|
||||
private final static String SHELL_SERVICE = "shell.service"; //$NON-NLS-1$
|
||||
private final static String FILE_SERVICE = "file.service"; //$NON-NLS-1$
|
||||
private final static String EXIT_CMD = "exit"; //$NON-NLS-1$
|
||||
private final static String CMD_DELIMITER = ";"; //$NON-NLS-1$
|
||||
|
||||
|
@ -92,13 +86,15 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
if (monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
if (!RSECorePlugin.isInitComplete(RSECorePlugin.INIT_MODEL)) {
|
||||
if (!RSECorePlugin.isInitComplete(RSECorePlugin.INIT_MODEL)) {
|
||||
monitor.subTask(Messages.RemoteRunLaunchDelegate_10);
|
||||
try {
|
||||
RSECorePlugin.waitForInitCompletion(RSECorePlugin.INIT_MODEL);
|
||||
RSECorePlugin
|
||||
.waitForInitCompletion(RSECorePlugin.INIT_MODEL);
|
||||
} catch (InterruptedException e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, getPluginID(),
|
||||
IStatus.OK, e.getLocalizedMessage(), e));
|
||||
throw new CoreException(new Status(IStatus.ERROR,
|
||||
getPluginID(), IStatus.OK, e.getLocalizedMessage(),
|
||||
e));
|
||||
}
|
||||
}
|
||||
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
|
@ -255,65 +251,13 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
String remoteConnection = config.getAttribute(
|
||||
IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION,
|
||||
""); //$NON-NLS-1$
|
||||
|
||||
IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHosts();
|
||||
int i = 0;
|
||||
for (i = 0; i < connections.length; i++)
|
||||
if (connections[i].getAliasName().equals(remoteConnection))
|
||||
break;
|
||||
if (i >= connections.length) {
|
||||
IHost connection = RSEHelper
|
||||
.getRemoteConnectionByName(remoteConnection);
|
||||
if (connection == null) {
|
||||
abort(Messages.RemoteRunLaunchDelegate_13, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
return connections[i];
|
||||
}
|
||||
|
||||
protected IService getConnectedRemoteService(ILaunchConfiguration config,
|
||||
String kindOfService, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
||||
// Check that the service requested is file or shell.
|
||||
if (!kindOfService.equals(SHELL_SERVICE)
|
||||
&& !kindOfService.equals(FILE_SERVICE))
|
||||
abort(Messages.RemoteRunLaunchDelegate_3, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
|
||||
IHost currentConnection = getCurrentConnection(config);
|
||||
|
||||
ISubSystem[] subSystems = currentConnection.getSubSystems();
|
||||
int i = 0;
|
||||
for (i = 0; i < subSystems.length; i++) {
|
||||
if (subSystems[i] instanceof IShellServiceSubSystem
|
||||
&& kindOfService.equals(SHELL_SERVICE))
|
||||
break;
|
||||
if (subSystems[i] instanceof IFileServiceSubSystem
|
||||
&& kindOfService.equals(FILE_SERVICE))
|
||||
break;
|
||||
}
|
||||
if (i >= subSystems.length)
|
||||
abort(Messages.RemoteRunLaunchDelegate_4, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
|
||||
final ISubSystem subsystem = subSystems[i];
|
||||
try {
|
||||
subsystem.connect(monitor, false);
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
} catch (OperationCanceledException e) {
|
||||
throw new CoreException(Status.CANCEL_STATUS);
|
||||
} catch (Exception e) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, getPluginID(),
|
||||
IStatus.OK, e.getLocalizedMessage(), e));
|
||||
}
|
||||
|
||||
if (!subsystem.isConnected())
|
||||
abort(Messages.RemoteRunLaunchDelegate_5, null,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
|
||||
if (kindOfService.equals(SHELL_SERVICE))
|
||||
return ((IShellServiceSubSystem) subsystem).getShellService();
|
||||
else
|
||||
return ((IFileServiceSubSystem) subsystem).getFileService();
|
||||
return connection;
|
||||
}
|
||||
|
||||
protected Process remoteFileDownload(ILaunchConfiguration config,
|
||||
|
@ -329,11 +273,14 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
// Nothing to do. Download is skipped.
|
||||
return null;
|
||||
monitor.beginTask(Messages.RemoteRunLaunchDelegate_2, 100);
|
||||
IFileService fileService = (IFileService) getConnectedRemoteService(
|
||||
config, FILE_SERVICE, new SubProgressMonitor(monitor, 10));
|
||||
File file = new File(localExePath);
|
||||
Path remotePath = new Path(remoteExePath);
|
||||
IFileService fileService;
|
||||
try {
|
||||
fileService = (IFileService) RSEHelper
|
||||
.getConnectedRemoteFileService(
|
||||
getCurrentConnection(config),
|
||||
new SubProgressMonitor(monitor, 10));
|
||||
File file = new File(localExePath);
|
||||
Path remotePath = new Path(remoteExePath);
|
||||
fileService.upload(file, remotePath.removeLastSegments(1)
|
||||
.toString(), remotePath.lastSegment(), true, null, null,
|
||||
new SubProgressMonitor(monitor, 85));
|
||||
|
@ -379,28 +326,37 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
|||
if (!prelaunchCmd.trim().equals("")) //$NON-NLS-1$
|
||||
remote_command = prelaunchCmd + CMD_DELIMITER + remote_command;
|
||||
|
||||
IShellService shellService = (IShellService) getConnectedRemoteService(
|
||||
config, SHELL_SERVICE, new SubProgressMonitor(monitor, 7));
|
||||
|
||||
// This is necessary because runCommand does not actually run the
|
||||
// command right now.
|
||||
String env[] = new String[0];
|
||||
IShellService shellService;
|
||||
Process p = null;
|
||||
try {
|
||||
IHostShell hostShell = shellService.launchShell(
|
||||
"", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$
|
||||
hostShell.writeToShell(remote_command);
|
||||
p = new HostShellProcessAdapter(hostShell);
|
||||
} catch (Exception e) {
|
||||
if (p != null) {
|
||||
p.destroy();
|
||||
shellService = (IShellService) RSEHelper
|
||||
.getConnectedRemoteShellService(
|
||||
getCurrentConnection(config),
|
||||
new SubProgressMonitor(monitor, 7));
|
||||
|
||||
// This is necessary because runCommand does not actually run the
|
||||
// command right now.
|
||||
String env[] = new String[0];
|
||||
try {
|
||||
IHostShell hostShell = shellService.launchShell(
|
||||
"", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$
|
||||
hostShell.writeToShell(remote_command);
|
||||
p = new HostShellProcessAdapter(hostShell);
|
||||
} catch (Exception e) {
|
||||
if (p != null) {
|
||||
p.destroy();
|
||||
}
|
||||
abort(Messages.RemoteRunLaunchDelegate_7, e,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
abort(Messages.RemoteRunLaunchDelegate_7, e,
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
abort(e1.getMessage(), e1,
|
||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
monitor.done();
|
||||
return p;
|
||||
|
||||
}
|
||||
|
||||
protected String getPluginID() {
|
||||
|
|
Loading…
Add table
Reference in a new issue