KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 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:
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.internal.core.feature.FeatureImport;
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.IFeatureImport;
20 import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
21 import org.eclipse.swt.widgets.Shell;
22
23 public class CreateFeaturePatchOperation extends AbstractCreateFeatureOperation {
24
25     private IFeatureModel fFeatureModel;
26
27     public CreateFeaturePatchOperation(IProject project, IPath location,
28             FeatureData featureData, IFeatureModel featureModel, Shell shell) {
29         super(project, location, featureData, shell);
30         fFeatureModel = featureModel;
31     }
32
33     protected void configureFeature(IFeature feature, WorkspaceFeatureModel model) throws CoreException {
34         FeatureImport featureImport = (FeatureImport) model.getFactory().createImport();
35         if (fFeatureModel != null) {
36             featureImport.loadFrom(fFeatureModel.getFeature());
37             featureImport.setPatch(true);
38             featureImport.setVersion(fFeatureModel.getFeature().getVersion());
39             featureImport.setId(fFeatureModel.getFeature().getId());
40         } else if (fFeatureData.isPatch) {
41             featureImport.setType(IFeatureImport.FEATURE);
42             featureImport.setPatch(true);
43             featureImport.setVersion(fFeatureData.featureToPatchVersion);
44             featureImport.setId(fFeatureData.featureToPatchId);
45         }
46         feature.addImports(new IFeatureImport[] { featureImport });
47     }
48
49 }
50
Popular Tags