Search in sources :

Example 1 with IRemoteServicesManager

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;
}
Also used : IRemoteConnectionType(org.eclipse.remote.core.IRemoteConnectionType) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager) IRemoteConnectionWorkingCopy(org.eclipse.remote.core.IRemoteConnectionWorkingCopy)

Example 2 with IRemoteServicesManager

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;
}
Also used : IRemoteConnectionType(org.eclipse.remote.core.IRemoteConnectionType) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager) URISyntaxException(java.net.URISyntaxException) IRemoteUIFileService(org.eclipse.remote.ui.IRemoteUIFileService) URI(java.net.URI) IRemoteFileService(org.eclipse.remote.core.IRemoteFileService)

Example 3 with IRemoteServicesManager

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);
}
Also used : IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager) BundleContext(org.osgi.framework.BundleContext)

Example 4 with IRemoteServicesManager

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) {
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager) IFileStore(org.eclipse.core.filesystem.IFileStore) IRemoteFileService(org.eclipse.remote.core.IRemoteFileService)

Example 5 with IRemoteServicesManager

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);
}
Also used : IRemoteConnectionType(org.eclipse.remote.core.IRemoteConnectionType) IRemoteServicesManager(org.eclipse.remote.core.IRemoteServicesManager)

Aggregations

IRemoteServicesManager (org.eclipse.remote.core.IRemoteServicesManager)5 IRemoteConnection (org.eclipse.remote.core.IRemoteConnection)3 IRemoteConnectionType (org.eclipse.remote.core.IRemoteConnectionType)3 IRemoteFileService (org.eclipse.remote.core.IRemoteFileService)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IRemoteConnectionWorkingCopy (org.eclipse.remote.core.IRemoteConnectionWorkingCopy)1 IRemoteUIFileService (org.eclipse.remote.ui.IRemoteUIFileService)1 BundleContext (org.osgi.framework.BundleContext)1