Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/SourceViewer.d @ 134:51e6e63f930e
Regex fix for casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 01:46:20 +0200 |
parents | 7d818bd32d63 |
children | b6bad70d540a |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
569 * @since 3.0 | 569 * @since 3.0 |
570 */ | 570 */ |
571 protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) { | 571 protected IAnnotationModel createVisualAnnotationModel(IAnnotationModel annotationModel) { |
572 IAnnotationModelExtension model= new AnnotationModel(); | 572 IAnnotationModelExtension model= new AnnotationModel(); |
573 model.addAnnotationModel(MODEL_ANNOTATION_MODEL, annotationModel); | 573 model.addAnnotationModel(MODEL_ANNOTATION_MODEL, annotationModel); |
574 return (IAnnotationModel) model; | 574 return cast(IAnnotationModel) model; |
575 } | 575 } |
576 | 576 |
577 /** | 577 /** |
578 * Disposes the visual annotation model. | 578 * Disposes the visual annotation model. |
579 * | 579 * |
583 if (fVisualAnnotationModel !is null) { | 583 if (fVisualAnnotationModel !is null) { |
584 if (getDocument() !is null) | 584 if (getDocument() !is null) |
585 fVisualAnnotationModel.disconnect(getDocument()); | 585 fVisualAnnotationModel.disconnect(getDocument()); |
586 | 586 |
587 if ( fVisualAnnotationModel instanceof IAnnotationModelExtension) | 587 if ( fVisualAnnotationModel instanceof IAnnotationModelExtension) |
588 ((IAnnotationModelExtension)fVisualAnnotationModel).removeAnnotationModel(MODEL_ANNOTATION_MODEL); | 588 (cast(IAnnotationModelExtension)fVisualAnnotationModel).removeAnnotationModel(MODEL_ANNOTATION_MODEL); |
589 | 589 |
590 fVisualAnnotationModel= null; | 590 fVisualAnnotationModel= null; |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
617 /* | 617 /* |
618 * @see ISourceViewer#getAnnotationModel() | 618 * @see ISourceViewer#getAnnotationModel() |
619 */ | 619 */ |
620 public IAnnotationModel getAnnotationModel() { | 620 public IAnnotationModel getAnnotationModel() { |
621 if (fVisualAnnotationModel instanceof IAnnotationModelExtension) { | 621 if (fVisualAnnotationModel instanceof IAnnotationModelExtension) { |
622 IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; | 622 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fVisualAnnotationModel; |
623 return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL); | 623 return extension.getAnnotationModel(MODEL_ANNOTATION_MODEL); |
624 } | 624 } |
625 return null; | 625 return null; |
626 } | 626 } |
627 | 627 |
824 protected void restoreSelection() { | 824 protected void restoreSelection() { |
825 | 825 |
826 if (!fSelections.isEmpty()) { | 826 if (!fSelections.isEmpty()) { |
827 | 827 |
828 final IDocument document= getDocument(); | 828 final IDocument document= getDocument(); |
829 final Position position= (Position) fSelections.pop(); | 829 final Position position= cast(Position) fSelections.pop(); |
830 | 830 |
831 try { | 831 try { |
832 document.removePosition(fSelectionCategory, position); | 832 document.removePosition(fSelectionCategory, position); |
833 Point currentSelection= getSelectedRange(); | 833 Point currentSelection= getSelectedRange(); |
834 if (currentSelection is null || currentSelection.x !is position.getOffset() || currentSelection.y !is position.getLength()) | 834 if (currentSelection is null || currentSelection.x !is position.getOffset() || currentSelection.y !is position.getLength()) |
889 final IDocument document= getDocument(); | 889 final IDocument document= getDocument(); |
890 IFormattingContext context= null; | 890 IFormattingContext context= null; |
891 DocumentRewriteSession rewriteSession= null; | 891 DocumentRewriteSession rewriteSession= null; |
892 | 892 |
893 if (document instanceof IDocumentExtension4) { | 893 if (document instanceof IDocumentExtension4) { |
894 IDocumentExtension4 extension= (IDocumentExtension4) document; | 894 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
895 DocumentRewriteSessionType type= selection.y is 0 || selection.y > 1000 ? DocumentRewriteSessionType.SEQUENTIAL : DocumentRewriteSessionType.UNRESTRICTED_SMALL; | 895 DocumentRewriteSessionType type= selection.y is 0 || selection.y > 1000 ? DocumentRewriteSessionType.SEQUENTIAL : DocumentRewriteSessionType.UNRESTRICTED_SMALL; |
896 rewriteSession= extension.startRewriteSession(type); | 896 rewriteSession= extension.startRewriteSession(type); |
897 } else { | 897 } else { |
898 setRedraw(false); | 898 setRedraw(false); |
899 target.beginCompoundChange(); | 899 target.beginCompoundChange(); |
904 final String rememberedContents= document.get(); | 904 final String rememberedContents= document.get(); |
905 | 905 |
906 try { | 906 try { |
907 | 907 |
908 if (fContentFormatter instanceof IContentFormatterExtension) { | 908 if (fContentFormatter instanceof IContentFormatterExtension) { |
909 final IContentFormatterExtension extension= (IContentFormatterExtension) fContentFormatter; | 909 final IContentFormatterExtension extension= cast(IContentFormatterExtension) fContentFormatter; |
910 context= createFormattingContext(); | 910 context= createFormattingContext(); |
911 if (selection.y is 0) { | 911 if (selection.y is 0) { |
912 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); | 912 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); |
913 } else { | 913 } else { |
914 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE); | 914 context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.FALSE); |
937 } | 937 } |
938 | 938 |
939 } finally { | 939 } finally { |
940 | 940 |
941 if (document instanceof IDocumentExtension4) { | 941 if (document instanceof IDocumentExtension4) { |
942 IDocumentExtension4 extension= (IDocumentExtension4) document; | 942 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
943 extension.stopRewriteSession(rewriteSession); | 943 extension.stopRewriteSession(rewriteSession); |
944 } else { | 944 } else { |
945 target.endCompoundChange(); | 945 target.endCompoundChange(); |
946 setRedraw(true); | 946 setRedraw(true); |
947 } | 947 } |
965 * @since 3.0 | 965 * @since 3.0 |
966 */ | 966 */ |
967 protected void updateSlaveDocuments(IDocument masterDocument) { | 967 protected void updateSlaveDocuments(IDocument masterDocument) { |
968 ISlaveDocumentManager manager= getSlaveDocumentManager(); | 968 ISlaveDocumentManager manager= getSlaveDocumentManager(); |
969 if (manager instanceof ISlaveDocumentManagerExtension) { | 969 if (manager instanceof ISlaveDocumentManagerExtension) { |
970 ISlaveDocumentManagerExtension extension= (ISlaveDocumentManagerExtension) manager; | 970 ISlaveDocumentManagerExtension extension= cast(ISlaveDocumentManagerExtension) manager; |
971 IDocument[] slaves= extension.getSlaveDocuments(masterDocument); | 971 IDocument[] slaves= extension.getSlaveDocuments(masterDocument); |
972 if (slaves !is null) { | 972 if (slaves !is null) { |
973 for (int i= 0; i < slaves.length; i++) { | 973 for (int i= 0; i < slaves.length; i++) { |
974 if (slaves[i] instanceof ChildDocument) { | 974 if (slaves[i] instanceof ChildDocument) { |
975 ChildDocument child= (ChildDocument) slaves[i]; | 975 ChildDocument child= cast(ChildDocument) slaves[i]; |
976 Position p= child.getParentDocumentRange(); | 976 Position p= child.getParentDocumentRange(); |
977 try { | 977 try { |
978 | 978 |
979 if (!updateSlaveDocument(child, p.getOffset(), p.getLength())) | 979 if (!updateSlaveDocument(child, p.getOffset(), p.getLength())) |
980 child.repairLineInformation(); | 980 child.repairLineInformation(); |
1046 setSelectedRange(start, 0); | 1046 setSelectedRange(start, 0); |
1047 revealRange(start, length); | 1047 revealRange(start, length); |
1048 } | 1048 } |
1049 | 1049 |
1050 if (fRangeIndicator !is null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { | 1050 if (fRangeIndicator !is null && fVisualAnnotationModel instanceof IAnnotationModelExtension) { |
1051 IAnnotationModelExtension extension= (IAnnotationModelExtension) fVisualAnnotationModel; | 1051 IAnnotationModelExtension extension= cast(IAnnotationModelExtension) fVisualAnnotationModel; |
1052 extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); | 1052 extension.modifyAnnotationPosition(fRangeIndicator, new Position(start, length)); |
1053 } | 1053 } |
1054 } | 1054 } |
1055 | 1055 |
1056 /* | 1056 /* |
1101 private bool isVerticalRulerOnlyShowingAnnotations() { | 1101 private bool isVerticalRulerOnlyShowingAnnotations() { |
1102 if (fVerticalRuler instanceof VerticalRuler) | 1102 if (fVerticalRuler instanceof VerticalRuler) |
1103 return true; | 1103 return true; |
1104 | 1104 |
1105 if (fVerticalRuler instanceof CompositeRuler) { | 1105 if (fVerticalRuler instanceof CompositeRuler) { |
1106 Iterator iter= ((CompositeRuler)fVerticalRuler).getDecoratorIterator(); | 1106 Iterator iter= (cast(CompositeRuler)fVerticalRuler).getDecoratorIterator(); |
1107 return iter.hasNext() && iter.next() instanceof AnnotationRulerColumn && !iter.hasNext(); | 1107 return iter.hasNext() && iter.next() instanceof AnnotationRulerColumn && !iter.hasNext(); |
1108 } | 1108 } |
1109 return false; | 1109 return false; |
1110 } | 1110 } |
1111 | 1111 |