Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ptp-dev] Getting URI for file in a synchronized project

John, Roland
I'm trying to get a URI for a file that is in a synchronized project using the following code

                        location = null;
                        try {
                                if (project.getNature(RemoteSyncNature.NATURE_ID) != null) {
                                        IManagedBuildInfo buildInfo;
                                        buildInfo = ManagedBuildManager.getBuildInfo(project);
                                        if (buildInfo != null) {
                                                IConfiguration config;

                                                config = buildInfo.getDefaultConfiguration();
                                                if (config != null) {
                                                        BuildScenario build;
                                                        IRemoteConnection connection;

                                                        build = BuildConfigurationManager.getInstance()
                                                                        .getBuildScenarioForBuildConfiguration(
                                                                                        config);
                                                        connection = build.getRemoteConnection();
                                                        location = connection
                                                                        .getRemoteServices()
                                                                        .getFileManager(connection)
                                                                        .toURI(new Path(file.getLocation().toString()));
                                                }
                                        }
                                } else {
                                        location = file.getLocationURI();
                                }
                        } catch (CoreException e) {

                        }

I'm starting with an IFile object named 'file' which I'm getting from an IStructuredSelection object where the user has right clicked on a file in the synchronized project and clicked my menu entry in the popup menu.
When the project is a synchronized project, location ends up being set to null where the toURI method is returning null for the Path it is given.

file.getLocation.toString() is returning the full path to the requested file on the local system, not the remote system, so it looks like the toURI method is failing somewhere in translating this to a remote system URI.

Is this the correct way to get the remote file URI or should I be doing this differently?

Also, I understand that ManagedBuildManager.getBuildInfo() returns null if this is not a CDT project. Is this a correct assumption if the project is a FORTRAN project or are FORTRAN projects not supported at this time?

I'm getting warnings complaining about discouraged access due to access restrictions for RemoteSyncNature.NATUREID, BuildConfigurationManager.getBuildScenarioForBuildConfiguration, BuildConfigurationManager.getInstance, BuildScenario.getRemoteConnection and the classes BuildConfigurationManager, BuildScenario, and RemoteSyncNature. Are these warnings anything that means I will have problems with this code?

Thanks
Dave

Back to the top