Skip to content

Commit

Permalink
[performance] faster ExecutionEnvironmentsPreferencePage.performOk()
Browse files Browse the repository at this point in the history
Group touching the projects to a single WorkspaceOperation
Reduces UI freeze by ~9 sec for platform workspace (~500 projects)

eclipse-jdt/eclipse.jdt.core#2884
  • Loading branch information
EcljpseB0T committed Sep 3, 2024
1 parent 1f509a5 commit be9e12a
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.HashMap;
import java.util.Map;

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
Expand Down Expand Up @@ -259,6 +261,15 @@ public void checkStateChanged(CheckStateChangedEvent event) {
*/
@Override
public boolean performOk() {
try {
ResourcesPlugin.getWorkspace().run(p -> updateAllEnvironments(), null);
} catch (CoreException e) {
throw new RuntimeException(e);
}
return super.performOk();
}

public void updateAllEnvironments() {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (int i = 0; i < environments.length; i++) {
Expand All @@ -272,7 +283,6 @@ public boolean performOk() {
}
environment.setDefaultVM(vm);
}
return super.performOk();
}

}

0 comments on commit be9e12a

Please sign in to comment.