1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Merge "Bug 460067 - Update remote terminal to new API"

This commit is contained in:
Greg Watson 2015-02-18 09:56:57 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit 849fa0e175
4 changed files with 35 additions and 16 deletions

View file

@ -62,7 +62,7 @@
<platform-site>http://download.eclipse.org/eclipse/updates/${sdk-version}milestones</platform-site> <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> <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> <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> <swtbot-site>http://download.eclipse.org/technology/swtbot/releases/latest/</swtbot-site>
<rxtx-site>http://archive.eclipse.org/tm/updates/rxtx</rxtx-site> <rxtx-site>http://archive.eclipse.org/tm/updates/rxtx</rxtx-site>
</properties> </properties>

View file

@ -14,6 +14,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.tm.internal.terminal.remote.messages.Messages; import org.eclipse.tm.internal.terminal.remote.messages.Messages;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/** /**
* The activator class controls the plug-in life cycle * The activator class controls the plug-in life cycle
@ -108,4 +109,17 @@ public class Activator extends Plugin {
} }
return getDefault().getBundle().getSymbolicName(); 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;
}
} }

View file

@ -22,12 +22,13 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.eclipse.remote.core.IRemoteCommandShellService;
import org.eclipse.remote.core.IRemoteConnection; 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.IRemoteProcess;
import org.eclipse.remote.core.IRemoteProcessBuilder; import org.eclipse.remote.core.IRemoteProcessBuilder;
import org.eclipse.remote.core.IRemoteServices; import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.RemoteServices; import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException; import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
@ -65,13 +66,11 @@ public class RemoteConnectionManager extends Job {
IRemoteConnection remoteConnection = null; IRemoteConnection remoteConnection = null;
try { try {
String remoteServices = connector.getSshSettings().getRemoteServices(); IRemoteServicesManager svcMgr = Activator.getService(IRemoteServicesManager.class);
IRemoteServices services = RemoteServices.getRemoteServices(remoteServices); String connTypeId = connector.getSshSettings().getRemoteServices();
if (services != null) { IRemoteConnectionType connType = svcMgr.getConnectionType(connTypeId);
IRemoteConnectionManager connMgr = services.getConnectionManager(); if (connType != null) {
if (connMgr != null) { remoteConnection = connType.getConnection(connector.getSshSettings().getConnectionName());
remoteConnection = connMgr.getConnection(connector.getSshSettings().getConnectionName());
}
} }
if (remoteConnection == null) { if (remoteConnection == null) {
throw new RemoteConnectionException(NLS.bind(Messages.RemoteConnectionManager_0, connector.getSshSettings() 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()); IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$ String terminalShellCommand = prefs.get(IRemoteTerminalConstants.PREF_TERMINAL_SHELL_COMMAND, ""); //$NON-NLS-1$
if (!("".equals(terminalShellCommand)) //$NON-NLS-1$ if (!("".equals(terminalShellCommand)) //$NON-NLS-1$
&& (remoteConnection.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_SUPPORTS_COMMAND_SHELL) != 0) { && remoteConnection.hasService(IRemoteCommandShellService.class)) {
remoteProcess = remoteConnection.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY); IRemoteCommandShellService cmdShellSvc = remoteConnection.getService(IRemoteCommandShellService.class);
remoteProcess = cmdShellSvc.getCommandShell(IRemoteProcessBuilder.ALLOCATE_PTY);
} else { } else {
if ("".equals(terminalShellCommand)) { //$NON-NLS-1$ if ("".equals(terminalShellCommand)) { //$NON-NLS-1$
terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$ terminalShellCommand = "/bin/bash -l"; //$NON-NLS-1$
} }
IRemoteProcessBuilder processBuilder = remoteConnection.getProcessBuilder(new ArgumentParser( IRemoteProcessService procSvc = remoteConnection.getService(IRemoteProcessService.class);
terminalShellCommand).getTokenList()); IRemoteProcessBuilder processBuilder = procSvc.getProcessBuilder(new ArgumentParser(terminalShellCommand)
.getTokenList());
remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY); remoteProcess = processBuilder.start(IRemoteProcessBuilder.ALLOCATE_PTY);
} }
} }

View file

@ -23,11 +23,13 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
fTerminalSettings = settings; fTerminalSettings = settings;
} }
@Override
public void saveSettings() { public void saveSettings() {
fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getRemoteServices().getId()); fTerminalSettings.setRemoteServices(fRemoteConnectionWidget.getConnection().getConnectionType().getId());
fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName()); fTerminalSettings.setConnectionName(fRemoteConnectionWidget.getConnection().getName());
} }
@Override
public void loadSettings() { public void loadSettings() {
if (fTerminalSettings != null) { if (fTerminalSettings != null) {
fRemoteConnectionWidget.setConnection(fTerminalSettings.getRemoteServices(), fTerminalSettings.getConnectionName()); fRemoteConnectionWidget.setConnection(fTerminalSettings.getRemoteServices(), fTerminalSettings.getConnectionName());
@ -41,6 +43,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
return value; return value;
} }
@Override
public boolean validateSettings() { public boolean validateSettings() {
if (fRemoteConnectionWidget.getConnection() == null) { if (fRemoteConnectionWidget.getConnection() == null) {
return false; return false;
@ -48,6 +51,7 @@ public class RemoteSettingsPage extends AbstractSettingsPage {
return true; return true;
} }
@Override
public void createControl(Composite parent) { public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE); Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false); GridLayout gridLayout = new GridLayout(2, false);