1 9 package org.eclipse.ui.intro.universal; 10 11 import org.eclipse.core.runtime.CoreException; 12 import org.eclipse.core.runtime.IConfigurationElement; 13 import org.eclipse.core.runtime.IExecutableExtension; 14 import org.eclipse.core.runtime.IExecutableExtensionFactory; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.ui.internal.intro.universal.UniversalIntroPlugin; 18 import org.eclipse.ui.internal.intro.universal.WelcomeCustomizationPreferencePage; 19 20 37 38 public class ExtensionFactory implements IExecutableExtensionFactory, IExecutableExtension { 39 40 private String id; 41 private IConfigurationElement config; 42 private String propertyName; 43 private static final String WELCOME_CUSTOMIZATION_PREFERENCE_PAGE = "welcomeCustomization"; 45 50 public Object create() throws CoreException { 51 if (WELCOME_CUSTOMIZATION_PREFERENCE_PAGE.equals(id)) 52 return configure(new WelcomeCustomizationPreferencePage()); 53 54 throw new CoreException(new Status(IStatus.ERROR, UniversalIntroPlugin.PLUGIN_ID, 0, 55 "Unknown id in data argument for " + getClass(), null)); } 57 58 private Object configure(Object obj) throws CoreException { 59 if (obj instanceof IExecutableExtension) { 60 ((IExecutableExtension) obj).setInitializationData(config, propertyName, null); 61 } 62 return obj; 63 } 64 65 71 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) 72 throws CoreException { 73 if (data instanceof String ) 74 id = (String ) data; 75 else 76 throw new CoreException(new Status(IStatus.ERROR, UniversalIntroPlugin.PLUGIN_ID, 0, 77 "Data argument must be a String for " + getClass(), null)); this.config = config; 79 this.propertyName = propertyName; 80 } 81 } | Popular Tags |