mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Merge "Bug 460067 - Update remote terminal to new API"
This commit is contained in:
commit
849fa0e175
4 changed files with 35 additions and 16 deletions
|
@ -62,7 +62,7 @@
|
|||
<platform-site>http://download.eclipse.org/eclipse/updates/${sdk-version}milestones</platform-site>
|
||||
<orbit-site>http://download.eclipse.org/tools/orbit/downloads/drops/R20150124073747/repository/</orbit-site>
|
||||
<cdt-site>http://download.eclipse.org/tools/cdt/releases/8.5</cdt-site>
|
||||
<remote-site>http://download.eclipse.org/tools/ptp/updates/remote/1.1.0</remote-site>
|
||||
<remote-site>http://download.eclipse.org/tools/ptp/builds/remote/mars/milestones</remote-site>
|
||||
<swtbot-site>http://download.eclipse.org/technology/swtbot/releases/latest/</swtbot-site>
|
||||
<rxtx-site>http://archive.eclipse.org/tm/updates/rxtx</rxtx-site>
|
||||
</properties>
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
|
|||
import org.eclipse.tm.internal.terminal.remote.messages.Messages;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
|
@ -108,4 +109,17 @@ public class Activator extends Plugin {
|
|||
}
|
||||
return getDefault().getBundle().getSymbolicName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service
|
||||
* service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
final BundleContext context = plugin.getBundle().getBundleContext();
|
||||
final ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,13 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteCommandShellService;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteProcess;
|
||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
|
@ -65,13 +66,11 @@ public class RemoteConnectionManager extends Job {
|
|||
IRemoteConnection remoteConnection = null;
|
||||
|
||||
try {
|
||||
String remoteServices = connector.getSshSettings().getRemoteServices();
|
||||
IRemoteServices services = RemoteServices.getRemoteServices(remoteServices);
|
||||
if (services != null) {
|
||||
IRemoteConnectionManager connMgr = services.getConnectionManager();
|
||||
if (connMgr != null) {
|
||||
remoteConnection = connMgr.getConnection(connector.getSshSettings().getConnectionName());
|
||||
}
|
||||
IRemoteServicesManager svcMgr = Activator.getService(IRemoteServicesManager.class);
|
||||
String connTypeId = connector.getSshSettings().getRemoteServices();
|
||||
IRemoteConnectionType connType = svcMgr.getConnectionType(connTypeId);
|
||||
if (connType != null) {
|
||||
remoteConnection = connType.getConnection(connector.getSshSettings().getConnectionName());
|
||||
}
|
||||
if (remoteConnection == null) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_0, connector.getSshSettings()
|
||||
|
@ -96,14 +95,16 @@ public class RemoteConnectionManager extends Job {
|
|||
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
|
||||
String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$
|
||||
if (!("".equals(terminalShellCommand)) //$NON-NLS-1$
|
||||
&& (remoteConnection.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_SUPPORTS_COMMAND_SHELL) != 0) {
|
||||
remoteProcess = remoteConnection.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
|
||||
&& remoteConnection.hasService(IRemoteCommandShellService.class)) {
|
||||
IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class);
|
||||
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
|
||||
} else {
|
||||
if ("".equals(terminalShellCommand)) { //$NON-NLS-1$
|
||||
terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$
|
||||
}
|
||||
IRemoteProcessBuilder processBuilder = remoteConnection.getProcessBuilder(new ArgumentParser(
|
||||
terminalShellCommand).getTokenList());
|
||||
IRemoteProcessService procSvc = remoteConnection.getService(IRemoteProcessService.class);
|
||||
IRemoteProcessBuilder processBuilder = procSvc.getProcessBuilder(new ArgumentParser(terminalShellCommand)
|
||||
.getTokenList());
|
||||
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,13 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
fTerminalSettings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getRemoteServices().getId());
|
||||
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
|
||||
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSettings() {
|
||||
if (fTerminalSettings != null) {
|
||||
fRemoteConnectionWidget.setConnection(fTerminalSettings.getRemoteServices(), fTerminalSettings.getConnectionName());
|
||||
|
@ -41,6 +43,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateSettings() {
|
||||
if (fRemoteConnectionWidget.getConnection() == null) {
|
||||
return false;
|
||||
|
@ -48,6 +51,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout gridLayout = new GridLayout(2, false);
|
||||
|
|
Loading…
Add table
Reference in a new issue