KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > site > BuildTimeSiteContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
3  * This program and the accompanying materials are made available under the
4  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors: IBM - Initial API and implementation
8  ******************************************************************************/

9 package org.eclipse.pde.internal.build.site;
10
11 import java.io.File JavaDoc;
12 import java.net.URL JavaDoc;
13 import java.util.*;
14 import org.eclipse.pde.internal.build.*;
15 import org.eclipse.update.core.ISiteContentProvider;
16 import org.eclipse.update.core.SiteContentProvider;
17
18 public class BuildTimeSiteContentProvider extends SiteContentProvider implements ISiteContentProvider, IPDEBuildConstants {
19     private String JavaDoc installedBaseURL;
20     private String JavaDoc[] urls;
21     private PDEUIStateWrapper pdeUIState;
22
23     public BuildTimeSiteContentProvider(String JavaDoc[] urls, String JavaDoc installedBaseURL, PDEUIStateWrapper initialState) {
24         super(null);
25         this.installedBaseURL = installedBaseURL;
26         this.urls = urls;
27         this.pdeUIState = initialState;
28     }
29
30     /**
31      * Returns the URL where an eclipse install can be provided. Can be null.
32      * @return URL
33      */

34     public String JavaDoc getInstalledBaseURL() {
35         return installedBaseURL;
36     }
37
38     public Collection getPluginPaths() {
39         Collection pluginsToCompile = findPluginXML(Utils.asFile(urls));
40         if (installedBaseURL != null) {
41             pluginsToCompile.addAll(Arrays.asList(PluginPathFinder.getPluginPaths(installedBaseURL)));
42         }
43         return pluginsToCompile;
44     }
45
46     public URL JavaDoc getURL() {
47         throw new RuntimeException JavaDoc();
48     }
49
50     //For every entry, return all the children of this entry is it is named plugins, otherwise return the entry itself
51
private Collection findPluginXML(File JavaDoc[] location) {
52         Collection collectedElements = new ArrayList(10);
53         for (int i = 0; i < location.length; i++) {
54             File JavaDoc f = new File JavaDoc(location[i], DEFAULT_PLUGIN_LOCATION);
55             if (f.exists()) {
56                 collectedElements.addAll(Arrays.asList(f.listFiles()));
57             } else {
58                 collectedElements.add(location[i]);
59             }
60         }
61         return collectedElements;
62     }
63
64     public PDEUIStateWrapper getInitialState() {
65         return pdeUIState;
66     }
67 }
68
Popular Tags