1 11 package org.eclipse.pde.internal.ui.wizards.exports; 12 13 import javax.xml.parsers.DocumentBuilderFactory ; 14 import javax.xml.parsers.FactoryConfigurationError ; 15 import javax.xml.parsers.ParserConfigurationException ; 16 17 import org.eclipse.pde.internal.core.FeatureModelManager; 18 import org.eclipse.pde.internal.core.PDECore; 19 import org.eclipse.pde.internal.core.exports.FeatureExportInfo; 20 import org.eclipse.pde.internal.core.ifeature.IFeatureModel; 21 import org.eclipse.pde.internal.ui.PDEPluginImages; 22 import org.eclipse.pde.internal.ui.build.FeatureExportJob; 23 import org.eclipse.ui.progress.IProgressConstants; 24 import org.w3c.dom.DOMException ; 25 import org.w3c.dom.Document ; 26 import org.w3c.dom.Element ; 27 28 public class FeatureExportWizard extends AntGeneratingExportWizard { 29 private static final String STORE_SECTION = "FeatureExportWizard"; private CrossPlatformExportPage fPage2; 31 32 35 public FeatureExportWizard() { 36 setDefaultPageImageDescriptor(PDEPluginImages.DESC_FEATURE_EXPORT_WIZ); 37 } 38 39 public void addPages() { 40 super.addPages(); 41 FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager(); 42 IFeatureModel model = manager.findFeatureModel("org.eclipse.platform.launchers"); if (model != null) { 44 fPage2 = new CrossPlatformExportPage("environment", model); addPage(fPage2); 46 } 47 } 48 49 protected BaseExportWizardPage createPage1() { 50 return new FeatureExportWizardPage(getSelection()); 51 } 52 53 protected String getSettingsSectionName() { 54 return STORE_SECTION; 55 } 56 57 protected void scheduleExportJob() { 58 FeatureExportInfo info = new FeatureExportInfo(); 59 info.toDirectory = fPage.doExportToDirectory(); 60 info.useJarFormat = fPage.useJARFormat(); 61 info.exportSource = fPage.doExportSource(); 62 info.destinationDirectory = fPage.getDestination(); 63 info.zipFileName = fPage.getFileName(); 64 if (fPage2 != null && ((FeatureExportWizardPage)fPage).doMultiPlatform()) 65 info.targets = fPage2.getTargets(); 66 info.items = fPage.getSelectedItems(); 67 info.signingInfo = fPage.getSigningInfo(); 68 info.jnlpInfo = ((FeatureExportWizardPage)fPage).getJNLPInfo(); 69 info.qualifier = fPage.getQualifier(); 70 71 FeatureExportJob job = new FeatureExportJob(info); 72 job.setUser(true); 73 job.schedule(); 74 job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); 75 } 76 77 protected Document generateAntTask() { 78 try { 79 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 80 Document doc = factory.newDocumentBuilder().newDocument(); 81 Element root = doc.createElement("project"); root.setAttribute("name", "build"); root.setAttribute("default", "feature_export"); doc.appendChild(root); 85 86 Element target = doc.createElement("target"); target.setAttribute("name", "feature_export"); root.appendChild(target); 89 90 Element export = doc.createElement("pde.exportFeatures"); export.setAttribute("features", getFeatureIDs()); export.setAttribute("destination", fPage.getDestination()); String filename = fPage.getFileName(); 94 if (filename != null) 95 export.setAttribute("filename", filename); export.setAttribute("exportType", getExportOperation()); export.setAttribute("useJARFormat", Boolean.toString(fPage.useJARFormat())); export.setAttribute("exportSource", Boolean.toString(fPage.doExportSource())); String qualifier = fPage.getQualifier(); 100 if (qualifier != null) 101 export.setAttribute("qualifier", qualifier); target.appendChild(export); 103 return doc; 104 } catch (DOMException e) { 105 } catch (FactoryConfigurationError e) { 106 } catch (ParserConfigurationException e) { 107 } 108 return null; 109 } 110 111 private String getFeatureIDs() { 112 StringBuffer buffer = new StringBuffer (); 113 Object [] objects = fPage.getSelectedItems(); 114 for (int i = 0; i < objects.length; i++) { 115 Object object = objects[i]; 116 if (object instanceof IFeatureModel) { 117 buffer.append(((IFeatureModel)object).getFeature().getId()); 118 if (i < objects.length - 1) 119 buffer.append(","); } 121 } 122 return buffer.toString(); 123 } 124 125 } 126 | Popular Tags |