1 11 package org.eclipse.pde.internal.core.plugin; 12 13 import java.io.PrintWriter ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.pde.core.plugin.IFragment; 17 import org.eclipse.pde.core.plugin.IPluginBase; 18 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 19 import org.eclipse.pde.core.plugin.IPluginModelBase; 20 import org.w3c.dom.Node ; 21 22 public class PluginExtensionPoint extends IdentifiablePluginObject 23 implements IPluginExtensionPoint { 24 25 private static final long serialVersionUID = 1L; 26 27 protected String fSchema; 28 29 public boolean isValid() { 30 return fID != null && fName != null; 31 } 32 33 public String getFullId() { 34 String pointId = getId(); 35 IPluginModelBase modelBase = getPluginModel(); 36 IPluginBase pluginBase = modelBase.getPluginBase(); 37 if ("3.2".equals(pluginBase.getSchemaVersion())) { if (pointId.indexOf('.') > 0) 39 return pointId; 40 } 41 42 if (pluginBase instanceof IFragment) 43 return ((IFragment) pluginBase).getPluginId() + '.' + pointId; 44 return pluginBase.getId() + '.' + pointId; 45 } 46 47 public String getSchema() { 48 return fSchema; 49 } 50 51 void load(Node node) { 52 this.fID = getNodeAttribute(node, "id"); fName = getNodeAttribute(node, "name"); fSchema = getNodeAttribute(node, "schema"); fStartLine = Integer.parseInt(getNodeAttribute(node, "line")); } 57 58 public boolean equals(Object obj) { 59 if (obj == this) 60 return true; 61 if (obj instanceof IPluginExtensionPoint) { 62 IPluginExtensionPoint target = (IPluginExtensionPoint) obj; 63 if (target.getModel().equals(getModel())) 66 return false; 67 if (stringEqualWithNull(target.getId(), getId()) 68 && stringEqualWithNull(target.getName(), getName()) 69 && stringEqualWithNull(target.getSchema(), getSchema())) 70 return true; 71 } 72 return false; 73 } 74 75 public void setSchema(String newSchema) throws CoreException { 76 ensureModelEditable(); 77 String oldValue = fSchema; 78 fSchema = newSchema; 79 firePropertyChanged(P_SCHEMA, oldValue, fSchema); 80 } 81 82 public void restoreProperty(String name, Object oldValue, Object newValue) 83 throws CoreException { 84 if (name.equals(P_SCHEMA)) { 85 setSchema(newValue != null ? newValue.toString() : null); 86 return; 87 } 88 super.restoreProperty(name, oldValue, newValue); 89 } 90 91 public void write(String indent, PrintWriter writer) { 92 writer.print(indent); 93 writer.print("<extension-point"); if (getId() != null) 95 writer.print(" id=\"" + getWritableString(getId()) + "\""); if (getName() != null) 97 writer.print(" name=\"" + getWritableString(getName()) + "\""); if (getSchema() != null) 99 writer.print(" schema=\"" + getSchema() + "\""); writer.println("/>"); } 102 } 103 | Popular Tags |