Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2015-06-15 13:54:24 +0000
committerMickael Istria2015-06-18 12:45:37 +0000
commit702867a9f5817194fc6df5d959f577830025ecb3 (patch)
tree19c26eab3da334a3a890b7a44c8ff800174d6c90
parent2e04a563504975e3a62b771d40987c1c9d7dc260 (diff)
downloadorg.eclipse.e4.ui-702867a9f5817194fc6df5d959f577830025ecb3.tar.gz
org.eclipse.e4.ui-702867a9f5817194fc6df5d959f577830025ecb3.tar.xz
org.eclipse.e4.ui-702867a9f5817194fc6df5d959f577830025ecb3.zip
[Importer] Small performance hacks
Do not force project refresh immediately and lazily refresh necessary directories.
-rw-r--r--bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/EasymportJob.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/EasymportJob.java b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/EasymportJob.java
index 5753c8ed..f9344c69 100644
--- a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/EasymportJob.java
+++ b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/EasymportJob.java
@@ -79,7 +79,8 @@ public class EasymportJob extends Job {
this.isRootANewProject = projectAlreadyExistsInWorkspace(this.rootDirectory) == null;
this.rootProject = toExistingOrNewProject(
this.rootDirectory,
- monitor);
+ monitor,
+ IResource.NONE); // complete load of the root project
if (this.recursiveConfigure) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
@@ -161,6 +162,7 @@ public class EasymportJob extends Job {
}
private Set<IProject> searchAndImportChildrenProjectsRecursively(IContainer parentContainer, Set<IPath> directoriesToExclude, final IProgressMonitor progressMonitor) throws Exception {
+ parentContainer.refreshLocal(IResource.DEPTH_ONE, progressMonitor); // make sure we know all children
Set<IFolder> childrenToProcess = new HashSet<IFolder>();
final Set<IProject> res = Collections.synchronizedSet(new HashSet<IProject>());
for (IResource childResource : parentContainer.members()) {
@@ -179,7 +181,6 @@ public class EasymportJob extends Job {
}
}
// TODO parallelize here
-
for (final IFolder childFolder : childrenToProcess) {
CrawlFolderJob crawlerJob = new CrawlFolderJob("Crawling " + childFolder.getLocation().toString(), childFolder, res);
crawlerJob.run(progressMonitor);
@@ -199,6 +200,7 @@ public class EasymportJob extends Job {
if (progressMonitor.isCanceled()) {
return null;
}
+ container.refreshLocal(IResource.DEPTH_INFINITE, progressMonitor); // Make sure we have folder content
if (this.configurationManager == null) {
this.configurationManager = new ProjectConfiguratorExtensionManager();
}
@@ -217,12 +219,10 @@ public class EasymportJob extends Job {
mainProjectConfigurators.add(configurator);
if (project == null) {
// Create project
- project = toExistingOrNewProject(container.getLocation().toFile(), progressMonitor);
+ project = toExistingOrNewProject(container.getLocation().toFile(), progressMonitor, IResource.BACKGROUND_REFRESH);
if (this.listener != null) {
this.listener.projectCreated(project);
}
- // use directly project for next analysis
- container = project;
projectFromCurrentContainer.add(project);
}
} else {
@@ -248,7 +248,7 @@ public class EasymportJob extends Job {
if (allNestedProjects.isEmpty() && isRootProject) {
// No sub-project found, so apply available configurators anyway
progressMonitor.beginTask("Configuring 'leaf' of project at " + container.getLocation().toFile().getAbsolutePath(), activeConfigurators.size());
- project = toExistingOrNewProject(container.getLocation().toFile(), progressMonitor);
+ project = toExistingOrNewProject(container.getLocation().toFile(), progressMonitor, IResource.NONE);
if (this.listener != null) {
listener.projectCreated(project);
}
@@ -288,10 +288,11 @@ public class EasymportJob extends Job {
/**
* @param directory
* @param workingSets
+ * @param refreshMode One {@link IResource#BACKGROUND_REFRESH} for background refresh, or {@link IResource#NONE} for immediate refresh
* @return
* @throws Exception
*/
- private IProject toExistingOrNewProject(File directory, IProgressMonitor progressMonitor) throws CouldNotImportProjectException {
+ private IProject toExistingOrNewProject(File directory, IProgressMonitor progressMonitor, int refreshMode) throws CouldNotImportProjectException {
try {
progressMonitor.setTaskName("Import project at " + directory.getAbsolutePath());
IProject project = projectAlreadyExistsInWorkspace(directory);
@@ -302,7 +303,7 @@ public class EasymportJob extends Job {
if (progressMonitor.isCanceled()) {
return null;
}
- project.open(progressMonitor);
+ project.open(refreshMode, progressMonitor);
if (!this.report.containsKey(project)) {
this.report.put(project, new ArrayList<ProjectConfigurator>());
}

Back to the top