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.core.plugin.IPluginModelBase; 18 import org.eclipse.pde.internal.core.exports.FeatureExportInfo; 19 import org.eclipse.pde.internal.ui.PDEPluginImages; 20 import org.eclipse.pde.internal.ui.build.PluginExportJob; 21 import org.eclipse.ui.progress.IProgressConstants; 22 import org.w3c.dom.DOMException ; 23 import org.w3c.dom.Document ; 24 import org.w3c.dom.Element ; 25 26 public class PluginExportWizard extends AntGeneratingExportWizard { 27 private static final String STORE_SECTION = "PluginExportWizard"; 29 public PluginExportWizard() { 30 setDefaultPageImageDescriptor(PDEPluginImages.DESC_PLUGIN_EXPORT_WIZ); 31 } 32 33 protected BaseExportWizardPage createPage1() { 34 return new PluginExportWizardPage(getSelection()); 35 } 36 37 protected String getSettingsSectionName() { 38 return STORE_SECTION; 39 } 40 41 protected void scheduleExportJob() { 42 FeatureExportInfo info = new FeatureExportInfo(); 43 info.toDirectory = fPage.doExportToDirectory(); 44 info.useJarFormat = fPage.useJARFormat(); 45 info.exportSource = fPage.doExportSource(); 46 info.destinationDirectory = fPage.getDestination(); 47 info.zipFileName = fPage.getFileName(); 48 info.items = fPage.getSelectedItems(); 49 info.signingInfo = fPage.useJARFormat() ? fPage.getSigningInfo() : null; 50 info.qualifier = fPage.getQualifier(); 51 52 PluginExportJob job = new PluginExportJob(info); 53 job.setUser(true); 54 job.schedule(); 55 job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PLUGIN_OBJ); 56 } 57 58 protected Document generateAntTask() { 59 try { 60 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 61 Document doc = factory.newDocumentBuilder().newDocument(); 62 Element root = doc.createElement("project"); root.setAttribute("name", "build"); root.setAttribute("default", "plugin_export"); doc.appendChild(root); 66 67 Element target = doc.createElement("target"); target.setAttribute("name", "plugin_export"); root.appendChild(target); 70 71 Element export = doc.createElement("pde.exportPlugins"); export.setAttribute("plugins", getPluginIDs()); export.setAttribute("destination", fPage.getDestination()); String filename = fPage.getFileName(); 75 if (filename != null) 76 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(); 81 if (qualifier != null) 82 export.setAttribute("qualifier", qualifier); target.appendChild(export); 84 return doc; 85 } catch (DOMException e) { 86 } catch (FactoryConfigurationError e) { 87 } catch (ParserConfigurationException e) { 88 } 89 return null; 90 } 91 92 private String getPluginIDs() { 93 StringBuffer buffer = new StringBuffer (); 94 Object [] objects = fPage.getSelectedItems(); 95 for (int i = 0; i < objects.length; i++) { 96 Object object = objects[i]; 97 if (object instanceof IPluginModelBase) { 98 buffer.append(((IPluginModelBase)object).getPluginBase().getId()); 99 if (i < objects.length - 1) 100 buffer.append(","); } 102 } 103 return buffer.toString(); 104 } 105 106 } 107 | Popular Tags |