View | Details | Raw Unified | Return to bug 245142
Collapse All | Expand All

(-)src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizard.java (+129 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ajdt.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.wizards.exports.AntGeneratingExportWizard;
23
import org.eclipse.pde.internal.ui.wizards.exports.BaseExportWizardPage;
24
import org.eclipse.pde.internal.ui.wizards.exports.CrossPlatformExportPage;
25
import org.eclipse.ui.progress.IProgressConstants;
26
import org.w3c.dom.DOMException;
27
import org.w3c.dom.Document;
28
import org.w3c.dom.Element;
29
30
public class AJFeatureExportWizard extends AntGeneratingExportWizard {
31
	private static final String STORE_SECTION = "FeatureExportWizard"; //$NON-NLS-1$
32
	private CrossPlatformExportPage fPage2;
33
34
	/**
35
	 * The constructor.
36
	 */
37
	public AJFeatureExportWizard() {
38
		setDefaultPageImageDescriptor(PDEPluginImages.DESC_FEATURE_EXPORT_WIZ);
39
	}
40
41
	public void addPages() {
42
		super.addPages();
43
		FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager();
44
		IFeatureModel model = manager.getDeltaPackFeature();
45
		if (model != null) {
46
			fPage2 = new CrossPlatformExportPage("environment", model); //$NON-NLS-1$
47
			addPage(fPage2);
48
		}
49
	}
50
51
	protected BaseExportWizardPage createPage1() {
52
		// AspectJ change - use AJPluginExportWizardPage
53
		return new AJFeatureExportWizardPage(getSelection());
54
	}
55
56
	protected String getSettingsSectionName() {
57
		return STORE_SECTION;
58
	}
59
60
	protected void scheduleExportJob() {
61
		FeatureExportInfo info = new FeatureExportInfo();
62
		info.toDirectory = ((AJFeatureExportWizardPage)fPage).doExportToDirectory();
63
		info.useJarFormat = ((AJFeatureExportWizardPage)fPage).useJARFormat();
64
		info.exportSource = ((AJFeatureExportWizardPage)fPage).doExportSource();
65
		info.destinationDirectory = ((AJFeatureExportWizardPage)fPage).getDestination();
66
		info.zipFileName = ((AJFeatureExportWizardPage)fPage).getFileName();
67
		if (fPage2 != null && ((AJFeatureExportWizardPage) fPage).doMultiPlatform())
68
			info.targets = fPage2.getTargets();
69
		info.exportMetadata = ((AJFeatureExportWizardPage)fPage).doExportMetadata();
70
		info.items = ((AJFeatureExportWizardPage)fPage).getSelectedItems();
71
		info.signingInfo = ((AJFeatureExportWizardPage)fPage).getSigningInfo();
72
		info.jnlpInfo = ((AJFeatureExportWizardPage)fPage).getJNLPInfo();
73
		info.qualifier = ((AJFeatureExportWizardPage)fPage).getQualifier();
74
75
		AJFeatureExportJob job = new AJFeatureExportJob(info);
76
		job.setUser(true);
77
		job.schedule();
78
		job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ);
79
	}
80
81
	protected Document generateAntTask() {
82
		try {
83
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
84
			Document doc = factory.newDocumentBuilder().newDocument();
85
			Element root = doc.createElement("project"); //$NON-NLS-1$
86
			root.setAttribute("name", "build"); //$NON-NLS-1$ //$NON-NLS-2$
87
			root.setAttribute("default", "feature_export"); //$NON-NLS-1$ //$NON-NLS-2$
88
			doc.appendChild(root);
89
90
			Element target = doc.createElement("target"); //$NON-NLS-1$
91
			target.setAttribute("name", "feature_export"); //$NON-NLS-1$ //$NON-NLS-2$
92
			root.appendChild(target);
93
94
			Element export = doc.createElement("pde.exportFeatures"); //$NON-NLS-1$
95
			export.setAttribute("features", getFeatureIDs()); //$NON-NLS-1$
96
			export.setAttribute("destination", ((AJFeatureExportWizardPage)fPage).getDestination()); //$NON-NLS-1$
97
			String filename = ((AJFeatureExportWizardPage)fPage).getFileName();
98
			if (filename != null)
99
				export.setAttribute("filename", filename); //$NON-NLS-1$
100
			export.setAttribute("exportType", getExportOperation()); //$NON-NLS-1$
101
			export.setAttribute("useJARFormat", Boolean.toString(((AJFeatureExportWizardPage)fPage).useJARFormat())); //$NON-NLS-1$
102
			export.setAttribute("exportSource", Boolean.toString(((AJFeatureExportWizardPage)fPage).doExportSource())); //$NON-NLS-1$
103
			String qualifier = ((AJFeatureExportWizardPage)fPage).getQualifier();
104
			if (qualifier != null)
105
				export.setAttribute("qualifier", qualifier); //$NON-NLS-1$
106
			target.appendChild(export);
107
			return doc;
108
		} catch (DOMException e) {
109
		} catch (FactoryConfigurationError e) {
110
		} catch (ParserConfigurationException e) {
111
		}
112
		return null;
113
	}
114
115
	private String getFeatureIDs() {
116
		StringBuffer buffer = new StringBuffer();
117
		Object[] objects = ((AJFeatureExportWizardPage)fPage).getSelectedItems();
118
		for (int i = 0; i < objects.length; i++) {
119
			Object object = objects[i];
120
			if (object instanceof IFeatureModel) {
121
				buffer.append(((IFeatureModel) object).getFeature().getId());
122
				if (i < objects.length - 1)
123
					buffer.append(","); //$NON-NLS-1$
124
			}
125
		}
126
		return buffer.toString();
127
	}
128
129
}
(-)src/org/eclipse/ajdt/internal/ui/wizards/exports/AJFeatureExportWizardPage.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: Sian January - initial version
9
 * ...
10
 **********************************************************************/
11
package org.eclipse.ajdt.internal.ui.wizards.exports;
12
13
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.pde.internal.ui.wizards.exports.FeatureExportWizardPage;
15
16
/**
17
 * Extends FeatureExportWizardPage to allow AJFeatureExportWizard
18
 * access to protected methods
19
 */
20
public class AJFeatureExportWizardPage extends FeatureExportWizardPage {
21
22
	public AJFeatureExportWizardPage(IStructuredSelection selection) {
23
		super(selection);
24
	}
25
	
26
	protected boolean doExportToDirectory() {
27
		return super.doExportToDirectory();
28
	}
29
30
	protected boolean useJARFormat() {
31
		return super.useJARFormat();
32
	}
33
	
34
	protected boolean doExportSource() {
35
		return super.doExportSource();
36
	}
37
	
38
	protected String getDestination() {
39
		return super.getDestination();
40
	}
41
	
42
	protected String getFileName() {
43
		return super.getFileName();
44
	}
45
	
46
	protected String[] getSigningInfo() {
47
		return super.getSigningInfo();
48
	}
49
50
	protected boolean doMultiPlatform() {
51
		return super.doMultiPlatform();
52
	}
53
54
	protected String[] getJNLPInfo() {
55
		return super.getJNLPInfo();
56
	}
57
58
	protected boolean doExportMetadata() {
59
		return super.doExportMetadata();
60
	}
61
62
	protected String getQualifier() {
63
		return super.getQualifier();
64
	}
65
66
}

Return to bug 245142