1 11 12 package org.eclipse.ui.internal.statushandlers; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IConfigurationElement; 19 import org.eclipse.ui.IPluginContribution; 20 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; 21 import org.eclipse.ui.statushandlers.AbstractStatusHandler; 22 23 28 public class StatusHandlerDescriptor implements IPluginContribution { 29 30 private AbstractStatusHandler cachedInstance; 31 32 private final static String PREFIX = "prefix"; 34 private IConfigurationElement configElement; 35 36 private String id; 37 38 private String pluginId; 39 40 private String prefix; 41 42 45 public StatusHandlerDescriptor(IConfigurationElement configElement) { 46 super(); 47 this.configElement = configElement; 48 id = configElement.getAttribute(IWorkbenchRegistryConstants.ATT_ID); 49 pluginId = configElement.getContributor().getName(); 50 } 51 52 59 public synchronized AbstractStatusHandler getStatusHandler() 60 throws CoreException { 61 if (cachedInstance == null) { 62 AbstractStatusHandler statusHandler = (AbstractStatusHandler) configElement 63 .createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS); 64 statusHandler.setId(configElement 65 .getAttribute(IWorkbenchRegistryConstants.ATT_ID)); 66 67 IConfigurationElement parameters[] = configElement 68 .getChildren(IWorkbenchRegistryConstants.TAG_PARAMETER); 69 70 Map params = new HashMap (); 71 72 for (int i = 0; i < parameters.length; i++) { 73 params 74 .put( 75 parameters[i] 76 .getAttribute(IWorkbenchRegistryConstants.ATT_NAME), 77 parameters[i] 78 .getAttribute(IWorkbenchRegistryConstants.ATT_VALUE)); 79 } 80 81 statusHandler.setParams(params); 82 cachedInstance = statusHandler; 83 } 84 return cachedInstance; 85 } 86 87 92 public String getPrefix() { 93 IConfigurationElement parameters[] = configElement 94 .getChildren(IWorkbenchRegistryConstants.TAG_PARAMETER); 95 96 for (int i = 0; i < parameters.length; i++) { 97 if (parameters[i] 98 .getAttribute(IWorkbenchRegistryConstants.ATT_NAME).equals( 99 PREFIX)) { 100 prefix = parameters[i] 101 .getAttribute(IWorkbenchRegistryConstants.ATT_VALUE); 102 } 103 } 104 return prefix; 105 } 106 107 112 public String getId() { 113 return id; 114 } 115 116 121 public String getLocalId() { 122 return id; 123 } 124 125 130 public String getPluginId() { 131 return pluginId; 132 } 133 } 134 | Popular Tags |