1 11 package org.eclipse.debug.internal.ui.memory; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IConfigurationElement; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.debug.internal.ui.DebugUIPlugin; 18 import org.eclipse.debug.ui.IDebugUIConstants; 19 import org.eclipse.debug.ui.memory.IMemoryRendering; 20 import org.eclipse.debug.ui.memory.IMemoryRenderingType; 21 import org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate; 22 23 28 class MemoryRenderingType implements IMemoryRenderingType { 29 30 private IConfigurationElement fConfigurationElement; 31 private IMemoryRenderingTypeDelegate fDelegate; 32 33 static final String ATTR_MEM_RENDERING_TYPE_NAME = "name"; static final String ATTR_MEM_RENDERING_TYPE_ID = "id"; static final String ATTR_MEM_RENDERING_TYPE_DELEGATE = "class"; 38 41 MemoryRenderingType(IConfigurationElement element) { 42 fConfigurationElement = element; 43 } 44 45 48 public String getLabel() { 49 return fConfigurationElement.getAttribute(ATTR_MEM_RENDERING_TYPE_NAME); 50 } 51 52 55 public String getId() { 56 return fConfigurationElement.getAttribute(ATTR_MEM_RENDERING_TYPE_ID); 57 } 58 59 62 public IMemoryRendering createRendering() throws CoreException { 63 if (fDelegate == null) { 64 fDelegate = (IMemoryRenderingTypeDelegate) fConfigurationElement.createExecutableExtension(ATTR_MEM_RENDERING_TYPE_DELEGATE); 65 } 66 return fDelegate.createRendering(getId()); 67 } 68 69 74 void validate() throws CoreException { 75 verifyPresent(ATTR_MEM_RENDERING_TYPE_ID); 76 verifyPresent(ATTR_MEM_RENDERING_TYPE_NAME); 77 verifyPresent(ATTR_MEM_RENDERING_TYPE_DELEGATE); 78 } 79 80 private void verifyPresent(String attrName) throws CoreException { 81 if (fConfigurationElement.getAttribute(attrName) == null) { 82 Status status = new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.INTERNAL_ERROR, 83 "<memoryRenderingType> element missing required attribute: " + attrName, null); throw new CoreException(status); 85 } 86 } 87 } 88 | Popular Tags |