Mercurial > projects > dwt-addons
comparison dwtx/jface/text/TextViewer.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 | 65801ad2b265 |
comparison
equal
deleted
inserted
replaced
133:7d818bd32d63 | 134:51e6e63f930e |
---|---|
297 | 297 |
298 if (length !is 0) { | 298 if (length !is 0) { |
299 try { | 299 try { |
300 | 300 |
301 if (e instanceof SlaveDocumentEvent) { | 301 if (e instanceof SlaveDocumentEvent) { |
302 SlaveDocumentEvent slave= (SlaveDocumentEvent) e; | 302 SlaveDocumentEvent slave= cast(SlaveDocumentEvent) e; |
303 DocumentEvent master= slave.getMasterEvent(); | 303 DocumentEvent master= slave.getMasterEvent(); |
304 if (master !is null) | 304 if (master !is null) |
305 preservedText= master.getDocument().get(master.getOffset(), master.getLength()); | 305 preservedText= master.getDocument().get(master.getOffset(), master.getLength()); |
306 } else { | 306 } else { |
307 preservedText= e.getDocument().get(e.getOffset(), e.getLength()); | 307 preservedText= e.getDocument().get(e.getOffset(), e.getLength()); |
308 } | 308 } |
309 | 309 |
310 } catch (BadLocationException x) { | 310 } catch (BadLocationException x) { |
311 preservedText= null; | 311 preservedText= null; |
312 if (TRACE_ERRORS) | 312 if cast(TRACE_ERRORS) |
313 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.WidgetCommand.setEvent")); //$NON-NLS-1$ | 313 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.WidgetCommand.setEvent")); //$NON-NLS-1$ |
314 } | 314 } |
315 } else | 315 } else |
316 preservedText= null; | 316 preservedText= null; |
317 } | 317 } |
342 */ | 342 */ |
343 public void getNextOffset(MovementEvent event) { | 343 public void getNextOffset(MovementEvent event) { |
344 if (event.movement !is DWT.MOVEMENT_WORD_END) | 344 if (event.movement !is DWT.MOVEMENT_WORD_END) |
345 return; | 345 return; |
346 | 346 |
347 if (TRACE_DOUBLE_CLICK) { | 347 if cast(TRACE_DOUBLE_CLICK) { |
348 System.out.println("\n+++"); //$NON-NLS-1$ | 348 System.out.println("\n+++"); //$NON-NLS-1$ |
349 print(event); | 349 print(event); |
350 } | 350 } |
351 | 351 |
352 if (fDoubleClickSelection !is null) { | 352 if (fDoubleClickSelection !is null) { |
361 */ | 361 */ |
362 public void getPreviousOffset(MovementEvent event) { | 362 public void getPreviousOffset(MovementEvent event) { |
363 if (event.movement !is DWT.MOVEMENT_WORD_START) | 363 if (event.movement !is DWT.MOVEMENT_WORD_START) |
364 return; | 364 return; |
365 | 365 |
366 if (TRACE_DOUBLE_CLICK) { | 366 if cast(TRACE_DOUBLE_CLICK) { |
367 System.out.println("\n---"); //$NON-NLS-1$ | 367 System.out.println("\n---"); //$NON-NLS-1$ |
368 print(event); | 368 print(event); |
369 } | 369 } |
370 if (fDoubleClickSelection is null) { | 370 if (fDoubleClickSelection is null) { |
371 ITextDoubleClickStrategy s= (ITextDoubleClickStrategy) selectContentTypePlugin(getSelectedRange().x, fDoubleClickStrategies); | 371 ITextDoubleClickStrategy s= cast(ITextDoubleClickStrategy) selectContentTypePlugin(getSelectedRange().x, fDoubleClickStrategies); |
372 if (s !is null) { | 372 if (s !is null) { |
373 StyledText textWidget= getTextWidget(); | 373 StyledText textWidget= getTextWidget(); |
374 s.doubleClicked(TextViewer.this); | 374 s.doubleClicked(TextViewer.this); |
375 fDoubleClickSelection= textWidget.getSelection(); | 375 fDoubleClickSelection= textWidget.getSelection(); |
376 event.newOffset= fDoubleClickSelection.x; | 376 event.newOffset= fDoubleClickSelection.x; |
377 if (TRACE_DOUBLE_CLICK) | 377 if cast(TRACE_DOUBLE_CLICK) |
378 System.out.println("- setting selection: x= " + fDoubleClickSelection.x + ", y= " + fDoubleClickSelection.y); //$NON-NLS-1$ //$NON-NLS-2$ | 378 System.out.println("- setting selection: x= " + fDoubleClickSelection.x + ", y= " + fDoubleClickSelection.y); //$NON-NLS-1$ //$NON-NLS-2$ |
379 } | 379 } |
380 } else { | 380 } else { |
381 if (fDoubleClickSelection.x <= event.offset && event.offset <= fDoubleClickSelection.y) | 381 if (fDoubleClickSelection.x <= event.offset && event.offset <= fDoubleClickSelection.y) |
382 event.newOffset= fDoubleClickSelection.x; | 382 event.newOffset= fDoubleClickSelection.x; |
612 | 612 |
613 try { | 613 try { |
614 fReentranceCount++; | 614 fReentranceCount++; |
615 Iterator iterator= fListeners.iterator(); | 615 Iterator iterator= fListeners.iterator(); |
616 while (iterator.hasNext() && event.doit) { | 616 while (iterator.hasNext() && event.doit) { |
617 VerifyKeyListener listener= (VerifyKeyListener) iterator.next(); | 617 VerifyKeyListener listener= cast(VerifyKeyListener) iterator.next(); |
618 listener.verifyKey(event); // we might trigger reentrant calls on GTK | 618 listener.verifyKey(event); // we might trigger reentrant calls on GTK |
619 } | 619 } |
620 } finally { | 620 } finally { |
621 fReentranceCount--; | 621 fReentranceCount--; |
622 } | 622 } |
629 */ | 629 */ |
630 private void processBatchedRequests() { | 630 private void processBatchedRequests() { |
631 if (!fBatched.isEmpty()) { | 631 if (!fBatched.isEmpty()) { |
632 Iterator e= fBatched.iterator(); | 632 Iterator e= fBatched.iterator(); |
633 while (e.hasNext()) { | 633 while (e.hasNext()) { |
634 Batch batch= (Batch) e.next(); | 634 Batch batch= cast(Batch) e.next(); |
635 insertListener(batch.listener, batch.index); | 635 insertListener(batch.listener, batch.index); |
636 } | 636 } |
637 fBatched.clear(); | 637 fBatched.clear(); |
638 } | 638 } |
639 } | 639 } |
1124 IDocument document= TextViewer.this.getDocument(); | 1124 IDocument document= TextViewer.this.getDocument(); |
1125 | 1125 |
1126 if (replaceAll) { | 1126 if (replaceAll) { |
1127 | 1127 |
1128 if (document instanceof IDocumentExtension4) { | 1128 if (document instanceof IDocumentExtension4) { |
1129 IDocumentExtension4 extension= (IDocumentExtension4) document; | 1129 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
1130 fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); | 1130 fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); |
1131 } else { | 1131 } else { |
1132 TextViewer.this.setRedraw(false); | 1132 TextViewer.this.setRedraw(false); |
1133 TextViewer.this.startSequentialRewriteMode(false); | 1133 TextViewer.this.startSequentialRewriteMode(false); |
1134 | 1134 |
1139 } | 1139 } |
1140 | 1140 |
1141 } else { | 1141 } else { |
1142 | 1142 |
1143 if (document instanceof IDocumentExtension4) { | 1143 if (document instanceof IDocumentExtension4) { |
1144 IDocumentExtension4 extension= (IDocumentExtension4) document; | 1144 IDocumentExtension4 extension= cast(IDocumentExtension4) document; |
1145 extension.stopRewriteSession(fRewriteSession); | 1145 extension.stopRewriteSession(fRewriteSession); |
1146 } else { | 1146 } else { |
1147 TextViewer.this.setRedraw(true); | 1147 TextViewer.this.setRedraw(true); |
1148 TextViewer.this.stopSequentialRewriteMode(); | 1148 TextViewer.this.stopSequentialRewriteMode(); |
1149 | 1149 |
1225 * @see java.lang.Object#equals(java.lang.Object) | 1225 * @see java.lang.Object#equals(java.lang.Object) |
1226 */ | 1226 */ |
1227 public bool equals(Object obj) { | 1227 public bool equals(Object obj) { |
1228 if (obj is null || obj.getClass() !is getClass()) | 1228 if (obj is null || obj.getClass() !is getClass()) |
1229 return false; | 1229 return false; |
1230 TextHoverKey textHoverKey= (TextHoverKey)obj; | 1230 TextHoverKey textHoverKey= cast(TextHoverKey)obj; |
1231 return textHoverKey.fContentType.equals(fContentType) && textHoverKey.fStateMask is fStateMask; | 1231 return textHoverKey.fContentType.equals(fContentType) && textHoverKey.fStateMask is fStateMask; |
1232 } | 1232 } |
1233 | 1233 |
1234 /* | 1234 /* |
1235 * @see java.lang.Object#hashCode() | 1235 * @see java.lang.Object#hashCode() |
2097 */ | 2097 */ |
2098 protected final void setAutoEditStrategies(IAutoEditStrategy[] strategies, String contentType) { | 2098 protected final void setAutoEditStrategies(IAutoEditStrategy[] strategies, String contentType) { |
2099 if (fAutoIndentStrategies is null) | 2099 if (fAutoIndentStrategies is null) |
2100 fAutoIndentStrategies= new HashMap(); | 2100 fAutoIndentStrategies= new HashMap(); |
2101 | 2101 |
2102 List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType); | 2102 List autoEditStrategies= cast(List) fAutoIndentStrategies.get(contentType); |
2103 | 2103 |
2104 if (strategies is null) { | 2104 if (strategies is null) { |
2105 if (autoEditStrategies is null) | 2105 if (autoEditStrategies is null) |
2106 return; | 2106 return; |
2107 | 2107 |
2128 throw new IllegalArgumentException(); | 2128 throw new IllegalArgumentException(); |
2129 | 2129 |
2130 if (fAutoIndentStrategies is null) | 2130 if (fAutoIndentStrategies is null) |
2131 fAutoIndentStrategies= new HashMap(); | 2131 fAutoIndentStrategies= new HashMap(); |
2132 | 2132 |
2133 List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType); | 2133 List autoEditStrategies= cast(List) fAutoIndentStrategies.get(contentType); |
2134 if (autoEditStrategies is null) { | 2134 if (autoEditStrategies is null) { |
2135 autoEditStrategies= new ArrayList(); | 2135 autoEditStrategies= new ArrayList(); |
2136 fAutoIndentStrategies.put(contentType, autoEditStrategies); | 2136 fAutoIndentStrategies.put(contentType, autoEditStrategies); |
2137 } | 2137 } |
2138 | 2138 |
2145 */ | 2145 */ |
2146 public void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType) { | 2146 public void removeAutoEditStrategy(IAutoEditStrategy strategy, String contentType) { |
2147 if (fAutoIndentStrategies is null) | 2147 if (fAutoIndentStrategies is null) |
2148 return; | 2148 return; |
2149 | 2149 |
2150 List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType); | 2150 List autoEditStrategies= cast(List) fAutoIndentStrategies.get(contentType); |
2151 if (autoEditStrategies is null) | 2151 if (autoEditStrategies is null) |
2152 return; | 2152 return; |
2153 | 2153 |
2154 for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) { | 2154 for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) { |
2155 if (iterator.next().equals(strategy)) { | 2155 if (iterator.next().equals(strategy)) { |
2275 if (fTextHovers is null) | 2275 if (fTextHovers is null) |
2276 return; | 2276 return; |
2277 | 2277 |
2278 Iterator iter= new HashSet(fTextHovers.keySet()).iterator(); | 2278 Iterator iter= new HashSet(fTextHovers.keySet()).iterator(); |
2279 while (iter.hasNext()) { | 2279 while (iter.hasNext()) { |
2280 TextHoverKey key= (TextHoverKey)iter.next(); | 2280 TextHoverKey key= cast(TextHoverKey)iter.next(); |
2281 if (key.fContentType.equals(contentType)) | 2281 if (key.fContentType.equals(contentType)) |
2282 fTextHovers.remove(key); | 2282 fTextHovers.remove(key); |
2283 } | 2283 } |
2284 } | 2284 } |
2285 | 2285 |
2315 if (textHover is null) { | 2315 if (textHover is null) { |
2316 // Use default text hover | 2316 // Use default text hover |
2317 key.setStateMask(ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); | 2317 key.setStateMask(ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK); |
2318 textHover= fTextHovers.get(key); | 2318 textHover= fTextHovers.get(key); |
2319 } | 2319 } |
2320 return (ITextHover) textHover; | 2320 return cast(ITextHover) textHover; |
2321 } catch (BadLocationException x) { | 2321 } catch (BadLocationException x) { |
2322 if (TRACE_ERRORS) | 2322 if cast(TRACE_ERRORS) |
2323 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$ | 2323 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$ |
2324 } | 2324 } |
2325 return null; | 2325 return null; |
2326 } | 2326 } |
2327 | 2327 |
2388 if (fWidgetTokenKeeper is requester) | 2388 if (fWidgetTokenKeeper is requester) |
2389 return true; | 2389 return true; |
2390 | 2390 |
2391 bool accepted= false; | 2391 bool accepted= false; |
2392 if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) { | 2392 if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) { |
2393 IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper; | 2393 IWidgetTokenKeeperExtension extension= cast(IWidgetTokenKeeperExtension) fWidgetTokenKeeper; |
2394 accepted= extension.requestWidgetToken(this, priority); | 2394 accepted= extension.requestWidgetToken(this, priority); |
2395 } else { | 2395 } else { |
2396 accepted= fWidgetTokenKeeper.requestWidgetToken(this); | 2396 accepted= fWidgetTokenKeeper.requestWidgetToken(this); |
2397 } | 2397 } |
2398 | 2398 |
2549 /* | 2549 /* |
2550 * @see Viewer#setSelection(ISelection) | 2550 * @see Viewer#setSelection(ISelection) |
2551 */ | 2551 */ |
2552 public void setSelection(ISelection selection, bool reveal) { | 2552 public void setSelection(ISelection selection, bool reveal) { |
2553 if (selection instanceof ITextSelection) { | 2553 if (selection instanceof ITextSelection) { |
2554 ITextSelection s= (ITextSelection) selection; | 2554 ITextSelection s= cast(ITextSelection) selection; |
2555 setSelectedRange(s.getOffset(), s.getLength()); | 2555 setSelectedRange(s.getOffset(), s.getLength()); |
2556 if (reveal) | 2556 if (reveal) |
2557 revealRange(s.getOffset(), s.getLength()); | 2557 revealRange(s.getOffset(), s.getLength()); |
2558 } | 2558 } |
2559 } | 2559 } |
2712 private void firePostSelectionChanged(SelectionChangedEvent event) { | 2712 private void firePostSelectionChanged(SelectionChangedEvent event) { |
2713 List listeners= fPostSelectionChangedListeners; | 2713 List listeners= fPostSelectionChangedListeners; |
2714 if (listeners !is null) { | 2714 if (listeners !is null) { |
2715 listeners= new ArrayList(listeners); | 2715 listeners= new ArrayList(listeners); |
2716 for (int i= 0; i < listeners.size(); i++) { | 2716 for (int i= 0; i < listeners.size(); i++) { |
2717 ISelectionChangedListener l= (ISelectionChangedListener) listeners.get(i); | 2717 ISelectionChangedListener l= cast(ISelectionChangedListener) listeners.get(i); |
2718 l.selectionChanged(event); | 2718 l.selectionChanged(event); |
2719 } | 2719 } |
2720 } | 2720 } |
2721 } | 2721 } |
2722 | 2722 |
2783 List textListeners= fTextListeners; | 2783 List textListeners= fTextListeners; |
2784 if (textListeners !is null) { | 2784 if (textListeners !is null) { |
2785 textListeners= new ArrayList(textListeners); | 2785 textListeners= new ArrayList(textListeners); |
2786 DocumentEvent event= cmd.event; | 2786 DocumentEvent event= cmd.event; |
2787 if (event instanceof SlaveDocumentEvent) | 2787 if (event instanceof SlaveDocumentEvent) |
2788 event= ((SlaveDocumentEvent) event).getMasterEvent(); | 2788 event= (cast(SlaveDocumentEvent) event).getMasterEvent(); |
2789 | 2789 |
2790 TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws()); | 2790 TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws()); |
2791 for (int i= 0; i < textListeners.size(); i++) { | 2791 for (int i= 0; i < textListeners.size(); i++) { |
2792 ITextListener l= (ITextListener) textListeners.get(i); | 2792 ITextListener l= cast(ITextListener) textListeners.get(i); |
2793 l.textChanged(e); | 2793 l.textChanged(e); |
2794 } | 2794 } |
2795 } | 2795 } |
2796 } | 2796 } |
2797 | 2797 |
2834 */ | 2834 */ |
2835 protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { | 2835 protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { |
2836 List listener= fTextInputListeners; | 2836 List listener= fTextInputListeners; |
2837 if (listener !is null) { | 2837 if (listener !is null) { |
2838 for (int i= 0; i < listener.size(); i++) { | 2838 for (int i= 0; i < listener.size(); i++) { |
2839 ITextInputListener l= (ITextInputListener) listener.get(i); | 2839 ITextInputListener l= cast(ITextInputListener) listener.get(i); |
2840 l.inputDocumentAboutToBeChanged(oldInput, newInput); | 2840 l.inputDocumentAboutToBeChanged(oldInput, newInput); |
2841 } | 2841 } |
2842 } | 2842 } |
2843 } | 2843 } |
2844 | 2844 |
2851 */ | 2851 */ |
2852 protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) { | 2852 protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) { |
2853 List listener= fTextInputListeners; | 2853 List listener= fTextInputListeners; |
2854 if (listener !is null) { | 2854 if (listener !is null) { |
2855 for (int i= 0; i < listener.size(); i++) { | 2855 for (int i= 0; i < listener.size(); i++) { |
2856 ITextInputListener l= (ITextInputListener) listener.get(i); | 2856 ITextInputListener l= cast(ITextInputListener) listener.get(i); |
2857 l.inputDocumentChanged(oldInput, newInput); | 2857 l.inputDocumentChanged(oldInput, newInput); |
2858 } | 2858 } |
2859 } | 2859 } |
2860 } | 2860 } |
2861 | 2861 |
2880 */ | 2880 */ |
2881 public void setInput(Object input) { | 2881 public void setInput(Object input) { |
2882 | 2882 |
2883 IDocument document= null; | 2883 IDocument document= null; |
2884 if (input instanceof IDocument) | 2884 if (input instanceof IDocument) |
2885 document= (IDocument) input; | 2885 document= cast(IDocument) input; |
2886 | 2886 |
2887 setDocument(document); | 2887 setDocument(document); |
2888 } | 2888 } |
2889 | 2889 |
2890 /* | 2890 /* |
2966 * @since 2.1 | 2966 * @since 2.1 |
2967 * @deprecated use <code>updateSlaveDocument</code> instead | 2967 * @deprecated use <code>updateSlaveDocument</code> instead |
2968 */ | 2968 */ |
2969 protected bool updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException { | 2969 protected bool updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException { |
2970 if (visibleDocument instanceof ChildDocument) { | 2970 if (visibleDocument instanceof ChildDocument) { |
2971 ChildDocument childDocument= (ChildDocument) visibleDocument; | 2971 ChildDocument childDocument= cast(ChildDocument) visibleDocument; |
2972 | 2972 |
2973 IDocument document= childDocument.getParentDocument(); | 2973 IDocument document= childDocument.getParentDocument(); |
2974 int line= document.getLineOfOffset(visibleRegionOffset); | 2974 int line= document.getLineOfOffset(visibleRegionOffset); |
2975 int offset= document.getLineOffset(line); | 2975 int offset= document.getLineOffset(line); |
2976 int length= (visibleRegionOffset - offset) + visibleRegionLength; | 2976 int length= (visibleRegionOffset - offset) + visibleRegionLength; |
3078 if (redraws()) { | 3078 if (redraws()) { |
3079 int topPixel= fTextWidget.getTopPixel(); | 3079 int topPixel= fTextWidget.getTopPixel(); |
3080 if (topPixel >= 0 && topPixel !is fLastTopPixel) { | 3080 if (topPixel >= 0 && topPixel !is fLastTopPixel) { |
3081 if (fViewportListeners !is null) { | 3081 if (fViewportListeners !is null) { |
3082 for (int i= 0; i < fViewportListeners.size(); i++) { | 3082 for (int i= 0; i < fViewportListeners.size(); i++) { |
3083 IViewportListener l= (IViewportListener) fViewportListeners.get(i); | 3083 IViewportListener l= cast(IViewportListener) fViewportListeners.get(i); |
3084 l.viewportChanged(topPixel); | 3084 l.viewportChanged(topPixel); |
3085 } | 3085 } |
3086 } | 3086 } |
3087 fLastTopPixel= topPixel; | 3087 fLastTopPixel= topPixel; |
3088 } | 3088 } |
3162 int top= fTextWidget.getTopIndex(); | 3162 int top= fTextWidget.getTopIndex(); |
3163 try { | 3163 try { |
3164 top= getVisibleDocument().getLineOffset(top); | 3164 top= getVisibleDocument().getLineOffset(top); |
3165 return widgetOffset2ModelOffset(top); | 3165 return widgetOffset2ModelOffset(top); |
3166 } catch (BadLocationException ex) { | 3166 } catch (BadLocationException ex) { |
3167 if (TRACE_ERRORS) | 3167 if cast(TRACE_ERRORS) |
3168 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getTopIndexStartOffset")); //$NON-NLS-1$ | 3168 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getTopIndexStartOffset")); //$NON-NLS-1$ |
3169 } | 3169 } |
3170 } | 3170 } |
3171 | 3171 |
3172 return -1; | 3172 return -1; |
3187 | 3187 |
3188 int coverageEndOffset= coverage.getOffset() + coverage.getLength() - 1; | 3188 int coverageEndOffset= coverage.getOffset() + coverage.getLength() - 1; |
3189 return Math.min(coverageEndOffset, bottomEndOffset); | 3189 return Math.min(coverageEndOffset, bottomEndOffset); |
3190 | 3190 |
3191 } catch (BadLocationException ex) { | 3191 } catch (BadLocationException ex) { |
3192 if (TRACE_ERRORS) | 3192 if cast(TRACE_ERRORS) |
3193 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndexEndOffset")); //$NON-NLS-1$ | 3193 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getBottomIndexEndOffset")); //$NON-NLS-1$ |
3194 return getDocument().getLength() - 1; | 3194 return getDocument().getLength() - 1; |
3195 } | 3195 } |
3196 } | 3196 } |
3197 | 3197 |
3298 else if (selectionPixelWidth + bufferZone < visibleWidth) | 3298 else if (selectionPixelWidth + bufferZone < visibleWidth) |
3299 newOffset= endPixel + bufferZone - visibleWidth; | 3299 newOffset= endPixel + bufferZone - visibleWidth; |
3300 else | 3300 else |
3301 newOffset= startPixel; | 3301 newOffset= startPixel; |
3302 | 3302 |
3303 float index= ((float)newOffset) / ((float)getAverageCharWidth()); | 3303 float index= (cast(float)newOffset) / (cast(float)getAverageCharWidth()); |
3304 | 3304 |
3305 fTextWidget.setHorizontalIndex(Math.round(index)); | 3305 fTextWidget.setHorizontalIndex(Math.round(index)); |
3306 } | 3306 } |
3307 | 3307 |
3308 } | 3308 } |
3553 */ | 3553 */ |
3554 protected int _getVisibleRegionOffset() { | 3554 protected int _getVisibleRegionOffset() { |
3555 | 3555 |
3556 IDocument document= getVisibleDocument(); | 3556 IDocument document= getVisibleDocument(); |
3557 if (document instanceof ChildDocument) { | 3557 if (document instanceof ChildDocument) { |
3558 ChildDocument cdoc= (ChildDocument) document; | 3558 ChildDocument cdoc= cast(ChildDocument) document; |
3559 return cdoc.getParentDocumentRange().getOffset(); | 3559 return cdoc.getParentDocumentRange().getOffset(); |
3560 } | 3560 } |
3561 | 3561 |
3562 return 0; | 3562 return 0; |
3563 } | 3563 } |
3567 */ | 3567 */ |
3568 public IRegion getVisibleRegion() { | 3568 public IRegion getVisibleRegion() { |
3569 | 3569 |
3570 IDocument document= getVisibleDocument(); | 3570 IDocument document= getVisibleDocument(); |
3571 if (document instanceof ChildDocument) { | 3571 if (document instanceof ChildDocument) { |
3572 Position p= ((ChildDocument) document).getParentDocumentRange(); | 3572 Position p= (cast(ChildDocument) document).getParentDocumentRange(); |
3573 return new Region(p.getOffset(), p.getLength()); | 3573 return new Region(p.getOffset(), p.getLength()); |
3574 } | 3574 } |
3575 | 3575 |
3576 return new Region(0, document is null ? 0 : document.getLength()); | 3576 return new Region(0, document is null ? 0 : document.getLength()); |
3577 } | 3577 } |
3580 * @see ITextViewer#overlapsWithVisibleRegion(int, int) | 3580 * @see ITextViewer#overlapsWithVisibleRegion(int, int) |
3581 */ | 3581 */ |
3582 public bool overlapsWithVisibleRegion(int start, int length) { | 3582 public bool overlapsWithVisibleRegion(int start, int length) { |
3583 IDocument document= getVisibleDocument(); | 3583 IDocument document= getVisibleDocument(); |
3584 if (document instanceof ChildDocument) { | 3584 if (document instanceof ChildDocument) { |
3585 ChildDocument cdoc= (ChildDocument) document; | 3585 ChildDocument cdoc= cast(ChildDocument) document; |
3586 return cdoc.getParentDocumentRange().overlapsWith(start, length); | 3586 return cdoc.getParentDocumentRange().overlapsWith(start, length); |
3587 } else if (document !is null) { | 3587 } else if (document !is null) { |
3588 int size= document.getLength(); | 3588 int size= document.getLength(); |
3589 return (start >= 0 && length >= 0 && start + length <= size); | 3589 return (start >= 0 && length >= 0 && start + length <= size); |
3590 } | 3590 } |
3657 */ | 3657 */ |
3658 protected Object selectContentTypePlugin(int offset, Map plugins) { | 3658 protected Object selectContentTypePlugin(int offset, Map plugins) { |
3659 try { | 3659 try { |
3660 return selectContentTypePlugin(TextUtilities.getContentType(getDocument(), getDocumentPartitioning(), offset, true), plugins); | 3660 return selectContentTypePlugin(TextUtilities.getContentType(getDocument(), getDocumentPartitioning(), offset, true), plugins); |
3661 } catch (BadLocationException x) { | 3661 } catch (BadLocationException x) { |
3662 if (TRACE_ERRORS) | 3662 if cast(TRACE_ERRORS) |
3663 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$ | 3663 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.selectContentTypePlugin")); //$NON-NLS-1$ |
3664 } | 3664 } |
3665 return null; | 3665 return null; |
3666 } | 3666 } |
3667 | 3667 |
3696 IDocument document= getDocument(); | 3696 IDocument document= getDocument(); |
3697 | 3697 |
3698 if (fTabsToSpacesConverter !is null) | 3698 if (fTabsToSpacesConverter !is null) |
3699 fTabsToSpacesConverter.customizeDocumentCommand(document, command); | 3699 fTabsToSpacesConverter.customizeDocumentCommand(document, command); |
3700 | 3700 |
3701 List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies); | 3701 List strategies= cast(List) selectContentTypePlugin(command.offset, fAutoIndentStrategies); |
3702 if (strategies is null) | 3702 if (strategies is null) |
3703 return; | 3703 return; |
3704 | 3704 |
3705 switch (strategies.size()) { | 3705 switch (strategies.size()) { |
3706 // optimization | 3706 // optimization |
3707 case 0: | 3707 case 0: |
3708 break; | 3708 break; |
3709 | 3709 |
3710 case 1: | 3710 case 1: |
3711 ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(document, command); | 3711 (cast(IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(document, command); |
3712 break; | 3712 break; |
3713 | 3713 |
3714 // make iterator robust against adding/removing strategies from within strategies | 3714 // make iterator robust against adding/removing strategies from within strategies |
3715 default: | 3715 default: |
3716 strategies= new ArrayList(strategies); | 3716 strategies= new ArrayList(strategies); |
3717 for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); ) | 3717 for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); ) |
3718 ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command); | 3718 (cast(IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command); |
3719 | 3719 |
3720 break; | 3720 break; |
3721 } | 3721 } |
3722 } | 3722 } |
3723 | 3723 |
3776 | 3776 |
3777 fTextWidget.showSelection(); | 3777 fTextWidget.showSelection(); |
3778 } | 3778 } |
3779 } catch (BadLocationException x) { | 3779 } catch (BadLocationException x) { |
3780 | 3780 |
3781 if (TRACE_ERRORS) | 3781 if cast(TRACE_ERRORS) |
3782 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$ | 3782 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$ |
3783 | 3783 |
3784 } finally { | 3784 } finally { |
3785 | 3785 |
3786 if (compoundChange && fUndoManager !is null) | 3786 if (compoundChange && fUndoManager !is null) |
3932 | 3932 |
3933 fIgnoreAutoIndent= ignore; | 3933 fIgnoreAutoIndent= ignore; |
3934 | 3934 |
3935 IDocument document= getDocument(); | 3935 IDocument document= getDocument(); |
3936 if (document instanceof IDocumentExtension2) { | 3936 if (document instanceof IDocumentExtension2) { |
3937 IDocumentExtension2 extension= (IDocumentExtension2) document; | 3937 IDocumentExtension2 extension= cast(IDocumentExtension2) document; |
3938 if (ignore) | 3938 if (ignore) |
3939 extension.ignorePostNotificationReplaces(); | 3939 extension.ignorePostNotificationReplaces(); |
3940 else | 3940 else |
3941 extension.acceptPostNotificationReplaces(); | 3941 extension.acceptPostNotificationReplaces(); |
3942 } | 3942 } |
4075 | 4075 |
4076 offset= d.getLineOffset(startLine + 1); | 4076 offset= d.getLineOffset(startLine + 1); |
4077 return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1); | 4077 return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1); |
4078 | 4078 |
4079 } catch (BadLocationException x) { | 4079 } catch (BadLocationException x) { |
4080 if (TRACE_ERRORS) | 4080 if cast(TRACE_ERRORS) |
4081 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getFirstCompleteLineOfRegion")); //$NON-NLS-1$ | 4081 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.getFirstCompleteLineOfRegion")); //$NON-NLS-1$ |
4082 } | 4082 } |
4083 | 4083 |
4084 return -1; | 4084 return -1; |
4085 } | 4085 } |
4155 lines[j + 1]= (lines[j] is -1 ? -1 : d.getLineOfOffset(offset)); | 4155 lines[j + 1]= (lines[j] is -1 ? -1 : d.getLineOfOffset(offset)); |
4156 lineCount += lines[j + 1] - lines[j] + 1; | 4156 lineCount += lines[j + 1] - lines[j] + 1; |
4157 } | 4157 } |
4158 | 4158 |
4159 if (d instanceof IDocumentExtension4) { | 4159 if (d instanceof IDocumentExtension4) { |
4160 IDocumentExtension4 extension= (IDocumentExtension4) d; | 4160 IDocumentExtension4 extension= cast(IDocumentExtension4) d; |
4161 rewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); | 4161 rewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL); |
4162 } else { | 4162 } else { |
4163 setRedraw(false); | 4163 setRedraw(false); |
4164 startSequentialRewriteMode(true); | 4164 startSequentialRewriteMode(true); |
4165 } | 4165 } |
4177 shiftLeft(lines[j], lines[j + 1], prefixes, ignoreWhitespace); | 4177 shiftLeft(lines[j], lines[j + 1], prefixes, ignoreWhitespace); |
4178 } | 4178 } |
4179 } | 4179 } |
4180 | 4180 |
4181 } catch (BadLocationException x) { | 4181 } catch (BadLocationException x) { |
4182 if (TRACE_ERRORS) | 4182 if cast(TRACE_ERRORS) |
4183 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.shift_1")); //$NON-NLS-1$ | 4183 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.shift_1")); //$NON-NLS-1$ |
4184 | 4184 |
4185 } finally { | 4185 } finally { |
4186 | 4186 |
4187 if (partitioners !is null) | 4187 if (partitioners !is null) |
4188 TextUtilities.addDocumentPartitioners(d, partitioners); | 4188 TextUtilities.addDocumentPartitioners(d, partitioners); |
4189 | 4189 |
4190 if (d instanceof IDocumentExtension4) { | 4190 if (d instanceof IDocumentExtension4) { |
4191 IDocumentExtension4 extension= (IDocumentExtension4) d; | 4191 IDocumentExtension4 extension= cast(IDocumentExtension4) d; |
4192 extension.stopRewriteSession(rewriteSession); | 4192 extension.stopRewriteSession(rewriteSession); |
4193 } else { | 4193 } else { |
4194 stopSequentialRewriteMode(); | 4194 stopSequentialRewriteMode(); |
4195 setRedraw(true); | 4195 setRedraw(true); |
4196 } | 4196 } |
4217 while (startLine <= endLine) { | 4217 while (startLine <= endLine) { |
4218 d.replace(d.getLineOffset(startLine++), 0, prefix); | 4218 d.replace(d.getLineOffset(startLine++), 0, prefix); |
4219 } | 4219 } |
4220 | 4220 |
4221 } catch (BadLocationException x) { | 4221 } catch (BadLocationException x) { |
4222 if (TRACE_ERRORS) | 4222 if cast(TRACE_ERRORS) |
4223 System.out.println("TextViewer.shiftRight: BadLocationException"); //$NON-NLS-1$ | 4223 System.out.println("TextViewer.shiftRight: BadLocationException"); //$NON-NLS-1$ |
4224 } | 4224 } |
4225 } | 4225 } |
4226 | 4226 |
4227 /** | 4227 /** |
4283 d.replace(r.getOffset() - decrement, r.getLength(), ""); //$NON-NLS-1$ | 4283 d.replace(r.getOffset() - decrement, r.getLength(), ""); //$NON-NLS-1$ |
4284 decrement += r.getLength(); | 4284 decrement += r.getLength(); |
4285 } | 4285 } |
4286 | 4286 |
4287 } catch (BadLocationException x) { | 4287 } catch (BadLocationException x) { |
4288 if (TRACE_ERRORS) | 4288 if cast(TRACE_ERRORS) |
4289 System.out.println("TextViewer.shiftLeft: BadLocationException"); //$NON-NLS-1$ | 4289 System.out.println("TextViewer.shiftLeft: BadLocationException"); //$NON-NLS-1$ |
4290 } | 4290 } |
4291 } | 4291 } |
4292 | 4292 |
4293 /** | 4293 /** |
4417 | 4417 |
4418 return widgetOffset2ModelOffset(widgetPos); | 4418 return widgetOffset2ModelOffset(widgetPos); |
4419 } | 4419 } |
4420 | 4420 |
4421 } catch (BadLocationException x) { | 4421 } catch (BadLocationException x) { |
4422 if (TRACE_ERRORS) | 4422 if cast(TRACE_ERRORS) |
4423 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$ | 4423 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$ |
4424 } | 4424 } |
4425 | 4425 |
4426 return -1; | 4426 return -1; |
4427 } | 4427 } |
4495 return modelPos; | 4495 return modelPos; |
4496 } | 4496 } |
4497 | 4497 |
4498 | 4498 |
4499 } catch (BadLocationException x) { | 4499 } catch (BadLocationException x) { |
4500 if (TRACE_ERRORS) | 4500 if cast(TRACE_ERRORS) |
4501 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$ | 4501 System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.findAndSelect")); //$NON-NLS-1$ |
4502 } | 4502 } |
4503 | 4503 |
4504 return -1; | 4504 return -1; |
4505 } | 4505 } |
4554 fTextWidget.setStyleRange(range); | 4554 fTextWidget.setStyleRange(range); |
4555 | 4555 |
4556 ArrayList ranges= new ArrayList(presentation.getDenumerableRanges()); | 4556 ArrayList ranges= new ArrayList(presentation.getDenumerableRanges()); |
4557 Iterator e= presentation.getNonDefaultStyleRangeIterator(); | 4557 Iterator e= presentation.getNonDefaultStyleRangeIterator(); |
4558 while (e.hasNext()) { | 4558 while (e.hasNext()) { |
4559 range= (StyleRange) e.next(); | 4559 range= cast(StyleRange) e.next(); |
4560 range= modelStyleRange2WidgetStyleRange(range); | 4560 range= modelStyleRange2WidgetStyleRange(range); |
4561 if (range !is null) | 4561 if (range !is null) |
4562 ranges.add(range); | 4562 ranges.add(range); |
4563 } | 4563 } |
4564 | 4564 |
4571 return; | 4571 return; |
4572 | 4572 |
4573 List list= new ArrayList(presentation.getDenumerableRanges()); | 4573 List list= new ArrayList(presentation.getDenumerableRanges()); |
4574 Iterator e= presentation.getAllStyleRangeIterator(); | 4574 Iterator e= presentation.getAllStyleRangeIterator(); |
4575 while (e.hasNext()) { | 4575 while (e.hasNext()) { |
4576 range= (StyleRange) e.next(); | 4576 range= cast(StyleRange) e.next(); |
4577 range= modelStyleRange2WidgetStyleRange(range); | 4577 range= modelStyleRange2WidgetStyleRange(range); |
4578 if (range !is null) | 4578 if (range !is null) |
4579 list.add(range); | 4579 list.add(range); |
4580 } | 4580 } |
4581 | 4581 |
4596 private void applyTextPresentation(TextPresentation presentation) { | 4596 private void applyTextPresentation(TextPresentation presentation) { |
4597 | 4597 |
4598 List list= new ArrayList(presentation.getDenumerableRanges()); | 4598 List list= new ArrayList(presentation.getDenumerableRanges()); |
4599 Iterator e= presentation.getAllStyleRangeIterator(); | 4599 Iterator e= presentation.getAllStyleRangeIterator(); |
4600 while (e.hasNext()) { | 4600 while (e.hasNext()) { |
4601 StyleRange range= (StyleRange) e.next(); | 4601 StyleRange range= cast(StyleRange) e.next(); |
4602 range= modelStyleRange2WidgetStyleRange(range); | 4602 range= modelStyleRange2WidgetStyleRange(range); |
4603 if (range !is null) | 4603 if (range !is null) |
4604 list.add(range); | 4604 list.add(range); |
4605 } | 4605 } |
4606 | 4606 |
4619 */ | 4619 */ |
4620 protected IRegion _internalGetVisibleRegion() { | 4620 protected IRegion _internalGetVisibleRegion() { |
4621 | 4621 |
4622 IDocument document= getVisibleDocument(); | 4622 IDocument document= getVisibleDocument(); |
4623 if (document instanceof ChildDocument) { | 4623 if (document instanceof ChildDocument) { |
4624 Position p= ((ChildDocument) document).getParentDocumentRange(); | 4624 Position p= (cast(ChildDocument) document).getParentDocumentRange(); |
4625 return new Region(p.getOffset(), p.getLength()); | 4625 return new Region(p.getOffset(), p.getLength()); |
4626 } | 4626 } |
4627 | 4627 |
4628 return null; | 4628 return null; |
4629 } | 4629 } |
4645 * and let them apply their presentation. | 4645 * and let them apply their presentation. |
4646 */ | 4646 */ |
4647 if (fTextPresentationListeners !is null) { | 4647 if (fTextPresentationListeners !is null) { |
4648 ArrayList listeners= new ArrayList(fTextPresentationListeners); | 4648 ArrayList listeners= new ArrayList(fTextPresentationListeners); |
4649 for (int i= 0, size= listeners.size(); i < size; i++) { | 4649 for (int i= 0, size= listeners.size(); i < size; i++) { |
4650 ITextPresentationListener listener= (ITextPresentationListener)listeners.get(i); | 4650 ITextPresentationListener listener= cast(ITextPresentationListener)listeners.get(i); |
4651 listener.applyTextPresentation(presentation); | 4651 listener.applyTextPresentation(presentation); |
4652 } | 4652 } |
4653 } | 4653 } |
4654 | 4654 |
4655 if (presentation.isEmpty()) | 4655 if (presentation.isEmpty()) |
4782 * @see Viewer#inputChanged(Object, Object) | 4782 * @see Viewer#inputChanged(Object, Object) |
4783 * @since 2.0 | 4783 * @since 2.0 |
4784 */ | 4784 */ |
4785 protected void inputChanged(Object newInput, Object oldInput) { | 4785 protected void inputChanged(Object newInput, Object oldInput) { |
4786 | 4786 |
4787 IDocument oldDocument= (IDocument) oldInput; | 4787 IDocument oldDocument= cast(IDocument) oldInput; |
4788 if (oldDocument !is null) { | 4788 if (oldDocument !is null) { |
4789 | 4789 |
4790 if (fMarkPosition !is null && !fMarkPosition.isDeleted()) | 4790 if (fMarkPosition !is null && !fMarkPosition.isDeleted()) |
4791 oldDocument.removePosition(fMarkPosition); | 4791 oldDocument.removePosition(fMarkPosition); |
4792 | 4792 |
4799 } | 4799 } |
4800 | 4800 |
4801 fMarkPosition= null; | 4801 fMarkPosition= null; |
4802 | 4802 |
4803 if (oldDocument instanceof IDocumentExtension4) { | 4803 if (oldDocument instanceof IDocumentExtension4) { |
4804 IDocumentExtension4 document= (IDocumentExtension4) oldDocument; | 4804 IDocumentExtension4 document= cast(IDocumentExtension4) oldDocument; |
4805 document.removeDocumentRewriteSessionListener(fDocumentRewriteSessionListener); | 4805 document.removeDocumentRewriteSessionListener(fDocumentRewriteSessionListener); |
4806 } | 4806 } |
4807 | 4807 |
4808 super.inputChanged(newInput, oldInput); | 4808 super.inputChanged(newInput, oldInput); |
4809 | 4809 |
4810 if (newInput instanceof IDocumentExtension4) { | 4810 if (newInput instanceof IDocumentExtension4) { |
4811 IDocumentExtension4 document= (IDocumentExtension4) newInput; | 4811 IDocumentExtension4 document= cast(IDocumentExtension4) newInput; |
4812 document.addDocumentRewriteSessionListener(fDocumentRewriteSessionListener); | 4812 document.addDocumentRewriteSessionListener(fDocumentRewriteSessionListener); |
4813 } | 4813 } |
4814 | 4814 |
4815 IDocument newDocument= (IDocument) newInput; | 4815 IDocument newDocument= cast(IDocument) newInput; |
4816 if (newDocument !is null) { | 4816 if (newDocument !is null) { |
4817 newDocument.addPositionCategory(MARK_POSITION_CATEGORY); | 4817 newDocument.addPositionCategory(MARK_POSITION_CATEGORY); |
4818 newDocument.addPositionUpdater(fMarkPositionUpdater); | 4818 newDocument.addPositionUpdater(fMarkPositionUpdater); |
4819 } | 4819 } |
4820 } | 4820 } |
4844 * @param topIndex the top index to be set or <code>-1</code> | 4844 * @param topIndex the top index to be set or <code>-1</code> |
4845 * @since 3.0 | 4845 * @since 3.0 |
4846 */ | 4846 */ |
4847 protected void enabledRedrawing(int topIndex) { | 4847 protected void enabledRedrawing(int topIndex) { |
4848 if (fDocumentAdapter instanceof IDocumentAdapterExtension) { | 4848 if (fDocumentAdapter instanceof IDocumentAdapterExtension) { |
4849 IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter; | 4849 IDocumentAdapterExtension extension= cast(IDocumentAdapterExtension) fDocumentAdapter; |
4850 StyledText textWidget= getTextWidget(); | 4850 StyledText textWidget= getTextWidget(); |
4851 if (textWidget !is null && !textWidget.isDisposed()) { | 4851 if (textWidget !is null && !textWidget.isDisposed()) { |
4852 extension.resumeForwardingDocumentChanges(); | 4852 extension.resumeForwardingDocumentChanges(); |
4853 if (topIndex > -1) { | 4853 if (topIndex > -1) { |
4854 try { | 4854 try { |
4878 protected void disableRedrawing() { | 4878 protected void disableRedrawing() { |
4879 if (fViewerState is null) | 4879 if (fViewerState is null) |
4880 fViewerState= new ViewerState(); | 4880 fViewerState= new ViewerState(); |
4881 | 4881 |
4882 if (fDocumentAdapter instanceof IDocumentAdapterExtension) { | 4882 if (fDocumentAdapter instanceof IDocumentAdapterExtension) { |
4883 IDocumentAdapterExtension extension= (IDocumentAdapterExtension) fDocumentAdapter; | 4883 IDocumentAdapterExtension extension= cast(IDocumentAdapterExtension) fDocumentAdapter; |
4884 extension.stopForwardingDocumentChanges(); | 4884 extension.stopForwardingDocumentChanges(); |
4885 } | 4885 } |
4886 | 4886 |
4887 if (fTextWidget !is null && !fTextWidget.isDisposed()) | 4887 if (fTextWidget !is null && !fTextWidget.isDisposed()) |
4888 fTextWidget.setRedraw(false); | 4888 fTextWidget.setRedraw(false); |
4948 * @deprecated since 3.1 use {@link IDocumentExtension4#startRewriteSession(DocumentRewriteSessionType)} instead | 4948 * @deprecated since 3.1 use {@link IDocumentExtension4#startRewriteSession(DocumentRewriteSessionType)} instead |
4949 */ | 4949 */ |
4950 protected final void startSequentialRewriteMode(bool normalized) { | 4950 protected final void startSequentialRewriteMode(bool normalized) { |
4951 IDocument document= getDocument(); | 4951 IDocument document= getDocument(); |
4952 if (document instanceof IDocumentExtension) { | 4952 if (document instanceof IDocumentExtension) { |
4953 IDocumentExtension extension= (IDocumentExtension) document; | 4953 IDocumentExtension extension= cast(IDocumentExtension) document; |
4954 extension.startSequentialRewrite(normalized); | 4954 extension.startSequentialRewrite(normalized); |
4955 } | 4955 } |
4956 } | 4956 } |
4957 | 4957 |
4958 /** | 4958 /** |
4962 * @deprecated since 3.1 use {@link IDocumentExtension4#stopRewriteSession(DocumentRewriteSession)} instead | 4962 * @deprecated since 3.1 use {@link IDocumentExtension4#stopRewriteSession(DocumentRewriteSession)} instead |
4963 */ | 4963 */ |
4964 protected final void stopSequentialRewriteMode() { | 4964 protected final void stopSequentialRewriteMode() { |
4965 IDocument document= getDocument(); | 4965 IDocument document= getDocument(); |
4966 if (document instanceof IDocumentExtension) { | 4966 if (document instanceof IDocumentExtension) { |
4967 IDocumentExtension extension= (IDocumentExtension) document; | 4967 IDocumentExtension extension= cast(IDocumentExtension) document; |
4968 extension.stopSequentialRewrite(); | 4968 extension.stopSequentialRewrite(); |
4969 } | 4969 } |
4970 } | 4970 } |
4971 | 4971 |
4972 /* | 4972 /* |
5113 return modelRange2WidgetRange(modelRange); | 5113 return modelRange2WidgetRange(modelRange); |
5114 | 5114 |
5115 try { | 5115 try { |
5116 if (modelRange.getLength() < 0) { | 5116 if (modelRange.getLength() < 0) { |
5117 Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength()); | 5117 Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength()); |
5118 IRegion result= ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(reversed); | 5118 IRegion result= (cast(IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(reversed); |
5119 if (result !is null) | 5119 if (result !is null) |
5120 return new Region(result.getOffset() + result.getLength(), -result.getLength()); | 5120 return new Region(result.getOffset() + result.getLength(), -result.getLength()); |
5121 } | 5121 } |
5122 return ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(modelRange); | 5122 return (cast(IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(modelRange); |
5123 | 5123 |
5124 } catch (BadLocationException x) { | 5124 } catch (BadLocationException x) { |
5125 } | 5125 } |
5126 | 5126 |
5127 return null; | 5127 return null; |
5259 * @since 2.1 | 5259 * @since 2.1 |
5260 */ | 5260 */ |
5261 protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) { | 5261 protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) { |
5262 IRegion region= modelRange2WidgetRange(new Region(range.start, range.length)); | 5262 IRegion region= modelRange2WidgetRange(new Region(range.start, range.length)); |
5263 if (region !is null) { | 5263 if (region !is null) { |
5264 StyleRange result= (StyleRange) range.clone(); | 5264 StyleRange result= cast(StyleRange) range.clone(); |
5265 result.start= region.getOffset(); | 5265 result.start= region.getOffset(); |
5266 result.length= region.getLength(); | 5266 result.length= region.getLength(); |
5267 return result; | 5267 return result; |
5268 } | 5268 } |
5269 return null; | 5269 return null; |
5358 * @see dwtx.jface.text.ITextViewerExtension4#moveFocusToWidgetToken() | 5358 * @see dwtx.jface.text.ITextViewerExtension4#moveFocusToWidgetToken() |
5359 * @since 3.0 | 5359 * @since 3.0 |
5360 */ | 5360 */ |
5361 public bool moveFocusToWidgetToken() { | 5361 public bool moveFocusToWidgetToken() { |
5362 if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) { | 5362 if (fWidgetTokenKeeper instanceof IWidgetTokenKeeperExtension) { |
5363 IWidgetTokenKeeperExtension extension= (IWidgetTokenKeeperExtension) fWidgetTokenKeeper; | 5363 IWidgetTokenKeeperExtension extension= cast(IWidgetTokenKeeperExtension) fWidgetTokenKeeper; |
5364 return extension.setFocus(this); | 5364 return extension.setFocus(this); |
5365 } | 5365 } |
5366 return false; | 5366 return false; |
5367 } | 5367 } |
5368 | 5368 |
5450 */ | 5450 */ |
5451 public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) { | 5451 public void setHyperlinkDetectors(IHyperlinkDetector[] hyperlinkDetectors, int eventStateMask) { |
5452 if (fHyperlinkDetectors !is null) { | 5452 if (fHyperlinkDetectors !is null) { |
5453 for (int i= 0; i < fHyperlinkDetectors.length; i++) { | 5453 for (int i= 0; i < fHyperlinkDetectors.length; i++) { |
5454 if (fHyperlinkDetectors[i] instanceof IHyperlinkDetectorExtension) | 5454 if (fHyperlinkDetectors[i] instanceof IHyperlinkDetectorExtension) |
5455 ((IHyperlinkDetectorExtension)fHyperlinkDetectors[i]).dispose(); | 5455 (cast(IHyperlinkDetectorExtension)fHyperlinkDetectors[i]).dispose(); |
5456 } | 5456 } |
5457 } | 5457 } |
5458 | 5458 |
5459 bool enable= hyperlinkDetectors !is null && hyperlinkDetectors.length > 0; | 5459 bool enable= hyperlinkDetectors !is null && hyperlinkDetectors.length > 0; |
5460 fHyperlinkStateMask= eventStateMask; | 5460 fHyperlinkStateMask= eventStateMask; |