1 11 package org.eclipse.debug.internal.ui; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IExtensionPoint; 19 import org.eclipse.core.runtime.Platform; 20 import org.eclipse.debug.ui.IDebugUIConstants; 21 import org.eclipse.debug.ui.actions.IVariableValueEditor; 22 23 31 public class VariableValueEditorManager { 32 33 40 private Map fEditorMap= new HashMap (); 41 42 45 private static VariableValueEditorManager fgManager; 46 47 52 private VariableValueEditorManager() { 53 loadVariableEditors(); 54 } 55 56 60 public static VariableValueEditorManager getDefault() { 61 if (fgManager == null) { 62 fgManager= new VariableValueEditorManager(); 63 } 64 return fgManager; 65 } 66 67 75 public IVariableValueEditor getVariableValueEditor(String modelIdentifier) { 76 Object object = fEditorMap.get(modelIdentifier); 77 IVariableValueEditor editor= null; 78 if (object instanceof IVariableValueEditor) { 79 editor= (IVariableValueEditor) object; 80 } else if (object instanceof IConfigurationElement) { 81 try { 82 editor = (IVariableValueEditor) ((IConfigurationElement) object).createExecutableExtension("class"); fEditorMap.put(modelIdentifier, editor); 84 } catch (CoreException e) { 85 DebugUIPlugin.log(e); 88 } 89 } 90 return editor; 91 } 92 93 97 private void loadVariableEditors() { 98 IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_VARIABLE_VALUE_EDITORS); 99 IConfigurationElement[] elements = ep.getConfigurationElements(); 100 for (int i = 0; i < elements.length; i++) { 101 IConfigurationElement element = elements[i]; 102 String modelId = element.getAttribute("modelId"); if (modelId != null) { 104 fEditorMap.put(modelId, element); 105 } 106 } 107 } 108 } 109 | Popular Tags |