1 11 package org.eclipse.ui.cheatsheets; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IConfigurationElement; 15 import org.eclipse.core.runtime.IExecutableExtension; 16 import org.eclipse.core.runtime.IExecutableExtensionFactory; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.ui.PlatformUI; 20 import org.eclipse.ui.internal.cheatsheets.actions.CheatSheetHelpMenuAction; 21 22 31 32 public class CheatSheetExtensionFactory implements IExecutableExtensionFactory, 33 IExecutableExtension { 34 37 public static final String HELP_MENU_ACTION = "helpMenuAction"; 39 private IConfigurationElement config; 40 41 private String id; 42 43 private String propertyName; 44 45 48 public CheatSheetExtensionFactory() { 49 } 51 52 57 public Object create() throws CoreException { 58 if (HELP_MENU_ACTION.equals(id)) 59 return configure(new CheatSheetHelpMenuAction()); 60 throw new CoreException(new Status(IStatus.ERROR, 61 "org.eclipse.ui.cheatsheets", 0, "Unknown id in data argument for " + getClass(), null)); } 64 65 71 public void setInitializationData(IConfigurationElement config, 72 String propertyName, Object data) throws CoreException { 73 if (data instanceof String ) 74 id = (String ) data; 75 else 76 throw new CoreException(new Status(IStatus.ERROR, 77 PlatformUI.PLUGIN_ID, 0, 78 "Data argument must be a String for " + getClass(), null)); this.config = config; 80 this.propertyName = propertyName; 81 } 82 83 private Object configure(Object obj) throws CoreException { 84 if (obj instanceof IExecutableExtension) { 85 ((IExecutableExtension) obj).setInitializationData(config, 86 propertyName, null); 87 } 88 return obj; 89 } 90 } | Popular Tags |