KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > packager > ElementCollector


1 /*******************************************************************************
2  * Copyright (c) 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 - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.packager;
12
13 import java.util.*;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.pde.internal.build.*;
16 import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
17 import org.eclipse.update.core.IFeature;
18 import org.eclipse.update.core.IIncludedFeatureReference;
19 import org.eclipse.update.core.model.IncludedFeatureReferenceModel;
20
21 public class ElementCollector extends FeatureBuildScriptGenerator {
22     public ElementCollector(String JavaDoc featureId, AssemblyInformation assemblageInformation) throws CoreException {
23         super(featureId, null, assemblageInformation);
24     }
25
26     protected void generateIncludedFeatureBuildFile() throws CoreException {
27         IIncludedFeatureReference[] referencedFeatures = feature.getIncludedFeatureReferences();
28         for (int i = 0; i < referencedFeatures.length; i++) {
29             String JavaDoc featureId = ((IncludedFeatureReferenceModel) referencedFeatures[i]).getFeatureIdentifier();
30             FeatureBuildScriptGenerator generator = new ElementCollector(featureId, assemblyData);
31             generator.setGenerateIncludedFeatures(true);
32             generator.setAnalyseChildren(true);
33             generator.setSourceFeatureGeneration(false);
34             generator.setBinaryFeatureGeneration(true);
35             generator.setScriptGeneration(false);
36             generator.setPluginPath(pluginPath);
37             generator.setBuildSiteFactory(siteFactory);
38             generator.setDevEntries(devEntries);
39             generator.setCompiledElements(getCompiledElements());
40             generator.setBuildingOSGi(isBuildingOSGi());
41             generator.includePlatformIndependent(isPlatformIndependentIncluded());
42             generator.setIgnoreMissingPropertiesFile(isIgnoreMissingPropertiesFile());
43             try {
44                 generator.generate();
45             } catch (CoreException exception) {
46                 //If the referenced feature is not optional, there is a real problem and the exception is re-thrown.
47
if (exception.getStatus().getCode() != EXCEPTION_FEATURE_MISSING || (exception.getStatus().getCode() == EXCEPTION_FEATURE_MISSING && !referencedFeatures[i].isOptional()))
48                     throw exception;
49             }
50         }
51     }
52
53     protected void collectElementToAssemble(IFeature featureToCollect) {
54         if (assemblyData == null)
55             return;
56         List correctConfigs = selectConfigs(featureToCollect);
57         // Here, we could sort if the feature is a common one or not by comparing the size of correctConfigs
58
for (Iterator iter = correctConfigs.iterator(); iter.hasNext();) {
59             Config config = (Config) iter.next();
60             assemblyData.addFeature(config, feature);
61         }
62     }
63
64 }
65
Popular Tags