From 5a964614c4493757f0952d32afc13ae0d79a309e Mon Sep 17 00:00:00 2001 From: mhussein Date: Tue, 19 Jun 2012 19:51:05 +0300 Subject: [PATCH] Bug 380132: BuildOptionSettingsUI need to correctly load custom field editors Update: removed unused import. Change-Id: I4e665eda7921f573f340a57807d7a23c110daf88 Reviewed-on: https://git.eclipse.org/r/6047 Reviewed-by: Andrew Gvozdev IP-Clean: Andrew Gvozdev Tested-by: Andrew Gvozdev --- .../ui/properties/BuildOptionSettingsUI.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java index d082e0c696e..42e1a7dcab4 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java @@ -89,8 +89,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; -import org.osgi.framework.Bundle; - import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; @@ -522,25 +520,17 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { */ private class CustomFieldEditorDescriptor { - private final String editorClassName; - private final String bundleName; + private final IConfigurationElement element; - CustomFieldEditorDescriptor(String editorClassName, String bundleName) { - this.editorClassName = editorClassName; - this.bundleName = bundleName; + public CustomFieldEditorDescriptor(IConfigurationElement providerElement) { + this.element = providerElement; } FieldEditor createEditor() { try { - Bundle bundle = Platform.getBundle(this.bundleName); - if(bundle != null) { - Class editorClass = bundle.loadClass(this.editorClassName); - if(editorClass != null) { - Object editor = editorClass.newInstance(); - if(editor instanceof FieldEditor && editor instanceof ICustomBuildOptionEditor) { - return (FieldEditor)editor; - } - } + Object editor = element.createExecutableExtension("class"); //$NON-NLS-1$ + if(editor instanceof FieldEditor && editor instanceof ICustomBuildOptionEditor) { + return (FieldEditor)editor; } } catch(Exception x) { @@ -567,11 +557,8 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { for(IExtension e : ep.getExtensions()) { for(IConfigurationElement providerElement : e.getConfigurationElements()) { String editorId = providerElement.getAttribute("id"); //$NON-NLS-1$ - String editorClassName = providerElement.getAttribute("class"); //$NON-NLS-1$ - String bundleName = providerElement.getContributor().getName(); - - this.customFieldEditorDescriptorIndex.put(editorId, new CustomFieldEditorDescriptor(editorClassName, bundleName)); + this.customFieldEditorDescriptorIndex.put(editorId, new CustomFieldEditorDescriptor(providerElement)); } } }