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