01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.feature;
11:
12: import org.eclipse.core.resources.IProject;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.core.runtime.IPath;
15: import org.eclipse.pde.core.plugin.IPluginBase;
16: import org.eclipse.pde.internal.core.feature.FeaturePlugin;
17: import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
18: import org.eclipse.pde.internal.core.ifeature.IFeature;
19: import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
20: import org.eclipse.pde.internal.core.util.CoreUtility;
21: import org.eclipse.swt.widgets.Shell;
22:
23: public class CreateFeatureProjectOperation extends
24: AbstractCreateFeatureOperation {
25:
26: protected IPluginBase[] fPlugins;
27:
28: public CreateFeatureProjectOperation(IProject project,
29: IPath location, FeatureData featureData,
30: IPluginBase[] plugins, Shell shell) {
31: super (project, location, featureData, shell);
32: fPlugins = plugins != null ? plugins : new IPluginBase[0];
33: }
34:
35: protected void configureFeature(IFeature feature,
36: WorkspaceFeatureModel model) throws CoreException {
37: IFeaturePlugin[] added = new IFeaturePlugin[fPlugins.length];
38: for (int i = 0; i < fPlugins.length; i++) {
39: IPluginBase plugin = fPlugins[i];
40: FeaturePlugin fplugin = (FeaturePlugin) model.getFactory()
41: .createPlugin();
42: fplugin.loadFrom(plugin);
43: fplugin.setVersion("0.0.0"); //$NON-NLS-1$
44: fplugin.setUnpack(CoreUtility.guessUnpack(plugin
45: .getPluginModel().getBundleDescription()));
46: added[i] = fplugin;
47: }
48: feature.addPlugins(added);
49: }
50:
51: }
|