01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
03: * This program and the accompanying materials are made available under the
04: * terms of the Eclipse Public License v1.0 which accompanies this distribution,
05: * and is available at http://www.eclipse.org/legal/epl-v10.html
06: *
07: * Contributors: IBM - Initial API and implementation
08: ******************************************************************************/package org.eclipse.pde.internal.build.site;
09:
10: import java.io.File;
11: import java.net.URL;
12: import java.util.*;
13: import org.eclipse.pde.internal.build.*;
14: import org.eclipse.update.core.ISiteContentProvider;
15: import org.eclipse.update.core.SiteContentProvider;
16:
17: public class BuildTimeSiteContentProvider extends SiteContentProvider
18: implements ISiteContentProvider, IPDEBuildConstants {
19: private String installedBaseURL;
20: private String[] urls;
21: private PDEUIStateWrapper pdeUIState;
22:
23: public BuildTimeSiteContentProvider(String[] urls,
24: String installedBaseURL, PDEUIStateWrapper initialState) {
25: super (null);
26: this .installedBaseURL = installedBaseURL;
27: this .urls = urls;
28: this .pdeUIState = initialState;
29: }
30:
31: /**
32: * Returns the URL where an eclipse install can be provided. Can be null.
33: * @return URL
34: */
35: public String getInstalledBaseURL() {
36: return installedBaseURL;
37: }
38:
39: public Collection getPluginPaths() {
40: Collection pluginsToCompile = findPluginXML(Utils.asFile(urls));
41: if (installedBaseURL != null) {
42: pluginsToCompile.addAll(Arrays.asList(PluginPathFinder
43: .getPluginPaths(installedBaseURL)));
44: }
45: return pluginsToCompile;
46: }
47:
48: public URL getURL() {
49: throw new RuntimeException();
50: }
51:
52: //For every entry, return all the children of this entry is it is named plugins, otherwise return the entry itself
53: private Collection findPluginXML(File[] location) {
54: Collection collectedElements = new ArrayList(10);
55: for (int i = 0; i < location.length; i++) {
56: File f = new File(location[i], DEFAULT_PLUGIN_LOCATION);
57: if (f.exists()) {
58: collectedElements.addAll(Arrays.asList(f.listFiles()));
59: } else {
60: collectedElements.add(location[i]);
61: }
62: }
63: return collectedElements;
64: }
65:
66: public PDEUIStateWrapper getInitialState() {
67: return pdeUIState;
68: }
69: }
|