|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.debug.internal.core; |
| 12 |
|
| 13 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
| 14 |
import org.eclipse.core.runtime.preferences.IPreferenceNodeVisitor; |
| 15 |
import org.eclipse.core.runtime.preferences.PreferenceModifyListener; |
| 16 |
import org.eclipse.debug.core.DebugPlugin; |
| 17 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
| 18 |
import org.eclipse.debug.core.ILaunchManager; |
| 19 |
import org.osgi.service.prefs.BackingStoreException; |
| 20 |
|
| 21 |
/** |
| 22 |
* Used to listen for preference imports that include changes to |
| 23 |
* preferred launch delegates. |
| 24 |
* |
| 25 |
* @since 3.6 |
| 26 |
*/ |
| 27 |
public class PreferredDelegateModifyListener extends PreferenceModifyListener { |
| 28 |
class Visitor implements IPreferenceNodeVisitor { |
| 29 |
|
| 30 |
public boolean visit(IEclipsePreferences node) throws BackingStoreException { |
| 31 |
if (node.name().equals(DebugPlugin.getUniqueIdentifier())) { |
| 32 |
// reset preferred delegates, so they are re-initialized from the preferences |
| 33 |
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); |
| 34 |
ILaunchConfigurationType[] types = manager.getLaunchConfigurationTypes(); |
| 35 |
for (int i = 0; i < types.length; i++) { |
| 36 |
((LaunchConfigurationType) types[i]).resetPreferredDelegates(); |
| 37 |
} |
| 38 |
return false; |
| 39 |
} |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
public IEclipsePreferences preApply(IEclipsePreferences node) { |
| 46 |
try { |
| 47 |
// force VMs to be initialized before we import the new VMs |
| 48 |
node.accept(new Visitor()); |
| 49 |
} catch (BackingStoreException e) { |
| 50 |
DebugPlugin.log(e); |
| 51 |
} |
| 52 |
return node; |
| 53 |
} |
| 54 |
|
| 55 |
} |