KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > ant > FeatureExportTask


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 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.ant;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.StringTokenizer JavaDoc;
15
16 import org.eclipse.core.runtime.jobs.Job;
17 import org.eclipse.pde.internal.core.PDECore;
18 import org.eclipse.pde.internal.core.WorkspaceModelManager;
19 import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
20 import org.eclipse.pde.internal.ui.build.FeatureExportInfo;
21 import org.eclipse.pde.internal.ui.build.FeatureExportJob;
22
23 public class FeatureExportTask extends BaseExportTask {
24     private IFeatureModel[] fFeatures = new IFeatureModel[0];
25     
26     /* (non-Javadoc)
27      * @see org.eclipse.pde.internal.ui.ant.BaseExportTask#getExportJob()
28      */

29     protected Job getExportJob() {
30         FeatureExportInfo info = new FeatureExportInfo();
31         info.toDirectory = fToDirectory;
32         info.useJarFormat = fUseJarFormat;
33         info.exportSource = fExportSource;
34         info.destinationDirectory = fDestination;
35         info.zipFileName = fZipFilename;
36         info.items = fFeatures;
37         info.javacSource = fJavacSource;
38         info.javacTarget = fJavacTarget;
39         return new FeatureExportJob(info);
40     }
41     
42     public void setFeatures(String JavaDoc features) {
43         StringTokenizer JavaDoc tok = new StringTokenizer JavaDoc(features, ","); //$NON-NLS-1$
44
ArrayList JavaDoc list = new ArrayList JavaDoc();
45         while (tok.hasMoreTokens()) {
46             list.add(tok.nextToken().trim());
47         }
48         
49         WorkspaceModelManager manager = PDECore.getDefault().getWorkspaceModelManager();
50         ArrayList JavaDoc featureList = new ArrayList JavaDoc();
51         IFeatureModel[] models = manager.getFeatureModels();
52         for (int i = 0; i < models.length; i++) {
53             String JavaDoc id = models[i].getFeature().getId();
54             if (list.contains(id))
55                 featureList.add(models[i]);
56         }
57         fFeatures = (IFeatureModel[])featureList.toArray(new IFeatureModel[featureList.size()]);
58     }
59 }
60
Popular Tags