Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2024 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -37,6 +37,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
Expand Down Expand Up @@ -65,6 +66,38 @@

public class MinimalState {

private static final IPreferenceChangeListener PREF_CHANGE_LISTENER = e -> {
if (e.getKey().equals("org.eclipse.jdt.launching.PREF_DEFAULT_ENVIRONMENTS_XML")) { //$NON-NLS-1$
Object oldValue = e.getOldValue() == null ? "" : e.getOldValue(); //$NON-NLS-1$
Object newValue = e.getNewValue() == null ? "" : e.getNewValue(); //$NON-NLS-1$
if (!oldValue.equals(newValue)) {
triggerSystemPackagesReload();
}
}
};

private static final IVMInstallChangedListener VM_CHANGED_LISTENER = new IVMInstallChangedListener() {
@Override
public void vmRemoved(IVMInstall vm) {
triggerSystemPackagesReload();
}

@Override
public void vmChanged(PropertyChangeEvent event) {
triggerSystemPackagesReload();
}

@Override
public void vmAdded(IVMInstall vm) {
triggerSystemPackagesReload();
}

@Override
public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) {
triggerSystemPackagesReload();
}
};

Comment thread
HannesWell marked this conversation as resolved.
protected State fState;

protected long fId;
Expand Down Expand Up @@ -268,39 +301,20 @@ protected boolean initializePlatformProperties() {
static {
// Listen to changes in the available VMInstalls and
// ExecutionEnvironment defaults
@SuppressWarnings("restriction")
String nodeQualifier = org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN;
IEclipsePreferences launchingNode = InstanceScope.INSTANCE.getNode(nodeQualifier);
launchingNode.addPreferenceChangeListener(e -> {
if (e.getKey().equals("org.eclipse.jdt.launching.PREF_DEFAULT_ENVIRONMENTS_XML")) { //$NON-NLS-1$
Object oldValue = e.getOldValue() == null ? "" : e.getOldValue(); //$NON-NLS-1$
Object newValue = e.getNewValue() == null ? "" : e.getNewValue(); //$NON-NLS-1$
if (!oldValue.equals(newValue)) {
triggerSystemPackagesReload();
}
}
});
JavaRuntime.addVMInstallChangedListener(new IVMInstallChangedListener() {
@Override
public void vmRemoved(IVMInstall vm) {
triggerSystemPackagesReload();
}

@Override
public void vmChanged(PropertyChangeEvent event) {
triggerSystemPackagesReload();
}
IEclipsePreferences launchingNode = getJdtLaunchingPreferences();
launchingNode.addPreferenceChangeListener(PREF_CHANGE_LISTENER);
JavaRuntime.addVMInstallChangedListener(VM_CHANGED_LISTENER);
}

@Override
public void vmAdded(IVMInstall vm) {
triggerSystemPackagesReload();
}
static void shutdown() {
IEclipsePreferences launchingNode = getJdtLaunchingPreferences();
launchingNode.removePreferenceChangeListener(PREF_CHANGE_LISTENER);
JavaRuntime.removeVMInstallChangedListener(VM_CHANGED_LISTENER);
}

@Override
public void defaultVMInstallChanged(IVMInstall previous, IVMInstall current) {
triggerSystemPackagesReload();
}
});
@SuppressWarnings("restriction")
private static IEclipsePreferences getJdtLaunchingPreferences() {
return InstanceScope.INSTANCE.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN);
}

public static void triggerSystemPackagesReload() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -424,6 +424,8 @@ public void stop(BundleContext context) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.removeSaveParticipant(PLUGIN_ID);
workspace.removeResourceChangeListener(bndResourceChangeListener);

MinimalState.shutdown();
}

/**
Expand Down
Loading