KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > ui > model > SimpleFeatureAdapter


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.model;
12
13 import java.net.*;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.update.core.*;
17
18 /**
19  * @version 1.0
20  * @author
21  */

22 public class SimpleFeatureAdapter extends FeatureAdapter {
23     protected IFeature feature;
24     private boolean optional;
25     public SimpleFeatureAdapter(IFeature feature) {
26         this(feature, false);
27     }
28     public SimpleFeatureAdapter(IFeature feature, boolean optional) {
29         this.feature = feature;
30         this.optional = optional;
31     }
32     
33     public IFeature getFeature(IProgressMonitor monitor) throws CoreException {
34         return feature;
35     }
36     
37     public String JavaDoc getFastLabel() {
38         return feature.getLabel();
39     }
40     
41     public URL getURL() {
42         return feature.getURL();
43     }
44     
45     public ISite getSite() {
46         return feature.getSite();
47     }
48     
49     public IFeatureAdapter[] getIncludedFeatures(IProgressMonitor monitor) {
50         try {
51             IIncludedFeatureReference[] included = getFeature(monitor).getIncludedFeatureReferences();
52             SimpleFeatureAdapter[] result =
53                 new SimpleFeatureAdapter[included.length];
54             for (int i = 0; i < included.length; i++) {
55                 result[i] =
56                     new SimpleFeatureAdapter(included[i].getFeature(null), included[i].isOptional());
57                 result[i].setIncluded(true);
58             }
59             return result;
60         } catch (CoreException e) {
61             return new IFeatureAdapter[0];
62         }
63     }
64     public boolean isOptional() {
65         return optional;
66     }
67 }
68
Popular Tags