1 11 package org.eclipse.debug.internal.core; 12 13 import com.ibm.icu.text.MessageFormat; 14 import java.util.HashSet ; 15 import java.util.Set ; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IStatus; 19 import org.eclipse.core.runtime.Status; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; 22 23 27 public class ContributedDelegate { 28 29 32 private IConfigurationElement fElement; 33 34 37 private Set fModes; 38 39 42 private ILaunchConfigurationDelegate fDelegate; 43 44 50 protected ContributedDelegate(IConfigurationElement element) { 51 setConfigurationElement(element); 52 } 53 54 59 private void setConfigurationElement(IConfigurationElement element) { 60 fElement = element; 61 } 62 63 68 protected IConfigurationElement getConfigurationElement() { 69 return fElement; 70 } 71 72 77 protected Set getModes() { 78 if (fModes == null) { 79 String modes= getConfigurationElement().getAttribute("modes"); if (modes == null) { 81 return new HashSet (0); 82 } 83 String [] strings = modes.split(","); fModes = new HashSet (3); 85 for (int i = 0; i < strings.length; i++) { 86 String string = strings[i]; 87 fModes.add(string.trim()); 88 } 89 } 90 return fModes; 91 } 92 93 97 protected String getLaunchConfigurationType() { 98 return getConfigurationElement().getAttribute("type"); } 100 101 protected ILaunchConfigurationDelegate getDelegate() throws CoreException { 102 if (fDelegate == null) { 103 Object object = getConfigurationElement().createExecutableExtension("delegate"); if (object instanceof ILaunchConfigurationDelegate) { 105 fDelegate = (ILaunchConfigurationDelegate)object; 106 } else { 107 throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_Launch_delegate_for__0__does_not_implement_required_interface_ILaunchConfigurationDelegate__1, new String []{getIdentifier()}), null)); 108 } 109 } 110 return fDelegate; 111 } 112 113 116 protected String getIdentifier() { 117 return getConfigurationElement().getAttribute("id"); } 119 120 129 protected String getSourcePathComputerId() { 130 return getConfigurationElement().getAttribute("sourcePathComputerId"); } 132 133 142 protected String getSourceLocaterId() { 143 return getConfigurationElement().getAttribute("sourceLocatorId"); } 145 } 146 | Popular Tags |