comparison dwtx/jface/text/source/projection/ProjectionViewer.d @ 138:b6bad70d540a

Regex instanceof changes
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 02:26:23 +0200
parents 6dcb0baaa031
children 53b889547456
comparison
equal deleted inserted replaced
137:25170b5a8951 138:b6bad70d540a
341 * Adds the projection annotation model to the given annotation model. 341 * Adds the projection annotation model to the given annotation model.
342 * 342 *
343 * @param model the model to which the projection annotation model is added 343 * @param model the model to which the projection annotation model is added
344 */ 344 */
345 private void addProjectionAnnotationModel(IAnnotationModel model) { 345 private void addProjectionAnnotationModel(IAnnotationModel model) {
346 if (model instanceof IAnnotationModelExtension) { 346 if ( cast(IAnnotationModelExtension)model ) {
347 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model; 347 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
348 extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel); 348 extension.addAnnotationModel(ProjectionSupport.PROJECTION, fProjectionAnnotationModel);
349 model.addAnnotationModelListener(fAnnotationModelListener); 349 model.addAnnotationModelListener(fAnnotationModelListener);
350 } 350 }
351 } 351 }
355 * 355 *
356 * @param model the mode from which the projection annotation model is removed 356 * @param model the mode from which the projection annotation model is removed
357 * @return the removed projection annotation model or <code>null</code> if there was none 357 * @return the removed projection annotation model or <code>null</code> if there was none
358 */ 358 */
359 private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) { 359 private IAnnotationModel removeProjectionAnnotationModel(IAnnotationModel model) {
360 if (model instanceof IAnnotationModelExtension) { 360 if ( cast(IAnnotationModelExtension)model ) {
361 model.removeAnnotationModelListener(fAnnotationModelListener); 361 model.removeAnnotationModelListener(fAnnotationModelListener);
362 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model; 362 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
363 return extension.removeAnnotationModel(ProjectionSupport.PROJECTION); 363 return extension.removeAnnotationModel(ProjectionSupport.PROJECTION);
364 } 364 }
365 return null; 365 return null;
400 * 400 *
401 * @return the projection annotation model 401 * @return the projection annotation model
402 */ 402 */
403 public ProjectionAnnotationModel getProjectionAnnotationModel() { 403 public ProjectionAnnotationModel getProjectionAnnotationModel() {
404 IAnnotationModel model= getVisualAnnotationModel(); 404 IAnnotationModel model= getVisualAnnotationModel();
405 if (model instanceof IAnnotationModelExtension) { 405 if ( cast(IAnnotationModelExtension)model ) {
406 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model; 406 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) model;
407 return cast(ProjectionAnnotationModel) extension.getAnnotationModel(ProjectionSupport.PROJECTION); 407 return cast(ProjectionAnnotationModel) extension.getAnnotationModel(ProjectionSupport.PROJECTION);
408 } 408 }
409 return null; 409 return null;
410 } 410 }
418 418
419 /* 419 /*
420 * @see dwtx.jface.text.TextViewer#updateSlaveDocument(dwtx.jface.text.IDocument, int, int) 420 * @see dwtx.jface.text.TextViewer#updateSlaveDocument(dwtx.jface.text.IDocument, int, int)
421 */ 421 */
422 protected bool updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) { 422 protected bool updateSlaveDocument(IDocument slaveDocument, int modelRangeOffset, int modelRangeLength) {
423 if (slaveDocument instanceof ProjectionDocument) { 423 if ( cast(ProjectionDocument)slaveDocument ) {
424 ProjectionDocument projection= cast(ProjectionDocument) slaveDocument; 424 ProjectionDocument projection= cast(ProjectionDocument) slaveDocument;
425 425
426 int offset= modelRangeOffset; 426 int offset= modelRangeOffset;
427 int length= modelRangeLength; 427 int length= modelRangeLength;
428 428
803 */ 803 */
804 private void collapse(int offset, int length, bool fireRedraw) { 804 private void collapse(int offset, int length, bool fireRedraw) {
805 ProjectionDocument projection= null; 805 ProjectionDocument projection= null;
806 806
807 IDocument visibleDocument= getVisibleDocument(); 807 IDocument visibleDocument= getVisibleDocument();
808 if (visibleDocument instanceof ProjectionDocument) 808 if ( cast(ProjectionDocument)visibleDocument )
809 projection= cast(ProjectionDocument) visibleDocument; 809 projection= cast(ProjectionDocument) visibleDocument;
810 else { 810 else {
811 IDocument master= getDocument(); 811 IDocument master= getDocument();
812 IDocument slave= createSlaveDocument(getDocument()); 812 IDocument slave= createSlaveDocument(getDocument());
813 if (slave instanceof ProjectionDocument) { 813 if ( cast(ProjectionDocument)slave ) {
814 projection= cast(ProjectionDocument) slave; 814 projection= cast(ProjectionDocument) slave;
815 addMasterDocumentRange(projection, 0, master.getLength()); 815 addMasterDocumentRange(projection, 0, master.getLength());
816 replaceVisibleDocument(projection); 816 replaceVisibleDocument(projection);
817 } 817 }
818 } 818 }
841 * <code>false</code> otherwise 841 * <code>false</code> otherwise
842 * @throws BadLocationException in case the range is invalid 842 * @throws BadLocationException in case the range is invalid
843 */ 843 */
844 private void expand(int offset, int length, bool fireRedraw) { 844 private void expand(int offset, int length, bool fireRedraw) {
845 IDocument slave= getVisibleDocument(); 845 IDocument slave= getVisibleDocument();
846 if (slave instanceof ProjectionDocument) { 846 if ( cast(ProjectionDocument)slave ) {
847 ProjectionDocument projection= cast(ProjectionDocument) slave; 847 ProjectionDocument projection= cast(ProjectionDocument) slave;
848 848
849 // expand 849 // expand
850 addMasterDocumentRange(projection, offset, length); 850 addMasterDocumentRange(projection, offset, length);
851 851
945 * identical to this viewer's document 945 * identical to this viewer's document
946 * @since 3.1 946 * @since 3.1
947 */ 947 */
948 private bool isVisibleMasterDocumentSameAsDocument() { 948 private bool isVisibleMasterDocumentSameAsDocument() {
949 IDocument visibleDocument= getVisibleDocument(); 949 IDocument visibleDocument= getVisibleDocument();
950 return (visibleDocument instanceof ProjectionDocument) && (cast(ProjectionDocument)visibleDocument).getMasterDocument() is getDocument(); 950 return ( cast(ProjectionDocument)visibleDocument ) && (cast(ProjectionDocument)visibleDocument).getMasterDocument() is getDocument();
951 } 951 }
952 952
953 /** 953 /**
954 * Adapts the slave visual document of this viewer to the changes described 954 * Adapts the slave visual document of this viewer to the changes described
955 * in the annotation model event. When the event is <code>null</code>, 955 * in the annotation model event. When the event is <code>null</code>,
1132 try { 1132 try {
1133 IDocument document= getDocument(); 1133 IDocument document= getDocument();
1134 if (document is null) 1134 if (document is null)
1135 return null; 1135 return null;
1136 1136
1137 if (position instanceof IProjectionPosition) { 1137 if ( cast(IProjectionPosition)position ) {
1138 IProjectionPosition projPosition= cast(IProjectionPosition) position; 1138 IProjectionPosition projPosition= cast(IProjectionPosition) position;
1139 return projPosition.computeProjectionRegions(document); 1139 return projPosition.computeProjectionRegions(document);
1140 } 1140 }
1141 1141
1142 int line= document.getLineOfOffset(position.getOffset()); 1142 int line= document.getLineOfOffset(position.getOffset());
1166 IDocument document= getDocument(); 1166 IDocument document= getDocument();
1167 if (document is null) 1167 if (document is null)
1168 return null; 1168 return null;
1169 1169
1170 int captionOffset= position.getOffset(); 1170 int captionOffset= position.getOffset();
1171 if (position instanceof IProjectionPosition) 1171 if ( cast(IProjectionPosition)position )
1172 captionOffset+= (cast(IProjectionPosition) position).computeCaptionOffset(document); 1172 captionOffset+= (cast(IProjectionPosition) position).computeCaptionOffset(document);
1173 1173
1174 IRegion lineInfo= document.getLineInformationOfOffset(captionOffset); 1174 IRegion lineInfo= document.getLineInformationOfOffset(captionOffset);
1175 return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0); 1175 return new Position(lineInfo.getOffset() + lineInfo.getLength(), 0);
1176 } catch (BadLocationException x) { 1176 } catch (BadLocationException x) {
1223 ISlaveDocumentManager manager= getSlaveDocumentManager(); 1223 ISlaveDocumentManager manager= getSlaveDocumentManager();
1224 if (manager !is null) { 1224 if (manager !is null) {
1225 IDocument master= getDocument(); 1225 IDocument master= getDocument();
1226 if (master !is null) { 1226 if (master !is null) {
1227 IDocument slave= manager.createSlaveDocument(master); 1227 IDocument slave= manager.createSlaveDocument(master);
1228 if (slave instanceof ProjectionDocument) { 1228 if ( cast(ProjectionDocument)slave ) {
1229 projection= cast(ProjectionDocument) slave; 1229 projection= cast(ProjectionDocument) slave;
1230 addMasterDocumentRange(projection, 0, master.getLength()); 1230 addMasterDocumentRange(projection, 0, master.getLength());
1231 } 1231 }
1232 } 1232 }
1233 } 1233 }
1268 * 1268 *
1269 * @param column the column to be added 1269 * @param column the column to be added
1270 */ 1270 */
1271 public void addVerticalRulerColumn(IVerticalRulerColumn column) { 1271 public void addVerticalRulerColumn(IVerticalRulerColumn column) {
1272 IVerticalRuler ruler= getVerticalRuler(); 1272 IVerticalRuler ruler= getVerticalRuler();
1273 if (ruler instanceof CompositeRuler) { 1273 if ( cast(CompositeRuler)ruler ) {
1274 CompositeRuler compositeRuler= cast(CompositeRuler) ruler; 1274 CompositeRuler compositeRuler= cast(CompositeRuler) ruler;
1275 compositeRuler.addDecorator(99, column); 1275 compositeRuler.addDecorator(99, column);
1276 } 1276 }
1277 } 1277 }
1278 1278
1281 * 1281 *
1282 * @param column the column to be removed 1282 * @param column the column to be removed
1283 */ 1283 */
1284 public void removeVerticalRulerColumn(IVerticalRulerColumn column) { 1284 public void removeVerticalRulerColumn(IVerticalRulerColumn column) {
1285 IVerticalRuler ruler= getVerticalRuler(); 1285 IVerticalRuler ruler= getVerticalRuler();
1286 if (ruler instanceof CompositeRuler) { 1286 if ( cast(CompositeRuler)ruler ) {
1287 CompositeRuler compositeRuler= cast(CompositeRuler) ruler; 1287 CompositeRuler compositeRuler= cast(CompositeRuler) ruler;
1288 compositeRuler.removeDecorator(column); 1288 compositeRuler.removeDecorator(column);
1289 } 1289 }
1290 } 1290 }
1291 1291
1403 */ 1403 */
1404 public IRegion[] getCoveredModelRanges(IRegion modelRange) { 1404 public IRegion[] getCoveredModelRanges(IRegion modelRange) {
1405 if (fInformationMapping is null) 1405 if (fInformationMapping is null)
1406 return new IRegion[] { new Region(modelRange.getOffset(), modelRange.getLength()) }; 1406 return new IRegion[] { new Region(modelRange.getOffset(), modelRange.getLength()) };
1407 1407
1408 if (fInformationMapping instanceof IDocumentInformationMappingExtension) { 1408 if ( cast(IDocumentInformationMappingExtension)fInformationMapping ) {
1409 IDocumentInformationMappingExtension extension= cast(IDocumentInformationMappingExtension) fInformationMapping; 1409 IDocumentInformationMappingExtension extension= cast(IDocumentInformationMappingExtension) fInformationMapping;
1410 try { 1410 try {
1411 return extension.getExactCoverage(modelRange); 1411 return extension.getExactCoverage(modelRange);
1412 } catch (BadLocationException x) { 1412 } catch (BadLocationException x) {
1413 } 1413 }