1 11 package org.eclipse.ui.internal.intro; 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.jface.resource.ImageDescriptor; 18 import org.eclipse.ui.IPluginContribution; 19 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; 20 import org.eclipse.ui.intro.IIntroPart; 21 import org.eclipse.ui.intro.IntroContentDetector; 22 import org.eclipse.ui.plugin.AbstractUIPlugin; 23 24 29 public class IntroDescriptor implements IIntroDescriptor, IPluginContribution { 30 31 32 private IConfigurationElement element; 33 34 private ImageDescriptor imageDescriptor; 35 36 39 public IntroDescriptor(IConfigurationElement configElement) 40 throws CoreException { 41 element = configElement; 42 43 if (configElement.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS) == null) { 44 throw new CoreException(new Status(IStatus.ERROR, configElement 45 .getNamespace(), 0, 46 "Invalid extension (Missing class name): " + getId(), null)); 48 } 49 } 50 51 54 public IIntroPart createIntro() throws CoreException { 55 return (IIntroPart) element.createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS); 56 } 57 58 public IntroContentDetector getIntroContentDetector() throws CoreException { 59 if (element.getAttribute(IWorkbenchRegistryConstants.ATT_CONTENT_DETECTOR) == null) { 60 return null; 61 } 62 return (IntroContentDetector) element.createExecutableExtension(IWorkbenchRegistryConstants.ATT_CONTENT_DETECTOR); 63 } 64 65 68 public String getId() { 69 return element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); 70 } 71 72 75 public ImageDescriptor getImageDescriptor() { 76 if (imageDescriptor != null) { 77 return imageDescriptor; 78 } 79 String iconName = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON); 80 if (iconName == null) { 81 return null; 82 } 83 84 imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(element 85 .getNamespace(), iconName); 86 return imageDescriptor; 87 } 88 89 92 public String getLocalId() { 93 return element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); 94 } 95 96 99 public String getPluginId() { 100 return element.getNamespace(); 101 } 102 103 109 public IConfigurationElement getConfigurationElement() { 110 return element; 111 } 112 113 116 public String getLabelOverride() { 117 return element.getAttribute(IWorkbenchRegistryConstants.ATT_LABEL); 118 } 119 } 120 | Popular Tags |