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 async operation with workspace
rule. Totally get rid of UI Freeze. And ~9 sec faster for platform
workspace (~500 projects)

eclipse-jdt/eclipse.jdt.core#2884

Pattern taken from JavaCompilerPropertyPage.performOk()
  • Loading branch information
EcljpseB0T committed Sep 3, 2024
1 parent 1f509a5 commit cfb989b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;

import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
Expand Down Expand Up @@ -257,22 +258,30 @@ public void checkStateChanged(CheckStateChangedEvent event) {
/* (non-Javadoc)
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
@SuppressWarnings("restriction")
@Override
public boolean performOk() {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (int i = 0; i < environments.length; i++) {
IExecutionEnvironment environment = environments[i];
IVMInstall vm = (IVMInstall) fDefaults.get(environment);
// if the VM no longer exists - set to default to avoid illegal argument exception (bug 267914)
if (vm != null) {
if (vm.getVMInstallType().findVMInstall(vm.getId()) == null) {
vm = null;
WorkbenchRunnableAdapter op = new WorkbenchRunnableAdapter(monitor -> {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
monitor.beginTask(JREMessages.ExecutionEnvironmentsPreferencePage_performOk, environments.length);
for (int i = 0; i < environments.length; i++) {
IExecutionEnvironment environment = environments[i];
monitor.setTaskName(environment.getDescription());
IVMInstall vm = (IVMInstall) fDefaults.get(environment);
// if the VM no longer exists - set to default to avoid illegal argument exception (bug 267914)
if (vm != null) {
if (vm.getVMInstallType().findVMInstall(vm.getId()) == null) {
vm = null;
}
}
environment.setDefaultVM(vm);
monitor.worked(1);
}
environment.setDefaultVM(vm);
}
});
op.runAsUserJob(JREMessages.ExecutionEnvironmentsPreferencePage_performOk, null);
return super.performOk();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public class JREMessages extends NLS {

public static String EEVMPage_7;

public static String ExecutionEnvironmentsPreferencePage_performOk;

public static String VMTypePage_0;

public static String VMTypePage_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ EEVMPage_4=Enter definition file
EEVMPage_5=Definition file does not exist
EEVMPage_6=JRE Definition
EEVMPage_7=Specify attributes for a JRE
ExecutionEnvironmentsPreferencePage_performOk=Updating Execution Environments
LibraryLabelProvider_0=Javadoc location:
VMTypePage_0=Select JRE Type
VMTypePage_1=Select the type of JRE to add to the workspace.
Expand Down

0 comments on commit cfb989b

Please sign in to comment.