KickJava   Java API By Example, From Geeks To Geeks.

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


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