1 11 package org.eclipse.pde.internal.core.schema; 12 13 import java.io.*; 14 import java.net.*; 15 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.pde.core.plugin.*; 18 import org.eclipse.pde.internal.core.*; 19 20 public class ExternalSchemaDescriptor extends DevelopmentSchemaDescriptor { 21 private IPluginExtensionPoint info; 22 private File file; 23 private String fullId; 24 private boolean enabled; 25 26 public ExternalSchemaDescriptor(IPluginExtensionPoint info) { 27 this.info = info; 28 fullId = info.getFullId(); 29 } 30 31 public ExternalSchemaDescriptor(File file, String fullId, boolean enabled) { 32 this.file = file; 33 this.fullId = fullId; 34 this.enabled = enabled; 35 } 36 37 public String getPointId() { 38 return fullId; 39 } 40 41 private File getInstallLocationFile() { 42 IPluginModelBase model = info.getPluginModel(); 43 String installLocation = model.getInstallLocation() + File.separator; 44 return new File(installLocation + info.getSchema()); 45 } 46 47 private File getSourceLocationFile() { 48 SourceLocationManager sourceManager = 49 PDECore.getDefault().getSourceLocationManager(); 50 return sourceManager.findSourceFile( 51 info.getPluginBase(), 52 new Path(info.getSchema())); 53 } 54 55 public URL getSchemaURL() { 56 try { 57 if (file!=null) { 58 return new URL("file:" + file.getPath()); } 60 File installFile = getInstallLocationFile(); 61 if (installFile != null && installFile.exists()) { 62 return new URL("file:" + installFile.getPath()); } 64 File sourceLocationFile = getSourceLocationFile(); 65 if (sourceLocationFile != null && sourceLocationFile.exists()) { 66 return new URL("file:" + sourceLocationFile.getPath()); } 68 } catch (MalformedURLException e) { 69 } 70 return null; 71 } 72 73 public boolean isEnabled() { 74 return (info!=null)?info.getPluginModel().isEnabled():enabled; 75 } 76 } 77 | Popular Tags |