1 11 package org.eclipse.pde.internal.ui.model.plugin; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.pde.core.plugin.*; 15 import org.eclipse.pde.internal.core.*; 16 import org.eclipse.pde.internal.core.ischema.*; 17 import org.eclipse.pde.internal.core.schema.*; 18 import org.eclipse.pde.internal.ui.model.*; 19 20 public class PluginExtensionNode extends PluginParentNode 21 implements 22 IPluginExtension { 23 private static final long serialVersionUID = 1L; 24 private transient ISchema fSchema; 25 26 29 public String getPoint() { 30 return getXMLAttributeValue(P_POINT); 31 } 32 35 public void setPoint(String point) throws CoreException { 36 setXMLAttribute(P_POINT, point); 37 } 38 39 42 public void setName(String name) throws CoreException { 43 setXMLAttribute(P_NAME, name); 44 } 45 46 49 public String getName() { 50 return getXMLAttributeValue(P_NAME); 51 } 52 53 56 public String getTranslatedName() { 57 String name = getName(); 58 return (name == null || name.trim().length() == 0) ? getPoint() : getResourceString(name); 59 } 60 63 public String getId() { 64 return getXMLAttributeValue(P_ID); 65 } 66 69 public void setId(String id) throws CoreException { 70 setXMLAttribute(P_ID, id); 71 } 72 73 76 public String write(boolean indent) { 77 String sep = getLineDelimiter(); 78 StringBuffer buffer = new StringBuffer (); 79 if (indent) 80 buffer.append(getIndent()); 81 buffer.append(writeShallow(false)); 82 IDocumentNode[] children = getChildNodes(); 83 for (int i = 0; i < children.length; i++) { 84 children[i].setLineIndent(getLineIndent() + 3); 85 buffer.append(sep + children[i].write(true)); 86 } 87 buffer.append(sep + getIndent() + "</extension>"); return buffer.toString(); 89 } 90 91 94 public String writeShallow(boolean terminate) { 95 String sep = getLineDelimiter(); 96 String attrIndent = " "; StringBuffer buffer = new StringBuffer ("<extension"); IDocumentAttribute attr = getDocumentAttribute(P_ID); 99 if (attr != null && attr.getAttributeValue().trim().length() > 0) 100 buffer.append(sep + getIndent() + attrIndent + attr.write()); 101 attr = getDocumentAttribute(P_NAME); 102 if (attr != null && attr.getAttributeValue().trim().length() > 0) 103 buffer.append(sep + getIndent() + attrIndent + attr.write()); 104 attr = getDocumentAttribute(P_POINT); 105 if (attr != null && attr.getAttributeValue().trim().length() > 0) 106 buffer.append(sep + getIndent() + attrIndent + attr.write()); 107 if (terminate) 108 buffer.append("/"); buffer.append(">"); return buffer.toString(); 111 } 112 113 116 public Object getSchema() { 117 if (fSchema == null) { 118 SchemaRegistry registry = PDECore.getDefault().getSchemaRegistry(); 119 fSchema = registry.getSchema(getPoint()); 120 } else if (fSchema.isDisposed()) { 121 fSchema = null; 122 } 123 return fSchema; 124 } 125 } 126 | Popular Tags |