Index: src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizard.java =================================================================== RCS file: src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizard.java diff -N src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizard.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizard.java 14 Sep 2009 13:04:05 -0000 @@ -0,0 +1,129 @@ +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ajdt.internal.ui.wizards.exports; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.pde.internal.core.FeatureModelManager; +import org.eclipse.pde.internal.core.PDECore; +import org.eclipse.pde.internal.core.exports.FeatureExportInfo; +import org.eclipse.pde.internal.core.ifeature.IFeatureModel; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.wizards.exports.AntGeneratingExportWizard; +import org.eclipse.pde.internal.ui.wizards.exports.BaseExportWizardPage; +import org.eclipse.pde.internal.ui.wizards.exports.CrossPlatformExportPage; +import org.eclipse.ui.progress.IProgressConstants; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class AJFeatureExportWizard extends AntGeneratingExportWizard { + private static final String STORE_SECTION = "FeatureExportWizard"; //$NON-NLS-1$ + private CrossPlatformExportPage fPage2; + + /** + * The constructor. + */ + public AJFeatureExportWizard() { + setDefaultPageImageDescriptor(PDEPluginImages.DESC_FEATURE_EXPORT_WIZ); + } + + public void addPages() { + super.addPages(); + FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager(); + IFeatureModel model = manager.getDeltaPackFeature(); + if (model != null) { + fPage2 = new CrossPlatformExportPage("environment", model); //$NON-NLS-1$ + addPage(fPage2); + } + } + + protected BaseExportWizardPage createPage1() { + // AspectJ change - use AJPluginExportWizardPage + return new AJFeatureExportWizardPage(getSelection()); + } + + protected String getSettingsSectionName() { + return STORE_SECTION; + } + + protected void scheduleExportJob() { + FeatureExportInfo info = new FeatureExportInfo(); + info.toDirectory = ((AJFeatureExportWizardPage)fPage).doExportToDirectory(); + info.useJarFormat = ((AJFeatureExportWizardPage)fPage).useJARFormat(); + info.exportSource = ((AJFeatureExportWizardPage)fPage).doExportSource(); + info.destinationDirectory = ((AJFeatureExportWizardPage)fPage).getDestination(); + info.zipFileName = ((AJFeatureExportWizardPage)fPage).getFileName(); + if (fPage2 != null && ((AJFeatureExportWizardPage) fPage).doMultiPlatform()) + info.targets = fPage2.getTargets(); + info.exportMetadata = ((AJFeatureExportWizardPage)fPage).doExportMetadata(); + info.items = ((AJFeatureExportWizardPage)fPage).getSelectedItems(); + info.signingInfo = ((AJFeatureExportWizardPage)fPage).getSigningInfo(); + info.jnlpInfo = ((AJFeatureExportWizardPage)fPage).getJNLPInfo(); + info.qualifier = ((AJFeatureExportWizardPage)fPage).getQualifier(); + + AJFeatureExportJob job = new AJFeatureExportJob(info); + job.setUser(true); + job.schedule(); + job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); + } + + protected Document generateAntTask() { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + Document doc = factory.newDocumentBuilder().newDocument(); + Element root = doc.createElement("project"); //$NON-NLS-1$ + root.setAttribute("name", "build"); //$NON-NLS-1$ //$NON-NLS-2$ + root.setAttribute("default", "feature_export"); //$NON-NLS-1$ //$NON-NLS-2$ + doc.appendChild(root); + + Element target = doc.createElement("target"); //$NON-NLS-1$ + target.setAttribute("name", "feature_export"); //$NON-NLS-1$ //$NON-NLS-2$ + root.appendChild(target); + + Element export = doc.createElement("pde.exportFeatures"); //$NON-NLS-1$ + export.setAttribute("features", getFeatureIDs()); //$NON-NLS-1$ + export.setAttribute("destination", ((AJFeatureExportWizardPage)fPage).getDestination()); //$NON-NLS-1$ + String filename = ((AJFeatureExportWizardPage)fPage).getFileName(); + if (filename != null) + export.setAttribute("filename", filename); //$NON-NLS-1$ + export.setAttribute("exportType", getExportOperation()); //$NON-NLS-1$ + export.setAttribute("useJARFormat", Boolean.toString(((AJFeatureExportWizardPage)fPage).useJARFormat())); //$NON-NLS-1$ + export.setAttribute("exportSource", Boolean.toString(((AJFeatureExportWizardPage)fPage).doExportSource())); //$NON-NLS-1$ + String qualifier = ((AJFeatureExportWizardPage)fPage).getQualifier(); + if (qualifier != null) + export.setAttribute("qualifier", qualifier); //$NON-NLS-1$ + target.appendChild(export); + return doc; + } catch (DOMException e) { + } catch (FactoryConfigurationError e) { + } catch (ParserConfigurationException e) { + } + return null; + } + + private String getFeatureIDs() { + StringBuffer buffer = new StringBuffer(); + Object[] objects = ((AJFeatureExportWizardPage)fPage).getSelectedItems(); + for (int i = 0; i < objects.length; i++) { + Object object = objects[i]; + if (object instanceof IFeatureModel) { + buffer.append(((IFeatureModel) object).getFeature().getId()); + if (i < objects.length - 1) + buffer.append(","); //$NON-NLS-1$ + } + } + return buffer.toString(); + } + +} Index: src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizardPage.java =================================================================== RCS file: src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizardPage.java diff -N src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizardPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizardPage.java 14 Sep 2009 13:04:05 -0000 @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Sian January - initial version + * ... + **********************************************************************/ +package org.eclipse.ajdt.internal.ui.wizards.exports; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.pde.internal.ui.wizards.exports.FeatureExportWizardPage; + +/** + * Extends FeatureExportWizardPage to allow AJFeatureExportWizard + * access to protected methods + */ +public class AJFeatureExportWizardPage extends FeatureExportWizardPage { + + public AJFeatureExportWizardPage(IStructuredSelection selection) { + super(selection); + } + + protected boolean doExportToDirectory() { + return super.doExportToDirectory(); + } + + protected boolean useJARFormat() { + return super.useJARFormat(); + } + + protected boolean doExportSource() { + return super.doExportSource(); + } + + protected String getDestination() { + return super.getDestination(); + } + + protected String getFileName() { + return super.getFileName(); + } + + protected String[] getSigningInfo() { + return super.getSigningInfo(); + } + + protected boolean doMultiPlatform() { + return super.doMultiPlatform(); + } + + protected String[] getJNLPInfo() { + return super.getJNLPInfo(); + } + + protected boolean doExportMetadata() { + return super.doExportMetadata(); + } + + protected String getQualifier() { + return super.getQualifier(); + } + +}