1 11 package org.eclipse.pde.internal.ui.wizards.templates; 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.IPluginReference; 18 import org.eclipse.pde.internal.ui.IHelpContextIds; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.eclipse.pde.ui.templates.TemplateOption; 21 22 23 public class HelloOSGiTemplate extends PDETemplateSection { 24 25 public static final String KEY_START_MESSAGE = "startMessage"; public static final String KEY_STOP_MESSAGE = "stopMessage"; public static final String KEY_APPLICATION_CLASS = "applicationClass"; 29 private HelloOSGiNewWizard osgiWizard; 30 31 public HelloOSGiTemplate(HelloOSGiNewWizard wizard) { 32 setPageCount(1); 33 osgiWizard = wizard; 34 addOption(KEY_START_MESSAGE, PDEUIMessages.HelloOSGiTemplate_startMessage, "Hello World!!", 0); addOption(KEY_STOP_MESSAGE, PDEUIMessages.HelloOSGiTemplate_stopMessage, "Goodbye World!!", 0); } 37 38 public void addPages(Wizard wizard) { 39 WizardPage page = createPage(0, IHelpContextIds.TEMPLATE_RCP_MAIL); 40 page.setTitle(PDEUIMessages.HelloOSGiTemplate_pageTitle); 41 page.setDescription(PDEUIMessages.HelloOSGiTemplate_pageDescription); 42 wizard.addPage(page); 43 markPagesAdded(); 44 } 45 46 public String getReplacementString(String fileName, String key) { 47 if (KEY_APPLICATION_CLASS.equals(key)) { 48 String className = osgiWizard.fData.getClassname(); 49 return className.substring(className.lastIndexOf(".") + 1); } else if (KEY_PACKAGE_NAME.equals(key)) 51 return getFormattedPackageName(osgiWizard.fData.getId()); 52 return super.getReplacementString(fileName, key); 53 } 54 55 60 public String getSectionId() { 61 return "helloOSGi"; } 63 64 67 public void validateOptions(TemplateOption source) { 68 if (source.isRequired() && source.isEmpty()) { 69 flagMissingRequiredOption(source); 70 } else { 71 validateContainerPage(source); 72 } 73 } 74 75 private void validateContainerPage(TemplateOption source) { 76 TemplateOption[] allPageOptions = getOptions(0); 77 for (int i = 0; i < allPageOptions.length; i++) { 78 TemplateOption nextOption = allPageOptions[i]; 79 if (nextOption.isRequired() && nextOption.isEmpty()) { 80 flagMissingRequiredOption(nextOption); 81 return; 82 } 83 } 84 resetPageState(); 85 } 86 87 90 protected void updateModel(IProgressMonitor monitor) throws CoreException { 91 92 } 93 94 97 public String getUsedExtensionPoint() { 98 return null; 99 } 100 101 104 public boolean isDependentOnParentWizard() { 105 return true; 106 } 107 108 111 public int getNumberOfWorkUnits() { 112 return super.getNumberOfWorkUnits() + 1; 113 } 114 115 public IPluginReference[] getDependencies(String schemaVersion) { 116 return new IPluginReference[0]; 117 } 118 } 119 | Popular Tags |