Search in sources :

Example 1 with IRemoteUIFileService

use of org.eclipse.remote.ui.IRemoteUIFileService 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)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 IRemoteConnection (org.eclipse.remote.core.IRemoteConnection)1 IRemoteConnectionType (org.eclipse.remote.core.IRemoteConnectionType)1 IRemoteFileService (org.eclipse.remote.core.IRemoteFileService)1 IRemoteServicesManager (org.eclipse.remote.core.IRemoteServicesManager)1 IRemoteUIFileService (org.eclipse.remote.ui.IRemoteUIFileService)1