1 11 package org.eclipse.debug.internal.ui.stringsubstitution; 12 13 import com.ibm.icu.text.MessageFormat; 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IConfigurationElement; 19 import org.eclipse.core.runtime.IExtensionPoint; 20 import org.eclipse.core.runtime.Platform; 21 import org.eclipse.core.variables.IStringVariable; 22 import org.eclipse.debug.internal.ui.DebugUIPlugin; 23 24 29 public class StringVariablePresentationManager { 30 31 37 public static final String EXTENSION_POINT_STRING_VARIABLE_PRESENTATIONS = "stringVariablePresentations"; 39 private static StringVariablePresentationManager fgManager; 41 42 public static final String ATTR_NAME = "variableName"; public static final String ATTR_ARGUMENT_SELECTOR = "argumentSelector"; 46 50 private Map fConfigurations; 51 52 57 public static StringVariablePresentationManager getDefault() { 58 if (fgManager == null) { 59 fgManager = new StringVariablePresentationManager(); 60 } 61 return fgManager; 62 } 63 64 71 public IArgumentSelector getArgumentSelector(IStringVariable variable) { 72 IConfigurationElement element = (IConfigurationElement) fConfigurations.get(variable.getName()); 73 if (element != null) { 74 try { 75 return (IArgumentSelector)element.createExecutableExtension(ATTR_ARGUMENT_SELECTOR); 76 } catch (CoreException e) { 77 DebugUIPlugin.log(e); 78 } 79 } 80 return null; 81 } 82 83 86 private StringVariablePresentationManager() { 87 initialize(); 88 } 89 90 93 private void initialize() { 94 fConfigurations = new HashMap (); 95 IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), EXTENSION_POINT_STRING_VARIABLE_PRESENTATIONS); 96 IConfigurationElement elements[]= point.getConfigurationElements(); 97 for (int i = 0; i < elements.length; i++) { 98 IConfigurationElement element = elements[i]; 99 String name= element.getAttribute(ATTR_NAME); 100 if (name == null) { 101 DebugUIPlugin.logErrorMessage(MessageFormat.format("String variable presentation extension missing required 'variableName' attribute: {0}", new String [] {element.getDeclaringExtension().getLabel()})); continue; 103 } 104 fConfigurations.put(name, element); 105 } 106 } 107 108 109 } 110 | Popular Tags |