1 11 package org.eclipse.pde.internal.core.plugin; 12 13 import java.io.File ; 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 17 import org.eclipse.core.runtime.IPath; 18 import org.eclipse.core.runtime.Path; 19 import org.eclipse.osgi.service.resolver.BundleDescription; 20 import org.eclipse.pde.core.build.IBuildModel; 21 import org.eclipse.pde.internal.core.NLResourceHelper; 22 import org.eclipse.pde.internal.core.PDEManager; 23 import org.eclipse.pde.internal.core.PDEState; 24 25 public abstract class ExternalPluginModelBase extends AbstractPluginModelBase { 26 27 private String fInstallLocation; 28 29 private String fLocalization; 30 31 public ExternalPluginModelBase() { 32 super(); 33 } 34 35 protected NLResourceHelper createNLResourceHelper() { 36 return (fLocalization == null) 37 ? null : new NLResourceHelper(fLocalization, PDEManager.getNLLookupLocations(this)); } 39 40 public URL getNLLookupLocation() { 41 try { 42 if (fInstallLocation != null && new File (fInstallLocation).isDirectory() && !fInstallLocation.endsWith("/")) return new URL ("file:" + fInstallLocation + "/"); return new URL ("file:" + fInstallLocation); } catch (MalformedURLException e) { 46 return null; 47 } 48 } 49 50 public IBuildModel getBuildModel() { 51 return null; 52 } 53 54 public String getInstallLocation() { 55 return fInstallLocation; 56 } 57 58 public boolean isEditable() { 59 return false; 60 } 61 62 public void load() { 63 } 64 65 public void load(BundleDescription description, PDEState state) { 66 IPath path = new Path(description.getLocation()); 67 String device = path.getDevice(); 68 if (device != null) 69 path = path.setDevice(device.toUpperCase()); 70 setInstallLocation(path.toOSString()); 71 fLocalization = state.getBundleLocalization(description.getBundleId()); 72 super.load(description, state); 73 } 74 75 public boolean isInSync() { 76 return isInSync(getLocalFile()); 77 } 78 79 private File getLocalFile() { 80 File file = new File (getInstallLocation()); 81 if (file.isFile()) 82 return file; 83 84 file = new File (file, "META-INF/MANIFEST.MF"); if (!file.exists()) { 86 String manifest = isFragmentModel() ? "fragment.xml" : "plugin.xml"; file = new File (getInstallLocation(), manifest); 88 } 89 return file; 90 } 91 92 protected void updateTimeStamp() { 93 updateTimeStamp(getLocalFile()); 94 } 95 96 public void setInstallLocation(String newInstallLocation) { 97 fInstallLocation = newInstallLocation; 98 } 99 100 public String getLocalization() { 101 return fLocalization; 102 } 103 } 104 | Popular Tags |