1 11 package org.eclipse.debug.internal.core; 12 13 import com.ibm.icu.text.MessageFormat; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IConfigurationElement; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.debug.core.*; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.model.*; 22 import org.eclipse.debug.core.model.IValue; 23 24 27 public class LogicalStructureType implements ILogicalStructureType { 28 29 private IConfigurationElement fConfigurationElement; 30 private ILogicalStructureTypeDelegate fDelegate; 31 private String fModelId; 32 private boolean fVerifiedDescription = false; 35 36 42 public LogicalStructureType(IConfigurationElement element) throws CoreException { 43 fConfigurationElement = element; 44 verifyAttributes(); 45 } 46 47 52 private void verifyAttributes() throws CoreException { 53 verifyAttributeExists("id"); verifyAttributeExists("class"); fModelId = fConfigurationElement.getAttribute("modelIdentifier"); if (fModelId == null) { 57 missingAttribute("modelIdentifier"); } 59 } 60 61 66 private void verifyAttributeExists(String name) throws CoreException { 67 if (fConfigurationElement.getAttribute(name) == null) { 68 missingAttribute(name); 69 } 70 } 71 72 private void missingAttribute(String attrName) throws CoreException { 73 throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LogicalStructureType_7,new String []{attrName}), null)); 74 } 75 76 79 public String getDescription() { 80 return fConfigurationElement.getAttribute("description"); } 82 83 86 public String getId() { 87 return fConfigurationElement.getAttribute("id"); } 89 90 93 public IValue getLogicalStructure(IValue value) throws CoreException { 94 return getDelegate().getLogicalStructure(value); 95 } 96 97 100 public boolean providesLogicalStructure(IValue value) { 101 if (value.getModelIdentifier().equals(fModelId)) { 102 return getDelegate().providesLogicalStructure(value); 103 } 104 return false; 105 } 106 107 protected ILogicalStructureTypeDelegate getDelegate() { 108 if (fDelegate == null) { 109 try { 110 fDelegate = (ILogicalStructureTypeDelegate) fConfigurationElement.createExecutableExtension("class"); } catch (CoreException e) { 112 DebugPlugin.log(e); 113 } 114 } 115 return fDelegate; 116 } 117 118 121 public String getDescription(IValue value) { 122 ILogicalStructureTypeDelegate delegate = getDelegate(); 123 if (delegate instanceof ILogicalStructureTypeDelegate2) { 124 ILogicalStructureTypeDelegate2 d2 = (ILogicalStructureTypeDelegate2) delegate; 125 return d2.getDescription(value); 126 } 127 if (!fVerifiedDescription) { 128 fVerifiedDescription = true; 129 try { 130 verifyAttributeExists("description"); } catch (CoreException e) { 132 DebugPlugin.log(e); 133 } 134 } 135 String description = getDescription(); 136 if (description == null) { 137 return DebugCoreMessages.LogicalStructureType_0; 138 } 139 return description; 140 } 141 } 142 | Popular Tags |