KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > ProductProvider


1 /*******************************************************************************
2  * Copyright (c) 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.update.internal.core;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.update.configurator.*;
17 import org.eclipse.update.internal.configurator.FeatureEntry;
18
19 /**
20  * Maps primary features to IProduct
21  */

22 public class ProductProvider implements IProductProvider {
23     /* (non-Javadoc)
24      * @see org.eclipse.core.runtime.IProductProvider#getProducts()
25      */

26     public IProduct[] getProducts() {
27         IPlatformConfiguration configuration = ConfiguratorUtils.getCurrentPlatformConfiguration();
28         if (configuration == null)
29             return new IProduct[0];
30         IPlatformConfiguration.IFeatureEntry[] features = configuration.getConfiguredFeatureEntries();
31         ArrayList JavaDoc primaryFeatures = new ArrayList JavaDoc();
32         for (int i = 0; i < features.length; i++)
33             if (features[i].canBePrimary() && (features[i] instanceof FeatureEntry))
34                 primaryFeatures.add(new FeatureEntryWrapper((FeatureEntry) features[i]));
35         // TODO handle unmanaged plugins later
36
return (IProduct[]) primaryFeatures.toArray(new IProduct[primaryFeatures.size()]);
37     }
38
39     /* (non-Javadoc)
40      * @see org.eclipse.core.runtime.IProductProvider#getName()
41      */

42     public String JavaDoc getName() {
43         return Messages.ProductProvider;
44     }
45 }
46
Popular Tags