Mercurial > projects > dwt-addons
comparison dwtx/text/undo/DocumentUndoManagerRegistry.d @ 161:f8d52b926852
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:49:30 +0200 |
parents | f70d9508c95c |
children |
comparison
equal
deleted
inserted
replaced
160:3678e4f1a766 | 161:f8d52b926852 |
---|---|
52 } | 52 } |
53 private int count; | 53 private int count; |
54 private IDocumentUndoManager undoManager; | 54 private IDocumentUndoManager undoManager; |
55 } | 55 } |
56 | 56 |
57 private static Map fgFactory= new HashMap(); | 57 private static Map fgFactory_; |
58 private static Map fgFactory(){ | |
59 if( fgFactory_ is null ) fgFactory_ = new HashMap(); | |
60 return fgFactory_; | |
61 } | |
58 | 62 |
59 private this() { | 63 private this() { |
60 // Do not instantiate | 64 // Do not instantiate |
61 } | 65 } |
62 | 66 |
69 * <em>The recoding of changes starts with the first {@link #connect(IDocument)}.</em></p> | 73 * <em>The recoding of changes starts with the first {@link #connect(IDocument)}.</em></p> |
70 * | 74 * |
71 * @param document the document to be connected | 75 * @param document the document to be connected |
72 */ | 76 */ |
73 public static synchronized void connect(IDocument document) { | 77 public static synchronized void connect(IDocument document) { |
74 Assert.isNotNull(document); | 78 Assert.isNotNull(cast(Object)document); |
75 Record record= cast(Record)fgFactory.get(document); | 79 Record record= cast(Record)fgFactory.get(cast(Object)document); |
76 if (record is null) { | 80 if (record is null) { |
77 record= new Record(document); | 81 record= new Record(document); |
78 fgFactory.put(document, record); | 82 fgFactory.put(cast(Object)document, record); |
79 } | 83 } |
80 record.count++; | 84 record.count++; |
81 } | 85 } |
82 | 86 |
83 /** | 87 /** |
84 * Disconnects the given document from this registry. | 88 * Disconnects the given document from this registry. |
85 * | 89 * |
86 * @param document the document to be disconnected | 90 * @param document the document to be disconnected |
87 */ | 91 */ |
88 public static synchronized void disconnect(IDocument document) { | 92 public static synchronized void disconnect(IDocument document) { |
89 Assert.isNotNull(document); | 93 Assert.isNotNull(cast(Object)document); |
90 Record record= cast(Record)fgFactory.get(document); | 94 Record record= cast(Record)fgFactory.get(cast(Object)document); |
91 record.count--; | 95 record.count--; |
92 if (record.count is 0) | 96 if (record.count is 0) |
93 fgFactory.remove(document); | 97 fgFactory.remove(cast(Object)document); |
94 | 98 |
95 } | 99 } |
96 | 100 |
97 /** | 101 /** |
98 * Returns the file buffer managed for the given location or <code>null</code> | 102 * Returns the file buffer managed for the given location or <code>null</code> |
106 * | 110 * |
107 * @param document the document for which to get its undo manager | 111 * @param document the document for which to get its undo manager |
108 * @return the document undo manager or <code>null</code> | 112 * @return the document undo manager or <code>null</code> |
109 */ | 113 */ |
110 public static synchronized IDocumentUndoManager getDocumentUndoManager(IDocument document) { | 114 public static synchronized IDocumentUndoManager getDocumentUndoManager(IDocument document) { |
111 Assert.isNotNull(document); | 115 Assert.isNotNull(cast(Object)document); |
112 Record record= cast(Record)fgFactory.get(document); | 116 Record record= cast(Record)fgFactory.get(cast(Object)document); |
113 if (record is null) | 117 if (record is null) |
114 return null; | 118 return null; |
115 return record.undoManager; | 119 return record.undoManager; |
116 } | 120 } |
117 | 121 |