1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import java.io.IOException ; 25 import javax.swing.event.UndoableEditListener ; 26 import org.netbeans.modules.xml.xam.ModelSource; 27 import org.netbeans.modules.xml.schema.model.SchemaComponent; 28 import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel; 29 import org.netbeans.modules.xml.xam.ComponentListener; 30 import org.netbeans.modules.xml.xam.ComponentEvent; 31 import org.netbeans.modules.xml.xam.dom.DocumentModel; 32 import org.netbeans.modules.xml.xam.Model.State; 33 import org.netbeans.modules.xml.xam.dom.DocumentModelAccess; 34 import org.w3c.dom.Document ; 35 import org.w3c.dom.Element ; 36 37 41 public class EmbeddedSchemaModelImpl extends SchemaModelImpl { 42 43 private DocumentModel delegate; 44 private Element element; 45 private SchemaImpl schema; 46 47 public EmbeddedSchemaModelImpl(DocumentModel delegate, Element element) { 48 super(delegate.getModelSource()); 49 if (! (delegate instanceof AbstractDocumentModel)) { 50 throw new IllegalArgumentException ("Expect instance of AbstractComponent"); 51 } 52 this.delegate = delegate; 53 this.element = element; 54 } 55 56 public void addComponentListener(ComponentListener cl){ 58 delegate.addComponentListener(cl); 59 } 60 61 public void removeComponentListener(ComponentListener cl){ 62 delegate.removeComponentListener(cl); 63 } 64 65 public void removePropertyChangeListener(PropertyChangeListener pcl){ 66 delegate.removePropertyChangeListener(pcl); 67 } 68 69 public void addPropertyChangeListener(PropertyChangeListener pcl){ 70 delegate.addPropertyChangeListener(pcl); 71 } 72 73 public void removeUndoableEditListener(UndoableEditListener uel){ 74 delegate.removeUndoableEditListener(uel); 75 } 76 77 public void addUndoableEditListener(UndoableEditListener uel){ 78 delegate.addUndoableEditListener(uel); 79 } 80 81 public ModelSource getModelSource() { 82 return delegate.getModelSource(); 83 } 84 85 public void sync() throws java.io.IOException { 86 delegate.sync(); 87 } 88 89 public boolean inSync(){ 90 return delegate.inSync(); 91 } 92 93 public State getState(){ 94 return delegate.getState(); 95 } 96 97 public boolean isIntransaction(){ 98 return delegate.isIntransaction(); 99 } 100 101 public boolean startTransaction(){ 102 return delegate.startTransaction(); 103 } 104 105 public void endTransaction() { 106 delegate.endTransaction(); 107 } 108 109 public SchemaImpl getSchema() { 110 if(schema == null){ 111 schema = (SchemaImpl)this.getFactory().create(element, null); 112 } 113 return schema; 114 } 115 116 public Document getDocument(){ 118 return delegate.getDocument(); 119 } 120 121 public synchronized void validateWrite() { 122 getDelegate().validateWrite(); 123 } 124 125 public DocumentModelAccess getAccess(){ 126 return getDelegate().getAccess(); 127 } 128 129 public void firePropertyChangeEvent(PropertyChangeEvent event) { 130 getDelegate().firePropertyChangeEvent(event); 131 } 132 133 public void fireComponentChangedEvent(ComponentEvent evt) { 134 getDelegate().fireComponentChangedEvent(evt); 135 } 136 137 public SchemaComponent getRootComponent() { 138 return getSchema(); 139 } 140 141 private AbstractDocumentModel getDelegate() { 142 return (AbstractDocumentModel) delegate; 143 } 144 } 145 | Popular Tags |