Mercurial > projects > dwt-addons
comparison dwtx/jface/text/link/LinkedModeUI.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 |
---|---|
98 /* cycle constants */ | 98 /* cycle constants */ |
99 /** | 99 /** |
100 * Constant indicating that this UI should never cycle from the last | 100 * Constant indicating that this UI should never cycle from the last |
101 * position to the first and vice versa. | 101 * position to the first and vice versa. |
102 */ | 102 */ |
103 public static const Object CYCLE_NEVER= new Object(); | 103 public static Object CYCLE_NEVER_; |
104 public static Object CYCLE_NEVER(){ | |
105 if( CYCLE_NEVER_ is null ){ | |
106 synchronized( LinkedModeUI.classinfo ){ | |
107 if( CYCLE_NEVER_ is null ){ | |
108 CYCLE_NEVER_ = new Object(); | |
109 } | |
110 } | |
111 } | |
112 return CYCLE_NEVER_; | |
113 } | |
104 /** | 114 /** |
105 * Constant indicating that this UI should always cycle from the last | 115 * Constant indicating that this UI should always cycle from the last |
106 * position to the first and vice versa. | 116 * position to the first and vice versa. |
107 */ | 117 */ |
108 public static const Object CYCLE_ALWAYS= new Object(); | 118 public static Object CYCLE_ALWAYS_; |
119 public static Object CYCLE_ALWAYS(){ | |
120 if( CYCLE_ALWAYS_ is null ){ | |
121 synchronized( LinkedModeUI.classinfo ){ | |
122 if( CYCLE_ALWAYS_ is null ){ | |
123 CYCLE_ALWAYS_ = new Object(); | |
124 } | |
125 } | |
126 } | |
127 return CYCLE_ALWAYS_; | |
128 } | |
109 /** | 129 /** |
110 * Constant indicating that this UI should cycle from the last position to | 130 * Constant indicating that this UI should cycle from the last position to |
111 * the first and vice versa if its model is not nested. | 131 * the first and vice versa if its model is not nested. |
112 */ | 132 */ |
113 public static const Object CYCLE_WHEN_NO_PARENT= new Object(); | 133 public static Object CYCLE_WHEN_NO_PARENT_; |
134 public static Object CYCLE_WHEN_NO_PARENT(){ | |
135 if( CYCLE_WHEN_NO_PARENT_ is null ){ | |
136 synchronized( LinkedModeUI.classinfo ){ | |
137 if( CYCLE_WHEN_NO_PARENT_ is null ){ | |
138 CYCLE_WHEN_NO_PARENT_ = new Object(); | |
139 } | |
140 } | |
141 } | |
142 return CYCLE_WHEN_NO_PARENT_; | |
143 } | |
114 | 144 |
115 /** | 145 /** |
116 * Listener that gets notified when the linked mode UI switches its focus position. | 146 * Listener that gets notified when the linked mode UI switches its focus position. |
117 * <p> | 147 * <p> |
118 * Clients may implement this interface. | 148 * Clients may implement this interface. |
190 | 220 |
191 /** | 221 /** |
192 * @param viewer the viewer | 222 * @param viewer the viewer |
193 */ | 223 */ |
194 public this(ITextViewer viewer) { | 224 public this(ITextViewer viewer) { |
195 Assert.isNotNull(viewer); | 225 Assert.isNotNull(cast(Object)viewer); |
196 fTextViewer= viewer; | 226 fTextViewer= viewer; |
197 } | 227 } |
198 | 228 |
199 /* | 229 /* |
200 * @see dwtx.jdt.internal.ui.text.link2.LinkedModeUI.ILinkedUITarget#getViewer() | 230 * @see dwtx.jdt.internal.ui.text.link2.LinkedModeUI.ILinkedUITarget#getViewer() |
330 // Better: | 360 // Better: |
331 // Check with content assistant and only leave if its not the proposal shell that took the | 361 // Check with content assistant and only leave if its not the proposal shell that took the |
332 // focus away. | 362 // focus away. |
333 | 363 |
334 StyledText text; | 364 StyledText text; |
335 final ITextViewer viewer; | 365 ITextViewer viewer; |
336 Display display; | 366 Display display; |
337 | 367 |
338 if (fCurrentTarget is null || (text= fCurrentTarget.fWidget) is null | 368 if (fCurrentTarget is null || (text= fCurrentTarget.fWidget) is null |
339 || text.isDisposed() || (display= text.getDisplay()) is null | 369 || text.isDisposed() || (display= text.getDisplay()) is null |
340 || display.isDisposed() | 370 || display.isDisposed() |
343 leave(ILinkedModeListener.EXIT_ALL); | 373 leave(ILinkedModeListener.EXIT_ALL); |
344 } | 374 } |
345 else | 375 else |
346 { | 376 { |
347 // Post in UI thread since the assistant popup will only get the focus after we lose it. | 377 // Post in UI thread since the assistant popup will only get the focus after we lose it. |
348 display.asyncExec(new class() Runnable { | 378 display.asyncExec(dgRunnable( (ITextViewer viewer_) { |
349 public void run() { | 379 if (fIsActive && cast(IEditingSupportRegistry)viewer_ ) { |
350 if (fIsActive && cast(IEditingSupportRegistry)viewer ) { | 380 IEditingSupport[] helpers= (cast(IEditingSupportRegistry) viewer_).getRegisteredSupports(); |
351 IEditingSupport[] helpers= (cast(IEditingSupportRegistry) viewer).getRegisteredSupports(); | 381 for (int i= 0; i < helpers.length; i++) { |
352 for (int i= 0; i < helpers.length; i++) { | 382 if (helpers[i].ownsFocusShell()) |
353 if (helpers[i].ownsFocusShell()) | 383 return; |
354 return; | |
355 } | |
356 } | 384 } |
357 | |
358 // else | |
359 leave(ILinkedModeListener.EXIT_ALL); | |
360 | |
361 } | 385 } |
362 }); | 386 |
387 // else | |
388 leave(ILinkedModeListener.EXIT_ALL); | |
389 | |
390 }, viewer )); | |
363 } | 391 } |
364 } | 392 } |
365 | 393 |
366 public void shellDeiconified(ShellEvent e) { | 394 public void shellDeiconified(ShellEvent e) { |
367 } | 395 } |
585 /** The iterator over the tab stop positions. */ | 613 /** The iterator over the tab stop positions. */ |
586 private TabStopIterator fIterator; | 614 private TabStopIterator fIterator; |
587 | 615 |
588 /* Our team of event listeners */ | 616 /* Our team of event listeners */ |
589 /** The shell listener. */ | 617 /** The shell listener. */ |
590 private Closer fCloser= new Closer(); | 618 private Closer fCloser; |
591 /** The linked mode listener. */ | 619 /** The linked mode listener. */ |
592 private ILinkedModeListener fLinkedListener= new ExitListener(); | 620 private ILinkedModeListener fLinkedListener; |
593 /** The selection listener. */ | 621 /** The selection listener. */ |
594 private MySelectionListener fSelectionListener= new MySelectionListener(); | 622 private MySelectionListener fSelectionListener; |
595 /** The content assist listener. */ | 623 /** The content assist listener. */ |
596 private ProposalListener fProposalListener= new ProposalListener(); | 624 private ProposalListener fProposalListener; |
597 /** | 625 /** |
598 * The document listener. | 626 * The document listener. |
599 * @since 3.1 | 627 * @since 3.1 |
600 */ | 628 */ |
601 private IDocumentListener fDocumentListener= new DocumentListener(); | 629 private IDocumentListener fDocumentListener; |
602 | 630 |
603 /** The last caret position, used by fCaretListener. */ | 631 /** The last caret position, used by fCaretListener. */ |
604 private const Position fCaretPosition= new Position(0, 0); | 632 private const Position fCaretPosition; |
605 /** The exit policy to control custom exit behavior */ | 633 /** The exit policy to control custom exit behavior */ |
606 private IExitPolicy fExitPolicy= new NullExitPolicy(); | 634 private IExitPolicy fExitPolicy; |
607 /** The current frame position shown in the UI, or <code>null</code>. */ | 635 /** The current frame position shown in the UI, or <code>null</code>. */ |
608 private LinkedPosition fFramePosition; | 636 private LinkedPosition fFramePosition; |
609 /** The last visited position, used for undo / redo. */ | 637 /** The last visited position, used for undo / redo. */ |
610 private LinkedPosition fPreviousPosition; | 638 private LinkedPosition fPreviousPosition; |
611 /** The content assistant used to show proposals. */ | 639 /** The content assistant used to show proposals. */ |
613 /** The exit position. */ | 641 /** The exit position. */ |
614 private LinkedPosition fExitPosition; | 642 private LinkedPosition fExitPosition; |
615 /** State indicator to prevent multiple invocation of leave. */ | 643 /** State indicator to prevent multiple invocation of leave. */ |
616 private bool fIsActive= false; | 644 private bool fIsActive= false; |
617 /** The position updater for the exit position. */ | 645 /** The position updater for the exit position. */ |
618 private IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(getCategory()); | 646 private IPositionUpdater fPositionUpdater; |
619 /** Whether to show context info. */ | 647 /** Whether to show context info. */ |
620 private bool fDoContextInfo= false; | 648 private bool fDoContextInfo= false; |
621 /** Whether we have begun a compound change, but not yet closed. */ | 649 /** Whether we have begun a compound change, but not yet closed. */ |
622 private bool fHasOpenCompoundChange= false; | 650 private bool fHasOpenCompoundChange= false; |
623 /** The position listener. */ | 651 /** The position listener. */ |
624 private ILinkedModeUIFocusListener fPositionListener= new EmtpyFocusListener(); | 652 private ILinkedModeUIFocusListener fPositionListener; |
625 private IAutoEditStrategy fAutoEditVetoer= new class() IAutoEditStrategy { | 653 private IAutoEditStrategy fAutoEditVetoer; |
626 | 654 private void fAutoEditVetoer_init(){ |
627 /* | 655 fAutoEditVetoer = new class() IAutoEditStrategy { |
628 * @see dwtx.jface.text.IAutoEditStrategy#customizeDocumentCommand(dwtx.jface.text.IDocument, dwtx.jface.text.DocumentCommand) | 656 /* |
629 */ | 657 * @see dwtx.jface.text.IAutoEditStrategy#customizeDocumentCommand(dwtx.jface.text.IDocument, dwtx.jface.text.DocumentCommand) |
630 public void customizeDocumentCommand(IDocument document, DocumentCommand command) { | 658 */ |
631 // invalidate the change to ensure that the change is performed on the document only. | 659 public void customizeDocumentCommand(IDocument document, DocumentCommand command) { |
632 if (fModel.anyPositionContains(command.offset)) { | 660 // invalidate the change to ensure that the change is performed on the document only. |
633 command.doit= false; | 661 if (fModel.anyPositionContains(command.offset)) { |
634 command.caretOffset= command.offset + command.length; | 662 command.doit= false; |
635 } | 663 command.caretOffset= command.offset + command.length; |
636 | 664 } |
637 } | 665 |
638 }; | 666 } |
639 | 667 }; |
668 } | |
640 | 669 |
641 /** Whether this UI is in simple highlighting mode or not. */ | 670 /** Whether this UI is in simple highlighting mode or not. */ |
642 private bool fSimple; | 671 private bool fSimple; |
643 | 672 |
644 /** | 673 /** |
645 * Tells whether colored labels support is enabled. | 674 * Tells whether colored labels support is enabled. |
646 * @since 3.4 | 675 * @since 3.4 |
647 */ | 676 */ |
648 private bool fIsColoredLabelsSupportEnabled= false; | 677 private bool fIsColoredLabelsSupportEnabled= false; |
678 | |
679 private this(){ | |
680 fCloser= new Closer(); | |
681 fLinkedListener= new ExitListener(); | |
682 fSelectionListener= new MySelectionListener(); | |
683 fProposalListener= new ProposalListener(); | |
684 fDocumentListener= new DocumentListener(); | |
685 fCaretPosition= new Position(0, 0); | |
686 fExitPolicy= new NullExitPolicy(); | |
687 fPositionUpdater= new DefaultPositionUpdater(getCategory()); | |
688 fPositionListener= new EmtpyFocusListener(); | |
689 fAutoEditVetoer_init(); | |
690 } | |
649 | 691 |
650 /** | 692 /** |
651 * Creates a new UI on the given model and the set of viewers. The model | 693 * Creates a new UI on the given model and the set of viewers. The model |
652 * must provide a tab stop sequence with a non-empty list of tab stops. | 694 * must provide a tab stop sequence with a non-empty list of tab stops. |
653 * | 695 * |
654 * @param model the linked mode model | 696 * @param model the linked mode model |
655 * @param targets the non-empty list of targets upon which the linked mode | 697 * @param targets the non-empty list of targets upon which the linked mode |
656 * UI should act | 698 * UI should act |
657 */ | 699 */ |
658 public this(LinkedModeModel model, LinkedModeUITarget[] targets) { | 700 public this(LinkedModeModel model, LinkedModeUITarget[] targets) { |
701 this(); | |
659 constructor(model, targets); | 702 constructor(model, targets); |
660 } | 703 } |
661 | 704 |
662 /** | 705 /** |
663 * Convenience constructor for just one viewer. | 706 * Convenience constructor for just one viewer. |
664 * | 707 * |
665 * @param model the linked mode model | 708 * @param model the linked mode model |
666 * @param viewer the viewer upon which the linked mode UI should act | 709 * @param viewer the viewer upon which the linked mode UI should act |
667 */ | 710 */ |
668 public this(LinkedModeModel model, ITextViewer viewer) { | 711 public this(LinkedModeModel model, ITextViewer viewer) { |
712 this(); | |
669 constructor(model, [new EmptyTarget(viewer)]); | 713 constructor(model, [new EmptyTarget(viewer)]); |
670 } | 714 } |
671 | 715 |
672 /** | 716 /** |
673 * Convenience constructor for multiple viewers. | 717 * Convenience constructor for multiple viewers. |
675 * @param model the linked mode model | 719 * @param model the linked mode model |
676 * @param viewers the non-empty list of viewers upon which the linked mode | 720 * @param viewers the non-empty list of viewers upon which the linked mode |
677 * UI should act | 721 * UI should act |
678 */ | 722 */ |
679 public this(LinkedModeModel model, ITextViewer[] viewers) { | 723 public this(LinkedModeModel model, ITextViewer[] viewers) { |
724 this(); | |
680 LinkedModeUITarget[] array= new LinkedModeUITarget[viewers.length]; | 725 LinkedModeUITarget[] array= new LinkedModeUITarget[viewers.length]; |
681 for (int i= 0; i < array.length; i++) { | 726 for (int i= 0; i < array.length; i++) { |
682 array[i]= new EmptyTarget(viewers[i]); | 727 array[i]= new EmptyTarget(viewers[i]); |
683 } | 728 } |
684 constructor(model, array); | 729 constructor(model, array); |
689 * | 734 * |
690 * @param model the linked mode model | 735 * @param model the linked mode model |
691 * @param target the target upon which the linked mode UI should act | 736 * @param target the target upon which the linked mode UI should act |
692 */ | 737 */ |
693 public this(LinkedModeModel model, LinkedModeUITarget target) { | 738 public this(LinkedModeModel model, LinkedModeUITarget target) { |
739 this(); | |
694 constructor(model, [target]); | 740 constructor(model, [target]); |
695 } | 741 } |
696 | 742 |
697 /** | 743 /** |
698 * This does the actual constructor work. | 744 * This does the actual constructor work. |
701 * @param targets the non-empty array of targets upon which the linked mode UI | 747 * @param targets the non-empty array of targets upon which the linked mode UI |
702 * should act | 748 * should act |
703 */ | 749 */ |
704 private void constructor(LinkedModeModel model, LinkedModeUITarget[] targets) { | 750 private void constructor(LinkedModeModel model, LinkedModeUITarget[] targets) { |
705 Assert.isNotNull(model); | 751 Assert.isNotNull(model); |
706 Assert.isNotNull(targets); | 752 //Assert.isNotNull(targets); |
707 Assert.isTrue(targets.length > 0); | 753 Assert.isTrue(targets.length > 0); |
708 Assert.isTrue(model.getTabStopSequence().size() > 0); | 754 Assert.isTrue(model.getTabStopSequence().size() > 0); |
709 | 755 |
710 fModel= model; | 756 fModel= model; |
711 fTargets= targets; | 757 fTargets= targets; |
797 * | 843 * |
798 * @param mode the new cycling mode. | 844 * @param mode the new cycling mode. |
799 */ | 845 */ |
800 public void setCyclingMode(Object mode) { | 846 public void setCyclingMode(Object mode) { |
801 if (mode !is CYCLE_ALWAYS && mode !is CYCLE_NEVER && mode !is CYCLE_WHEN_NO_PARENT) | 847 if (mode !is CYCLE_ALWAYS && mode !is CYCLE_NEVER && mode !is CYCLE_WHEN_NO_PARENT) |
802 throw new IllegalArgumentException(); | 848 throw new IllegalArgumentException(null); |
803 | 849 |
804 if (mode is CYCLE_ALWAYS || mode is CYCLE_WHEN_NO_PARENT && !fModel.isNested()) | 850 if (mode is CYCLE_ALWAYS || mode is CYCLE_WHEN_NO_PARENT && !fModel.isNested()) |
805 fIterator.setCycling(true); | 851 fIterator.setCycling(true); |
806 else | 852 else |
807 fIterator.setCycling(false); | 853 fIterator.setCycling(false); |
845 | 891 |
846 fAssistant.setCompletions(new ICompletionProposal[0]); | 892 fAssistant.setCompletions(new ICompletionProposal[0]); |
847 fAssistant.hidePossibleCompletions(); | 893 fAssistant.hidePossibleCompletions(); |
848 } | 894 } |
849 | 895 |
850 private void switchPosition(LinkedPosition pos, bool select, bool showProposals) { | 896 private void switchPosition(LinkedPosition pos, bool select_, bool showProposals) { |
851 Assert.isNotNull(pos); | 897 Assert.isNotNull(pos); |
852 if (pos.equals(fFramePosition)) | 898 if (pos.equals(fFramePosition)) |
853 return; | 899 return; |
854 | 900 |
855 if (fFramePosition !is null && fCurrentTarget !is null) | 901 if (fFramePosition !is null && fCurrentTarget !is null) |
863 IDocument newDoc= pos.getDocument(); | 909 IDocument newDoc= pos.getDocument(); |
864 | 910 |
865 switchViewer(oldDoc, newDoc, pos); | 911 switchViewer(oldDoc, newDoc, pos); |
866 fFramePosition= pos; | 912 fFramePosition= pos; |
867 | 913 |
868 if (select) | 914 if (select_) |
869 select(); | 915 select(); |
870 if (fFramePosition is fExitPosition && !fIterator.isCycling()) | 916 if (fFramePosition is fExitPosition && !fIterator.isCycling()) |
871 leave(ILinkedModeListener.NONE); | 917 leave(ILinkedModeListener.NONE); |
872 else { | 918 else { |
873 redraw(); // redraw new position | 919 redraw(); // redraw new position |
890 if ( cast(ISourceViewer)viewer ) { | 936 if ( cast(ISourceViewer)viewer ) { |
891 ISourceViewer sv= cast(ISourceViewer) viewer; | 937 ISourceViewer sv= cast(ISourceViewer) viewer; |
892 IAnnotationModel model= sv.getAnnotationModel(); | 938 IAnnotationModel model= sv.getAnnotationModel(); |
893 if ( cast(IAnnotationModelExtension)model ) { | 939 if ( cast(IAnnotationModelExtension)model ) { |
894 IAnnotationModelExtension ext= cast(IAnnotationModelExtension) model; | 940 IAnnotationModelExtension ext= cast(IAnnotationModelExtension) model; |
895 IAnnotationModel ourModel= ext.getAnnotationModel(getUniqueKey()); | 941 IAnnotationModel ourModel= ext.getAnnotationModel(stringcast(getUniqueKey())); |
896 if (ourModel is null) { | 942 if (ourModel is null) { |
897 ext.addAnnotationModel(getUniqueKey(), lpa); | 943 ext.addAnnotationModel(stringcast(getUniqueKey()), lpa); |
898 } | 944 } |
899 } | 945 } |
900 } | 946 } |
901 } | 947 } |
902 } | 948 } |
906 if ( cast(ISourceViewer)viewer ) { | 952 if ( cast(ISourceViewer)viewer ) { |
907 ISourceViewer sv= cast(ISourceViewer) viewer; | 953 ISourceViewer sv= cast(ISourceViewer) viewer; |
908 IAnnotationModel model= sv.getAnnotationModel(); | 954 IAnnotationModel model= sv.getAnnotationModel(); |
909 if ( cast(IAnnotationModelExtension)model ) { | 955 if ( cast(IAnnotationModelExtension)model ) { |
910 IAnnotationModelExtension ext= cast(IAnnotationModelExtension) model; | 956 IAnnotationModelExtension ext= cast(IAnnotationModelExtension) model; |
911 ext.removeAnnotationModel(getUniqueKey()); | 957 ext.removeAnnotationModel(stringcast(getUniqueKey())); |
912 } | 958 } |
913 } | 959 } |
914 } | 960 } |
915 | 961 |
916 private void switchViewer(IDocument oldDoc, IDocument newDoc, LinkedPosition pos) { | 962 private void switchViewer(IDocument oldDoc, IDocument newDoc, LinkedPosition pos) { |
957 } | 1003 } |
958 | 1004 |
959 private void connect() { | 1005 private void connect() { |
960 Assert.isNotNull(fCurrentTarget); | 1006 Assert.isNotNull(fCurrentTarget); |
961 ITextViewer viewer= fCurrentTarget.getViewer(); | 1007 ITextViewer viewer= fCurrentTarget.getViewer(); |
962 Assert.isNotNull(viewer); | 1008 Assert.isNotNull(cast(Object)viewer); |
963 fCurrentTarget.fWidget= viewer.getTextWidget(); | 1009 fCurrentTarget.fWidget= viewer.getTextWidget(); |
964 if (fCurrentTarget.fWidget is null) | 1010 if (fCurrentTarget.fWidget is null) |
965 leave(ILinkedModeListener.EXIT_ALL); | 1011 leave(ILinkedModeListener.EXIT_ALL); |
966 | 1012 |
967 if (fCurrentTarget.fKeyListener is null) { | 1013 if (fCurrentTarget.fKeyListener is null) { |
1070 if ( cast(IDocumentExtension3)document ) { | 1116 if ( cast(IDocumentExtension3)document ) { |
1071 IDocumentExtension3 ext= cast(IDocumentExtension3) document; | 1117 IDocumentExtension3 ext= cast(IDocumentExtension3) document; |
1072 String[] partitionings= ext.getPartitionings(); | 1118 String[] partitionings= ext.getPartitionings(); |
1073 Set contentTypes= new HashSet(20); | 1119 Set contentTypes= new HashSet(20); |
1074 for (int i= 0; i < partitionings.length; i++) { | 1120 for (int i= 0; i < partitionings.length; i++) { |
1075 contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitionings[i]))); | 1121 contentTypes.addAll(Arrays.asList(stringcast(ext.getLegalContentTypes(partitionings[i])))); |
1076 } | 1122 } |
1077 contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE); | 1123 contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE); |
1078 return (String[]) contentTypes.toArray(new String[contentTypes.size()]); | 1124 return stringcast( contentTypes.toArray()); |
1079 } | 1125 } |
1080 return document.getLegalContentTypes(); | 1126 return document.getLegalContentTypes(); |
1081 } | 1127 } |
1082 | 1128 |
1083 private void createAnnotationModel() { | 1129 private void createAnnotationModel() { |
1095 fCurrentTarget.fAnnotationModel= lpa; | 1141 fCurrentTarget.fAnnotationModel= lpa; |
1096 } | 1142 } |
1097 } | 1143 } |
1098 | 1144 |
1099 private String getUniqueKey() { | 1145 private String getUniqueKey() { |
1100 return "linked.annotationmodelkey."+toString(); //$NON-NLS-1$ | 1146 return "linked.annotationmodelkey."~toString(); //$NON-NLS-1$ |
1101 } | 1147 } |
1102 | 1148 |
1103 private void disconnect() { | 1149 private void disconnect() { |
1104 Assert.isNotNull(fCurrentTarget); | 1150 Assert.isNotNull(fCurrentTarget); |
1105 ITextViewer viewer= fCurrentTarget.getViewer(); | 1151 ITextViewer viewer= fCurrentTarget.getViewer(); |
1106 Assert.isNotNull(viewer); | 1152 Assert.isNotNull(cast(Object)viewer); |
1107 | 1153 |
1108 viewer.getDocument().removeDocumentListener(fDocumentListener); | 1154 viewer.getDocument().removeDocumentListener(fDocumentListener); |
1109 | 1155 |
1110 fAssistant.uninstall(); | 1156 fAssistant.uninstall(); |
1111 fAssistant.removeProposalListener(fProposalListener); | 1157 fAssistant.removeProposalListener(fProposalListener); |
1133 (cast(IPostSelectionProvider) viewer).removePostSelectionChangedListener(fSelectionListener); | 1179 (cast(IPostSelectionProvider) viewer).removePostSelectionChangedListener(fSelectionListener); |
1134 | 1180 |
1135 redraw(); | 1181 redraw(); |
1136 } | 1182 } |
1137 | 1183 |
1138 void leave(final int flags) { | 1184 void leave(int flags) { |
1139 if (!fIsActive) | 1185 if (!fIsActive) |
1140 return; | 1186 return; |
1141 fIsActive= false; | 1187 fIsActive= false; |
1142 | 1188 |
1143 endCompoundChange(); | 1189 endCompoundChange(); |
1178 | 1224 |
1179 final List docs= new ArrayList(); | 1225 final List docs= new ArrayList(); |
1180 for (int i= 0; i < fTargets.length; i++) { | 1226 for (int i= 0; i < fTargets.length; i++) { |
1181 IDocument doc= fTargets[i].getViewer().getDocument(); | 1227 IDocument doc= fTargets[i].getViewer().getDocument(); |
1182 if (doc !is null) | 1228 if (doc !is null) |
1183 docs.add(doc); | 1229 docs.add(cast(Object)doc); |
1184 } | 1230 } |
1185 | 1231 |
1186 fModel.stopForwarding(flags); | 1232 fModel.stopForwarding(flags); |
1187 | 1233 |
1188 Runnable runnable= new class() Runnable { | 1234 Runnable runnable= dgRunnable( (int flags_){ |
1189 public void run() { | 1235 if (fExitPosition !is null) |
1190 if (fExitPosition !is null) | 1236 fExitPosition.getDocument().removePosition(fExitPosition); |
1191 fExitPosition.getDocument().removePosition(fExitPosition); | 1237 |
1192 | 1238 for (Iterator iter = docs.iterator(); iter.hasNext(); ) { |
1193 for (Iterator iter = docs.iterator(); iter.hasNext(); ) { | 1239 IDocument doc= cast(IDocument) iter.next(); |
1194 IDocument doc= cast(IDocument) iter.next(); | 1240 doc.removePositionUpdater(fPositionUpdater); |
1195 doc.removePositionUpdater(fPositionUpdater); | 1241 bool uninstallCat= false; |
1196 bool uninstallCat= false; | 1242 String[] cats= doc.getPositionCategories(); |
1197 String[] cats= doc.getPositionCategories(); | 1243 for (int j= 0; j < cats.length; j++) { |
1198 for (int j= 0; j < cats.length; j++) { | 1244 if (getCategory().equals(cats[j])) { |
1199 if (getCategory().equals(cats[j])) { | 1245 uninstallCat= true; |
1200 uninstallCat= true; | 1246 break; |
1201 break; | |
1202 } | |
1203 } | 1247 } |
1204 if (uninstallCat) | |
1205 try { | |
1206 doc.removePositionCategory(getCategory()); | |
1207 } catch (BadPositionCategoryException e) { | |
1208 // ignore | |
1209 } | |
1210 } | 1248 } |
1211 fModel.exit(flags); | 1249 if (uninstallCat) |
1212 } | 1250 try { |
1213 }; | 1251 doc.removePositionCategory(getCategory()); |
1252 } catch (BadPositionCategoryException e) { | |
1253 // ignore | |
1254 } | |
1255 } | |
1256 fModel.exit(flags_); | |
1257 }, flags ); | |
1214 | 1258 |
1215 // remove positions (both exit positions AND linked positions in the | 1259 // remove positions (both exit positions AND linked positions in the |
1216 // model) asynchronously to make sure that the annotation painter | 1260 // model) asynchronously to make sure that the annotation painter |
1217 // gets correct document offsets. | 1261 // gets correct document offsets. |
1218 if (display !is null) | 1262 if (display !is null) |
1276 * </p> | 1320 * </p> |
1277 * | 1321 * |
1278 * @param listener the new listener, never <code>null</code>. | 1322 * @param listener the new listener, never <code>null</code>. |
1279 */ | 1323 */ |
1280 protected void setPositionListener(ILinkedModeUIFocusListener listener) { | 1324 protected void setPositionListener(ILinkedModeUIFocusListener listener) { |
1281 Assert.isNotNull(listener); | 1325 Assert.isNotNull(cast(Object)listener); |
1282 fPositionListener= listener; | 1326 fPositionListener= listener; |
1283 } | 1327 } |
1284 | 1328 |
1285 /** | 1329 /** |
1286 * Sets the "simple" mode of the receiver. A linked mode UI in simple mode | 1330 * Sets the "simple" mode of the receiver. A linked mode UI in simple mode |