1 11 package org.eclipse.pde.internal.core.build; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 import java.net.URL ; 17 18 import org.eclipse.core.runtime.IPath; 19 20 public class ExternalBuildModel extends BuildModel { 21 22 private static final long serialVersionUID = 1L; 23 private String fInstallLocation; 24 25 public ExternalBuildModel(String installLocation) { 26 fInstallLocation = installLocation; 27 } 28 29 public String getInstallLocation() { 30 return fInstallLocation; 31 } 32 33 public boolean isEditable() { 34 return false; 35 } 36 37 public void load() { 38 try { 39 URL url = null; 40 File file = new File (getInstallLocation()); 41 if (file.isFile() && file.getName().endsWith(".jar")) { url = new URL ("jar:file:" + file.getAbsolutePath() + "!/build.properties"); } else { 44 url = new URL ("file:" + file.getAbsolutePath() + IPath.SEPARATOR + "build.properties"); } 46 InputStream stream = url.openStream(); 47 load(stream, false); 48 stream.close(); 49 } catch (IOException e) { 50 fBuild = new Build(); 51 fBuild.setModel(this); 52 setLoaded(true); 53 } 54 } 55 56 protected void updateTimeStamp() { 57 updateTimeStamp(getLocalFile()); 58 } 59 60 private File getLocalFile() { 61 File file = new File (getInstallLocation()); 62 return (file.isFile()) ? file : new File (file, "build.properties"); } 64 65 public boolean isInSync() { 66 return true; 67 } 68 } 69 | Popular Tags |