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;
}
Aggregations