01: /*******************************************************************************
02: * Copyright (c) 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.debug.core.ILaunchConfiguration;
16: import org.eclipse.debug.core.ILaunchConfigurationType;
17: import org.eclipse.pde.core.plugin.IPluginBase;
18: import org.eclipse.pde.core.plugin.IPluginModelBase;
19: import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
20: import org.eclipse.pde.internal.core.ifeature.IFeature;
21: import org.eclipse.pde.internal.ui.launcher.BundleLauncherHelper;
22: import org.eclipse.pde.internal.ui.launcher.LaunchPluginValidator;
23: import org.eclipse.swt.widgets.Shell;
24:
25: public class CreateFeatureProjectFromLaunchOperation extends
26: CreateFeatureProjectOperation {
27:
28: private ILaunchConfiguration fLaunchConfig;
29:
30: public CreateFeatureProjectFromLaunchOperation(IProject project,
31: IPath location, FeatureData featureData,
32: ILaunchConfiguration launchConfig, Shell shell) {
33: super (project, location, featureData, null, shell);
34: fLaunchConfig = launchConfig;
35: }
36:
37: protected void configureFeature(IFeature feature,
38: WorkspaceFeatureModel model) throws CoreException {
39: fPlugins = getPlugins();
40: super .configureFeature(feature, model);
41: }
42:
43: private IPluginBase[] getPlugins() {
44: IPluginModelBase[] models = null;
45: try {
46: ILaunchConfigurationType type = fLaunchConfig.getType();
47: String id = type.getIdentifier();
48: // if it is an Eclipse launch
49: if (id.equals("org.eclipse.pde.ui.RuntimeWorkbench")) //$NON-NLS-1$
50: models = LaunchPluginValidator
51: .getPluginList(fLaunchConfig);
52: // else if it is an OSGi launch
53: else if (id.equals("org.eclipse.pde.ui.EquinoxLauncher")) //$NON-NLS-1$
54: models = BundleLauncherHelper
55: .getMergedBundles(fLaunchConfig);
56: } catch (CoreException e) {
57: }
58: IPluginBase[] result = new IPluginBase[models == null ? 0
59: : models.length];
60: for (int i = 0; i < result.length; i++)
61: result[i] = models[i].getPluginBase(true);
62: return result;
63: }
64:
65: }
|