Mercurial > projects > dwt-addons
comparison dwtx/jface/text/contentassist/ContentAssistant.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 |
---|---|
474 switch (type) { | 474 switch (type) { |
475 case LAYOUT_PROPOSAL_SELECTOR: | 475 case LAYOUT_PROPOSAL_SELECTOR: |
476 if (fContextType is LAYOUT_CONTEXT_SELECTOR && | 476 if (fContextType is LAYOUT_CONTEXT_SELECTOR && |
477 Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { | 477 Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { |
478 // Restore event notification to the tip popup. | 478 // Restore event notification to the tip popup. |
479 addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); | 479 addContentAssistListener(cast(IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); |
480 } | 480 } |
481 break; | 481 break; |
482 | 482 |
483 case LAYOUT_CONTEXT_SELECTOR: | 483 case LAYOUT_CONTEXT_SELECTOR: |
484 if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { | 484 if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) { |
485 if (fProposalPopupOrientation is PROPOSAL_STACKED) | 485 if (fProposalPopupOrientation is PROPOSAL_STACKED) |
486 layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset()); | 486 layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset()); |
487 // Restore event notification to the proposal popup. | 487 // Restore event notification to the proposal popup. |
488 addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); | 488 addContentAssistListener(cast(IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); |
489 } | 489 } |
490 fContextType= LAYOUT_CONTEXT_INFO_POPUP; | 490 fContextType= LAYOUT_CONTEXT_INFO_POPUP; |
491 break; | 491 break; |
492 | 492 |
493 case LAYOUT_CONTEXT_INFO_POPUP: | 493 case LAYOUT_CONTEXT_INFO_POPUP: |
539 } else if (fContextType !is LAYOUT_CONTEXT_SELECTOR || | 539 } else if (fContextType !is LAYOUT_CONTEXT_SELECTOR || |
540 !Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { | 540 !Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) { |
541 // There are no other presentations to be concerned with, | 541 // There are no other presentations to be concerned with, |
542 // so place the proposal selector beneath the cursor line. | 542 // so place the proposal selector beneath the cursor line. |
543 Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR]; | 543 Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR]; |
544 CompletionProposalPopup popup= (CompletionProposalPopup) fPopups[LAYOUT_PROPOSAL_SELECTOR]; | 544 CompletionProposalPopup popup= cast(CompletionProposalPopup) fPopups[LAYOUT_PROPOSAL_SELECTOR]; |
545 shell.setBounds(computeBoundsBelowAbove(shell, shell.getSize(), offset, popup)); | 545 shell.setBounds(computeBoundsBelowAbove(shell, shell.getSize(), offset, popup)); |
546 } else { | 546 } else { |
547 CompletionProposalPopup popup= ((CompletionProposalPopup) fPopups[LAYOUT_PROPOSAL_SELECTOR]); | 547 CompletionProposalPopup popup= (cast(CompletionProposalPopup) fPopups[LAYOUT_PROPOSAL_SELECTOR]); |
548 switch (fProposalPopupOrientation) { | 548 switch (fProposalPopupOrientation) { |
549 case PROPOSAL_REMOVE: { | 549 case PROPOSAL_REMOVE: { |
550 // Remove the tip selector and place the | 550 // Remove the tip selector and place the |
551 // proposal selector beneath the cursor line. | 551 // proposal selector beneath the cursor line. |
552 fShells[LAYOUT_CONTEXT_SELECTOR].dispose(); | 552 fShells[LAYOUT_CONTEXT_SELECTOR].dispose(); |
769 switch (type) { | 769 switch (type) { |
770 case LAYOUT_PROPOSAL_SELECTOR: | 770 case LAYOUT_PROPOSAL_SELECTOR: |
771 if (fContextType is LAYOUT_CONTEXT_SELECTOR && | 771 if (fContextType is LAYOUT_CONTEXT_SELECTOR && |
772 Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) | 772 Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) |
773 // Disable event notification to the tip selector. | 773 // Disable event notification to the tip selector. |
774 removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); | 774 removeContentAssistListener(cast(IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR); |
775 break; | 775 break; |
776 case LAYOUT_CONTEXT_SELECTOR: | 776 case LAYOUT_CONTEXT_SELECTOR: |
777 if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) | 777 if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) |
778 // Disable event notification to the proposal selector. | 778 // Disable event notification to the proposal selector. |
779 removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); | 779 removeContentAssistListener(cast(IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR); |
780 break; | 780 break; |
781 case LAYOUT_CONTEXT_INFO_POPUP: | 781 case LAYOUT_CONTEXT_INFO_POPUP: |
782 break; | 782 break; |
783 } | 783 } |
784 } | 784 } |
1078 */ | 1078 */ |
1079 public IContentAssistProcessor getContentAssistProcessor(String contentType) { | 1079 public IContentAssistProcessor getContentAssistProcessor(String contentType) { |
1080 if (fProcessors is null) | 1080 if (fProcessors is null) |
1081 return null; | 1081 return null; |
1082 | 1082 |
1083 return (IContentAssistProcessor) fProcessors.get(contentType); | 1083 return cast(IContentAssistProcessor) fProcessors.get(contentType); |
1084 } | 1084 } |
1085 | 1085 |
1086 /** | 1086 /** |
1087 * Computes the sorted set of all auto activation trigger characters. | 1087 * Computes the sorted set of all auto activation trigger characters. |
1088 * | 1088 * |
1094 return ""; //$NON-NLS-1$ | 1094 return ""; //$NON-NLS-1$ |
1095 | 1095 |
1096 StringBuffer buf= new StringBuffer(5); | 1096 StringBuffer buf= new StringBuffer(5); |
1097 Iterator iter= fProcessors.entrySet().iterator(); | 1097 Iterator iter= fProcessors.entrySet().iterator(); |
1098 while (iter.hasNext()) { | 1098 while (iter.hasNext()) { |
1099 Entry entry= (Entry) iter.next(); | 1099 Entry entry= cast(Entry) iter.next(); |
1100 IContentAssistProcessor processor= (IContentAssistProcessor) entry.getValue(); | 1100 IContentAssistProcessor processor= cast(IContentAssistProcessor) entry.getValue(); |
1101 char[] triggers= processor.getCompletionProposalAutoActivationCharacters(); | 1101 char[] triggers= processor.getCompletionProposalAutoActivationCharacters(); |
1102 if (triggers !is null) | 1102 if (triggers !is null) |
1103 buf.append(triggers); | 1103 buf.append(triggers); |
1104 triggers= processor.getContextInformationAutoActivationCharacters(); | 1104 triggers= processor.getContextInformationAutoActivationCharacters(); |
1105 if (triggers !is null) | 1105 if (triggers !is null) |
1534 private bool acquireWidgetToken(int type) { | 1534 private bool acquireWidgetToken(int type) { |
1535 switch (type) { | 1535 switch (type) { |
1536 case CONTEXT_SELECTOR: | 1536 case CONTEXT_SELECTOR: |
1537 case PROPOSAL_SELECTOR: | 1537 case PROPOSAL_SELECTOR: |
1538 if (fContentAssistSubjectControl instanceof IWidgetTokenOwnerExtension) { | 1538 if (fContentAssistSubjectControl instanceof IWidgetTokenOwnerExtension) { |
1539 IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fContentAssistSubjectControl; | 1539 IWidgetTokenOwnerExtension extension= cast(IWidgetTokenOwnerExtension) fContentAssistSubjectControl; |
1540 return extension.requestWidgetToken(this, WIDGET_PRIORITY); | 1540 return extension.requestWidgetToken(this, WIDGET_PRIORITY); |
1541 } else if (fContentAssistSubjectControl instanceof IWidgetTokenOwner) { | 1541 } else if (fContentAssistSubjectControl instanceof IWidgetTokenOwner) { |
1542 IWidgetTokenOwner owner= (IWidgetTokenOwner) fContentAssistSubjectControl; | 1542 IWidgetTokenOwner owner= cast(IWidgetTokenOwner) fContentAssistSubjectControl; |
1543 return owner.requestWidgetToken(this); | 1543 return owner.requestWidgetToken(this); |
1544 } else if (fViewer instanceof IWidgetTokenOwnerExtension) { | 1544 } else if (fViewer instanceof IWidgetTokenOwnerExtension) { |
1545 IWidgetTokenOwnerExtension extension= (IWidgetTokenOwnerExtension) fViewer; | 1545 IWidgetTokenOwnerExtension extension= cast(IWidgetTokenOwnerExtension) fViewer; |
1546 return extension.requestWidgetToken(this, WIDGET_PRIORITY); | 1546 return extension.requestWidgetToken(this, WIDGET_PRIORITY); |
1547 } else if (fViewer instanceof IWidgetTokenOwner) { | 1547 } else if (fViewer instanceof IWidgetTokenOwner) { |
1548 IWidgetTokenOwner owner= (IWidgetTokenOwner) fViewer; | 1548 IWidgetTokenOwner owner= cast(IWidgetTokenOwner) fViewer; |
1549 return owner.requestWidgetToken(this); | 1549 return owner.requestWidgetToken(this); |
1550 } | 1550 } |
1551 } | 1551 } |
1552 return true; | 1552 return true; |
1553 } | 1553 } |
1624 */ | 1624 */ |
1625 private void releaseWidgetToken(int type) { | 1625 private void releaseWidgetToken(int type) { |
1626 if (fListeners[CONTEXT_SELECTOR] is null && fListeners[PROPOSAL_SELECTOR] is null) { | 1626 if (fListeners[CONTEXT_SELECTOR] is null && fListeners[PROPOSAL_SELECTOR] is null) { |
1627 IWidgetTokenOwner owner= null; | 1627 IWidgetTokenOwner owner= null; |
1628 if (fContentAssistSubjectControl instanceof IWidgetTokenOwner) | 1628 if (fContentAssistSubjectControl instanceof IWidgetTokenOwner) |
1629 owner= (IWidgetTokenOwner) fContentAssistSubjectControl; | 1629 owner= cast(IWidgetTokenOwner) fContentAssistSubjectControl; |
1630 else if (fViewer instanceof IWidgetTokenOwner) | 1630 else if (fViewer instanceof IWidgetTokenOwner) |
1631 owner= (IWidgetTokenOwner) fViewer; | 1631 owner= cast(IWidgetTokenOwner) fViewer; |
1632 if (owner !is null) | 1632 if (owner !is null) |
1633 owner.releaseWidgetToken(this); | 1633 owner.releaseWidgetToken(this); |
1634 } | 1634 } |
1635 } | 1635 } |
1636 | 1636 |
1841 | 1841 |
1842 ICompletionProposal[] result= null; | 1842 ICompletionProposal[] result= null; |
1843 | 1843 |
1844 IContentAssistProcessor p= getProcessor(contentAssistSubjectControl, offset); | 1844 IContentAssistProcessor p= getProcessor(contentAssistSubjectControl, offset); |
1845 if (p instanceof ISubjectControlContentAssistProcessor) { | 1845 if (p instanceof ISubjectControlContentAssistProcessor) { |
1846 result= ((ISubjectControlContentAssistProcessor) p).computeCompletionProposals(contentAssistSubjectControl, offset); | 1846 result= (cast(ISubjectControlContentAssistProcessor) p).computeCompletionProposals(contentAssistSubjectControl, offset); |
1847 fLastErrorMessage= p.getErrorMessage(); | 1847 fLastErrorMessage= p.getErrorMessage(); |
1848 } | 1848 } |
1849 | 1849 |
1850 return result; | 1850 return result; |
1851 } | 1851 } |
1913 | 1913 |
1914 IContextInformation[] result= null; | 1914 IContextInformation[] result= null; |
1915 | 1915 |
1916 IContentAssistProcessor p= getProcessor(contentAssistSubjectControl, offset); | 1916 IContentAssistProcessor p= getProcessor(contentAssistSubjectControl, offset); |
1917 if (p instanceof ISubjectControlContentAssistProcessor) { | 1917 if (p instanceof ISubjectControlContentAssistProcessor) { |
1918 result= ((ISubjectControlContentAssistProcessor) p).computeContextInformation(contentAssistSubjectControl, offset); | 1918 result= (cast(ISubjectControlContentAssistProcessor) p).computeContextInformation(contentAssistSubjectControl, offset); |
1919 fLastErrorMessage= p.getErrorMessage(); | 1919 fLastErrorMessage= p.getErrorMessage(); |
1920 } | 1920 } |
1921 | 1921 |
1922 return result; | 1922 return result; |
1923 } | 1923 } |
1964 * @since 2.0 | 1964 * @since 2.0 |
1965 */ | 1965 */ |
1966 IContextInformationPresenter getContextInformationPresenter(ITextViewer viewer, int offset) { | 1966 IContextInformationPresenter getContextInformationPresenter(ITextViewer viewer, int offset) { |
1967 IContextInformationValidator validator= getContextInformationValidator(viewer, offset); | 1967 IContextInformationValidator validator= getContextInformationValidator(viewer, offset); |
1968 if (validator instanceof IContextInformationPresenter) | 1968 if (validator instanceof IContextInformationPresenter) |
1969 return (IContextInformationPresenter) validator; | 1969 return cast(IContextInformationPresenter) validator; |
1970 return null; | 1970 return null; |
1971 } | 1971 } |
1972 | 1972 |
1973 /** | 1973 /** |
1974 * Returns the context information presenter that should be used to display context information. | 1974 * Returns the context information presenter that should be used to display context information. |
1980 * @since 3.0 | 1980 * @since 3.0 |
1981 */ | 1981 */ |
1982 IContextInformationPresenter getContextInformationPresenter(IContentAssistSubjectControl contentAssistSubjectControl, int offset) { | 1982 IContextInformationPresenter getContextInformationPresenter(IContentAssistSubjectControl contentAssistSubjectControl, int offset) { |
1983 IContextInformationValidator validator= getContextInformationValidator(contentAssistSubjectControl, offset); | 1983 IContextInformationValidator validator= getContextInformationValidator(contentAssistSubjectControl, offset); |
1984 if (validator instanceof IContextInformationPresenter) | 1984 if (validator instanceof IContextInformationPresenter) |
1985 return (IContextInformationPresenter) validator; | 1985 return cast(IContextInformationPresenter) validator; |
1986 return null; | 1986 return null; |
1987 } | 1987 } |
1988 | 1988 |
1989 /** | 1989 /** |
1990 * Returns the characters which when typed by the user should automatically initiate proposing | 1990 * Returns the characters which when typed by the user should automatically initiate proposing |
2245 if (fContentAssistSubjectControlAdapter !is null && !isProposalPopupActive()) { | 2245 if (fContentAssistSubjectControlAdapter !is null && !isProposalPopupActive()) { |
2246 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); | 2246 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); |
2247 ContentAssistEvent event= new ContentAssistEvent(this, processor, isAutoActivated); | 2247 ContentAssistEvent event= new ContentAssistEvent(this, processor, isAutoActivated); |
2248 Object[] listeners= fCompletionListeners.getListeners(); | 2248 Object[] listeners= fCompletionListeners.getListeners(); |
2249 for (int i= 0; i < listeners.length; i++) { | 2249 for (int i= 0; i < listeners.length; i++) { |
2250 ICompletionListener listener= (ICompletionListener)listeners[i]; | 2250 ICompletionListener listener= cast(ICompletionListener)listeners[i]; |
2251 listener.assistSessionStarted(event); | 2251 listener.assistSessionStarted(event); |
2252 } | 2252 } |
2253 } | 2253 } |
2254 } | 2254 } |
2255 | 2255 |
2262 if (fContentAssistSubjectControlAdapter !is null) { | 2262 if (fContentAssistSubjectControlAdapter !is null) { |
2263 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); | 2263 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); |
2264 ContentAssistEvent event= new ContentAssistEvent(this, processor); | 2264 ContentAssistEvent event= new ContentAssistEvent(this, processor); |
2265 Object[] listeners= fCompletionListeners.getListeners(); | 2265 Object[] listeners= fCompletionListeners.getListeners(); |
2266 for (int i= 0; i < listeners.length; i++) { | 2266 for (int i= 0; i < listeners.length; i++) { |
2267 ICompletionListener listener= (ICompletionListener)listeners[i]; | 2267 ICompletionListener listener= cast(ICompletionListener)listeners[i]; |
2268 if (listener instanceof ICompletionListenerExtension) | 2268 if (listener instanceof ICompletionListenerExtension) |
2269 ((ICompletionListenerExtension)listener).assistSessionRestarted(event); | 2269 (cast(ICompletionListenerExtension)listener).assistSessionRestarted(event); |
2270 } | 2270 } |
2271 } | 2271 } |
2272 } | 2272 } |
2273 | 2273 |
2274 /** | 2274 /** |
2280 if (fContentAssistSubjectControlAdapter !is null) { | 2280 if (fContentAssistSubjectControlAdapter !is null) { |
2281 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); | 2281 IContentAssistProcessor processor= getProcessor(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); |
2282 ContentAssistEvent event= new ContentAssistEvent(this, processor); | 2282 ContentAssistEvent event= new ContentAssistEvent(this, processor); |
2283 Object[] listeners= fCompletionListeners.getListeners(); | 2283 Object[] listeners= fCompletionListeners.getListeners(); |
2284 for (int i= 0; i < listeners.length; i++) { | 2284 for (int i= 0; i < listeners.length; i++) { |
2285 ICompletionListener listener= (ICompletionListener)listeners[i]; | 2285 ICompletionListener listener= cast(ICompletionListener)listeners[i]; |
2286 listener.assistSessionEnded(event); | 2286 listener.assistSessionEnded(event); |
2287 } | 2287 } |
2288 } | 2288 } |
2289 } | 2289 } |
2290 | 2290 |
2389 * @since 3.2 | 2389 * @since 3.2 |
2390 */ | 2390 */ |
2391 void fireSelectionEvent(ICompletionProposal proposal, bool smartToggle) { | 2391 void fireSelectionEvent(ICompletionProposal proposal, bool smartToggle) { |
2392 Object[] listeners= fCompletionListeners.getListeners(); | 2392 Object[] listeners= fCompletionListeners.getListeners(); |
2393 for (int i= 0; i < listeners.length; i++) { | 2393 for (int i= 0; i < listeners.length; i++) { |
2394 ICompletionListener listener= (ICompletionListener)listeners[i]; | 2394 ICompletionListener listener= cast(ICompletionListener)listeners[i]; |
2395 listener.selectionChanged(proposal, smartToggle); | 2395 listener.selectionChanged(proposal, smartToggle); |
2396 } | 2396 } |
2397 } | 2397 } |
2398 | 2398 |
2399 /* | 2399 /* |
2441 */ | 2441 */ |
2442 public final IHandler getHandler(String commandId) { | 2442 public final IHandler getHandler(String commandId) { |
2443 if (fHandlers is null) | 2443 if (fHandlers is null) |
2444 throw new IllegalStateException(); | 2444 throw new IllegalStateException(); |
2445 | 2445 |
2446 IHandler handler= (IHandler)fHandlers.get(commandId); | 2446 IHandler handler= cast(IHandler)fHandlers.get(commandId); |
2447 if (handler !is null) | 2447 if (handler !is null) |
2448 return handler; | 2448 return handler; |
2449 | 2449 |
2450 Assert.isLegal(false); | 2450 Assert.isLegal(false); |
2451 return null; | 2451 return null; |