1 11 package org.eclipse.pde.internal.core.schema; 12 13 import java.io.Serializable ; 14 15 import org.eclipse.core.runtime.PlatformObject; 16 import org.eclipse.pde.internal.core.ischema.ISchema; 17 import org.eclipse.pde.internal.core.ischema.ISchemaObject; 18 import org.eclipse.pde.internal.core.util.PDEXMLHelper; 19 20 public abstract class SchemaObject extends PlatformObject implements 21 ISchemaObject, Serializable { 22 protected String fName; 23 24 private String fDescription; 25 26 transient private ISchemaObject fParent; 27 28 public SchemaObject(ISchemaObject parent, String name) { 29 fParent = parent; 30 fName = name; 31 } 32 33 public String getDescription() { 34 return fDescription; 35 } 36 37 public java.lang.String getName() { 38 return fName; 39 } 40 41 public ISchemaObject getParent() { 42 return fParent; 43 } 44 45 public void setParent(ISchemaObject parent) { 46 fParent = parent; 47 } 48 49 public ISchema getSchema() { 50 ISchemaObject object = this; 51 52 while (object.getParent() != null) { 53 object = object.getParent(); 54 } 55 return (ISchema) object; 56 } 57 58 public String getWritableDescription() { 59 String lineDelimiter = System.getProperty("line.separator"); String description = PDEXMLHelper.getWritableString(getDescription()); 61 String platformDescription = description.replaceAll( 62 "\\r\\n|\\r|\\n", lineDelimiter); 64 return platformDescription; 65 } 66 67 public void setDescription(String newDescription) { 68 String oldValue = fDescription; 69 fDescription = newDescription; 70 getSchema().fireModelObjectChanged(this, P_DESCRIPTION, oldValue, 71 fDescription); 72 } 73 74 public void setName(String newName) { 75 String oldValue = fName; 76 fName = newName; 77 getSchema().fireModelObjectChanged(this, P_NAME, oldValue, fName); 78 } 79 80 public String toString() { 81 if (fName != null) 82 return fName; 83 return super.toString(); 84 } 85 86 } 87 | Popular Tags |