KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > feature > CreateFeatureProjectOperation


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.pde.internal.ui.wizards.feature;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.pde.core.plugin.IPluginBase;
17 import org.eclipse.pde.internal.core.feature.FeaturePlugin;
18 import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
19 import org.eclipse.pde.internal.core.ifeature.IFeature;
20 import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
21 import org.eclipse.pde.internal.core.util.CoreUtility;
22 import org.eclipse.swt.widgets.Shell;
23
24 public class CreateFeatureProjectOperation extends AbstractCreateFeatureOperation {
25
26     protected IPluginBase[] fPlugins;
27
28     public CreateFeatureProjectOperation(IProject project, IPath location,
29             FeatureData featureData, IPluginBase[] plugins, Shell shell) {
30         super(project, location, featureData, shell);
31         fPlugins = plugins != null ? plugins : new IPluginBase[0];
32     }
33
34     protected void configureFeature(IFeature feature, WorkspaceFeatureModel model) throws CoreException {
35         IFeaturePlugin[] added = new IFeaturePlugin[fPlugins.length];
36         for (int i = 0; i < fPlugins.length; i++) {
37             IPluginBase plugin = fPlugins[i];
38             FeaturePlugin fplugin = (FeaturePlugin) model.getFactory().createPlugin();
39             fplugin.loadFrom(plugin);
40             fplugin.setVersion("0.0.0"); //$NON-NLS-1$
41
fplugin.setUnpack(CoreUtility.guessUnpack(plugin.getPluginModel().getBundleDescription()));
42             added[i] = fplugin;
43         }
44         feature.addPlugins(added);
45     }
46
47 }
48
Popular Tags