1 11 12 package org.eclipse.pde.internal.ui.editor.contentassist; 13 14 import java.io.PrintWriter ; 15 import java.net.URL ; 16 17 import org.eclipse.pde.core.plugin.IPluginExtensionPoint; 18 import org.eclipse.pde.internal.core.ischema.ISchema; 19 import org.eclipse.pde.internal.core.ischema.ISchemaObject; 20 import org.eclipse.pde.internal.core.schema.SchemaAnnotationHandler; 21 import org.eclipse.pde.internal.core.schema.SchemaRegistry; 22 import org.eclipse.pde.internal.core.util.SchemaUtil; 23 import org.eclipse.pde.internal.core.util.XMLComponentRegistry; 24 25 public class VirtualSchemaObject implements ISchemaObject { 26 27 private String fName; 28 29 private Object fDescription; 30 31 private int fType; 32 33 public VirtualSchemaObject(String name, Object description, int type) { 34 fName = name; 35 fDescription = description; 36 fType = type; 37 } 38 39 public String getDescription() { 40 if (fDescription instanceof String ) { 41 return (String )fDescription; 42 } else if (fDescription instanceof IPluginExtensionPoint) { 43 return getSchemaDescription((IPluginExtensionPoint)fDescription); 50 } 51 return null; 52 } 53 54 public String getName() { 55 return fName; 56 } 57 58 public ISchemaObject getParent() { 59 return null; 60 } 61 62 public ISchema getSchema() { 63 return null; 64 } 65 66 public void setParent(ISchemaObject parent) { 67 } 68 69 public Object getAdapter(Class adapter) { 70 return null; 71 } 72 73 public void write(String indent, PrintWriter writer) { 74 } 75 76 public int getVType() { 77 return fType; 78 } 79 80 public void setVType(int type) { 81 fType = type; 82 } 83 84 private String getSchemaDescription(IPluginExtensionPoint point) { 85 String description = null; 86 if (point != null) { 87 description = XMLComponentRegistry.Instance().getDescription( 88 point.getFullId(), XMLComponentRegistry.F_SCHEMA_COMPONENT); 89 if (description == null) { 90 URL url = SchemaRegistry.getSchemaURL(point); 91 if (url != null) { 92 SchemaAnnotationHandler handler = 93 new SchemaAnnotationHandler(); 94 SchemaUtil.parseURL(url, handler); 95 description = handler.getDescription(); 96 XMLComponentRegistry.Instance().putDescription(point.getFullId(), 97 description, XMLComponentRegistry.F_SCHEMA_COMPONENT); 98 } 99 } 100 } 101 102 return description; 103 } 104 105 } 106 | Popular Tags |