1 11 12 package org.eclipse.ui.internal.intro.impl.model.loader; 13 14 import java.util.Hashtable ; 15 16 import org.eclipse.core.runtime.IConfigurationElement; 17 import org.eclipse.core.runtime.IExtensionRegistry; 18 import org.eclipse.ui.internal.intro.impl.model.IntroStandbyContentPart; 19 import org.eclipse.ui.internal.intro.impl.model.IntroURLAction; 20 import org.eclipse.ui.internal.intro.impl.util.Log; 21 import org.eclipse.ui.internal.intro.impl.util.Util; 22 23 28 29 public class SharedConfigExtensionsManager { 30 31 private IExtensionRegistry registry; 32 33 private Hashtable standbyParts = new Hashtable (); 36 37 private Hashtable commands = new Hashtable (); 39 40 43 protected SharedConfigExtensionsManager(IExtensionRegistry registry) { 44 this.registry = registry; 45 } 46 47 50 protected void loadSharedConfigExtensions() { 51 54 long start = 0; 55 if (Log.logPerformance) 57 start = System.currentTimeMillis(); 58 59 IConfigurationElement[] configExtensionElements = registry 60 .getConfigurationElementsFor(BaseExtensionPointManager.CONFIG_EXTENSION); 61 62 if (Log.logPerformance) 63 Util.logPerformanceTime( 64 "quering registry for configExtensions took: ", start); 66 for (int i = 0; i < configExtensionElements.length; i++) { 67 IConfigurationElement element = configExtensionElements[i]; 68 if (!ModelLoaderUtil.isValidElementName(element, 69 IntroStandbyContentPart.TAG_STANDBY_CONTENT_PART) 70 && !ModelLoaderUtil.isValidElementName(element, 71 IntroURLAction.TAG_ACTION)) 72 continue; 74 createModelClass(element); 75 } 76 } 77 78 79 84 private void createModelClass(IConfigurationElement element) { 85 if (element.getName().equals( 86 IntroStandbyContentPart.TAG_STANDBY_CONTENT_PART)) { 87 IntroStandbyContentPart standbyPartContent = new IntroStandbyContentPart( 88 element); 89 if (standbyPartContent.getId() == null) 90 return; 92 standbyParts.put(standbyPartContent.getId(), standbyPartContent); 93 } else { 94 IntroURLAction introURLCommand = new IntroURLAction(element); 95 if (introURLCommand.getName() == null 96 || introURLCommand.getReplaceValue() == null) 97 return; 99 commands.put(introURLCommand.getName(), introURLCommand); 100 } 101 } 102 103 104 105 108 public IntroStandbyContentPart getStandbyPart(String partId) { 109 if (partId == null) 110 return null; 111 return (IntroStandbyContentPart) standbyParts.get(partId); 112 } 113 114 117 public IntroURLAction getCommand(String commandName) { 118 if (commandName == null) 119 return null; 120 return (IntroURLAction) commands.get(commandName); 121 } 122 123 } 124 | Popular Tags |