1 11 package org.eclipse.core.internal.registry; 12 13 import java.util.ArrayList ; 14 import java.util.Arrays ; 15 import org.eclipse.core.runtime.*; 16 17 25 public class BaseExtensionPointHandle extends Handle implements IExtensionPoint { 26 27 public BaseExtensionPointHandle(IObjectManager objectManager, int id) { 28 super(objectManager, id); 29 } 30 31 public IExtension[] getExtensions() { 32 return (IExtension[]) objectManager.getHandles(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION); 33 } 34 35 public String getNamespace() { 37 return getContributor().getName(); 38 } 39 40 public String getNamespaceIdentifier() { 41 return getExtensionPoint().getNamespace(); 42 } 43 44 public IContributor getContributor() { 45 return getExtensionPoint().getContributor(); 46 } 47 48 protected boolean shouldPersist() { 49 return getExtensionPoint().shouldPersist(); 50 } 51 52 public IExtension getExtension(String extensionId) { 53 if (extensionId == null) 54 return null; 55 int[] children = getExtensionPoint().getRawChildren(); 56 for (int i = 0; i < children.length; i++) { 57 if (extensionId.equals(((Extension) objectManager.getObject(children[i], RegistryObjectManager.EXTENSION)).getUniqueIdentifier())) 59 return (ExtensionHandle) objectManager.getHandle(children[i], RegistryObjectManager.EXTENSION); 60 } 61 return null; 62 } 63 64 public IConfigurationElement[] getConfigurationElements() { 65 Extension[] tmpExtensions = (Extension[]) objectManager.getObjects(getExtensionPoint().getRawChildren(), RegistryObjectManager.EXTENSION); 67 if (tmpExtensions.length == 0) 68 return ConfigurationElementHandle.EMPTY_ARRAY; 69 70 ArrayList result = new ArrayList (); 71 for (int i = 0; i < tmpExtensions.length; i++) { 72 result.addAll(Arrays.asList(objectManager.getHandles(tmpExtensions[i].getRawChildren(), RegistryObjectManager.CONFIGURATION_ELEMENT))); 73 } 74 return (IConfigurationElement[]) result.toArray(new IConfigurationElement[result.size()]); 75 } 76 77 public String getLabel() { 78 return getExtensionPoint().getLabel(); 79 } 80 81 public String getSchemaReference() { 82 return getExtensionPoint().getSchemaReference(); 83 } 84 85 public String getSimpleIdentifier() { 86 return getExtensionPoint().getSimpleIdentifier(); 87 } 88 89 public String getUniqueIdentifier() { 90 return getExtensionPoint().getUniqueIdentifier(); 91 } 92 93 RegistryObject getObject() { 94 return getExtensionPoint(); 95 } 96 97 protected ExtensionPoint getExtensionPoint() { 98 return (ExtensionPoint) objectManager.getObject(getId(), RegistryObjectManager.EXTENSION_POINT); 99 } 100 101 public boolean isValid() { 102 try { 103 getExtensionPoint(); 104 } catch (InvalidRegistryObjectException e) { 105 return false; 106 } 107 return true; 108 } 109 } 110 | Popular Tags |