01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.build;
11:
12: import java.io.File;
13: import java.io.IOException;
14: import java.io.InputStream;
15: import java.net.URL;
16:
17: import org.eclipse.core.runtime.IPath;
18:
19: public class ExternalBuildModel extends BuildModel {
20:
21: private static final long serialVersionUID = 1L;
22: private String fInstallLocation;
23:
24: public ExternalBuildModel(String installLocation) {
25: fInstallLocation = installLocation;
26: }
27:
28: public String getInstallLocation() {
29: return fInstallLocation;
30: }
31:
32: public boolean isEditable() {
33: return false;
34: }
35:
36: public void load() {
37: try {
38: URL url = null;
39: File file = new File(getInstallLocation());
40: if (file.isFile() && file.getName().endsWith(".jar")) { //$NON-NLS-1$
41: url = new URL(
42: "jar:file:" + file.getAbsolutePath() + "!/build.properties"); //$NON-NLS-1$ //$NON-NLS-2$
43: } else {
44: url = new URL(
45: "file:" + file.getAbsolutePath() + IPath.SEPARATOR + "build.properties"); //$NON-NLS-1$ //$NON-NLS-2$
46: }
47: InputStream stream = url.openStream();
48: load(stream, false);
49: stream.close();
50: } catch (IOException e) {
51: fBuild = new Build();
52: fBuild.setModel(this );
53: setLoaded(true);
54: }
55: }
56:
57: protected void updateTimeStamp() {
58: updateTimeStamp(getLocalFile());
59: }
60:
61: private File getLocalFile() {
62: File file = new File(getInstallLocation());
63: return (file.isFile()) ? file : new File(file,
64: "build.properties"); //$NON-NLS-1$
65: }
66:
67: public boolean isInSync() {
68: return true;
69: }
70: }
|