1 11 package org.eclipse.pde.internal.ui.templates.rcp; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.jface.wizard.Wizard; 16 import org.eclipse.jface.wizard.WizardPage; 17 import org.eclipse.pde.core.plugin.IPluginBase; 18 import org.eclipse.pde.core.plugin.IPluginElement; 19 import org.eclipse.pde.core.plugin.IPluginExtension; 20 import org.eclipse.pde.core.plugin.IPluginModelBase; 21 import org.eclipse.pde.core.plugin.IPluginReference; 22 import org.eclipse.pde.internal.ui.templates.IHelpContextIds; 23 import org.eclipse.pde.internal.ui.templates.PDETemplateMessages; 24 import org.eclipse.pde.internal.ui.templates.PDETemplateSection; 25 import org.eclipse.pde.internal.ui.templates.PluginReference; 26 import org.eclipse.pde.ui.IFieldData; 27 28 29 public class HelloNonUIRCPTemplate extends PDETemplateSection { 30 31 public static final String KEY_APPLICATION_CLASS = "applicationClass"; public static final String KEY_APPLICATION_MESSAGE = "message"; 34 public HelloNonUIRCPTemplate() { 35 setPageCount(1); 36 createOptions(); 37 } 38 39 public void addPages(Wizard wizard) { 40 WizardPage page = createPage(0, IHelpContextIds.TEMPLATE_RCP_MAIL); 41 page.setTitle(PDETemplateMessages.HelloNonUIRCPTemplate_title); 42 page.setDescription(PDETemplateMessages.HelloNonUIRCPTemplate_desc); 43 wizard.addPage(page); 44 markPagesAdded(); 45 } 46 47 48 private void createOptions() { 49 addOption(KEY_PACKAGE_NAME, 50 PDETemplateMessages.MailTemplate_packageName, 51 (String ) null, 0); 52 53 addOption(KEY_APPLICATION_CLASS, 54 PDETemplateMessages.HelloNonUIRCPTemplate_appClass, 55 "Application", 0); 57 addOption(KEY_APPLICATION_MESSAGE, 58 PDETemplateMessages.HelloNonUIRCPTemplate_messageText, 59 PDETemplateMessages.HelloNonUIRCPTemplate_defaultMessage, 0); 60 } 61 62 protected void initializeFields(IFieldData data) { 63 String packageName = getFormattedPackageName(data.getId()); 66 initializeOption(KEY_PACKAGE_NAME, packageName); 67 } 68 69 public void initializeFields(IPluginModelBase model) { 70 String packageName = getFormattedPackageName(model.getPluginBase().getId()); 71 initializeOption(KEY_PACKAGE_NAME, packageName); 72 } 73 74 79 public String getSectionId() { 80 return "helloNonUIRCP"; } 82 83 86 protected void updateModel(IProgressMonitor monitor) throws CoreException { 87 createApplicationExtension(); 88 } 89 90 private void createApplicationExtension() throws CoreException { 91 IPluginBase plugin = model.getPluginBase(); 92 93 IPluginExtension extension = createExtension("org.eclipse.core.runtime.applications", true); extension.setId("application"); 96 IPluginElement element = model.getPluginFactory().createElement(extension); 97 element.setName("application"); extension.add(element); 99 100 IPluginElement run = model.getPluginFactory().createElement(element); 101 run.setName("run"); run.setAttribute("class", getStringOption(KEY_PACKAGE_NAME) + "." + getStringOption(KEY_APPLICATION_CLASS)); element.add(run); 104 105 if (!extension.isInTheModel()) 106 plugin.add(extension); 107 } 108 109 112 public String getUsedExtensionPoint() { 113 return null; 114 } 115 116 119 public boolean isDependentOnParentWizard() { 120 return true; 121 } 122 123 126 public int getNumberOfWorkUnits() { 127 return super.getNumberOfWorkUnits() + 1; 128 } 129 130 133 public IPluginReference[] getDependencies(String schemaVersion) { 134 IPluginReference[] dep = new IPluginReference[1]; 135 dep[0] = new PluginReference("org.eclipse.core.runtime", null, 0); return dep; 137 } 138 139 } 140 | Popular Tags |