1 11 package org.eclipse.debug.internal.core; 12 13 import com.ibm.icu.text.MessageFormat; 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.core.runtime.IConfigurationElement; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.debug.core.DebugPlugin; 19 import org.eclipse.debug.core.ILaunchMode; 20 21 24 public class LaunchMode implements ILaunchMode { 25 26 private IConfigurationElement fConfigurationElement; 27 28 34 public LaunchMode(IConfigurationElement element) throws CoreException { 35 fConfigurationElement = element; 36 verifyAttributes(); 37 } 38 39 44 private void verifyAttributes() throws CoreException { 45 verifyAttributeExists("mode"); verifyAttributeExists("label"); } 48 49 54 private void verifyAttributeExists(String name) throws CoreException { 55 if (fConfigurationElement.getAttribute(name) == null) { 56 missingAttribute(name); 57 } 58 } 59 60 private void missingAttribute(String attrName) throws CoreException { 61 throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchMode_1,new String []{attrName}), null)); 62 } 63 64 67 public String getIdentifier() { 68 return fConfigurationElement.getAttribute("mode"); } 70 73 public String getLabel() { 74 return fConfigurationElement.getAttribute("label"); } 76 77 80 public String getLaunchAsLabel() { 81 String label = fConfigurationElement.getAttribute("launchAsLabel"); if (label == null) { 83 return MessageFormat.format(DebugCoreMessages.LaunchMode_0, new String []{getLabel()}); 84 } 85 return label; 86 } 87 } 88 | Popular Tags |