comparison dwtx/jface/text/projection/ProjectionDocumentManager.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents f70d9508c95c
children
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
62 * @noextend This class is not intended to be subclassed by clients. 62 * @noextend This class is not intended to be subclassed by clients.
63 */ 63 */
64 public class ProjectionDocumentManager : IDocumentListener, ISlaveDocumentManager, ISlaveDocumentManagerExtension { 64 public class ProjectionDocumentManager : IDocumentListener, ISlaveDocumentManager, ISlaveDocumentManagerExtension {
65 65
66 /** Registry for master documents and their projection documents. */ 66 /** Registry for master documents and their projection documents. */
67 private Map fProjectionRegistry= new HashMap(); 67 private Map fProjectionRegistry;
68
69 this(){
70 fProjectionRegistry= new HashMap();
71 }
68 72
69 /** 73 /**
70 * Registers the given projection document for the given master document. 74 * Registers the given projection document for the given master document.
71 * 75 *
72 * @param master the master document 76 * @param master the master document
73 * @param projection the projection document 77 * @param projection the projection document
74 */ 78 */
75 private void add(IDocument master, ProjectionDocument projection) { 79 private void add(IDocument master, ProjectionDocument projection) {
76 List list= cast(List) fProjectionRegistry.get(master); 80 List list= cast(List) fProjectionRegistry.get(cast(Object)master);
77 if (list is null) { 81 if (list is null) {
78 list= new ArrayList(1); 82 list= new ArrayList(1);
79 fProjectionRegistry.put(master, list); 83 fProjectionRegistry.put(cast(Object)master, cast(Object)list);
80 } 84 }
81 list.add(projection); 85 list.add(projection);
82 } 86 }
83 87
84 /** 88 /**
86 * 90 *
87 * @param master the master document 91 * @param master the master document
88 * @param projection the projection document 92 * @param projection the projection document
89 */ 93 */
90 private void remove(IDocument master, ProjectionDocument projection) { 94 private void remove(IDocument master, ProjectionDocument projection) {
91 List list= cast(List) fProjectionRegistry.get(master); 95 List list= cast(List) fProjectionRegistry.get(cast(Object)master);
92 if (list !is null) { 96 if (list !is null) {
93 list.remove(projection); 97 list.remove(projection);
94 if (list.size() is 0) 98 if (list.size() is 0)
95 fProjectionRegistry.remove(master); 99 fProjectionRegistry.remove(cast(Object)master);
96 } 100 }
97 } 101 }
98 102
99 /** 103 /**
100 * Returns whether the given document is a master document. 104 * Returns whether the given document is a master document.
101 * 105 *
102 * @param master the document 106 * @param master the document
103 * @return <code>true</code> if the given document is a master document known to this manager 107 * @return <code>true</code> if the given document is a master document known to this manager
104 */ 108 */
105 private bool hasProjection(IDocument master) { 109 private bool hasProjection(IDocument master) {
106 return (cast(List)fProjectionRegistry.get(master) ); 110 return ( null !is cast(List)fProjectionRegistry.get(cast(Object)master) );
107 } 111 }
108 112
109 /** 113 /**
110 * Returns an iterator enumerating all projection documents registered for the given document or 114 * Returns an iterator enumerating all projection documents registered for the given document or
111 * <code>null</code> if the document is not a known master document. 115 * <code>null</code> if the document is not a known master document.
112 * 116 *
113 * @param master the document 117 * @param master the document
114 * @return an iterator for all registered projection documents or <code>null</code> 118 * @return an iterator for all registered projection documents or <code>null</code>
115 */ 119 */
116 private Iterator getProjectionsIterator(IDocument master) { 120 private Iterator getProjectionsIterator(IDocument master) {
117 List list= cast(List) fProjectionRegistry.get(master); 121 List list= cast(List) fProjectionRegistry.get(cast(Object)master);
118 if (list !is null) 122 if (list !is null)
119 return list.iterator(); 123 return list.iterator();
120 return null; 124 return null;
121 } 125 }
122 126
212 216
213 /* 217 /*
214 * @see dwtx.jface.text.ISlaveDocumentManager#isSlaveDocument(dwtx.jface.text.IDocument) 218 * @see dwtx.jface.text.ISlaveDocumentManager#isSlaveDocument(dwtx.jface.text.IDocument)
215 */ 219 */
216 public bool isSlaveDocument(IDocument document) { 220 public bool isSlaveDocument(IDocument document) {
217 return ( cast(ProjectionDocument)document ); 221 return ( null !is cast(ProjectionDocument)document );
218 } 222 }
219 223
220 /* 224 /*
221 * @see dwtx.jface.text.ISlaveDocumentManager#setAutoExpandMode(dwtx.jface.text.IDocument, bool) 225 * @see dwtx.jface.text.ISlaveDocumentManager#setAutoExpandMode(dwtx.jface.text.IDocument, bool)
222 */ 226 */
227 231
228 /* 232 /*
229 * @see dwtx.jface.text.ISlaveDocumentManagerExtension#getSlaveDocuments(dwtx.jface.text.IDocument) 233 * @see dwtx.jface.text.ISlaveDocumentManagerExtension#getSlaveDocuments(dwtx.jface.text.IDocument)
230 */ 234 */
231 public IDocument[] getSlaveDocuments(IDocument master) { 235 public IDocument[] getSlaveDocuments(IDocument master) {
232 List list= cast(List) fProjectionRegistry.get(master); 236 List list= cast(List) fProjectionRegistry.get(cast(Object)master);
233 if (list !is null) { 237 if (list !is null) {
234 IDocument[] result= new IDocument[list.size()]; 238 return arraycast!(IDocument)(list.toArray());
235 list.toArray(result);
236 return result;
237 } 239 }
238 return null; 240 return null;
239 } 241 }
240 } 242 }