KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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