Mercurial > projects > dwt-addons
comparison dwtx/jface/text/presentation/PresentationReconciler.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | f70d9508c95c |
children |
comparison
equal
deleted
inserted
replaced
158:25f1f92fa3df | 159:7926b636c282 |
---|---|
65 * </p> | 65 * </p> |
66 */ | 66 */ |
67 public class PresentationReconciler : IPresentationReconciler, IPresentationReconcilerExtension { | 67 public class PresentationReconciler : IPresentationReconciler, IPresentationReconcilerExtension { |
68 | 68 |
69 /** Prefix of the name of the position category for tracking damage regions. */ | 69 /** Prefix of the name of the position category for tracking damage regions. */ |
70 protected final static String TRACKED_PARTITION= "__reconciler_tracked_partition"; //$NON-NLS-1$ | 70 protected const static String TRACKED_PARTITION= "__reconciler_tracked_partition"; //$NON-NLS-1$ |
71 | 71 |
72 | 72 |
73 /** | 73 /** |
74 * Internal listener class. | 74 * Internal listener class. |
75 */ | 75 */ |
264 /** The map of presentation repairers. */ | 264 /** The map of presentation repairers. */ |
265 private Map fRepairers; | 265 private Map fRepairers; |
266 /** The target viewer. */ | 266 /** The target viewer. */ |
267 private ITextViewer fViewer; | 267 private ITextViewer fViewer; |
268 /** The internal listener. */ | 268 /** The internal listener. */ |
269 private InternalListener fInternalListener= new InternalListener(); | 269 private InternalListener fInternalListener; |
270 /** The name of the position category to track damage regions. */ | 270 /** The name of the position category to track damage regions. */ |
271 private String fPositionCategory; | 271 private String fPositionCategory; |
272 /** The position updated for the damage regions' position category. */ | 272 /** The position updated for the damage regions' position category. */ |
273 private IPositionUpdater fPositionUpdater; | 273 private IPositionUpdater fPositionUpdater; |
274 /** The positions representing the damage regions. */ | 274 /** The positions representing the damage regions. */ |
287 * Creates a new presentation reconciler. There are no damagers or repairers | 287 * Creates a new presentation reconciler. There are no damagers or repairers |
288 * registered with this reconciler by default. The default partitioning | 288 * registered with this reconciler by default. The default partitioning |
289 * <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used. | 289 * <code>IDocumentExtension3.DEFAULT_PARTITIONING</code> is used. |
290 */ | 290 */ |
291 public this() { | 291 public this() { |
292 super(); | 292 fInternalListener= new InternalListener(); |
293 // super(); | |
293 fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING; | 294 fPartitioning= IDocumentExtension3.DEFAULT_PARTITIONING; |
294 fPositionCategory= TRACKED_PARTITION + hashCode(); | 295 fPositionCategory= TRACKED_PARTITION ~ Integer.toString(toHash()); |
295 fPositionUpdater= new DefaultPositionUpdater(fPositionCategory); | 296 fPositionUpdater= new DefaultPositionUpdater(fPositionCategory); |
296 } | 297 } |
297 | 298 |
298 /** | 299 /** |
299 * Sets the document partitioning for this presentation reconciler. | 300 * Sets the document partitioning for this presentation reconciler. |
330 fDamagers= new HashMap(); | 331 fDamagers= new HashMap(); |
331 | 332 |
332 if (damager is null) | 333 if (damager is null) |
333 fDamagers.remove(contentType); | 334 fDamagers.remove(contentType); |
334 else | 335 else |
335 fDamagers.put(contentType, damager); | 336 fDamagers.put(stringcast(contentType), cast(Object)damager); |
336 } | 337 } |
337 | 338 |
338 /** | 339 /** |
339 * Registers the given presentation repairer for a particular content type. | 340 * Registers the given presentation repairer for a particular content type. |
340 * If there is already a repairer registered for this type, the old repairer | 341 * If there is already a repairer registered for this type, the old repairer |
351 fRepairers= new HashMap(); | 352 fRepairers= new HashMap(); |
352 | 353 |
353 if (repairer is null) | 354 if (repairer is null) |
354 fRepairers.remove(contentType); | 355 fRepairers.remove(contentType); |
355 else | 356 else |
356 fRepairers.put(contentType, repairer); | 357 fRepairers.put(stringcast(contentType), cast(Object)repairer); |
357 } | 358 } |
358 | 359 |
359 /* | 360 /* |
360 * @see IPresentationReconciler#install(ITextViewer) | 361 * @see IPresentationReconciler#install(ITextViewer) |
361 */ | 362 */ |
362 public void install(ITextViewer viewer) { | 363 public void install(ITextViewer viewer) { |
363 Assert.isNotNull(viewer); | 364 Assert.isNotNull(cast(Object)viewer); |
364 | 365 |
365 fViewer= viewer; | 366 fViewer= viewer; |
366 fViewer.addTextInputListener(fInternalListener); | 367 fViewer.addTextInputListener(fInternalListener); |
367 | 368 |
368 IDocument document= viewer.getDocument(); | 369 IDocument document= viewer.getDocument(); |
369 if (document !is null) | 370 if (document !is null) |
370 fInternalListener.inputDocumentChanged(null, document); | 371 fInternalListener.inputDocumentChanged(null, document); |
371 } | 372 } |
372 | 373 |
482 * computing the partitioning failed | 483 * computing the partitioning failed |
483 * @since 3.0 | 484 * @since 3.0 |
484 */ | 485 */ |
485 private IRegion getDamage(DocumentEvent e, bool optimize) { | 486 private IRegion getDamage(DocumentEvent e, bool optimize) { |
486 int length= e.getText() is null ? 0 : e.getText().length(); | 487 int length= e.getText() is null ? 0 : e.getText().length(); |
487 | 488 |
488 if (fDamagers is null || fDamagers.isEmpty()) { | 489 if (fDamagers is null || fDamagers.isEmpty()) { |
489 length= Math.max(e.getLength(), length); | 490 length= Math.max(e.getLength(), length); |
490 length= Math.min(e.getDocument().getLength() - e.getOffset(), length); | 491 length= Math.min(e.getDocument().getLength() - e.getOffset(), length); |
491 return new Region(e.getOffset(), length); | 492 return new Region(e.getOffset(), length); |
492 } | 493 } |
539 | 540 |
540 IDocument d= e.getDocument(); | 541 IDocument d= e.getDocument(); |
541 | 542 |
542 int length= 0; | 543 int length= 0; |
543 if (e.getText() !is null) { | 544 if (e.getText() !is null) { |
544 length= e.getText().length(); | 545 length= e.getText().length; |
545 if (length > 0) | 546 if (length > 0) |
546 -- length; | 547 -- length; |
547 } | 548 } |
548 | 549 |
549 ITypedRegion partition= getPartition(d, e.getOffset() + length); | 550 ITypedRegion partition= getPartition(d, e.getOffset() + length); |