use of org.eclipse.remote.core.IRemoteServicesManager in project linuxtools by eclipse.
the class AbstractRemoteTest method createJSchConnection.
/**
* Create a new connection. Save the connection working copy before return.
*
* @param connName Connection Name
* @param connTypeId The connection type identifier
* @return The created remote connection
* @throws RemoteConnectionException
*/
protected static IRemoteConnection createJSchConnection(String connName, String connTypeId) throws RemoteConnectionException {
checkConnectionInfo();
IRemoteServicesManager manager = getServicesManager();
IRemoteConnectionType ct = manager.getConnectionType(connTypeId);
assertNotNull(ct);
IRemoteConnectionWorkingCopy wc = ct.newConnection(connName);
wc.setAttribute(JSchConnection.ADDRESS_ATTR, HOST);
wc.setAttribute(JSchConnection.USERNAME_ATTR, USERNAME);
wc.setSecureAttribute(JSchConnection.PASSWORD_ATTR, PASSWORD);
IRemoteConnection conn = wc.save();
assertNotNull(conn);
conn.open(new NullProgressMonitor());
assertTrue(conn.isOpen());
return conn;
}
use of org.eclipse.remote.core.IRemoteServicesManager in project linuxtools by eclipse.
the class RDTResourceSelectorProxy method selectResource.
private URI selectResource(String scheme, String initialPath, String prompt, Shell shell, ResourceType resourceType) {
IRemoteUIFileService uiFileService;
boolean schemeSwitch = false;
URI uri;
try {
uri = new URI(initialPath);
if (!scheme.equals(uri.getScheme())) {
uri = getEmptyPathURI(scheme);
schemeSwitch = true;
}
} catch (URISyntaxException e) {
uri = getEmptyPathURI(scheme);
schemeSwitch = true;
}
IRemoteServicesManager sm = Activator.getService(IRemoteServicesManager.class);
IRemoteConnectionType ct = sm.getConnectionType(uri);
IRemoteConnection connection = ct.getConnection(uri);
IRemoteFileService fileService = connection.getService(IRemoteFileService.class);
// If the user is switching schemes, start with an empty host and path
uiFileService = ct.getService(IRemoteUIFileService.class);
uiFileService.showConnections(true);
if (!schemeSwitch) {
uiFileService.setConnection(connection);
}
String selectedPath = null;
switch(resourceType) {
case FILE:
selectedPath = uiFileService.browseFile(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
break;
case DIRECTORY:
selectedPath = uiFileService.browseDirectory(shell, prompt, uri.getPath(), IRemoteUIConstants.NONE);
break;
default:
Activator.log(IStatus.ERROR, Messages.RDTResourceSelectorProxy_unsupported_resourceType + resourceType);
return null;
}
URI selectedURI = null;
if (selectedPath != null) {
connection = uiFileService.getConnection();
fileService = connection.getService(IRemoteFileService.class);
selectedURI = fileService.toURI(selectedPath);
}
return selectedURI;
}
use of org.eclipse.remote.core.IRemoteServicesManager in project linuxtools by eclipse.
the class AbstractRemoteTest method getServicesManager.
private static IRemoteServicesManager getServicesManager() {
BundleContext context = Platform.getBundle(PLUGIN_ID).getBundleContext();
ServiceReference<IRemoteServicesManager> ref = context.getServiceReference(IRemoteServicesManager.class);
assertNotNull(ref);
return context.getService(ref);
}
use of org.eclipse.remote.core.IRemoteServicesManager in project linuxtools by eclipse.
the class AbstractRemoteTest method deleteResource.
protected void deleteResource(String directory) {
IRemoteServicesManager sm = getServicesManager();
IRemoteConnection conn = sm.getConnectionType("ssh").getConnection(CONNECTION_NAME);
assertNotNull(conn);
IRemoteFileService fileManager = conn.getService(IRemoteFileService.class);
assertNotNull(fileManager);
final IFileStore dstFileStore = fileManager.getResource(directory);
try {
dstFileStore.delete(EFS.NONE, null);
} catch (CoreException e) {
}
}
use of org.eclipse.remote.core.IRemoteServicesManager in project linuxtools by eclipse.
the class RDTProxyManager method getConnection.
/**
* Get the remote connection
*
* @param uri any valid URI to remote
* @return a remote connection
*
* @since 1.2
*/
public static IRemoteConnection getConnection(URI uri) {
IRemoteServicesManager sm = Activator.getService(IRemoteServicesManager.class);
IRemoteConnectionType ct = sm.getConnectionType(uri);
return ct.getConnection(uri);
}
Aggregations