Example usage for org.eclipse.jdt.internal.core ExternalFoldersManager createLinkFolder

List of usage examples for org.eclipse.jdt.internal.core ExternalFoldersManager createLinkFolder

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core ExternalFoldersManager createLinkFolder.

Prototype

public IFolder createLinkFolder(IPath externalFolderPath, boolean refreshIfExistAlready,
            IProgressMonitor monitor) throws CoreException 

Source Link

Usage

From source file:org.eclipse.oomph.targlets.internal.core.WorkspaceIUImporter.java

License:Open Source License

private Map<WorkspaceIUInfo, ResourcesUtil.ImportResult> updateWorkspace(
        final Set<WorkspaceIUInfo> workspaceIUInfos, IProgressMonitor monitor) throws CoreException {
    final Map<WorkspaceIUInfo, ResourcesUtil.ImportResult> importResults = new HashMap<WorkspaceIUInfo, ResourcesUtil.ImportResult>();

    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
        @SuppressWarnings("restriction")
        public void run(IProgressMonitor monitor) throws CoreException {
            // JDT lazily creates the external folder links,
            // but if many projects are imported, the resource deltas are processed early,
            // and then JDT creates ExternalPackageFragmentRoot instances for which linkedFolder.getLocation() is null,
            // which causes null pointer exceptions in that class' hashCode method, this.externalPath.hashCode(),
            // which completely screws up PDEs own notification handling
            // causing it to handle the same deltas more the once, making a mess of the PDE's model.
            // JDT doesn't create the links until the AutoBuildJob runs, which happens very late in the overall processing cycle.
            org.eclipse.jdt.internal.core.ExternalFoldersManager externalFoldersManager = org.eclipse.jdt.internal.core.ExternalFoldersManager
                    .getExternalFoldersManager();
            for (IPluginModelBase pluginModelBase : PluginRegistry.getExternalModels()) {
                String installLocation = pluginModelBase.getInstallLocation();
                if (installLocation != null) {
                    if (new File(installLocation).isDirectory()) {
                        externalFoldersManager.createLinkFolder(new Path(installLocation), false, null);
                    }/*from   w w  w .j  av a2  s.  co  m*/
                }
            }

            for (WorkspaceIUInfo info : workspaceIUInfos) {
                ResourcesUtil.ImportResult result = info.importIntoWorkspace(monitor);
                importResults.put(info, result);
            }
        }
    }, monitor);

    return importResults;
}