comparison dwtx/jface/internal/text/link/contentassist/CompletionProposalPopup2.d @ 138:b6bad70d540a

Regex instanceof changes
author Frank Benoit <benoit@tionex.de>
date Sun, 24 Aug 2008 02:26:23 +0200
parents 65801ad2b265
children 53b889547456
comparison
equal deleted inserted replaced
137:25170b5a8951 138:b6bad70d540a
389 389
390 try { 390 try {
391 391
392 IDocument document= fViewer.getDocument(); 392 IDocument document= fViewer.getDocument();
393 393
394 if (fViewer instanceof ITextViewerExtension) { 394 if ( cast(ITextViewerExtension)fViewer ) {
395 ITextViewerExtension extension= cast(ITextViewerExtension) fViewer; 395 ITextViewerExtension extension= cast(ITextViewerExtension) fViewer;
396 target= extension.getRewriteTarget(); 396 target= extension.getRewriteTarget();
397 } 397 }
398 398
399 if (target !is null) 399 if (target !is null)
400 target.beginCompoundChange(); 400 target.beginCompoundChange();
401 401
402 if (fViewer instanceof IEditingSupportRegistry) { 402 if ( cast(IEditingSupportRegistry)fViewer ) {
403 registry= cast(IEditingSupportRegistry) fViewer; 403 registry= cast(IEditingSupportRegistry) fViewer;
404 registry.register(fModificationEditingSupport); 404 registry.register(fModificationEditingSupport);
405 } 405 }
406 406
407 if (p instanceof ICompletionProposalExtension2) { 407 if ( cast(ICompletionProposalExtension2)p ) {
408 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p; 408 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p;
409 e.apply(fViewer, trigger, stateMask, offset); 409 e.apply(fViewer, trigger, stateMask, offset);
410 } else if (p instanceof ICompletionProposalExtension) { 410 } else if ( cast(ICompletionProposalExtension)p ) {
411 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p; 411 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p;
412 e.apply(document, trigger, offset); 412 e.apply(document, trigger, offset);
413 } else { 413 } else {
414 p.apply(document); 414 p.apply(document);
415 } 415 }
422 422
423 IContextInformation info= p.getContextInformation(); 423 IContextInformation info= p.getContextInformation();
424 if (info !is null) { 424 if (info !is null) {
425 425
426 int position; 426 int position;
427 if (p instanceof ICompletionProposalExtension) { 427 if ( cast(ICompletionProposalExtension)p ) {
428 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p; 428 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p;
429 position= e.getContextInformationPosition(); 429 position= e.getContextInformationPosition();
430 } else { 430 } else {
431 if (selection is null) 431 if (selection is null)
432 selection= fViewer.getSelectedRange(); 432 selection= fViewer.getSelectedRange();
466 */ 466 */
467 public void hide() { 467 public void hide() {
468 468
469 unregister(); 469 unregister();
470 470
471 if (fViewer instanceof IEditingSupportRegistry) { 471 if ( cast(IEditingSupportRegistry)fViewer ) {
472 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 472 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
473 registry.unregister(fFocusEditingSupport); 473 registry.unregister(fFocusEditingSupport);
474 } 474 }
475 475
476 if (Helper2.okToUse(fProposalShell)) { 476 if (Helper2.okToUse(fProposalShell)) {
500 StyledText styledText= fViewer.getTextWidget(); 500 StyledText styledText= fViewer.getTextWidget();
501 if (fKeyListener !is null && styledText !is null && !styledText.isDisposed()) 501 if (fKeyListener !is null && styledText !is null && !styledText.isDisposed())
502 styledText.removeKeyListener(fKeyListener); 502 styledText.removeKeyListener(fKeyListener);
503 503
504 if (fLastProposal !is null) { 504 if (fLastProposal !is null) {
505 if (fLastProposal instanceof ICompletionProposalExtension2) { 505 if ( cast(ICompletionProposalExtension2)fLastProposal ) {
506 ICompletionProposalExtension2 extension= cast(ICompletionProposalExtension2) fLastProposal; 506 ICompletionProposalExtension2 extension= cast(ICompletionProposalExtension2) fLastProposal;
507 extension.unselected(fViewer); 507 extension.unselected(fViewer);
508 } 508 }
509 509
510 fLastProposal= null; 510 fLastProposal= null;
531 */ 531 */
532 private void setProposals(ICompletionProposal[] proposals) { 532 private void setProposals(ICompletionProposal[] proposals) {
533 if (Helper2.okToUse(fProposalTable)) { 533 if (Helper2.okToUse(fProposalTable)) {
534 534
535 ICompletionProposal oldProposal= getSelectedProposal(); 535 ICompletionProposal oldProposal= getSelectedProposal();
536 if (oldProposal instanceof ICompletionProposalExtension2) 536 if ( cast(ICompletionProposalExtension2)oldProposal )
537 (cast(ICompletionProposalExtension2) oldProposal).unselected(fViewer); 537 (cast(ICompletionProposalExtension2) oldProposal).unselected(fViewer);
538 538
539 fFilteredProposals= proposals; 539 fFilteredProposals= proposals;
540 540
541 fProposalTable.setRedraw(false); 541 fProposalTable.setRedraw(false);
625 return result; 625 return result;
626 } 626 }
627 627
628 private bool validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) { 628 private bool validateProposal(IDocument document, ICompletionProposal p, int offset, DocumentEvent event) {
629 // detect selected 629 // detect selected
630 if (p instanceof ICompletionProposalExtension2) { 630 if ( cast(ICompletionProposalExtension2)p ) {
631 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p; 631 ICompletionProposalExtension2 e= cast(ICompletionProposalExtension2) p;
632 if (e.validate(document, offset, event)) 632 if (e.validate(document, offset, event))
633 return true; 633 return true;
634 } else if (p instanceof ICompletionProposalExtension) { 634 } else if ( cast(ICompletionProposalExtension)p ) {
635 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p; 635 ICompletionProposalExtension e= cast(ICompletionProposalExtension) p;
636 if (e.isValidFor(document, offset)) 636 if (e.isValidFor(document, offset))
637 return true; 637 return true;
638 } 638 }
639 return false; 639 return false;
678 IDocument document= fViewer.getDocument(); 678 IDocument document= fViewer.getDocument();
679 if (document !is null) 679 if (document !is null)
680 document.addDocumentListener(fDocumentListener); 680 document.addDocumentListener(fDocumentListener);
681 681
682 682
683 if (fViewer instanceof IEditingSupportRegistry) { 683 if ( cast(IEditingSupportRegistry)fViewer ) {
684 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer; 684 IEditingSupportRegistry registry= cast(IEditingSupportRegistry) fViewer;
685 registry.register(fFocusEditingSupport); 685 registry.register(fFocusEditingSupport);
686 } 686 }
687 687
688 fProposalShell.setVisible(true); 688 fProposalShell.setVisible(true);
785 // hide(); 785 // hide();
786 break; 786 break;
787 787
788 default: 788 default:
789 ICompletionProposal p= getSelectedProposal(); 789 ICompletionProposal p= getSelectedProposal();
790 if (p instanceof ICompletionProposalExtension) { 790 if ( cast(ICompletionProposalExtension)p ) {
791 ICompletionProposalExtension t= cast(ICompletionProposalExtension) p; 791 ICompletionProposalExtension t= cast(ICompletionProposalExtension) p;
792 char[] triggers= t.getTriggerCharacters(); 792 char[] triggers= t.getTriggerCharacters();
793 if (contains(triggers, key)) { 793 if (contains(triggers, key)) {
794 hide(); 794 hide();
795 if (key is ';') { 795 if (key is ';') {
815 * @since 2.1 815 * @since 2.1
816 */ 816 */
817 private void selectProposal(int index, bool smartToggle) { 817 private void selectProposal(int index, bool smartToggle) {
818 818
819 ICompletionProposal oldProposal= getSelectedProposal(); 819 ICompletionProposal oldProposal= getSelectedProposal();
820 if (oldProposal instanceof ICompletionProposalExtension2) 820 if ( cast(ICompletionProposalExtension2)oldProposal )
821 (cast(ICompletionProposalExtension2) oldProposal).unselected(fViewer); 821 (cast(ICompletionProposalExtension2) oldProposal).unselected(fViewer);
822 822
823 ICompletionProposal proposal= fFilteredProposals[index]; 823 ICompletionProposal proposal= fFilteredProposals[index];
824 if (proposal instanceof ICompletionProposalExtension2) 824 if ( cast(ICompletionProposalExtension2)proposal )
825 (cast(ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle); 825 (cast(ICompletionProposalExtension2) proposal).selected(fViewer, smartToggle);
826 826
827 fLastProposal= proposal; 827 fLastProposal= proposal;
828 828
829 fProposalTable.setSelection(index); 829 fProposalTable.setSelection(index);